Ignore:
Timestamp:
12/07/2023 10:01:55 AM (10 months ago)
Author:
Ken Moffat <ken@…>
Branches:
12.1, 12.2, gimp3, ken/TL2024, lazarus, plabs/newcss, python3.11, rahul/power-profiles-daemon, trunk, xry111/for-12.3, xry111/llvm18, xry111/spidermonkey128
Children:
ed3fb2c
Parents:
e75e99bd (diff), 366080f (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge branch 'ken/tuningfonts' into trunk

All changes, except for note in packages and changelog, are ready.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • x/installing/tuning-fontconfig.xml

    re75e99bd r6e2f45a  
    2626      If you only read text in English, and are happy with the common libre
    2727      fonts listed on the next page, you may never need to worry about the
    28       details of how <application>fontconfig</application> works. But there are
     28      details of how <application>Fontconfig</application> works. But there are
    2929      many things which can be altered if they do not suit your needs.
    3030    </para>
     
    3535      that some things have changed over the years, for example the autohinter
    3636      is no longer the default). The aim here is to give you enough information
    37       to understand the changes you are making.
    38     </para>
     37      to understand the changes you are making, why they may not always work,
     38      and to identify online information which is no-longer appropriate.
     39    </para>
     40
     41    <para>
     42      Unfortunately, some of the terminology is ambiguous (e.g. 'font face' can
     43      mean a name known to Fontconfig, <emphasis>or</emphasis> the ordinary,
     44      condensed, etc variations of a font) and 'style' can be used to
     45      differentiate 'ordinary' from 'italic', or in describing some classes of
     46      Serif fonts.
     47    </para>
     48
     49    <para>The following links are to assist navigation in this page.</para>
     50    <itemizedlist>
     51      <listitem>
     52        <para><xref linkend="xft-font-protocol"/></para>
     53      </listitem>
     54      <listitem>
     55        <para><xref linkend="useful-commands"/></para>
     56      </listitem>
     57      <listitem>
     58        <para><xref linkend="the-various-files"/></para>
     59      </listitem>
     60      <listitem>
     61        <para><xref linkend="rules-to-choose-a-font"/></para>
     62      </listitem>
     63      <listitem>
     64        <para><xref linkend="hinting-and-antialiasing"/></para>
     65      </listitem>
     66      <listitem>
     67        <para><xref linkend="disabling-bitmap-fonts"/></para>
     68      </listitem>
     69      <listitem>
     70        <para><xref linkend="synthetic-changes"/></para>
     71      </listitem>
     72      <listitem>
     73        <para><xref linkend="adding-extra-directories"/></para>
     74      </listitem>
     75      <listitem>
     76        <para><xref linkend="preferring-certain-fonts"/></para>
     77      </listitem>
     78      <listitem>
     79        <para><xref linkend="fontconfig-user-docs"/></para>
     80      </listitem>
     81      <listitem>
     82        <para><xref linkend="prefer-a-specific-font"/></para>
     83      </listitem>
     84      <listitem>
     85        <para><xref linkend="prefer-chosen-CJK-fonts"/></para>
     86      </listitem>
     87      <listitem>
     88        <para><xref linkend="editing-old-style-conf-files"/></para>
     89      </listitem>
     90      <listitem>
     91        <para><xref linkend="font-weights"/></para>
     92      </listitem>
     93      <listitem>
     94        <para><xref linkend="items-which-can-override-fontconfig"/></para>
     95      </listitem>
     96      <listitem>
     97        <para><xref linkend="external-links"/></para>
     98      </listitem>
     99    </itemizedlist>
    39100
    40101    </sect2>
     
    46107      The Xft font protocol provides antialiased font rendering through
    47108      <application>freetype</application>, and fonts are controlled from the
    48       client side using <application>fontconfig</application> (except for
     109      client side using <application>Fontconfig</application> (except for
    49110      <xref linkend="rxvt-unicode"/> which can use fonts listed in
    50111      <filename>~/.Xresources</filename>, and <xref linkend="abiword"/> which
     
    70131      class="directory">TTF</filename> <application>X</application> font
    71132      directories to <filename
    72       class="directory">/usr/share/fonts/X11-{OTF,TTF}</filename>. This allows
    73       <application>Fontconfig</application> to use the OpenType and TrueType
    74       fonts provided by <application>X</application>, although many people will
    75       prefer to use more modern fonts.
     133      class="directory">/usr/share/fonts/X11-{OTF,TTF}</filename> in Xorg Fonts.
     134      This allows <application>Fontconfig</application> to use the OpenType and
     135      TrueType fonts provided by <application>X</application>, although many
     136      people will prefer to use more modern fonts.
    76137    </para>
    77138
     
    90151
    91152    <para>
    92       The following commands may be helpful when working with fontconfig:
     153      The following commands may be helpful when working with
     154      <application>Fontconfig</application>,
     155      particularly if you are interested in overriding which font will be
     156      chosen.
    93157    </para>
    94158
    95159    <para>
    96160      <command>fc-list | less</command> : shows a list of all available fonts
    97       (/path/to/filename: Font Name:style). If you installed a font more than
    98       30 seconds ago but it does not show, then it or one of its directories is
    99       not readable by your user.
     161      (/path/to/filename: Font Name:style). If you installed a font and it
     162      doesn't show, then the directory it is contained in is not readable by
     163      your user.
    100164    </para>
    101165
     
    105169      see what happens if a font you have not installed is requested, but you
    106170      can also use it if the system is giving you a different font from
    107       what you expected (perhaps because <application>fontconfig</application>
     171      what you expected (perhaps because <application>Fontconfig</application>
    108172      does not think that the font supports your language).
    109173    </para>
    110174
    111175    <para>
    112       <command>fc-match -a 'Type' | less</command> : provides a list of all
    113       fonts which can be used for that type (Monospace, Sans, Serif). Note that
    114       in-extremis <application>fontconfig</application> will take a glyph from
    115       any available font, even if it is not of the specified type, and unless it
    116       knows about the font's type it will assume it is Sans.
     176      <command>fc-match <replaceable>TYPE</replaceable></command> : shows which
     177      font will be used in the current language for that
     178      <!-- match style of TYPE in command and explanations -->
     179      <replaceable>TYPE</replaceable> (Monospace, Sans, Serif <emphasis>(initial
     180      capital letter is optional)</emphasis>). If that font does not map a
     181      codepoint, <application>Fontconfig</application> can take a glyph from any
     182      available font, even if it is not of the specified type. Any other value
     183      for <replaceable>TYPE</replaceable> will be assumed to be Sans.
     184    </para>
     185
     186    <para>
     187      <command>fc-match 'Serif :lang=ja:weight=bold'</command> will tell you
     188      which font and weight will be chosen for Japanese text in bold weight.
     189      It does not mean that the reported font will necessarily be able to show
     190      Japanese ideograms, so a fallback might be used, or some glyphs may be
     191      missing. For language codesi, use ISO-639 values such as 'fr', 'ja', 'zh-cn'.
     192      Note that an unrecognized value such as just 'zh' will not return any
     193      match. To illustrate the fallback, on a system where both Noto Sans Mono
     194      and DejaVu Sans Mono are installed, <command>fc-match 'monospace
     195      :lang=en</command> shows Noto Sans Mono will be used, but if the lang is
     196      changed to 'ar' (arabic) DejaVu Sans will be used.
     197    </para>
     198
     199    <para>
     200      If you want to determine if a font file has hinting (many older fonts do not,
     201      because it was patented) use <command>fc-query
     202      <replaceable>/path/to/fontfile</replaceable> | grep 'fonthashint:'</command>:
     203      which will report 'True(s)' or 'False(s)'. Some recent fonts with both TTF
     204      and OTF versions will have hinting in the TTF files.
    117205    </para>
    118206
     
    132220      particularly useful for CJK languages, and you can also pass a
    133221      language, e.g. PANGO_LANGUAGE=en;ja (English, then assume Japanese)
    134       or just zh-cn (or other variants - 'zh' on its own is not valid).
     222      or just zh-cn (or other variants such as zh-sg or zh-tw).
    135223    </para>
    136224
    137225    </sect2>
    138226
    139     <sect2 role="configuration" id="the-various-files" xreflabel="The various files">
    140     <title>The various files</title>
     227    <sect2 role="configuration" id="the-various-files" xreflabel="The configuration files">
     228    <title>The configuration files</title>
    141229
    142230    <para>
     
    224312    </para>
    225313
    226     <note>
    227       <para>
    228         In fontconfig-2.14 the defaults were changed to Noto fonts. Some of the
    229         detail here is out of date and will be revised.
    230       </para>
    231     </note>
    232 
    233314    <para>
    234315      However, if the document or page requested a font which is not installed
     
    236317      following rules come into play: First,
    237318      <filename>30-metric-aliases.conf</filename> is used to map aliases for
    238       some fonts with the same metrics (same size, etc). After that, an
    239       unknown font will be searched for in <filename>45-latin.conf</filename> -
    240       if it is found it will be mapped as Serif or Monospace or Sans, otherwise
    241       it will be assumed to be Sans. Then <filename>50-latin.conf</filename>
    242       provides ordered lists of the fallbacks - <xref linkend="dejavu-fonts"/>
     319      some fonts with the same metrics (same size, etc). Note that there are
     320      both weak and strong aliases so that aliases for one form such as
     321      Helvetica or Times New Roman can be satisfied by the other style, i.e.
     322      anything which is an alias of Arial or Times in those examples. some
     323      examples of Latin fonts with the same metrics can be found in the
     324      'Substitutes' PDFs at <ulink
     325      url="http://zarniwhoop.uk/files/PDF-substitutes/">zarniwhoop.uk.</ulink>
     326    </para>
     327
     328    <para>
     329      After that, an unknown font will be searched for in
     330      <filename>45-latin.conf</filename>:
     331      'Latin' covers Cyrillic and Greek, and now also maps system-ui fonts which
     332      are used for User Interface messages in other alphabets. If the font
     333      is found it will be mapped as serif, sans-serif, monospace, fantasy,
     334      cursive, or system-ui.  Otherwise, 49-sansserif.conf will assume it is
     335      Sans.
     336    </para>
     337    <para>
     338      Then <filename>60-latin.conf</filename>
     339      provides ordered lists of the fallbacks - <xref linkend="noto-fonts"/>
    243340      will be used if you installed them. Cyrillic and Greek appear to be
    244       treated in the same way. There are similar files with a 65- prefix for
    245       Persian and other non-latin writing systems. All of these files prefer
     341      treated in the same way.All of these files prefer
    246342      commercial fonts if they are present, although modern libre fonts are
    247       often at least equal.
    248     </para>
    249 
    250     <para>
    251       Since fontconfig-2.12.5, there is also generic family matching for some
     343      often at least equal. Finally, if a codepoint is still not found it can
     344      be taken from any available system font. The following details only
     345      mention freely available fonts.
     346    </para>
     347
     348    <para>
     349      Default Persian fonts are dealt with in
     350      <filename>65-fonts-persian.conf</filename>. It looks as if all the listed
     351      fonts are commercial. Using fonts that support Persian (which has its own
     352      variant of the arabic alphabet, and its own font styles) is outside the
     353      skills of the BLFS editors.
     354    </para>
     355
     356    <para>
     357      All remaining scripts for which <application>Fontconfig</application> has
     358      preferences (CJK scripts,
     359      Indic scripts) are dealt with in <filename>65-nonlatin.conf</filename>.
     360      These are again nominally grouped as Serif, Sans-Serif, Monospace. Of the
     361      free fonts, WenQuanYi Zen Hei (Pan-CJK Sans) comes first for both Serif
     362      and for Sans. Therefore, if you install this as a fallback but want to
     363      use different fonts for Japanese or Korean you will need to set up a
     364      preference. Similarly, the old fireflysung Serif font is also listed for
     365      Sans.
     366    </para>
     367
     368    <para>
     369      After Pan-CJK and Chinese fonts come several Japanese fonts and then
     370      several Korean fonts (both split appropriately between Sans and Serif).
     371      Finally come the various Lohit Indic families (one font file per script),
     372      labelled as both Sans and Serif.
     373    </para>
     374
     375    <para>
     376      The Monospace fonts listed in <filename>65-nonlatin.conf</filename> do
     377      not include WenQuanYi Zen Hei although that will be available as a
     378      fallback if installed. Several Japanese Gothic fonts are listed, followed
     379      by AR PL KaitiM GB (a zh-sc 'Brush' font), AR PL Serif fonts for zh-sc
     380      (SungtiL) and zh-tw (Mingti2L), some Korean Sans fonts and the various
     381     Lohit Indic families.
     382    </para>
     383
     384    <para>
     385     For UI fonts, various Noto Sans UI fonts are the only listed free fonts.
     386    </para>
     387
     388    <para>
     389      The various Noto CJK fonts are <emphasis>not</emphasis> among the listed
     390      fonts, possibly the RedHat developers preferred other fonts.  These now
     391      come in many variations, and most users  who use these will not install
     392      any other CJK fonts.
     393    </para>
     394
     395    <para>
     396      Before Fontconfig-2.14, the first preferred Latin font family was Bitstream
     397      Vera. In practice that was rarely used because it covered so little. After
     398      that, DejaVu was the next preferred family, so people were recommended to
     399      install that. That has now changed, Bitstream Vera has been replaced by the
     400      relevant Noto fonts (Serif, Sans, Sans Mono), so these will be preferred if
     401      they have been installed, followed by DejaVu.
     402    </para>
     403
     404    <para>
     405      For serif, Times New Roman could have been aliased from Liberation Serif or
     406      Tinos, and Times from TeX Gyre Termes, so although the named fonts are not
     407      free, the metric-compatible fonts can be used. Ignoring other non-free fonts,
     408      the remaining order for serif is: Times New Roman, Luxi Serif, Nimbus Roman
     409      No9 L, and Times. In practice, that means those fonts at the end of the list
     410      are unlikely to be used unless a web page asks for them.
     411    </para>
     412
     413    <para>
     414      For sans-serif, the remaining order is anything mapped to Arial, Luxi Sans,
     415      Nimbus Sans L, and anything mapped to Helvetica.
     416    </para>
     417
     418    <para>
     419      The remaining alternatives for monospace are Inconsolata, anything mapped
     420      to Courier New, Luxi Mono, Nimbus Mono, and anything mapped to Courier.
     421    </para>
     422
     423    <para>
     424      For 'fantasy' there are no free fonts, so
     425      <application>Fontconfig</application> will fall back to sans-serif.
     426    </para>
     427
     428    <para>
     429      For 'cursive', the only free font is TeX Gyre Chorus as an alias for
     430      ITC Zapf chancery, otherwise <application>Fontconfig</application> will
     431      again fall back to sans-serif.
     432    </para>
     433
     434    <para>
     435      The system-ui category is unusual. It is for interface messages, so some
     436      scripts need special versions to fit in the available space. For Latin,
     437      Greek and Cyrillic an ordinary sans font should fit without problems. However,
     438      the first preferred font is Cantarell, followed by Noto Sans UI. Cantarell
     439      started as a Latin sans-serif font, that has been forked in Gnome under
     440      the same name but they only provide the source. The Noto Sans UI fonts are
     441      for other languages.
     442    </para>
     443
     444    <para>
     445      Since Fontconfig-2.12.5, there is also generic family matching for some
    252446      emoji and math fonts, please see {45,60}-generic.conf.
    253447    </para>
     
    276470      To try out different settings, you may need to exit from Xorg and then
    277471      run <command>startx</command> again so that all applications use the new
    278       settings. If you use GNOME, KDE, or LXQt, their desktops can override
    279       these changes. To explore the possibilities, create a file for your user:
     472      settings. Several things can override the fontconfig settings, see
     473      <xref linkend="items-which-can-override-fontconfig"/> below for more
     474      details. To explore the possibilities, create a file for your user:
    280475    </para>
    281476
     
    300495    &lt;!-- options for hintstyle:
    301496    hintfull: is supposed to give a crisp font that aligns well to the
    302     character-cell grid but at the cost of its proper shape.
    303 
    304     hintmedium: poorly documented, maybe a synonym for hintfull.
     497    character-cell grid but at the cost of its proper shape. However, anything
     498    using Pango >= 1.44 will not support full hinting, Pango now uses harfbuzz
     499    for hinting. Apps which use Skia (e.g. Chromium, Firefox) should not be
     500    affected by this. <!-- https://github.com/harfbuzz/harfbuzz/issues/2394 -->
     501
     502    hintmedium: is reported to be broken.
    305503    hintslight is the default: - supposed to be more fuzzy but retains shape.
    306504
     
    324522
    325523    <para>
    326       You will now need to edit the file in your preferred editor.
    327     </para>
     524      You will now need to edit the file in your preferred editor. Many of the
     525      different settings give very subtle differences and the results may differ
     526      for some of the fonts you use.
     527    </para>
     528
     529    <note>
     530      <para>
     531        Hinting, if enabled, is done in <application>FreeType</application>.
     532        Since FreeType-2.7 the default TrueType interpreter is v40. The
     533        original v35 hinter could be enabled by an environment variable, but
     534        is only really appropriate to original Microsoft TTF fonts (Arial, etc).
     535        The v38 hinter (Infinality) is not built by default and all the options
     536        to tune it have been removed. For full details see <xref
     537        linkend="subpixel-hinting"/> (Spoiler: there is NO sub-pixel hinting,
     538        the code simply ignores <emphasis>all</emphasis> horizontal hinting
     539        instructions).
     540      </para>
     541
     542      <para>
     543        Xorg assumes screens have 96 dots per inch (DPI). Most LCD screens are
     544        close to this, but some people detect colour fringing if their screen
     545        diverges from that size. See <xref linkend="calc-dpi"/>.
     546      </para>
     547
     548      <para>
     549        If you have a High DPI screen (often described as '4K' or larger) you
     550        will probably use larger font sizes and benefit from disabling hinting.
     551      </para>
     552    </note>
    328553
    329554    <para>
     
    347572      installed. Now, many people will not need to install any of them. But if
    348573      for some reason you have installed one or more bitmap fonts, you can
    349       prevent them from being used by <application>fontconfig</application> by
     574      prevent them from being used by <application>Fontconfig</application> by
    350575      creating the following file as the &root; user :
    351576    </para>
     
    368593  </sect2>
    369594
     595  <sect2 role="configuration" id="synthetic-changes" xreflabel="Synthetic changes">
     596  <title>Synthetic changes</title>
     597
     598  <para>
     599    In <filename>90-synthetic.conf</filename> there are examples of applying
     600    synthetic slanting and emboldening to a font. The synthetic emboldening can
     601    be applied to a visibly faint font, but the results are not always as
     602    expected: With just the embolden, <application>Epiphany</application> showed
     603    darker fonts while <application>Firefox</application> did not - so although
     604    <application>Cairo</application> is now used by
     605    <application>firefox</application> the comment about setting Weight is still
     606    valid. But setting both, <application>Epiphany</application> will show bold
     607    text by default, but it will show heavy text if markup for bold is used. In both
     608    cases, neither
     609    <application>libreOffice</application> nor <application>falkon</application>
     610    showed bolder text.
     611  </para>
     612
     613  </sect2>
     614
    370615  <sect2 role="configuration" id="adding-extra-directories" xreflabel="Adding extra font directories">
    371616  <title>Adding extra font directories</title>
     
    414659          system in a newer version, and if you have multiple versions of a font
    415660          it is unclear which one will be used by
    416           <application>fontconfig</application>.
     661          <application>Fontconfig</application>.
    417662        </para>
    418663      </listitem>
     
    452697
    453698    <para>
    454       There are many reasons why people may wish to have pages which specify a
    455       particular font use a different font, or prefer specific fonts in
    456       Monospace or Sans or Serif. As you will expect, there a number of
    457       different ways of achieving this.
    458     </para>
    459 
    460     <bridgehead renderas="sect3" id="fontconfig-user-docs"
    461     xreflabel="fontconfig-user-docs">Fontconfig user docs</bridgehead>
    462 
    463       <para>
    464         <application>Fontconfig</application> installs user documentation that
    465         includes an example 'User configuration file' which among other things
    466         prefers <xref linkend="wenquanyi-zenhei"/> (a Sans font) if a
    467         <emphasis>Serif</emphasis> font is requested for Chinese (this part
    468         might be anachronistic unless you have non-free Chinese fonts, because
    469         in <filename>65-nonlatin.conf</filename> this font is already among the
    470         preferred fonts when Serif is specified for Chinese) and to prefer the
    471         modern <xref linkend="VLGothic"/> font if a Sans font is specified on a
    472         Japanese page (otherwise a couple of other fonts would be preferred if
    473         they have been installed).
    474       </para>
    475 
    476       <para>
    477         If you have installed the current version, the user documentation is
    478         available in HTML, PDF, and text versions at <filename
    479         class="directory">/usr/share/doc/fontconfig-&fontconfig-version;/</filename>
    480         : change the version if you installed a different one.
    481       </para>
    482 
    483     <bridgehead renderas="sect3" id="prefer-a-specific-font"
    484     xreflabel="fontconfig-prefer-specific-font">Prefer a specific font</bridgehead>
    485 
    486       <para>
    487         As an example, if for some reason you wished to use the <ulink
    488         url="https://www.fontsquirrel.com/fonts/nimbus-roman-no9-l">Nimbus Roman
    489         No9 L</ulink> font wherever Times New Roman is referenced (it is
    490         metrically similar, and preferred for Times Roman, but the Serif font
    491         from <xref linkend="liberation-fonts"/> will be preferred for the Times
    492         <emphasis>New</emphasis> Roman font if installed), as an individual user
    493         you could install the font and then create the following file:
    494       </para>
     699      With the exception of web pages which use WOFF fonts and either supply
     700      them or link to google to download them, web pages have traditionally
     701      suggested a list of preferred font family names if they cared (e.g.
     702      Times New Roman, Serif). There are many reasons why people may wish to
     703      have pages which specify a  preferred font use a different font, or
     704      prefer specific fonts in Monospace or Sans or Serif. As you will expect,
     705      there a number of different ways of achieving this.
     706    </para>
     707
     708  </sect2>
     709
     710  <sect2 role="configuration" id="fontconfig-user-docs" xreflabel="Fontconfig user documentation">
     711  <title>Fontconfig user documentation</title>
     712
     713    <para>
     714      <application>Fontconfig</application> installs user documentation that
     715      includes an example 'User configuration file' which among other things
     716      prefers <xref linkend="wenquanyi-zenhei"/> (a Sans font) if a
     717      <emphasis>Serif</emphasis> font is requested for Chinese (this part
     718      might be anachronistic unless you have non-free Chinese fonts, because
     719      in <filename>65-nonlatin.conf</filename> this font is already among the
     720      preferred fonts when Serif is specified for Chinese) and to prefer the
     721      modern <xref linkend="VLGothic"/> font if a Sans font is specified on a
     722      Japanese page (otherwise a couple of other fonts would be preferred if
     723      they have been installed).
     724    </para>
     725
     726    <para>
     727      If you have installed the current version, the user documentation is
     728      available in HTML, PDF, and text versions at <filename
     729      class="directory">/usr/share/doc/fontconfig-&fontconfig-version;/</filename>
     730      : change the version if you installed a different one.
     731    </para>
     732
     733  </sect2>
     734
     735  <sect2 role="configuration" id="prefer-a-specific-font" xreflabel="Prefer a specific font">
     736  <title>Prefer a specific font</title>
     737
     738    <para>
     739      As an example, if for some reason you wished to use the <ulink
     740      url="https://www.fontsquirrel.com/fonts/nimbus-roman-no9-l">Nimbus Roman
     741      No9 L</ulink> font wherever Times New Roman is referenced (it is
     742      metrically similar, and preferred for Times Roman, but the Serif font
     743      from <xref linkend="liberation-fonts"/> will be preferred for the Times
     744      <emphasis>New</emphasis> Roman font if installed), as an individual user
     745      you could install the font and then create the following file:
     746    </para>
    495747
    496748<screen><userinput>mkdir -pv ~/.config/fontconfig/conf.d &amp;&amp;
     
    501753&lt;!-- prefer Nimbus Roman No9 L for Times New Roman as well as for Times,
    502754 without this Tinos and Liberation Serif take precedence for Times New Roman
    503  before fontconfig falls back to whatever matches Times --&gt;
     755 before Fontconfig falls back to whatever matches Times --&gt;
    504756    &lt;alias binding="same"&gt;
    505757        &lt;family&gt;Times New Roman&lt;/family&gt;
     
    511763EOF</userinput></screen>
    512764
    513       <para>
    514         This is something you would normally do in an individual user's
    515         settings, but the file in this case has been prefixed '35-' so that it
    516         could, if desired, be used system-wide in <filename
    517         class="directory">/etc/fonts/conf.d/</filename>.
    518       </para>
    519 
    520     <bridgehead renderas="sect3" id="prefer-chosen-CJK-fonts"
    521     xreflabel="Prefer chosen CJK fonts">Prefer chosen CJK fonts</bridgehead>
    522 
    523       <para>
    524         The following example of a local configuration (i.e. one that applies
    525         for all users of the machine) does several things. It is particularly
    526         appropriate where no language is specified, or for reading CJK text
    527         in a non-CJK locale, and where the Japanese forms of the codepoints
    528         shared with Chinese are preferred. In particular, alternative
    529         approaches would be to specify a Chinese font ahead of the Japanese
    530         font, meaning that only Kana symbols will be used from the Japanese
    531         font, or to not specify DejaVu so that the first font in each set
    532         of preferences is preferred for text using latin alphabets.
    533       </para>
    534 
    535       <orderedlist>
    536         <listitem>
    537           <para>
    538             If a Serif font is specified, it prefers <xref linkend="dejavu-fonts"/>.
    539             If Han codepoints are found, or the Japanese language is specified,
    540             the Mincho font from <xref linkend="IPAex"/> will be used. If Hangul
    541             codepoints are found or the Korean language is specified, UnBatang
    542             (see <xref linkend="Korean-fonts"/>) will be used: Change that line
    543             If you installed a different Korean serif font. After that,
    544             <xref linkend="wenquanyi-zenhei"/>  (Sans, but a default for Serif
    545             and monospace) is used. A previous version of this page mentioned
    546             using UMing which is a traditional-style Chinese font that ships
    547             with an old conf file preferring it for zh-tw and zh-hk language
    548             codes (and for sans-serif and monospace). But without the conf file,
    549             fontconfig will only treat it as suitable for zh-hk.
    550             The conf file needs to be edited to current style and will then be
    551             prepended, so specifying UMing does not belong in this
    552             <filename>local.conf</filename> file.
    553           </para>
    554         </listitem>
    555         <listitem>
    556           <para>
    557             For Sans Serif preferences again start with <xref linkend="dejavu-fonts"/>,
    558             then <xref linkend="VLGothic"/> for Japanese before falling back to
    559             WenQuanYi Zen Hei which is Sans and covers both Chinese and Korean
    560             Hangul.
    561           </para>
    562         </listitem>
    563         <listitem>
    564           <para>
    565             The Monospace fonts are forced to the preferred Sans fonts. If the
    566             text is in Chinese or Korean then <xref
    567             linkend="wenquanyi-zenhei"/> will be used.
    568           </para>
    569         </listitem>
    570       </orderedlist>
    571 
    572       <para>
    573         In a non-CJK locale, the result is that suitable fonts will be used for
    574         all variants of Chinese, Japanese and Hangul Korean (but Japanese variants
    575         of the glyphs shared with Chinese Han will be used). All other languages
    576         should already work if a font is present. As the <systemitem
    577         class="username">root</systemitem> user:
    578       </para>
     765    <para>
     766      This is something you would normally do in an individual user's
     767      settings, but the file in this case has been prefixed '35-' so that it
     768      could, if desired, be used system-wide in <filename
     769      class="directory">/etc/fonts/conf.d/</filename>.
     770    </para>
     771
     772  </sect2>
     773
     774  <sect2 role="configuration" id="prefer-chosen-CJK-fonts" xreflabel="Preferring chosen CJK fonts">
     775  <title>Prefer chosen CJK fonts</title>
     776
     777    <para>
     778      The following example of a local configuration (i.e. one that applies
     779      for all users of the machine) does several things. It is particularly
     780      appropriate where no language is specified, or for reading CJK text
     781      in a non-CJK locale, and where the Japanese forms of the codepoints
     782      shared with Chinese are preferred. In particular, alternative
     783      approaches would be to specify a Chinese font ahead of the Japanese
     784      font, meaning that only Kana symbols will be used from the Japanese
     785      font, or to not specify DejaVu so that the first font in each set
     786      of preferences is preferred for text using Latin alphabets.
     787    </para>
     788
     789    <orderedlist>
     790      <listitem>
     791        <para>
     792          If a Serif font is specified, it prefers <xref linkend="dejavu-fonts"/>.
     793          If Han codepoints are found, or the Japanese language is specified,
     794          the Mincho font from <xref linkend="IPAex"/> will be used. If Hangul
     795          codepoints are found or the Korean language is specified, UnBatang
     796          (see <xref linkend="Korean-fonts"/>) will be used: Change that line
     797          If you installed a different Korean serif font. After that,
     798          <xref linkend="wenquanyi-zenhei"/>  (Sans, but a default for Serif
     799          and monospace) is used. A previous version of this page mentioned
     800          using UMing which is a Traditional Chinese font that ships
     801          with an old conf file preferring it for zh-tw and zh-hk language
     802          codes (and for sans-serif and monospace). But without the conf file,
     803          <application>Fontconfig</application> will only treat it as suitable
     804          for zh-hk.
     805          The conf file needs to be edited to current style and will then be
     806          prepended, so specifying UMing does not belong in this
     807          <filename>local.conf</filename> file.
     808        </para>
     809      </listitem>
     810      <listitem>
     811        <para>
     812          For Sans Serif preferences again start with <xref linkend="dejavu-fonts"/>,
     813          then <xref linkend="VLGothic"/> for Japanese before falling back to
     814          WenQuanYi Zen Hei which is Sans and covers both Chinese and Korean
     815          Hangul.
     816        </para>
     817      </listitem>
     818      <listitem>
     819        <para>
     820          The Monospace fonts are forced to the preferred Sans fonts. If the
     821          text is in Chinese or Korean then <xref
     822          linkend="wenquanyi-zenhei"/> will be used.
     823        </para>
     824      </listitem>
     825    </orderedlist>
     826
     827    <para>
     828      In a non-CJK locale, the result is that suitable fonts will be used for
     829      all variants of Chinese, Japanese and Hangul Korean (but Japanese variants
     830      of the glyphs shared with Chinese Han will be used). All other languages
     831      should already work if a font is present. As the <systemitem
     832      class="username">root</systemitem> user:
     833    </para>
    579834
    580835<screen role="root"><userinput>cat > /etc/fonts/local.conf &lt;&lt; "EOF"
     
    613868  </sect2>
    614869
    615 
    616870  <sect2 role="configuration" id="editing-old-style-conf-files"
    617871  xreflabel="Editing Old-Style conf files">
     
    622876      installed in <filename class="directory">/etc/fonts/conf.d</filename>.
    623877      However, if you do that and then use a terminal to run any command which
    624       uses <application>fontconfig</application> you may see error messages such
     878      uses <application>Fontconfig</application> you may see error messages such
    625879      as :
    626880    </para>
     
    634888    <para>
    635889      In practice, these old rules do not work. For non-CJK users,
    636       <application>fontconfig</application> will usually do a good job
     890      <application>Fontconfig</application> will usually do a good job
    637891      <emphasis>without</emphasis> these rules. Their origin dates back to when
    638892      CJK users needed handcrafted bitmaps to be legible at small sizes, and
     
    652906    </para>
    653907
    654     <para>
    655       <literallayout>
     908<screen role="root">
    656909   &lt;match target="pattern"&gt;
    657910       &lt;test qual="any" name="lang" compare="contains"&gt;
     
    665918           &lt;string&gt;AR PL UMing CN&lt;/string&gt;
    666919       &lt;/edit&gt;
    667     &lt;/match&gt;</literallayout>
    668     </para>
     920   &lt;/match&gt;
     921</screen>
    669922
    670923    <para>
     
    680933    </para>
    681934
    682     <para>
    683       <literallayout>
     935<screen role="root">
    684936   &lt;match target="pattern"&gt;
    685937       &lt;test qual="any" name="lang" compare="contains"&gt;
     
    703955           &lt;string&gt;AR PL UMing CN&lt;/string&gt;
    704956       &lt;/edit&gt;
    705     &lt;/match&gt;</literallayout>
    706     </para>
    707 
    708   </sect2>
    709 
    710 
    711   <sect2 role="configuration" id="see-also" xreflabel="See Also">
    712   <title>See Also</title>
     957    &lt;/match&gt;
     958</screen>
     959
     960  </sect2>
     961
     962  <sect2 role="configuration" id="font-weights" xreflabel="About font weights">
     963  <title>About font weights</title>
     964
     965    <para>
     966      When this page and the next page were first created, Latin fonts came
     967      with a  maximum of two weights - either Regular or Book (Book typically
     968      has a larger X-height to make it easier to read in large blocks of text),
     969      and  Bold - and perhaps an Italic (or Slant) style. A few fonts also had
     970      Condensed faces (to fit more text into a line and usually only used when
     971      specified). Without CSS (Cascading Style Sheets) markup, text used the
     972      Regular or Book weight except when &lt;b&gt; ... &lt;/b&gt; markup was
     973      used for bold text. Italic styles would be invoked by &lt;i&gt; ... &lt;/i&gt;
     974      markup, along with the bold markup for Bold Italic.
     975    </para>
     976
     977    <para>
     978      Some faces now contain up to 9 weights, possibly also with a variable font
     979      (to save space by including all the alternatives in one file and possibly
     980      allowing intermediate weights). For most desktop users who do not need this
     981      wide range of weights for creating content, it is simpler to only install
     982      one or two weights. If a face has individual weights plus a variable font,
     983      the variable font is usually in the top level of the supplied directory,
     984      with individual weights in a <filename class="directory">static/</filename>
     985      subdirectory. Except when initially reviewing a font, it makes no sense to
     986      install both static and variable, nor all the possible weights.
     987    </para>
     988
     989    <para>
     990      The weights are labelled from 100 (Thin) to 900 (Black or Heavy) in CSS
     991      terminology, with 400 being normal and 700 bold. The full set of weights
     992      is described at <xref linkend="css-weights"/>.
     993    </para>
     994
     995    <para>
     996      If you have installed a font with a range of weights, you can copy <ulink
     997      url="https://&lfs-domainname;/~ken/font-weights.html">font-weights.html</ulink>
     998      to your local machine. As shiped it will use your default Serif font assuming
     999      you have one. Edit it to point to a specific installed font using the name
     1000      known to <application>Fontconfig</application> (also in the *EDITME FONTNAME*
     1001      text items) and open it
     1002      from your desktop browser. You can also use it to look at a font with only
     1003      two installed weights, e.g. for testing to see if you prefer other weights.
     1004    </para>
     1005
     1006    <para>
     1007      Despite the details in that Mozilla link, it appears that if only normal and
     1008      bold weights are installed, SemiBold (600) will be shown using bold.
     1009    </para>
     1010
     1011    <para>
     1012      There seems to be a little scope for changing which weights are used for
     1013      normal and bold <emphasis>if only two weights have been installed</emphasis>.
     1014      Firefox, and probably other browsers, will look for the next weight heavier
     1015      than normal. If that is less than bold (Medium, maybe SemiBold - uncertain)
     1016      it will be used for normal and then the next higher weight, if any will be
     1017      used for bold, allowing you to make the fonts slightly darker. Conversely,
     1018      if only a weight less than normal has been installed, such as Light, that
     1019      will be used for both normal and bold weights (the upward search happens
     1020      first).
     1021    </para>
     1022
     1023    <para>
     1024      If you remove some weights of a system font, you may need to run
     1025      <command>fc-cache</command> as the &root; user and then log out completely
     1026      to clear caches associated with your user.
     1027      <!-- I don't know for sure that there are user caches retained until you
     1028     log out, but certainly leaving X and restarting the browser is not always
     1029     adequate : ken -->
     1030    </para>
     1031
     1032  </sect2>
     1033
     1034  <sect2 role="configuration" id="items-which-can-override-fontconfig" xreflabel="Items which can override Fontconfig">
     1035  <title>Items which can override Fontconfig</title>
     1036
     1037    <para>
     1038      Several desktop environments, as well as some programs, will use
     1039      <application>Fontconfig</application>
     1040      to find fonts but may override certain things.
     1041    </para>
     1042
     1043    <para>
     1044      <application>GNOME</application>: The settings in
     1045      org.gnome.desktop.interface can be updated with
     1046      <application>dconf-editor</application>. You can set the fonts to your
     1047      preference and desired point size. To use the fonts chosen by
     1048      <application>Fontconfig</application> specify e.g. 'Sans 12', Serif 11',
     1049      'Mono 10' as desired. Also review the antialiasing, hinting and rgba
     1050      settings. Alternatively, <xref linkend="gnome-tweaks"/> can also update
     1051      the font settings in a GUI form.
     1052    </para>
     1053
     1054    <para>
     1055      <application>LXQt</application>: Change font settings as necessary to
     1056      match <application>Fontconfig</application> in
     1057      <application>lxqt-config-appearance</application>.
     1058    </para>
     1059
     1060    <para>
     1061      <application>KDE Plasma</application>: The settings can be adjusted in
     1062      <application>System Settings</application> under Appearance -> Fonts. This
     1063      will create or modify <filename>~/.config/fontconfig/fonts.conf</filename>
     1064      although <filename>~/.config/fontconfig/fonts.conf</filename>, if
     1065      installed, can override that.
     1066    </para>
     1067
     1068    <para>
     1069      <application>Xfce desktop</application>: The settings can be adjusted in
     1070      <application>Settings</application>i -> Appearance -> Fonts. Specify your
     1071      preferred fonts, e.g. 'Sans Regular' (to use the normal face and weight
     1072      rather than Bold and/or Italic) and adjust the point size in the option.
     1073      Review the Rendering and DPI options.
     1074    </para>
     1075
     1076    <para>
     1077      <application>Firefox</application>: This browser allows you to specify its
     1078      default fonts. For the 115esr series use the 'Hamburger' menu to go to
     1079      Preferences, General, and under Fonts -> Advanced select Sans Serif, Serif
     1080      or Monospace as appropriate if you wish to use the fonts which match
     1081      <application>Fontconfig</application>.  Set the point sizes as desired. In
     1082      later versions, the settings are at Preferences -> Fonts.
     1083      <!-- FIXME : Ken - when merging, add note in packages to update this when next ESR
     1084      series is used -->
     1085    </para>
     1086
     1087    <para>
     1088      <application>Libreoffice</application>: Tests using English text with an
     1089      old Japanese font (HanaMinA) which supports several European languages but
     1090      had only one weight and no italics or slant showed that although
     1091      <application>Libreoffice</application> uses
     1092      <application>Fontconfig</application> to find the font, it created its own
     1093      bold or slanted text. It is not clear if it will do the same where a font
     1094      actually has bold weight or an italic style. Also, documentation shows
     1095      that <application>Libreoffice</application> has its own substitution rules
     1096      for when a codepoint is not found in the selected font, but is unclear if
     1097      those rules apply on Linux using Fontconfig.
     1098    </para>
     1099
     1100    <para>
     1101      <application>Pango</application>: as noted in the example
     1102      <filename>~/.config/fontconfig</filename> above, anything using Pango-1.44
     1103      (from 2019) or later now uses <application>Harfbuzz</application> for
     1104      hinting, not <application>FreeType</application>, and
     1105      <literal>hintfull</literal> is not supported.
     1106    </para>
     1107
     1108    <para>
     1109      <application>Thunderbird</application>: The font settings can be changed
     1110      by going to "Edit -> Settings" and then scrolling down to "Fonts &amp;
     1111      Colors".
     1112    </para>
     1113
     1114  </sect2>
     1115
     1116  <sect2 role="configuration" id="external-links" xreflabel="External Links">
     1117  <title>External Links</title>
    7131118
    7141119    <bridgehead renderas="sect3" id="I-stared-into-the-fontconfig"
     
    7181123      The blog entries by <ulink
    7191124      url="https://eev.ee/blog/2015/05/20/i-stared-into-the-fontconfig-and-the-fontconfig-stared-back-at-me/">Eevee</ulink>
    720       are particularly useful if <application>fontconfig</application> does not
     1125      are particularly useful if <application>Fontconfig</application> does not
    7211126      think your chosen font supports your language, and for preferring some
    7221127      non-MS Japanese fonts when an ugly MS font is already installed.
     1128    </para>
     1129
     1130    <bridgehead renderas="sect3" id="subpixel-hinting"
     1131    xreflabel="subpixel-hinting">subpixel-hinting</bridgehead>
     1132
     1133    <para>The documentation of the FreeType v40 interpreter at <ulink
     1134      url="https://freetype.org/freetype2/docs/hinting/subpixel-hinting.html">freetype
     1135      docs</ulink>
     1136      explains how the current hinter works, and why the previous (slow) Infinality
     1137      interpreter was replaced.
     1138    </para>
     1139
     1140    <bridgehead renderas="sect3" id="calc-dpi"
     1141    xreflabel="calc-dpi">Calculating DPI</bridgehead>
     1142
     1143    <para>An old answer at <ulink
     1144      url="https://askubuntu.com/questions/197828/how-to-find-and-change-the-screen-dpi/">askubuntu</ulink>
     1145      gives some detail on calculating a screen's dots per inch, but essentailly
     1146      you just measure the width and height of the visible panel, convert to
     1147      inches if using metric measurements, and divide by the number of pixels.
     1148      You can then pass <option>-dpi <replaceable>90</replaceable></option> when
     1149      you start Xorg, using your own value.
     1150    </para>
     1151
     1152    <bridgehead renderas="sect3" id="css-weights"
     1153    xreflabel="Table of CSS font weights">Table of CSS font weights</bridgehead>
     1154
     1155    <para>Perhaps more than you ever wished to know is at <ulink
     1156      url="https://developer.mozilla.org/en-US/docs/Web/CSS/font-weight">Mozilla
     1157      CSS docs</ulink>.
     1158    </para>
     1159
     1160    <bridgehead renderas="sect3" id="ttfautohint"
     1161    xreflabel="Applying autohinting to a font">Applying autohinting to a font</bridgehead>
     1162
     1163    <para>
     1164      If you are using hinting and have a TTF (not OTF) font which lacks hints
     1165      but permits you to fork it, you might be able to apply hints using <ulink
     1166      url="https://freetype.org/ttfautohint/">ttfautohint</ulink> which is based
     1167      on the old autohinter. As of version 1.8.4 it fails to build without Qt5.
     1168      <!-- switch exists, configure passes but build fails -->
    7231169    </para>
    7241170
Note: See TracChangeset for help on using the changeset viewer.