Difference between revisions of "Font configuration"
m (→I want my font sizes to match my DPI settings: s/local.conf/.fonts.conf) |
|||
Line 156: | Line 156: | ||
===I don't like font <enter name here> and want to use <another font name> instead=== | ===I don't like font <enter name here> and want to use <another font name> instead=== | ||
− | The most reliable way to do this is to add an XML fragment similar to the one below to / | + | The most reliable way to do this is to add an XML fragment similar to the one below to ~/[[.fonts.conf]]. This will cause Bitstream Vera Sans to be used in place of Helvetica: |
+ | <match target="pattern" name="family" > | ||
+ | <test name="family" qual="any" > | ||
+ | <string>Helvetica</string> | ||
+ | </test> | ||
+ | <edit mode="assign" name="family" > | ||
+ | <string>Bitstream Vera Sans</string> | ||
+ | </edit> | ||
+ | </match> | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
Line 170: | Line 172: | ||
− | <!-- Replace Helvetica with Bitstream Vera Sans Mono --> | + | < !-- Replace Helvetica with Bitstream Vera Sans Mono --> |
− | <!-- Note, an alias for Helvetica should already exist in default | + | < !-- Note, an alias for Helvetica should already exist in default conf files --> |
<alias> | <alias> | ||
− | <family>Helvetica </family> | + | <family>Helvetica</family> |
<prefer><family>Bitstream Vera Sans Mono</family></prefer> | <prefer><family>Bitstream Vera Sans Mono</family></prefer> | ||
<default><family>fixed</family></default> | <default><family>fixed</family></default> |
Revision as of 01:11, 15 January 2008
by PhrakTure
Template:I18n links start
Template:I18n entry
Template:I18n entry
Template:I18n links end
Contents
- 1 X.org Font Configuration and beautification
- 2 X.org Font Path and /etc/fonts/
- 3 Some Font Downloads
- 4 Goodies
- 4.1 LCD ClearType Patch
- 4.2 My fonts look like crap - I've configured everything right but it appears I just have no good fonts.
- 4.3 I have some apps compiled against Gtk+ 2.2 and under and fonts still look like garbage.
- 4.4 I have a similar problem as above with older Qt based apps.
- 4.5 Fonts in Gtk apps are too small when using KDE
- 4.6 The bytecode interpreter makes my fonts look crappy, and it's compiled in, do I need to recompile?
- 4.7 Autohint works great but not for my bold fonts. How can I turn it off only for bold fonts?
- 4.8 I have a TFT/DFP/LCD display uses a DVI cable and fonts look odd and fuzzy
- 4.9 I don't want my fonts Antialiased under a certain point size.
- 4.10 I'm using MS TrueType fonts (verdana) and want to enable anti-aliasing but only for bigger fonts that look too jagged.
- 4.11 I want to add more fonts.
- 4.12 I want my font sizes to match my DPI settings
- 4.13 I don't like font <enter name here> and want to use <another font name> instead
- 4.14 I have tons of disgusting pixel fonts that I don't want
- 4.15 Something or someone disabled all my non-scalable (bitmap) fonts, I want them back
- 4.16 Fake bold & italic styles for incomplete fonts
- 4.17 A web developer's fonts/local.conf taken from arch forums
X.org Font Configuration and beautification
- See the Xorg Font Documentation for full details.
- See the FreeType2 Project Page for details on the freetype X.org Module.
- See Optimal Use of Fonts on Linux for more information about fonts in Linux.
xorg.conf modules
- freetype - support for True Type (ttf, ttc), Type1 (pfa, pfb), CID (cid), CFF, Open Type, bitmap (bdf, pcf, snf), Windows (fnt), PFR, and Type42 fonts
- type1 - support for Type1 (pfa, pfb) and CID (cid) fonts
- speedo - support for Bitstream Speedo (spd) fonts
- xtt - support for True Type (ttf, ttc) fonts (conflicts with freetype)
- bitmap - support for bitmap (bdf, pcf, snf) fonts
As you can see, freetype provides everything provided by these other modules already. In addition, xtt will conflict with freetype.
X.org Font Path and /etc/fonts/
xorg.conf font path
The font path described in the xorg.conf file is used for non-Xft fonts. It is worthwhile to specify a majority of fonts here. Applications which do not support Xft will fall back to the X Server's font path. Personally, I keep a minimum of fonts here - for use with xterm and its ilk.
/etc/fonts/ font directories
The conf files in /etc/fonts (fonts.conf and local.conf) are used for fontconfig (Xft fonts). fonts.conf should never be changed, and all changes should be done in local.conf (for system wide changes) or ~/.fonts.conf (for user based changes). Files in /etc/fonts/conf.d are sourced when they start with a number and end with .conf.
The directories listed in fonts.conf are scanned by fc-cache for use with fontconfig (/usr/share/fonts and ~/.fonts). All fonts should be placed in these directories. If installing new fonts, running fc-cache -fv will detect the changes.
Adding new fonts
When new fonts are added, they are just files on your system. A handful of utilities need to be run in order to tell the system that new fonts have been added.
/usr/bin/fc-cache
This will update the fontconfig cache, assuming the new fonts can be searched by fontconfig (see the above section about /etc/fonts)
/usr/bin/mkfontscale /usr/bin/mkfontdir ln -s /usr/X11R6/lib/X11/fonts/encodings/encodings.dir encodings.dir
These utilities need to be run from inside the directory of the new fonts. mkfontscale creates a fonts.scale file and mkfontdir creates a fonts.dir file. These files are used by the X Server, and only need to be done if the fonts are to be served through the FontPath of X.org. The encodings soft link allows the X Server to use these new fonts under all supported encodings. After all this, you should have 3 new files in the font dir : fonts.scale, fonts.dir, and encodings.dir.
fc-list and xlsfont utilities
These utilities will list, from the command line, all fonts available to each font subsystem. fc-list will list all fontconfig fonts, while xlsfont will list all X fonts. This is useful in combination with grep, i.e. "xlsfonts || grep -i bitstream" to see all bitstream fonts available.
Some Font Downloads
- Arkpandora TrueType fonts - Replacements for Arial and Times New Roman.
- PPants Angular Font Collection-Small collection of Angular-styled fonts with a general width of six pixels.
- Profont-Programming font.
Goodies
LCD ClearType Patch
http://bbs.archlinux.org/viewtopic.php?id=33955
My fonts look like crap - I've configured everything right but it appears I just have no good fonts.
I would suggest the following packages from pacman to fix this:
pacman -S ttf-ms-fonts ttf-cheapskate artwiz-fonts
I have some apps compiled against Gtk+ 2.2 and under and fonts still look like garbage.
Yeah, this happens. Modern GTK apps enable Xft by default, however, before 2.2 this was not the case. Maybe these apps should be updated to the newer GTK. If that is not an option, then adding the line export GDK_USE_XFT=1 to a global settings file (/etc/profile, /etc/profile.d/gnome.sh, ~/.xinitrc, etc) will enable Xft for older apps
I have a similar problem as above with older Qt based apps.
Similar solution, add export QT_XFT=true somewhere.
Fonts in Gtk apps are too small when using KDE
Install gtk-qt-engine:
pacman -Sy gtk-qt-engine
- Change the font size for Gtk apps in `Control Center' -> `Appearance & Themes' -> `GTK Styles and Fonts'.
The bytecode interpreter makes my fonts look crappy, and it's compiled in, do I need to recompile?
Nope, not at all. Freetype's internal auto-hinting is just shut off. In some distros, the bytecode interpreter is compiled in and enabled by default. As a result, the bytecode interpreter overrides the freetype autohinter (which the developers are very proud of). To force the autohinter to be on, add the following to /etc/fonts/local.conf or ~/.fonts.conf
<match target="pattern">
<edit name="autohint" mode=
"assign">
<bool>true</bool>
</edit>
</match>
Or change to the /etc/fonts/conf.d directory, and link the 10-autohint.conf file from the conf.avail directory into the conf.d directory. The following commands should work (the second command must be run with superuser privileges).
cd /etc/fonts/conf.d ln -s ../conf.avail/10-autohint.conf
Question: I don't understand this... The bytecode interpreter is supposed to beat the autohinter by a long shot so i don't see why anyone would want the autohinter. Reply: It appears that the bytecode interpreter in the 2.3 branch is quite poor. There's a forum post about it here: http://bbs.archlinux.org/viewtopic.php?id=29976 The above code made fonts much better for me. Although they didn't come into affect until after I rebooted - no idea why.
Autohint works great but not for my bold fonts. How can I turn it off only for bold fonts?
Autohinter can give you nice fonts but often makes fonts too wide. This is especially annoying with bold fonts. Fortunately you can turn off autohinter for bold fonts while leaving it on for the rest.
- First turn on autohinter (see above) and add the following to ~/.fonts.conf
<match target="font"> <test name="weight" compare=
"more"> <const>medium</const> </test> <edit name="autohint" mode=
"assign"> <bool>false</bool> </edit> </match>
I have a TFT/DFP/LCD display uses a DVI cable and fonts look odd and fuzzy
This is due to rendering differences between CRTs and non-CRTs. To fix this problem, you need to enable sub-pixel rendering. Edit the ~/.fonts.conf file. Add the following section to enable this feature. NOTE that this will do nothing but a minor amount of extra work on CRTs and does not improve the display quality. Possible values for the const section include - rgb, bgr, vrgb, bgrv, and none.
< !-- Enable sub-pixel rendering --> <match target="font" > <edit mode="assign" name="rgba" > <const>rgb</const> </edit> </match>
I don't want my fonts Antialiased under a certain point size.
A sample of this is in the /etc/fonts/local.conf file. It is commented, just like the subpixel rendering section. Changes, if anything, should be made to the compare="less_eq" portion, and the <int>12</int> portion - these are the comparison operation and point size to compare, respectively.
<match target="pattern"> <test qual="any" name="size" compare="less_eq"> <int>12</int> </test> <edit name="antialias" mode="assign"><bool>false</bool></edit> </match>
I'm using MS TrueType fonts (verdana) and want to enable anti-aliasing but only for bigger fonts that look too jagged.
<?xml version="1.0"?> <!DOCTYPE fontconfig SYSTEM "fonts.dtd"> <fontconfig>
<match target="font" > <test compare"more" name
"size" qual="any" > <double>12</double> </test> <edit mode"assign" name
"antialias" > <bool>true</bool> </edit> </match>
<match target="font" > <test compare"more" name
"pixelsize" qual="any" > <double>17</double> </test> <edit mode"assign" name
"antialias" > <bool>true</bool> </edit> </match> </fontconfig>
I want to add more fonts.
Save your fonts in a directory and add it to ~/.fonts.conf
< !-- Additional font directories --> <dir>/path/to/dir</dir>
I want my font sizes to match my DPI settings
Edit ~/.fonts.conf with the following. This setting should match your dpi settings in either xorg.conf or your startx command. Use xdpyinfo to get your current dpi setting. Most people recommend/use a value of 96 or 100. Changing and setting the dpi of X is beyond the scope of this document (see Xorg DisplaySize/DPI).
<match target="pattern">
<edit name="dpi" mode=
"assign"><double>100</double></edit>
</match>
I don't like font <enter name here> and want to use <another font name> instead
The most reliable way to do this is to add an XML fragment similar to the one below to ~/.fonts.conf. This will cause Bitstream Vera Sans to be used in place of Helvetica:
<match target="pattern" name="family" > <test name="family" qual="any" > <string>Helvetica</string> </test> <edit mode="assign" name="family" > <string>Bitstream Vera Sans</string> </edit> </match>
An alternate approach is to set the "preferred" font, but this only works if the original font is not on your system, in which case the one you specify will be substituted:
< !-- Replace Helvetica with Bitstream Vera Sans Mono --> < !-- Note, an alias for Helvetica should already exist in default conf files --> <alias> <family>Helvetica</family> <prefer><family>Bitstream Vera Sans Mono</family></prefer> <default><family>fixed</family></default> </alias>
I have tons of disgusting pixel fonts that I don't want
The only two fonts that you absolutely have to have in order to start X are 'cursor' and 'fixed', both of which are in the fonts/misc directory. If you want to get rid of all the pixel fonts besides these two, you can delete all the files in the misc directory besides cursor.pcf.gz and all the fonts that are similar to either 9x18.pcf.gz or 9x18-ISO8859-1.pcf.gz. When I deleted all the fonts besides those from the misc directory, I had about 337 files still in it, so if you have a lot less than that you should probably put them back before restarting X.
Something or someone disabled all my non-scalable (bitmap) fonts, I want them back
By default, fontconfig 2.3.2-4 and higher will disable the use of bitmap fonts. This setting is managed in /etc/fonts/conf.d/10-no-bitmaps.conf, or in higher versions, /etc/fonts/conf.d/10-bitmaps.conf. To enable bitmap fonts and keep them enabled after upgrades of fontconfig, place a symlink from yes-bitmaps.conf to 10-bitmaps.conf, overwriting the symlink to no-bitmaps.conf.
Fake bold & italic styles for incomplete fonts
Freetype already has had this capability for some time, but only if app asks so (which never happens) - it's not going to add Bold or Italic style for those regular-only fonts anyway. To make up them, you need to edit /usr/share/fonts/fonts.cache-1 manually (and keep your modification somewhere because font update (fc-cache) overrides it). Assume you have a font Dupree:
"dupree.ttf" 0 "Dupree:style=Regular:slant=0:weight=80:width=100:foundry=unknown:index=0:outline=True:....
Duplicate the line, change style=Regular to style=Bold or other styles you want. Also change slant=0 to slant=100 for italic, weight=80 to weight=200 for bold (combine for bold italic):
"dupree.ttf" 0 "Dupree:style=Bold Italic:slant=100:weight=200:width=100:foundry=unknown:index=0:outline=True:....
Now add necessary modification to ~/.fonts.conf:
<match target="font"> <test name="family" qual="any"> <string>Dupree</string> <!-- other fonts here .... --> </test> <test compare="more_eq" name="weight"><int>140</int></test> <edit mode="assign" name="embolden"><bool>true</bool></edit> </match> <match target="font"> <test name="family" qual="any"> <string>Dupree</string> <!-- other fonts here .... --> </test> <test compare="more_eq" name="slant"><int>80</int></test> <edit mode="assign" name="matrix"> <times> <name>matrix</name> <matrix> <double>1</double><double>0.2</double> <double>0</double><double>1</double> </matrix> </times> </edit> </match>
(Note that you can use embolden for bold fonts as well - to make them even bolder)
A web developer's fonts/local.conf taken from arch forums
Backup your current config and give this one a try. I noticed it especially improved the Georgia font.
<?xml version="1.0"?> <!DOCTYPE fontconfig SYSTEM "fonts.dtd"> <!-- the cathectic LCD tweaks, from linuxquestions.org, http://www.linuxquestions.org/questions/showthread.php?postid=1361098#post1361098 --> <fontconfig> <!-- Disable sub-pixel rendering. X detects it anyway, and if you set this as well, it just looks really horrible --> <match target="font" > <edit mode="assign" name="rgba" > <const>none</const> </edit> </match> <match target="font" > <edit mode="assign" name="hinting"> <bool>true</bool> </edit> </match> <match target="font" > <edit mode="assign" name="hintstyle"> <const>hintfull</const> </edit> </match> <!-- The first part of the 'magic.' This makes the fonts start to look nice, but some of the shapes will be distorted, so hinting is needed still --> <match target="font" > <edit mode="assign" name="antialias"> <bool>true</bool> </edit> </match> <!-- Autohinter is not turned on automatically. Only disable this if you have recompiled Freetype with the bytecode interpreter, which is run automatically.<br /> --> <match target="pattern" > <edit mode="assign" name="autohint"> <bool>true</bool> </edit> </match> <match target="font"> <test name="weight" compare="more"> <const>medium</const> </test> <edit name="autohint" mode="assign"> <bool>false</bool> </edit> </match> <!-- Helvetica is a non true type font, and will look bad. This replaces it with whatever is the default sans-serif font --> <match target="pattern" name="family" > <test name="family" qual="any" > <string>Helvetica</string> </test> <edit mode="assign" name="family" > <string>sans-serif</string> </edit> </match> <dir>~/.fonts</dir> </fontconfig>
WikiMigration--dlanor 14:05, 23 Jul 2005 (EDT)