Add 35-lang-normalize.conf

This avoids a situation where the score of lang becomes lower or equal to others
and then figures out the best font according to other properties and the order
of family names.

This typically happens only when our orthography files are the subset of lang
in patterns. i.e. fc-match :lang=en-us to match on en.orth.
In this case, the score is lower than the exact match (en to en) and the partial
match (en to en-us). thus, the result of 'fc-match :lang=en-us' isn't necessarily
same to 'fc-match :lang=en'.

So 35-lang-normalize.conf contains languages only which is available as orth
without countries and tries to update properties to match on orth exactly like:

  <match>
    <test name="lang" compare="contains">
      <string>en</string>
    </test>
    <edit name="lang" mode="assign" binding="same">
      <string>en</string>
    </edit>
  </match>

Fixes https://gitlab.freedesktop.org/fontconfig/fontconfig/issues/155
This commit is contained in:
Akira TAGOH 2019-07-26 07:24:16 +00:00
parent e2f9f28aed
commit f555f50a20
2 changed files with 24 additions and 1 deletions

View File

@ -21,7 +21,11 @@
# TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
# PERFORMANCE OF THIS SOFTWARE.
BUILT_SOURCES = README
NULL =
BUILT_SOURCES = \
README \
35-lang-normalize.conf \
$(NULL)
DOC_SOURCES = README.in
DOC_FILES = $(DOC_SOURCES:.in=)
@ -71,6 +75,7 @@ template_DATA = \
20-unhint-small-vera.conf \
25-unhint-nonlatin.conf \
30-metric-aliases.conf \
35-lang-normalize.conf \
40-nonlatin.conf \
45-generic.conf \
45-latin.conf \
@ -91,6 +96,9 @@ template_DATA = \
README: $(srcdir)/README.in
sed "s|\@TEMPLATEDIR\@|$(templatedir)|" $< > $@
35-lang-normalize.conf: ../fc-lang/Makefile.am
cd ../fc-lang && $(MAKE) $(AM_MAKEFLAGS) $(top_builddir)/conf.d/35-lang-normalize.conf
install-data-hook:
mkdir -p $(DESTDIR)$(configdir)
@(echo cd $(DESTDIR)$(configdir); \

View File

@ -285,4 +285,19 @@ ORTH = \
und_zmth.orth
# ^-------------- Add new orth files here
BUILT_SOURCES += $(top_builddir)/conf.d/35-lang-normalize.conf
DISTCLEANFILES = $(BUILT_SOURCES)
$(top_builddir)/conf.d/35-lang-normalize.conf: $(ORTH) Makefile
$(AM_V_GEN) echo "<fontconfig>" > $@ && \
for i in `echo $(ORTH) | sed -e 's/ /\n/g' | grep -v _ | sed -e 's/\.orth$$//g' | sort`; do \
echo " <!-- $$i* -> $$i -->" >> $@; \
echo " <match>" >> $@; \
echo " <test name=\"lang\" compare=\"contains\"><string>$$i</string></test>" >> $@; \
echo " <edit name=\"lang\" mode=\"assign\" binding=\"same\"><string>$$i</string></edit>" >> $@; \
echo " </match>" >> $@; \
done && \
echo "</fontconfig>" >> $@
-include $(top_srcdir)/git.mk