FontConfig

Differences between revisions 26 and 27
Revision 26 as of 2006-02-22 09:38:33
Size: 15374
Editor: gnulinux
Comment:
Revision 27 as of 2006-03-03 05:24:22
Size: 15348
Editor: cm61-18-176-102
Comment:
Deletions are marked like this. Additions are marked like this.
Line 7: Line 7:
 * Contributors: ["Atie"], ["Zero0w"], ["JunKobayashi"]  * Contributors: ["Atie"], ["JunKobayashi"]
Line 78: Line 78:
         * Thanks for the finding. After checking out the source of [http://fontconfig.org/release/fontconfig-2.3.93.tar.gz fontconfig 2.3.93], there is indeed a new propety called '''embeddedbitmap''', found in the XML config file "fonts.conf.in". Assuming fontconfig 2.4 is going to be released in January, we can wait to experiment this new property for enabling embedded bitmap after it comes out.
         * That's right. fontconfig 2.4 is NOT going to come out soon enough for the Dapper Drake release, so we have to resort to the old way for enabling embedded bitmap font by using the '''antialias''' attribute. This sucks, because now you need to know the size where the embedded bitmap font glyphs are present, for ''each'' of these CJK font sets. Use '''Fontforge''' to find it out.

Summary

This sub specification aims at improving Font configuration for CJK support in Ubuntu.

Rationale

Usually Chinese, Japanese and Korean (CJK) users make their own font configurations in ~/.fonts.conf so that they see the best looking, highest quality, ttf fonts. This is necessary due to lack of support by fontconfig; we don't currently have any method to simplify this process for CJK users.

Use cases

  • Chulsoo installed ttf-alee without ubuntu-desktop and found the fonts look fuzzy and didn't match with his English font while web browsing. He asked Linux forum about font configuration and finally got a good looking setup. But it was not a simple way to set it up because he didn't understand the xml tags and values.
  • Joe wants to learn Chinese and he is happy with ubuntu-desktop because it already has Chinese ttf fonts, but he is not satisfied with the display quality and his Chinese classmate tells him it looks poor. But he doesn't know how to improve the appearance.

Background

We believe we have established the following facts.

  • For CJK languages, users have different preferences as to their preferred font and it is not acceptable to provide only one option; or to put it another way, users must be able to choose between a few options without editing config files. Currently this is not possible.
  • The current defaults are suboptimal; they result (in some languages) in the use of fonts which are not a reasonable choice.
  • fontconfig's properties features can be used to provide different behaviour for different languages. In particular, the <edit> stanzas which are the preferred approach for selecting CJK fonts can be limited using <test> to particular languages.

  • All of the relevant ttf-* font packages are installed by default as dependencies of ubuntu-desktop.
  • There are 5 languages involved: Korean, Jananese, mainland Chinese, Chinese for Taiwan and Chinese for Hong Kong. Each language will have approximately two sensible choices of font, so we will need approximately 10 fontconfig XML stanzas.

Approach

The default choice of the font system must be improved. We would like the user to be able to make the choice of font using the normal font configuration mechanism (System / Preferences / Font and the corresponding Firefox preferences).

This will be achieved by providing language-specific fontconfig XML stanzas in the default install which (i) map sans-serif, the default font, to the "best" relevant CJK font (ii) provide a mapping for suitable name(s) for the plausible alternatives.

These XML stanzas will be provided in /etc/fonts/conf.d by the ttf-* packages. Providing them there means that, since all systems will have them installed, any bugs which make the changes break other languages will be detected; if they were in the language packs then such bugs would strike systems with multiple language support but be otherwise undetected. The other alternative would be to provide this information from the fontconfig package itself but since it's likely to be fairly large, and at least initially fairly volatile, and to some extent coupled to the ttf font packages' contents, this would be less than ideal.

Open Questions

The information here is currently based mainly on the knowledge of a Korean-language expert. The situation for the other affected languages needs to be checked.

There have been reports of trouble to do with ordering of the various fontconfig stanzas. fontconfig is sensitive to ordering and somewhat fragile. Certainly none of the language-specific changes to fontconfig files should involve reordering any existing configuration. We need to establish that writing appropriate XML to /etc/fonts/conf.d is sufficient, and whether there is any specific ordering constraint which affects the appropriate choice of filename. (Files in conf.d are read in lexicographical order, and recent practice is to prepend a sequence number to the filename.)

We currently have no confirmation that language-specific XML works correctly in practice. If it does not then we must either fix it (if this is feasible) or opt for a different approach (which will definitely be suboptimal for multilingual installs).

Exact syntax of the appropriate fontconfig XML stanzas need to be established and tested. We have examples for Korean (see below).

Notes

These notes predate the discussions and decision documented above but are retained because they contain information that may still be useful.

  • You can also use fontforge to open and explore the ttf files and determine whether or not they carry embedded bitmaps, and at what sizes.

    • There is also another way to enable embedded bitmap globally without the need to match certain range of font size over a particular font name. It is to patch the fontconfig and libXft package directly, here are the patches:
    • With these patches, a new fontconfig parameter called embeddedbitmap can be turned on, which will manage the process globally and only target the font with embedded bitmaps. This is better than the antialias parameter because antialias will turn off anti-aliasing even at those font sizes that are without embedded bitmaps. And that's the reason we need to limit it to certain range as we have been doing now.

    • I haven't been following the upstream discussions so I am not sure why these two patches were rejected. Maybe we can try to push it through the LaunchPad again.

      • ["BetterCJKSupportSpecification"] shows this
        • - update fontconfig with 2.3.92+cvs20051129 : Enable embeddedbitmap as default So I take it that Ubuntu is doing the patching on its own; can anyone confirm this?

          - Ok, forget what I said, the whole issue will be addressed in fontconfig 2.4 & libXft 1.8.

      • fontconfig 2.3.92 with [http://lists.freedesktop.org/archives/fontconfig/2005-November/001683.html these features]

      • fontconfig 2.4 will released by mid-January according to [http://lists.freedesktop.org/archives/fontconfig/2005-December/001809.html Towards a 2.4 release]

        • 2.4 release keeps delayed, can't hope it will be in Dapper due to stablity reason.
        • That's right. fontconfig 2.4 is NOT going to come out soon enough for the Dapper Drake release, so we have to resort to the old way for enabling embedded bitmap font by using the antialias attribute. This sucks, because now you need to know the size where the embedded bitmap font glyphs are present, for each of these CJK font sets. Use Fontforge to find it out. Note: When slant (italic) style is used, embeddedbitmap mode must be turned off - since bitmap glyph cannot be italicized - they must be reverted back to vector (non-bitmap) glyph. The comment and statement in "fonts.conf.in" has already addressed this situation so I suppose we don't need to worry about it anymore.

    • More discussions can be found in this [http://moto.debian.org.tw/viewtopic.php?p=42973&sid=4d707f6f4ec23567f9938d087c0e30ca#42973 Chinese Debian forum].

  • Chinese
    1. ttf-arphic-uming
    2. ttf-newsung (setting should be equivalent to uming)
    3. xfonts-wqy
  • Japanese
    1. ttf-kochi-gothic
    2. ttf-kochi-mincho
    3. ttf-sazanami-gothic
    4. ttf-sazanami-mincho
    5. ipafont
    6. ipamonafont

      Note: ipafont and ipamonafont package can be found in ubuntu-ja [http://archive.ubuntulinux.jp/ubuntu-ja/breezy/ breezy-extra].

      Also see the possible [http://ukai.org/b/log/debian/legal licensing issue].

    7. The following configuration including: If this configuration don't have bad effects on other languages, I think it may be good to merge the default /etc/fonts/fonts.conf.
      •   <alias>
            <family>serif</family>
            <prefer>
              <family>Bitstream Vera Serif</family>
              <family>DejaVu Serif</family>
              <family>Times New Roman</family>
              <family>Thorndale AMT</family>
              <family>Luxi Serif</family>
              <family>Nimbus Roman No9 L</family>
              <family>Times</family>
              <family>Frank Ruehl</family>
              <family>MgOpen Canonica</family>
              <family>IPAMonaPMincho</family>
              <family>IPAPMincho</family>
              <family>Sazanami Mincho</family>
              <family>Kochi Mincho</family>
              <family>AR PL SungtiL GB</family>
              <family>AR PL Mingti2L Big5</family>
              <family>MS 明朝</family>
              <family>Baekmuk Batang</family>
              <family>FreeSerif</family>
            </prefer>
          </alias>
          <alias>
            <family>sans-serif</family>
            <prefer>
              <family>Bitstream Vera Sans</family>
              <family>DejaVu Sans</family>
              <family>Verdana</family>
              <family>Arial</family>
              <family>Albany AMT</family>
              <family>Luxi Sans</family>
              <family>Nimbus Sans L</family>
              <family>Helvetica</family>
              <family>Nachlieli</family>
              <family>MgOpen Moderna</family>
              <family>IPAMonaPGothic</family>
              <family>IPAPGothic</family>
              <family>Sazanami Gothic</family>
              <family>Kochi Gothic</family>
              <family>AR PL KaitiM GB</family>
              <family>AR PL KaitiM Big5</family>
              <family>MS ゴシック</family>
              <family>Baekmuk Dotum</family>
              <family>SimSun</family>
              <family>FreeSans</family>
            </prefer>
          </alias>
          <alias>
            <family>monospace</family>
            <prefer>
              <family>Bitstream Vera Sans Mono</family>
              <family>DejaVu Sans Mono</family>
              <family>Andale Mono</family>
              <family>Courier New</family>
              <family>Cumberland AMT</family>
              <family>Luxi Mono</family>
              <family>Nimbus Mono L</family>
              <family>Courier</family>
              <family>Miriam Mono</family>
              <family>IPAMonaGothic</family>
              <family>IPAGothic</family>
              <family>Sazanami Gothic</family>
              <family>Kochi Gothic</family>
              <family>AR PL KaitiM GB</family>
              <family>Baekmuk Dotum</family>
              <family>FreeMono</family>
            </prefer>
          </alias>
  • Korean
    1. ttf-baekmuk ( Fonts in this package are used by fontconfig. By a survey, 5% of voters like this - due to lower quality for displaying than the others. )
    2. ttf-unfonts ( 63% of voters prefer this. Has several font-sets, even bold font-sets. )
      • To get better looking
           <match target="font" >
              <test name="family" qual="any" >
                 <string>UnPen</string>
                 <string>UnBatang</string>
                 <string>UnDotum</string>
                 <string>UnGungseo</string>
                 <string>UnPilgi</string>
                 <string>UnBom</string>
                 <string>UnYetgul</string>
                 <string>UnPenheulim</string>
                 <string>UnGraphic</string>
                 <string>UnSinmun</string>
              </test>
              <edit mode="assign" name="hinting" ><bool>false</bool></edit>
              <edit mode="assign" name="autohint" ><bool>true</bool></edit>
           </match>
    3. ttf-alee ( 30% of voters, includes bitmap font and good for screen display. )
      • To get best displaying
           <match target="font">
               <test name="family"><string>EunGuseul</string></test>
                   <edit mode="assign" name="autohint"><bool>true</bool></edit>
           </match>
           <match target="font">
               <test name="family"><string>EunGuseul</string></test>
               <test name="pixelsize" compare="more"><int>11</int></test>
               <test name="pixelsize" compare="less"><int>16</int></test>
                   <edit mode="assign" name="autohint"><bool>false</bool></edit>
                   <edit mode="assign" name="antialias"><bool>false</bool></edit>
           </match>
      • To match with Bitsream Vera fonts
           <match target="pattern">
               <test name="family"><string>EunGuseul</string></test>
                   <edit mode="append" binding="strong" Name="family">
                      <string>Bitstream Vera Sans</string>
                  </edit>
           </match>
           <match target="pattern">
               <test name="family"><string>EunGuseul Mono</string></test>
                   <edit mode="append" binding="strong" name="family">
                      <string>Bitstream Vera Sans Mono</string>
                   </edit>
           </match> 

2. Setting up a .conf file to /etc/fonts/conf.d when a ttf-font package installed, is it preferred way to solve this?

  • I think this may solve the problem of each CJK languages , but how can we configure it for defaultly using ? And also the configureation of each languages need more test , avoid affect other languages such as greek, English ,etc.
  • I think if fontsconf support this:
    • <test name='locale'><String>zh_CN.UTF-8</String></test> or <test name='locale'><String>zh_CN.*</String></test> now, Chinese,Japanese,Korean and other can do it by self.

  • There are lang, familylang, stylelang and fullnamelang properties of fontconfig, try them instead of <test name='locale'> above. ( [http://fontconfig.org/fontconfig-user.html fonts-conf] ) To list up installed ttf fonts per lang, use fc-list command like this, fc-list :lang=ko .

  • I found the name lang used on SuSE Linux 9 Japanese Edition. The following code is one part of suse-pre-user.conf. I'll report about other distributions when I check them up.

  •         <match target="font">
                    <test name="lang" compare="contains">
                            <string>ja</string>
                            <string>zh</string>
                            <string>ko</string>
                    </test>
                    <test name="spacing" compare="eq">
                            <const>dual</const>
                    </test>
                    <edit name="spacing">
                            <const>proportional</const>
                    </edit>
                    <edit name="globaladvance" binding="strong">
                            <bool>false</bool>
                    </edit>
            </match>

BetterCJKSupportSpecification/FontConfig (last edited 2008-08-06 16:14:54 by localhost)