https://wiki.archlinux.org/api.php?action=feedcontributions&user=Silencer&feedformat=atomArchWiki - User contributions [en]2024-03-28T16:07:26ZUser contributionsMediaWiki 1.41.0https://wiki.archlinux.org/index.php?title=Redshift&diff=306876Redshift2014-03-24T18:38:31Z<p>Silencer: changed project website and repository hyperlinks</p>
<hr />
<div>[[Category:X Server]]<br />
[[Category:Graphics]]<br />
[[Category:Eye candy]]<br />
[[Category:Audio/Video]]<br />
The [http://jonls.dk/redshift/ website] states:<br />
<br />
"Redshift adjusts the color temperature of your screen according to your surroundings. This may help your eyes hurt less if you are working in front of the screen at night. This program is inspired by [http://justgetflux.com f.lux] [...]."<br />
<br />
The project is developed on [https://github.com/jonls/redshift GitHub].<br />
<br />
== Installation ==<br />
<br />
The {{Pkg|redshift}} package is available in the [[Official repositories]].<br />
<br />
{{Note|If Redshift will not start, see section [[#Troubleshooting]].}}<br />
<br />
== Configuration ==<br />
<br />
Redshift will at least need your location to start, meaning the latitude and longitude of your location. Redshift employs several routines for obtaining your location. If none of them works (e.g. none of the used helper programs is installed), you need to enter your location manually: For most places/cities an easy way is to look up the wikipedia page of that place and get the location from there (search the page for "coordinates").<br />
<br />
=== Quick start ===<br />
<br />
To just get it up and running with a basic setup, issue:<br />
<br />
$ redshift -l LAT:LON<br />
<br />
where LAT is the latitude and LON is the longitude of your location.<br />
<br />
=== Automatic location based on GPS ===<br />
<br />
You can also use {{Pkg|gpsd}} to automatically determine your GPS location and use it as an input for Redshift. Create the following script and pass {{ic|$lat}} and {{ic|$lon}} to {{ic|redshift -l $lat;$lon}}:<br />
<br />
#!/bin/bash<br />
date<br />
#gpsdata=$( gpspipe -w -n 10 | grep -m 1 lon )<br />
gpsdata=$( gpspipe -w | grep -m 1 TPV )<br />
lat=$( echo "$gpsdata" | jsawk 'return this.lat' )<br />
lon=$( echo "$gpsdata" | jsawk 'return this.lon' )<br />
alt=$( echo "$gpsdata" | jsawk 'return this.alt' )<br />
dt=$( echo "$gpsdata" | jsawk 'return this.time' )<br />
echo "$dt"<br />
echo "You are here: $lat, $lon at $alt"<br />
<br />
For more information, see [https://bbs.archlinux.org/viewtopic.php?pid=1389735#p1389735 this] forums thread.<br />
<br />
=== Manual setup ===<br />
<br />
Redshift reads the configuration file {{ic|~/.config/redshift.conf}}, if it exists. However, Redshift does not create that configuration file, so you have to create it manually.<br />
Example for Hamburg/Germany:<br />
<br />
{{hc|~/.config/redshift.conf|<br />
; Global settings<br />
[redshift]<br />
temp-day&#61;5700<br />
temp-night&#61;3500<br />
transition&#61;1<br />
gamma&#61;0.8:0.7:0.8<br />
location-provider&#61;manual<br />
adjustment-method&#61;vidmode<br />
<br />
; The location provider and adjustment method settings<br />
; are in their own sections.<br />
[manual]<br />
; Hamburg<br />
lat&#61;53.3<br />
lon&#61;10.0<br />
<br />
; In this example screen 1 is adjusted by vidmode. Note<br />
; that the numbering starts from 0, so this is actually<br />
; the second screen.<br />
[vidmode]<br />
screen&#61;0<br />
screen&#61;1<br />
}}<br />
<br />
After you created that file, start redshift from the menu of your DE (called "redshift-gtk") or type the following in your terminal:<br />
<br />
$ redshift-gtk &<br />
<br />
Using "redshift-gtk" instead of "redshift" launches Redshift with a system tray icon for easier handling of the application.<br />
Finally, if you want to start Redshift automatically on system startup, rightclick the system tray icon an check "Autostart".<br />
<br />
== Troubleshooting ==<br />
<br />
=== Missing dependency ===<br />
<br />
{{Pkg|python2-xdg}}, {{Pkg|librsvg}} and {{Pkg|pygtk}} are needed for redshift-gtk. They are the optional dependencies for the redshift package. If you run into problems when trying to run redshift-gtk, check if they are installed. If they are not installed, install them as a dependency:<br />
# pacman --asdeps -S python2-xdg librsvg pygtk<br />
<br />
== See also ==<br />
* [http://jonls.dk/redshift Redshift website]<br />
* [https://launchpad.net/redshift Redshift on launchpad]</div>Silencerhttps://wiki.archlinux.org/index.php?title=Talk:Fish&diff=256827Talk:Fish2013-05-12T13:34:14Z<p>Silencer: </p>
<hr />
<div>Check out pacman.fish in the github head. - SanskritFritz 2013.05.11<br />
<br />
Did anybody try to write fish completions for pacman? I like tthe fish completion system and I have written the complations for some other apps, but I am not able to obtain combined options (that is I am not able to tell fish to expect only the sync options after a "pacman -S"). Any tip, suggestion?<br />
<br />
SanskritFritz: yes, I updated the pacman completions, it is now included into the main fish development head on github. I'll update the page to reflect latest happenings in fish development.<br />
<br />
Isn't 'License' paragraph redundant? It's open source anyway and 99.9% users don't care to know which parts are GPL, BSD, etc. - silenc3r</div>Silencerhttps://wiki.archlinux.org/index.php?title=Talk:Fish&diff=256639Talk:Fish2013-05-11T15:03:43Z<p>Silencer: </p>
<hr />
<div>Did anybody try to write fish completions for pacman? I like tthe fish completion system and I have written the complations for some other apps, but I am not able to obtain combined options (that is I am not able to tell fish to expect only the sync options after a "pacman -S"). Any tip, suggestion?<br />
<br />
SanskritFritz: yes, I updated the pacman completions, it is now included into the main fish development head on github. I'll update the page to reflect latest happenings in fish development.<br />
<br />
Isn't 'License' paragraph redundant? It's open source anyway and 99.9% users don't care to know which parts are GPL, BSD, etc.</div>Silencerhttps://wiki.archlinux.org/index.php?title=Font_configuration&diff=256596Font configuration2013-05-10T21:33:47Z<p>Silencer: /* Patched packages */</p>
<hr />
<div>[[Category:Fonts]]<br />
[[it:Font Configuration]]<br />
[[ru:Font Configuration]]<br />
[[sr:Font Configuration]]<br />
[[tr:Yazıtipi_yapılandırması]]<br />
[[zh-CN:Font Configuration]]<br />
{{Article summary start}}<br />
{{Article summary text|An overview of font configuration options and various techniques for improving the readability of fonts}}<br />
{{Article summary heading|Related}}<br />
{{Article summary wiki|Fonts}}: Information on adding fonts and font recommendations<br />
{{Article summary wiki|Font Configuration/fontconfig Examples}}<br />
{{Article summary wiki|Java Runtime Environment Fonts}}: Fonts specific to Sun's Java machine<br />
{{Article summary wiki|MS Fonts}}: Adding Microsoft fonts and mimicking Windows' font settings<br />
{{Article summary wiki|X Logical Font Description}}: The older core font system for X<br />
{{Article summary end}}<br />
<br />
Fontconfig is a library designed to provide a list of available [[fonts]] to applications, and also for configuration for how fonts get rendered. See package {{Pkg|fontconfig}} and [[Wikipedia:Fontconfig]]. The Free type library ({{Pkg|freetype2}} package) renders the fonts, based on this configuration.<br />
<br />
Though Fontconfig is the standard in today's Linux, some applications still rely on the original method of font selection and display, the [[X Logical Font Description]].<br />
<br />
The font rendering packages on Arch Linux includes support for ''freetype2'' with the bytecode interpreter (BCI) enabled. Patched packages exist for better font rendering, especially with an LCD monitor. See [[#Patched packages]] below. The [[#Infinality]] package allows both auto-hinting and subpixel rendering, allows the LCD filter to be tweaked without recompiling, and allows the auto-hinter to work well with bold fonts.<br />
<br />
==Font paths==<br />
<br />
For fonts to be known to applications, they must be cataloged for easy and quick access.<br />
<br />
The font paths initially known to Fontconfig are: {{ic|/usr/share/fonts/}} and {{ic|~/.fonts/}} (of which Fontconfig will scan recursively). For ease of organization and installation, it is recommended to use these font paths when [[Fonts#Installation|adding fonts]].<br />
<br />
To see a list of known Fontconfig fonts:<br />
$ fc-list : file<br />
<br />
See {{ic|man fc-list}} for more out put format.<br />
<br />
Check for Xorg's known font paths by reviewing its log:<br />
$ grep /fonts /var/log/Xorg.0.log<br />
<br />
{{Tip|You can also check the list of [[Xorg]]'s known font paths using the command {{ic|xset q}}.}}<br />
<br />
Keep in mind that Xorg does not search recursively through the {{ic|/usr/share/fonts/}} directory like Fontconfig does. To add a path, the full path must be used:<br />
Section "Files"<br />
FontPath "/usr/share/fonts/local/"<br />
EndSection<br />
<br />
If you want font paths to be set on a per-user basis, you can add and remove font paths from the default by adding the following line(s) to {{ic|~/.xinitrc}}:<br />
xset +fp /usr/share/fonts/local/ # Prepend a custom font path to Xorg's list of known font paths<br />
xset -fp /usr/share/fonts/sucky_fonts/ # Remove the specified font path from Xorg's list of known font paths<br />
<br />
To see a list of known Xorg fonts use {{ic|xlsfonts}}, from the {{Pkg|xorg-xlsfonts}} package.<br />
<br />
==Fontconfig configuration==<br />
<br />
Fontconfig is documented in the [http://fontconfig.org/fontconfig-user.html fonts.conf] man page.<br />
<br />
Configuration can be done per-user through {{ic|$XDG_CONFIG_HOME/fontconfig/fonts.conf}}, and globally with {{ic|/etc/fonts/local.conf}}. The settings in the per-user configuration have precedence over the global configuration. Both these files use the same syntax.<br />
{{Note|Configuration files and directories: {{ic|~/.fonts.conf}}, {{ic|~/.fonts.conf.d}} and {{ic|~/.fontconfig/*.cache-*}} are deprecated since fontconfig 2.10.1 ([http://cgit.freedesktop.org/fontconfig/commit/?id&#61;8c255fb185d5651b57380b0a9443001e8051b29d upstream commit]) and will not be read by default in the future versions of package. Use instead {{ic|$XDG_CONFIG_HOME/fontconfig/fonts.conf}}, {{ic|$XDG_CONFIG_HOME/fontconfig/conf.d}} and {{ic|$XDG_CACHE_HOME/fontconfig/*.cache-*}} respectively. If you use the second directory, the file '''must''' follow the naming convention {{ic|NN-name.conf}} (where NN it's a two digit number like 00, 10, or 99).}}<br />
<br />
Fontconfig gathers all its configurations in a central file ({{ic|/etc/fonts/fonts.conf}}). This file is replaced during fontconfig updates and shouldn't be edited. Fontconfig-aware applications source this file to know available fonts and how they get rendered. This file is a conglomeration of rules from the global configuration ({{ic|/etc/fonts/local.conf}}), the configured presets in {{ic|/etc/fonts/conf.d/}}, and the user configuration file ({{ic|$XDG_CONFIG_HOME/fontconfig/fonts.conf}}).<br />
<br />
{{Note|For some desktop environments (such as [[GNOME]] and [[KDE]]) using the ''Font Control Panel'' will automatically create or overwrite the user font configuration file. For these desktop environments, it is best to match your already defined font configurations to get the expected behavior.}}<br />
<br />
Fontconfig configuration files use [[Wikipedia:XML|XML]] format and need these headers:<br />
<br />
{{bc|<nowiki><br />
<?xml version="1.0"?><br />
<!DOCTYPE fontconfig SYSTEM "fonts.dtd"><br />
<fontconfig><br />
<br />
<!-- settings go here --><br />
<br />
</fontconfig><br />
</nowiki>}}<br />
<br />
The configuration examples in this article omit these tags.<br />
<br />
===Presets===<br />
<br />
There are presets installed in the directory {{ic|/etc/fonts/conf.avail}}. They can be enabled by creating [[Wikipedia:Symbolic link|symbolic link]]s to them, both per-user and globally, as described in {{ic|/etc/fonts/conf.d/README}}. These presets will override matching settings in their respective configuration files.<br />
<br />
For example, to enable sub-pixel RGB rendering globally:<br />
<br />
# cd /etc/fonts/conf.d<br />
# ln -s ../conf.avail/10-sub-pixel-rgb.conf<br />
<br />
To do the same but instead for a per-user configuration:<br />
<br />
$ mkdir $XDG_CONFIG_HOME/fontconfig/conf.d<br />
$ ln -s /etc/fonts/conf.avail/10-sub-pixel-rgb.conf $XDG_CONFIG_HOME/fontconfig/conf.d<br />
<br />
===Anti-aliasing===<br />
<br />
[[Wikipedia:Font rasterization|Font rasterization]] converts vector font data to bitmap data so that it can be displayed. The result can appear jagged due to [[Wikipedia:Aliasing|aliasing]]. [[Wikipedia:Anti-aliasing|anti-aliasing]] is enabled by default and increases the apparent resolution of font edges.<br />
<br />
{{bc|<nowiki><br />
<match target="font"><br />
<edit name="antialias" mode="assign"><br />
<bool>true</bool><br />
</edit><br />
</match><br />
</nowiki>}}<br />
<br />
Note: some applications, like [[Gnome|Gnome 3]] may [[#Troubleshooting|override default anti-alias settings]].<br />
<br />
===Hinting===<br />
<br />
[[Wikipedia:Font hinting|Font hinting]] (also known as instructing) is the use of mathematical instructions to adjust the display of an outline font so that it lines up with a rasterized grid, such as the pixel grid in a display. Fonts will not line up correctly without hinting until displays have 300 [[Wikipedia:Dots per inch|DPI]] or greater. Two types of hinting are available.<br />
<br />
====Byte-Code Interpreter (BCI)====<br />
Using normal hinting, TrueType hinting instructions in the font are interpreted by freetype's Byte-Code Interpreter. This works best for fonts with good hinting instructions.<br />
<br />
To enable normal hinting:<br />
<br />
{{bc|<nowiki><br />
<match target="font"><br />
<edit name="hinting" mode="assign"><br />
<bool>true</bool><br />
</edit><br />
</match><br />
</nowiki>}}<br />
<br />
====Autohinter====<br />
Auto-discovery for hinting. This looks worse than normal hinting for fonts with good instructions, but better for those with poor or no instructions. The autohinter and subpixel rendering are not designed to work together and should not be used in combination.<br />
<br />
To enable auto-hinting:<br />
<br />
{{bc|<nowiki><br />
<match target="font"><br />
<edit name="autohint" mode="assign"><br />
<bool>true</bool><br />
</edit><br />
</match><br />
</nowiki>}}<br />
<br />
====Hint style====<br />
<br />
Hint style is the amount of influence the hinting mode has. Hinting can be set to: {{ic|hintfull}}, {{ic|hintmedium}}, {{ic|hintslight}} and {{ic|hintnone}}. With BCI hinting, hintfull should work best for most fonts. With the autohinter, hintslight is recommended.<br />
<br />
{{bc|<nowiki><br />
<match target="font"><br />
<edit name="hintstyle" mode="assign"><br />
<const>hintfull</const><br />
</edit><br />
</match><br />
</nowiki>}}<br />
<br />
Note: some applications, like [[Gnome|Gnome 3]] may [[#Troubleshooting|override default hinting settings]].<br />
<br />
===Subpixel rendering===<br />
<br />
Subpixel rendering effectively triples the horizontal (or vertical) resolution for fonts by making use of subpixels. The autohinter and subpixel rendering are not designed to work together and should not be used in combination without the [[#Infinality]] patch set.<br />
<br />
Most monitors manufactured today use the Red, Green, Blue (RGB) specification. Fontconfig will need to know your monitor type to be able to display your fonts correctly.<br />
<br />
''RGB (most common), BGR, V-RGB (vertical), or V-BGR''<br />
<br />
To enable subpixel rendering:<br />
<br />
{{bc|<nowiki><br />
<match target="font"><br />
<edit name="rgba" mode="assign"><br />
<const>rgb</const><br />
</edit><br />
</match><br />
</nowiki>}}<br />
<br />
If you notice unusual colors around font's borders, the wrong subpixel arrangement might be configured. The [http://www.lagom.nl/lcd-test/subpixel.php Lagom subpixel layout test] web page can help identify it.<br />
<br />
====LCD filter====<br />
<br />
When using subpixel rendering, you should enable the LCD filter, which is designed to reduce colour fringing. This is described under [http://www.freetype.org/freetype2/docs/reference/ft2-lcd_filtering.html LCD filtering] in the FreeType 2 API reference. Different options are described under [http://www.freetype.org/freetype2/docs/reference/ft2-lcd_filtering.html#FT_LcdFilter FT_LcdFilter], and are illustrated by this [http://www.spasche.net/files/lcdfiltering/ LCD filter test] page.<br />
<br />
The {{ic|lcddefault}} filter will work for most users. Other filters are available that can be used in special situations: {{ic|lcdlight}}; a lighter filter ideal for fonts that look too bold or fuzzy, {{ic|lcdlegacy}}, the original Cairo filter; and {{ic|lcdnone}} to disable it entirely.<br />
<br />
{{bc|<nowiki><br />
<match target="font"><br />
<edit mode="assign" name="lcdfilter"><br />
<const>lcddefault</const><br />
</edit><br />
</match><br />
</nowiki>}}<br />
<br />
====Advanced LCD filter specification====<br />
<br />
If the available, built-in LCD filters are not satisfactory, it is possible to tweak the font rendering very specifically by building a custom freetype2 package and modifying the hardcoded filters. The [[Arch Build System]] can be used to build and install packages from source.<br />
<br />
First, refresh the freetype2 PKGBUILD as root:<br />
<br />
# abs extra/freetype2<br />
<br />
This example uses {{ic|/var/abs/build}} as the build directory, substitute it according to your personal ABS setup. Download and extract the freetype2 package as a regular user:<br />
<br />
$ cd /var/abs/build<br />
$ cp -r ../extra/freetype2 .<br />
$ cd freetype2<br />
$ makepkg -o<br />
<br />
Edit the file {{ic|src/freetype-VERSION/src/base/ftlcdfil.c}} and look up the definition of the constant {{ic|default_filter[5]}}:<br />
<br />
static const FT_Byte default_filter[5] =<br />
{ 0x10, 0x40, 0x70, 0x40, 0x10 };<br />
<br />
This constant defines a low-pass filter applied to the rendered glyph. Modify it as needed. Save the file, build and install the custom package:<br />
<br />
$ makepkg -e<br />
$ sudo pacman -Rd freetype2<br />
$ sudo pacman -U freetype2-VERSION-ARCH.pkg.tar.xz<br />
<br />
Reboot or restart X. The lcddefault filter should now render fonts differently.<br />
<br />
===Disable auto-hinter for bold fonts===<br />
<br />
The auto-hinter uses sophisticated methods for font rendering, but often makes bold fonts too wide. Fortunately, a solution can be turning off the autohinter for bold fonts while leaving it on for the rest:<br />
...<br />
<match target="font"><br />
<test name="weight" compare="more"><br />
<const>medium</const><br />
</test><br />
<edit name="autohint" mode="assign"><br />
<bool>false</bool><br />
</edit><br />
</match><br />
...<br />
<br />
=== Enable anti-aliasing only for bigger fonts ===<br />
<br />
''See also [http://sharpfonts.co.cc/ sharpfonts.co.cc] for related information.''<br />
<br />
Some users prefer the sharper rendering that anti-aliasing does not offer:<br />
<br />
{{bc|<nowiki><br />
...<br />
<match target="font"><br />
<edit name="antialias" mode="assign"><br />
<bool>false</bool><br />
</edit><br />
</match><br />
<br />
<match target="font" ><br />
<test name="size" qual="any" compare="more"><br />
<double>12</double><br />
</test><br />
<edit name="antialias" mode="assign"><br />
<bool>true</bool><br />
</edit><br />
</match><br />
<br />
<match target="font" ><br />
<test name="pixelsize" qual="any" compare="more"><br />
<double>16</double><br />
</test><br />
<edit name="antialias" mode="assign"><br />
<bool>true</bool><br />
</edit><br />
</match><br />
...<br />
</nowiki>}}<br />
<br />
===Replace fonts===<br />
<br />
The most reliable way to do this is to add an XML fragment similar to the one below. ''Using the "binding" attribute will give you better results'', for example, in Firefox where you may not want to change properties of font being replaced. This will cause Ubuntu to be used in place of Georgia:<br />
...<br />
<match target="pattern"><br />
<test qual="any" name="family"><string>georgia</string></test><br />
<edit name="family" mode="assign" binding="same"><string>Ubuntu</string></edit><br />
</match><br />
...<br />
An alternate approach is to set the "preferred" font, but ''this only works if the original font is not on the system'', in which case the one specified will be substituted:<br />
...<br />
< !-- Replace Helvetica with Bitstream Vera Sans Mono --><br />
< !-- Note, an alias for Helvetica should already exist in default conf files --><br />
<alias><br />
<family>Helvetica</family><br />
<prefer><family>Bitstream Vera Sans Mono</family></prefer><br />
<default><family>fixed</family></default><br />
</alias><br />
...<br />
<br />
===Disable bitmap fonts===<br />
<br />
To disable bitmap fonts in fontconfig, use {{ic|70-no-bitmaps.conf}} (which is not placed by fontconfig by default):<br />
<br />
# cd /etc/fonts/conf.d<br />
# rm 70-yes-bitmaps.conf<br />
# ln -s ../conf.avail/70-no-bitmaps.conf<br />
<br />
You may not need to remove {{ic|70-yes-bitmaps.conf}} if it does not exist. You can choose which fonts to replace bitmaps fonts with (Helvetica, Courier and Times bitmap mapts to TTF fonts) by:<br />
<br />
# cd /etc/fonts/conf.d<br />
# ln -s ../conf.avail/29-replace-bitmap-fonts.conf<br />
<br />
<div id="EmbeddedBitmap">To disable embedded bitmap for all fonts:<div><br />
<br />
{{hc|~/.config/fontconfig/conf.d/20-no-embeded.conf|<nowiki><br />
<?xml version="1.0"?><br />
<!DOCTYPE fontconfig SYSTEM "fonts.dtd"><br />
<fontconfig><br />
<match target="font"><br />
<edit name="embeddedbitmap" mode="assign"><br />
<bool>false</bool><br />
</edit><br />
</match><br />
</fontconfig><br />
</nowiki>}}<br />
<br />
To disable embedded bitmap fonts for a specific font:<br />
<br />
<match target="font"><br />
<test qual="any" name="family"><br />
<string>Monaco</string><br />
</test><br />
<edit name="embeddedbitmap"><bool>false</bool></edit><br />
</match><br />
<br />
===Disable scaling of bitmap fonts===<br />
<br />
To disable scaling of bitmap fonts (which often makes them blurry), remove {{ic|/etc/fonts/conf.d/10-scale-bitmap-fonts.conf}}.<br />
<br />
===Create bold and italic styles for incomplete fonts===<br />
<br />
Freetype has the ability to automatically create ''italic'' and '''bold''' styles for fonts that do not have them, but only if explicitly required by the application. Given programs rarely send these requests, this section covers manually forcing generation of missing styles.<br />
<br />
Start by editing {{ic|/usr/share/fonts/fonts.cache-1}} as explained below. Store a copy of the modifications on another file, because a font update with {{ic|fc-cache}} will overwrite {{ic|/usr/share/fonts/fonts.cache-1}}.<br />
<br />
Assuming the Dupree font is installed:<br />
"dupree.ttf" 0 "Dupree:style=Regular:slant=0:weight=80:width=100:foundry=unknown:index=0:outline=True:''etc...''<br />
<br />
Duplicate the line, change {{ic|<nowiki>style=Regular</nowiki>}} to {{ic|<nowiki>style=Bold</nowiki>}} or any other style. Also change {{ic|<nowiki>slant=0</nowiki>}} to {{ic|<nowiki>slant=100</nowiki>}} for italic, {{ic|<nowiki>weight=80</nowiki>}} to {{ic|<nowiki>weight=200</nowiki>}} for bold, or combine them for '''''bold italic''''':<br />
"dupree.ttf" 0 "Dupree:style=Bold Italic:slant=100:weight=200:width=100:foundry=unknown:index=0:outline=True:''etc...''<br />
<br />
Now add necessary modifications to {{ic|$XDG_CONFIG_HOME/fontconfig/fonts.conf}}:<br />
{{bc|<nowiki><br />
...<br />
<match target="font"><br />
<test name="family" qual="any"><br />
<string>Dupree</string><br />
&lt;!-- other fonts here .... --&gt;<br />
</test><br />
<test name="weight" compare="more_eq"><int>140</int></test><br />
<edit name="embolden" mode="assign"><bool>true</bool></edit><br />
</match><br />
<br />
<match target="font"><br />
<test name="family" qual="any"><br />
<string>Dupree</string><br />
&lt;!-- other fonts here .... --&gt;<br />
</test><br />
<test name="slant" compare="more_eq"><int>80</int></test><br />
<edit name="matrix" mode="assign"><br />
<times><br />
<name>matrix</name><br />
<matrix><br />
<double>1</double><double>0.2</double><br />
<double>0</double><double>1</double><br />
</matrix><br />
</times><br />
</edit><br />
</match><br />
...<br />
</nowiki>}}<br />
{{Tip| Use the value 'embolden' for existing bold fonts in order to make them even bolder.}}<br />
<br />
===Change rule overriding===<br />
<br />
Fontconfig processes files in {{ic|/etc/fonts/conf.d}} in numerical order. This enables rules or files to override one another, but often confuses users about what file gets parsed last.<br />
<br />
To guarantee that personal settings take precedence over any other rules, change their ordering:<br />
# cd /etc/fonts/conf.d<br />
# mv 50-user.conf 99-user.conf<br />
<br />
This change seems however to be unnecessary for the most of the cases, because a user is given enough control by default to set up own font preferences, hinting and antialiasing properties, alias new fonts to generic font families, etc.<br />
<br />
===Example fontconfig configurations===<br />
<br />
Example fontconfig configurations can be found on this [[Font_Configuration/fontconfig_Examples|page]].<br />
<br />
A simple starting point:<br />
<br />
{{hc|/etc/fonts/local.conf|<nowiki><br />
<?xml version='1.0'?><br />
<!DOCTYPE fontconfig SYSTEM 'fonts.dtd'><br />
<fontconfig><br />
<match target="font"><br />
<br />
<edit mode="assign" name="rgba"><br />
<const>rgb</const><br />
</edit><br />
<br />
<edit mode="assign" name="hinting"><br />
<bool>true</bool><br />
</edit><br />
<br />
<edit mode="assign" name="hintstyle"><br />
<const>hintslight</const><br />
</edit><br />
<br />
<edit mode="assign" name="antialias"><br />
<bool>true</bool><br />
</edit><br />
<br />
<edit mode="assign" name="lcdfilter"><br />
<const>lcddefault</const><br />
</edit><br />
<br />
</match><br />
</fontconfig><br />
</nowiki>}}<br />
<br />
==Patched packages==<br />
<br />
These patched packages are available in the [[Arch User Repository|AUR]]. A few considerations:<br />
<br />
* Configuration is usually necessary.<br />
* The new font rendering will not kick in until applications restart.<br />
* Applications which [[Wikipedia:Static library|statically link]] to a library will not be affected by patches applied to the system library.<br />
<br />
<div id="Infinality"><div><br />
===Infinality: the generic way===<br />
<br />
The infinality patchset aims to greatly improve freetype2 font rendering. It adds multiple new capabilities.<br />
<br />
*[http://www.infinality.net/blog/infinality-freetype-patches/ Home page].<br />
*[http://www.infinality.net/forum/ Forum].<br />
<br />
Infinality's settings are all configurable at runtime via environment variables in {{ic|/etc/profile.d/infinality-settings.sh}}, and include the following:<br />
<br />
*'''Emboldening Enhancement''': Disables Y emboldening, producing a much nicer result on fonts without bold versions. Works on native TT hinter and autohinter.<br />
*'''Auto-Autohint''': Automatically forces autohint on fonts that contain no TT instructions.<br />
*'''Autohint Enhancement''': Makes autohint snap horizontal stems to pixels. Gives a result that appears like a well-hinted truetype font, but is 100% patent-free (as far as I know).<br />
*'''Customized FIR Filter''': Select your own [http://www.infinality.net/forum/viewtopic.php?f=2&t=19 filter values] at run-time. Works on native TT hinter and autohinter.<br />
*'''Stem Alignment''': Aligns bitmap glyphs to optimized pixel boundaries. Works on native TT hinter and autohinter.<br />
*'''Pseudo Gamma Correction''': Lighten and darken glyphs at a given value, below a given size. Works on native TT hinter and autohinter.<br />
*'''Embolden Thin Fonts''': Embolden thin or light fonts so that they are more visible. Works on autohinter.<br />
*'''Force Slight Hinting''': Force slight hinting even when programs want full hinting. If you use the local.conf I provide (included in infinality-settings fedora package) you will notice nice improvements on @font-face fonts.<br />
*'''ChromeOS Style Sharpening''': ChromeOS uses a patch to sharpen the look of fonts. This is now included in the infinality patchset.<br />
<br />
A number of presets are included and can be used by setting the USE_STYLE variable in {{ic|/etc/profile.d/infinality-settings.sh}}.<br />
<br />
{{Note|1=The user bohoomil maintains a very good configuration in his [https://github.com/bohoomil/fontconf github repo] which is available as a [https://aur.archlinux.org/packages/fontconfig-infinality-ultimate/ package] in the AUR.}}<br />
<br />
{{Note|1=Install {{AUR|grip-git}} from AUR to have a realtime preview.}}<br />
<br />
{{AUR|freetype2-infinality}} can be installed from the [[Arch User Repository|AUR]]. Additionally, if you are using {{pkg|lib32-freetype2}} from [multilib], replace it with {{AUR|lib32-freetype2-infinality}} from the AUR. The AUR also contains a Git version of freetype2 that builds the latest development snapshot of freetype2 with the Infinality patchset: {{AUR|freetype2-git-infinality}}, {{AUR|lib32-freetype2-git-infinality}}.<br />
<br />
It is recommended to also install {{AUR|fontconfig-infinality}} to enable selection of predefined font substitution styles and antialiasing settings, apart from the rendering settings of the engine itself. After doing so, you can select the font style (win7, winxp, osx, linux, ...) with:<br />
# infctl setstyle<br />
<br />
If you set e.g. win7 or osx you need the corresponding fonts installed.<br />
<br />
{{Note|Default infinality settings can cause some programs to display fonts at 72 DPI instead of 96. If you notice a problem open /etc/fonts/infinality/infinality.conf search for the section on DPI and change 72 to 96. This problem can specifically affect conky causing the fonts to appear smaller than they should. Thus not aligning properly with images. }}<br />
<br />
{{Note|''The README for {{AUR|fontconfig-infinality}} says that /etc/fonts/local.conf should either not exist, or have no infinality-related configurations in it. The local.conf is now obsolete and completely replaced by this configuration.''}}<br />
<br />
for more information see this article: http://www.infinality.net/forum/viewtopic.php?f=2&t=77<br />
<br />
*[http://www.infinality.net/blog/infinality-freetype-patches/ Home page].<br />
<br />
===Infinality: the easy way===<br />
<br />
bohoomil also maintains '''infinality-bundle''' repository, offering three basic libraries (freetype2-infinality-ultimate, fontconfig-infinality-ultimate & cairo-infinality-ultimate) as pre-patched, pre-configured and pre-built binaries for all architectures (i686, x86_64, multilib). Using infinality-bundle makes the whole installation & configuration process dramatically simplified: all one has to do is install the three packages with<br />
<br />
{{bc|# pacman -S infinality-bundle}}<br />
<br />
which will replace the corresponding, generic Arch libraries (i.e. freetype2-infinality-ultimate will be used instead of freetype2, fontconfig-infinality-ultimate instead of fontconfig and fontconfig-infinality-ultimate from the AUR, and cairo-infinality-ultimate instead of the regular cairo). The libraries are fully compatible with the Arch packages and are meant to be used as drop-in replacements for them. No post installation/upgrade steps are required for most use scenarios: everything should work out of the box.<br />
<br />
To use the repository, add <br />
<br />
{{bc|1=[infinality-bundle]<br />
SigLevel = Never<br />
Server = http://bohoomil.cu.cc/infinality-bundle/$arch}}<br />
<br />
to your /etc/pacman.conf and issue<br />
<br />
{{bc|# pacman -Syy}}<br />
<br />
If you want to have access to multilib versions, add the following, too:<br />
<br />
{{bc|1=[infinality-bundle-multilib]<br />
SigLevel = Never<br />
Server = http://bohoomil.cu.cc/infinality-bundle-multilib/$arch}}<br />
<br />
In case of server down times, there is always a backup copy of the repository available via [https://www.dropbox.com/sh/ugmxbui00chidox/njDKnTG49W Dropbox].<br />
<br />
When installing some packages (like [https://www.archlinux.org/packages/?sort=&q=libgdiplus&maintainer=&flagged= libgdiplus]), you may encounter an error:<br />
<br />
{{bc|:: cairo and cairo-infinality-ultimate are in conflict. Remove cairo-infinality-ultimate? [y/N] n<br />
error: unresolvable package conflicts detected<br />
error: failed to prepare transaction (conflicting dependencies)}}<br />
<br />
If this happens, install the new package with {{bc|# pacman -Sd foo}} instead.<br />
<br />
For more information, see [http://bohoomil.github.io/ib.html infinality-bundle user notes].<br />
<br />
A support thread in the Forums is available [https://bbs.archlinux.org/viewtopic.php?id=162098 here].<br />
<br />
===Ubuntu===<br />
<br />
Ubuntu adds extra configurations, and occasionally patches to the font rendering libraries.<br />
<br />
Install the patched packages from the [[Arch User Repository|AUR]], the package names are: {{AUR|freetype2-ubuntu}} {{AUR|fontconfig-ubuntu}} {{AUR|cairo-ubuntu}}.<br />
<br />
The global configuration will need to be added. See [[#Example fontconfig configurations]] for a starting point.<br />
Ubuntu rendering works the best with ''hintslight'' option.<br />
<br />
===Reverting to unpatched packages===<br />
<br />
To restore the unpatched packages, reinstall the originals:<br />
<br />
# pacman -S --asdeps freetype2 cairo fontconfig<br />
<br />
==Applications without fontconfig support==<br />
<br />
Some applications like [[URxvt]] will ignore fontconfig settings. This is very apparent when using the infinality patches which are heavily reliant on proper configuration. You can work around this by using {{ic|~/.Xresources}}, but it is not nearly as flexible as fontconfig. Example (see [[#Fontconfig configuration]] for explanations of the options):<br />
<br />
{{hc|~/.Xresources|<nowiki><br />
Xft.autohint: 0<br />
Xft.lcdfilter: lcddefault<br />
Xft.hintstyle: hintfull<br />
Xft.hinting: 1<br />
Xft.antialias: 1<br />
Xft.rgba: rgb<br />
</nowiki>}}<br />
<br />
Make sure the settings are loaded properly when X starts with {{ic|xrdb -q}} (see [[Xresources]] for more information).<br />
<br />
==Troubleshooting==<br />
<br />
=== Distorted fonts ===<br />
<br />
{{Note|96 DPI is not a standard. You should use your monitor's actual DPI to get proper font rendering, especially when using subpixel rendering.}}<br />
<br />
If fonts are still unexpectedly large or small, poorly proportioned or simply rendering poorly, fontconfig may be using the incorrect DPI.<br />
<br />
Fontconfig should be able to detect DPI parameters as discovered by the Xorg server. You can check the automatically discovered DPI with {{ic|xdpyinfo}} (provided by the {{pkg|xorg-xdpyinfo}} package):<br />
<br />
{{hc|<nowiki>$ xdpyinfo | grep dots</nowiki>| resolution: 102x102 dots per inch}}<br />
<br />
If the DPI is detected incorrectly (usually due to an incorrect monitor EDID), you can specify it manually in the Xorg configuration, see [[Xorg#Display Size and DPI]]. This is the recommended solution, but it may not work with buggy drivers.<br />
<br />
Fontconfig will default to the Xft.dpi variable if it is set. Xft.dpi is usually set by desktop environments (usually to Xorg's DPI setting) or manually in {{ic|~/.Xdefaults}} or {{ic|~/.Xresources}}. Use xrdb to query for the value:<br />
<br />
{{hc|<nowiki>$ xrdb -query | grep dpi</nowiki>|Xft.dpi: 102}}<br />
<br />
Those still having problems can fall back to manually setting the DPI used by fontconfig:<br />
<br />
...<br />
<!-- Setup for DPI=96 --><br />
<match target="pattern"><br />
<edit name="dpi" mode="assign"><double>102</double></edit><br />
</match><br />
...<br />
<br />
===Calibri, Cambria, Monaco, etc. not rendering properly===<br />
<br />
Some scalable fonts have embedded bitmap versions which are rendered instead, mainly at smaller sizes. Force using scalable fonts at all sizes by [[#EmbeddedBitmap|#Disabling embedded bitmap]].<br />
<br />
===Older GTK and QT applications===<br />
<br />
Modern GTK apps enable Xft by default but this was not the case before version 2.2. If it is not possible to update these applications, force Xft for old [[GNOME]] applications by adding to {{ic|~/.bashrc}}:<br />
<br />
export GDK_USE_XFT=1<br />
<br />
For older QT applications:<br />
<br />
export QT_XFT=true<br />
<br />
===Applications overriding hinting===<br />
Some applications may override default fontconfig hinting and anti-aliasing settings. This may happen with [[Gnome]] 3, for example. Use the specific configuration program for the application in such cases. For gnome, try {{pkg|gnome-tweak-tool}}.<br />
<br />
==See also==<br />
*[http://www.x.org/X11R6.8.2/doc/fonts.html Fonts in X11R6.8.2] - Official Xorg font information<br />
*[http://freetype.sourceforge.net/freetype2/ FreeType 2 Overview]<br />
*[https://forums.gentoo.org/viewtopic-t-723341.html Gentoo font-rendering thread]</div>Silencerhttps://wiki.archlinux.org/index.php?title=Font_configuration&diff=256595Font configuration2013-05-10T21:33:07Z<p>Silencer: /* Patched packages */</p>
<hr />
<div>[[Category:Fonts]]<br />
[[it:Font Configuration]]<br />
[[ru:Font Configuration]]<br />
[[sr:Font Configuration]]<br />
[[tr:Yazıtipi_yapılandırması]]<br />
[[zh-CN:Font Configuration]]<br />
{{Article summary start}}<br />
{{Article summary text|An overview of font configuration options and various techniques for improving the readability of fonts}}<br />
{{Article summary heading|Related}}<br />
{{Article summary wiki|Fonts}}: Information on adding fonts and font recommendations<br />
{{Article summary wiki|Font Configuration/fontconfig Examples}}<br />
{{Article summary wiki|Java Runtime Environment Fonts}}: Fonts specific to Sun's Java machine<br />
{{Article summary wiki|MS Fonts}}: Adding Microsoft fonts and mimicking Windows' font settings<br />
{{Article summary wiki|X Logical Font Description}}: The older core font system for X<br />
{{Article summary end}}<br />
<br />
Fontconfig is a library designed to provide a list of available [[fonts]] to applications, and also for configuration for how fonts get rendered. See package {{Pkg|fontconfig}} and [[Wikipedia:Fontconfig]]. The Free type library ({{Pkg|freetype2}} package) renders the fonts, based on this configuration.<br />
<br />
Though Fontconfig is the standard in today's Linux, some applications still rely on the original method of font selection and display, the [[X Logical Font Description]].<br />
<br />
The font rendering packages on Arch Linux includes support for ''freetype2'' with the bytecode interpreter (BCI) enabled. Patched packages exist for better font rendering, especially with an LCD monitor. See [[#Patched packages]] below. The [[#Infinality]] package allows both auto-hinting and subpixel rendering, allows the LCD filter to be tweaked without recompiling, and allows the auto-hinter to work well with bold fonts.<br />
<br />
==Font paths==<br />
<br />
For fonts to be known to applications, they must be cataloged for easy and quick access.<br />
<br />
The font paths initially known to Fontconfig are: {{ic|/usr/share/fonts/}} and {{ic|~/.fonts/}} (of which Fontconfig will scan recursively). For ease of organization and installation, it is recommended to use these font paths when [[Fonts#Installation|adding fonts]].<br />
<br />
To see a list of known Fontconfig fonts:<br />
$ fc-list : file<br />
<br />
See {{ic|man fc-list}} for more out put format.<br />
<br />
Check for Xorg's known font paths by reviewing its log:<br />
$ grep /fonts /var/log/Xorg.0.log<br />
<br />
{{Tip|You can also check the list of [[Xorg]]'s known font paths using the command {{ic|xset q}}.}}<br />
<br />
Keep in mind that Xorg does not search recursively through the {{ic|/usr/share/fonts/}} directory like Fontconfig does. To add a path, the full path must be used:<br />
Section "Files"<br />
FontPath "/usr/share/fonts/local/"<br />
EndSection<br />
<br />
If you want font paths to be set on a per-user basis, you can add and remove font paths from the default by adding the following line(s) to {{ic|~/.xinitrc}}:<br />
xset +fp /usr/share/fonts/local/ # Prepend a custom font path to Xorg's list of known font paths<br />
xset -fp /usr/share/fonts/sucky_fonts/ # Remove the specified font path from Xorg's list of known font paths<br />
<br />
To see a list of known Xorg fonts use {{ic|xlsfonts}}, from the {{Pkg|xorg-xlsfonts}} package.<br />
<br />
==Fontconfig configuration==<br />
<br />
Fontconfig is documented in the [http://fontconfig.org/fontconfig-user.html fonts.conf] man page.<br />
<br />
Configuration can be done per-user through {{ic|$XDG_CONFIG_HOME/fontconfig/fonts.conf}}, and globally with {{ic|/etc/fonts/local.conf}}. The settings in the per-user configuration have precedence over the global configuration. Both these files use the same syntax.<br />
{{Note|Configuration files and directories: {{ic|~/.fonts.conf}}, {{ic|~/.fonts.conf.d}} and {{ic|~/.fontconfig/*.cache-*}} are deprecated since fontconfig 2.10.1 ([http://cgit.freedesktop.org/fontconfig/commit/?id&#61;8c255fb185d5651b57380b0a9443001e8051b29d upstream commit]) and will not be read by default in the future versions of package. Use instead {{ic|$XDG_CONFIG_HOME/fontconfig/fonts.conf}}, {{ic|$XDG_CONFIG_HOME/fontconfig/conf.d}} and {{ic|$XDG_CACHE_HOME/fontconfig/*.cache-*}} respectively. If you use the second directory, the file '''must''' follow the naming convention {{ic|NN-name.conf}} (where NN it's a two digit number like 00, 10, or 99).}}<br />
<br />
Fontconfig gathers all its configurations in a central file ({{ic|/etc/fonts/fonts.conf}}). This file is replaced during fontconfig updates and shouldn't be edited. Fontconfig-aware applications source this file to know available fonts and how they get rendered. This file is a conglomeration of rules from the global configuration ({{ic|/etc/fonts/local.conf}}), the configured presets in {{ic|/etc/fonts/conf.d/}}, and the user configuration file ({{ic|$XDG_CONFIG_HOME/fontconfig/fonts.conf}}).<br />
<br />
{{Note|For some desktop environments (such as [[GNOME]] and [[KDE]]) using the ''Font Control Panel'' will automatically create or overwrite the user font configuration file. For these desktop environments, it is best to match your already defined font configurations to get the expected behavior.}}<br />
<br />
Fontconfig configuration files use [[Wikipedia:XML|XML]] format and need these headers:<br />
<br />
{{bc|<nowiki><br />
<?xml version="1.0"?><br />
<!DOCTYPE fontconfig SYSTEM "fonts.dtd"><br />
<fontconfig><br />
<br />
<!-- settings go here --><br />
<br />
</fontconfig><br />
</nowiki>}}<br />
<br />
The configuration examples in this article omit these tags.<br />
<br />
===Presets===<br />
<br />
There are presets installed in the directory {{ic|/etc/fonts/conf.avail}}. They can be enabled by creating [[Wikipedia:Symbolic link|symbolic link]]s to them, both per-user and globally, as described in {{ic|/etc/fonts/conf.d/README}}. These presets will override matching settings in their respective configuration files.<br />
<br />
For example, to enable sub-pixel RGB rendering globally:<br />
<br />
# cd /etc/fonts/conf.d<br />
# ln -s ../conf.avail/10-sub-pixel-rgb.conf<br />
<br />
To do the same but instead for a per-user configuration:<br />
<br />
$ mkdir $XDG_CONFIG_HOME/fontconfig/conf.d<br />
$ ln -s /etc/fonts/conf.avail/10-sub-pixel-rgb.conf $XDG_CONFIG_HOME/fontconfig/conf.d<br />
<br />
===Anti-aliasing===<br />
<br />
[[Wikipedia:Font rasterization|Font rasterization]] converts vector font data to bitmap data so that it can be displayed. The result can appear jagged due to [[Wikipedia:Aliasing|aliasing]]. [[Wikipedia:Anti-aliasing|anti-aliasing]] is enabled by default and increases the apparent resolution of font edges.<br />
<br />
{{bc|<nowiki><br />
<match target="font"><br />
<edit name="antialias" mode="assign"><br />
<bool>true</bool><br />
</edit><br />
</match><br />
</nowiki>}}<br />
<br />
Note: some applications, like [[Gnome|Gnome 3]] may [[#Troubleshooting|override default anti-alias settings]].<br />
<br />
===Hinting===<br />
<br />
[[Wikipedia:Font hinting|Font hinting]] (also known as instructing) is the use of mathematical instructions to adjust the display of an outline font so that it lines up with a rasterized grid, such as the pixel grid in a display. Fonts will not line up correctly without hinting until displays have 300 [[Wikipedia:Dots per inch|DPI]] or greater. Two types of hinting are available.<br />
<br />
====Byte-Code Interpreter (BCI)====<br />
Using normal hinting, TrueType hinting instructions in the font are interpreted by freetype's Byte-Code Interpreter. This works best for fonts with good hinting instructions.<br />
<br />
To enable normal hinting:<br />
<br />
{{bc|<nowiki><br />
<match target="font"><br />
<edit name="hinting" mode="assign"><br />
<bool>true</bool><br />
</edit><br />
</match><br />
</nowiki>}}<br />
<br />
====Autohinter====<br />
Auto-discovery for hinting. This looks worse than normal hinting for fonts with good instructions, but better for those with poor or no instructions. The autohinter and subpixel rendering are not designed to work together and should not be used in combination.<br />
<br />
To enable auto-hinting:<br />
<br />
{{bc|<nowiki><br />
<match target="font"><br />
<edit name="autohint" mode="assign"><br />
<bool>true</bool><br />
</edit><br />
</match><br />
</nowiki>}}<br />
<br />
====Hint style====<br />
<br />
Hint style is the amount of influence the hinting mode has. Hinting can be set to: {{ic|hintfull}}, {{ic|hintmedium}}, {{ic|hintslight}} and {{ic|hintnone}}. With BCI hinting, hintfull should work best for most fonts. With the autohinter, hintslight is recommended.<br />
<br />
{{bc|<nowiki><br />
<match target="font"><br />
<edit name="hintstyle" mode="assign"><br />
<const>hintfull</const><br />
</edit><br />
</match><br />
</nowiki>}}<br />
<br />
Note: some applications, like [[Gnome|Gnome 3]] may [[#Troubleshooting|override default hinting settings]].<br />
<br />
===Subpixel rendering===<br />
<br />
Subpixel rendering effectively triples the horizontal (or vertical) resolution for fonts by making use of subpixels. The autohinter and subpixel rendering are not designed to work together and should not be used in combination without the [[#Infinality]] patch set.<br />
<br />
Most monitors manufactured today use the Red, Green, Blue (RGB) specification. Fontconfig will need to know your monitor type to be able to display your fonts correctly.<br />
<br />
''RGB (most common), BGR, V-RGB (vertical), or V-BGR''<br />
<br />
To enable subpixel rendering:<br />
<br />
{{bc|<nowiki><br />
<match target="font"><br />
<edit name="rgba" mode="assign"><br />
<const>rgb</const><br />
</edit><br />
</match><br />
</nowiki>}}<br />
<br />
If you notice unusual colors around font's borders, the wrong subpixel arrangement might be configured. The [http://www.lagom.nl/lcd-test/subpixel.php Lagom subpixel layout test] web page can help identify it.<br />
<br />
====LCD filter====<br />
<br />
When using subpixel rendering, you should enable the LCD filter, which is designed to reduce colour fringing. This is described under [http://www.freetype.org/freetype2/docs/reference/ft2-lcd_filtering.html LCD filtering] in the FreeType 2 API reference. Different options are described under [http://www.freetype.org/freetype2/docs/reference/ft2-lcd_filtering.html#FT_LcdFilter FT_LcdFilter], and are illustrated by this [http://www.spasche.net/files/lcdfiltering/ LCD filter test] page.<br />
<br />
The {{ic|lcddefault}} filter will work for most users. Other filters are available that can be used in special situations: {{ic|lcdlight}}; a lighter filter ideal for fonts that look too bold or fuzzy, {{ic|lcdlegacy}}, the original Cairo filter; and {{ic|lcdnone}} to disable it entirely.<br />
<br />
{{bc|<nowiki><br />
<match target="font"><br />
<edit mode="assign" name="lcdfilter"><br />
<const>lcddefault</const><br />
</edit><br />
</match><br />
</nowiki>}}<br />
<br />
====Advanced LCD filter specification====<br />
<br />
If the available, built-in LCD filters are not satisfactory, it is possible to tweak the font rendering very specifically by building a custom freetype2 package and modifying the hardcoded filters. The [[Arch Build System]] can be used to build and install packages from source.<br />
<br />
First, refresh the freetype2 PKGBUILD as root:<br />
<br />
# abs extra/freetype2<br />
<br />
This example uses {{ic|/var/abs/build}} as the build directory, substitute it according to your personal ABS setup. Download and extract the freetype2 package as a regular user:<br />
<br />
$ cd /var/abs/build<br />
$ cp -r ../extra/freetype2 .<br />
$ cd freetype2<br />
$ makepkg -o<br />
<br />
Edit the file {{ic|src/freetype-VERSION/src/base/ftlcdfil.c}} and look up the definition of the constant {{ic|default_filter[5]}}:<br />
<br />
static const FT_Byte default_filter[5] =<br />
{ 0x10, 0x40, 0x70, 0x40, 0x10 };<br />
<br />
This constant defines a low-pass filter applied to the rendered glyph. Modify it as needed. Save the file, build and install the custom package:<br />
<br />
$ makepkg -e<br />
$ sudo pacman -Rd freetype2<br />
$ sudo pacman -U freetype2-VERSION-ARCH.pkg.tar.xz<br />
<br />
Reboot or restart X. The lcddefault filter should now render fonts differently.<br />
<br />
===Disable auto-hinter for bold fonts===<br />
<br />
The auto-hinter uses sophisticated methods for font rendering, but often makes bold fonts too wide. Fortunately, a solution can be turning off the autohinter for bold fonts while leaving it on for the rest:<br />
...<br />
<match target="font"><br />
<test name="weight" compare="more"><br />
<const>medium</const><br />
</test><br />
<edit name="autohint" mode="assign"><br />
<bool>false</bool><br />
</edit><br />
</match><br />
...<br />
<br />
=== Enable anti-aliasing only for bigger fonts ===<br />
<br />
''See also [http://sharpfonts.co.cc/ sharpfonts.co.cc] for related information.''<br />
<br />
Some users prefer the sharper rendering that anti-aliasing does not offer:<br />
<br />
{{bc|<nowiki><br />
...<br />
<match target="font"><br />
<edit name="antialias" mode="assign"><br />
<bool>false</bool><br />
</edit><br />
</match><br />
<br />
<match target="font" ><br />
<test name="size" qual="any" compare="more"><br />
<double>12</double><br />
</test><br />
<edit name="antialias" mode="assign"><br />
<bool>true</bool><br />
</edit><br />
</match><br />
<br />
<match target="font" ><br />
<test name="pixelsize" qual="any" compare="more"><br />
<double>16</double><br />
</test><br />
<edit name="antialias" mode="assign"><br />
<bool>true</bool><br />
</edit><br />
</match><br />
...<br />
</nowiki>}}<br />
<br />
===Replace fonts===<br />
<br />
The most reliable way to do this is to add an XML fragment similar to the one below. ''Using the "binding" attribute will give you better results'', for example, in Firefox where you may not want to change properties of font being replaced. This will cause Ubuntu to be used in place of Georgia:<br />
...<br />
<match target="pattern"><br />
<test qual="any" name="family"><string>georgia</string></test><br />
<edit name="family" mode="assign" binding="same"><string>Ubuntu</string></edit><br />
</match><br />
...<br />
An alternate approach is to set the "preferred" font, but ''this only works if the original font is not on the system'', in which case the one specified will be substituted:<br />
...<br />
< !-- Replace Helvetica with Bitstream Vera Sans Mono --><br />
< !-- Note, an alias for Helvetica should already exist in default conf files --><br />
<alias><br />
<family>Helvetica</family><br />
<prefer><family>Bitstream Vera Sans Mono</family></prefer><br />
<default><family>fixed</family></default><br />
</alias><br />
...<br />
<br />
===Disable bitmap fonts===<br />
<br />
To disable bitmap fonts in fontconfig, use {{ic|70-no-bitmaps.conf}} (which is not placed by fontconfig by default):<br />
<br />
# cd /etc/fonts/conf.d<br />
# rm 70-yes-bitmaps.conf<br />
# ln -s ../conf.avail/70-no-bitmaps.conf<br />
<br />
You may not need to remove {{ic|70-yes-bitmaps.conf}} if it does not exist. You can choose which fonts to replace bitmaps fonts with (Helvetica, Courier and Times bitmap mapts to TTF fonts) by:<br />
<br />
# cd /etc/fonts/conf.d<br />
# ln -s ../conf.avail/29-replace-bitmap-fonts.conf<br />
<br />
<div id="EmbeddedBitmap">To disable embedded bitmap for all fonts:<div><br />
<br />
{{hc|~/.config/fontconfig/conf.d/20-no-embeded.conf|<nowiki><br />
<?xml version="1.0"?><br />
<!DOCTYPE fontconfig SYSTEM "fonts.dtd"><br />
<fontconfig><br />
<match target="font"><br />
<edit name="embeddedbitmap" mode="assign"><br />
<bool>false</bool><br />
</edit><br />
</match><br />
</fontconfig><br />
</nowiki>}}<br />
<br />
To disable embedded bitmap fonts for a specific font:<br />
<br />
<match target="font"><br />
<test qual="any" name="family"><br />
<string>Monaco</string><br />
</test><br />
<edit name="embeddedbitmap"><bool>false</bool></edit><br />
</match><br />
<br />
===Disable scaling of bitmap fonts===<br />
<br />
To disable scaling of bitmap fonts (which often makes them blurry), remove {{ic|/etc/fonts/conf.d/10-scale-bitmap-fonts.conf}}.<br />
<br />
===Create bold and italic styles for incomplete fonts===<br />
<br />
Freetype has the ability to automatically create ''italic'' and '''bold''' styles for fonts that do not have them, but only if explicitly required by the application. Given programs rarely send these requests, this section covers manually forcing generation of missing styles.<br />
<br />
Start by editing {{ic|/usr/share/fonts/fonts.cache-1}} as explained below. Store a copy of the modifications on another file, because a font update with {{ic|fc-cache}} will overwrite {{ic|/usr/share/fonts/fonts.cache-1}}.<br />
<br />
Assuming the Dupree font is installed:<br />
"dupree.ttf" 0 "Dupree:style=Regular:slant=0:weight=80:width=100:foundry=unknown:index=0:outline=True:''etc...''<br />
<br />
Duplicate the line, change {{ic|<nowiki>style=Regular</nowiki>}} to {{ic|<nowiki>style=Bold</nowiki>}} or any other style. Also change {{ic|<nowiki>slant=0</nowiki>}} to {{ic|<nowiki>slant=100</nowiki>}} for italic, {{ic|<nowiki>weight=80</nowiki>}} to {{ic|<nowiki>weight=200</nowiki>}} for bold, or combine them for '''''bold italic''''':<br />
"dupree.ttf" 0 "Dupree:style=Bold Italic:slant=100:weight=200:width=100:foundry=unknown:index=0:outline=True:''etc...''<br />
<br />
Now add necessary modifications to {{ic|$XDG_CONFIG_HOME/fontconfig/fonts.conf}}:<br />
{{bc|<nowiki><br />
...<br />
<match target="font"><br />
<test name="family" qual="any"><br />
<string>Dupree</string><br />
&lt;!-- other fonts here .... --&gt;<br />
</test><br />
<test name="weight" compare="more_eq"><int>140</int></test><br />
<edit name="embolden" mode="assign"><bool>true</bool></edit><br />
</match><br />
<br />
<match target="font"><br />
<test name="family" qual="any"><br />
<string>Dupree</string><br />
&lt;!-- other fonts here .... --&gt;<br />
</test><br />
<test name="slant" compare="more_eq"><int>80</int></test><br />
<edit name="matrix" mode="assign"><br />
<times><br />
<name>matrix</name><br />
<matrix><br />
<double>1</double><double>0.2</double><br />
<double>0</double><double>1</double><br />
</matrix><br />
</times><br />
</edit><br />
</match><br />
...<br />
</nowiki>}}<br />
{{Tip| Use the value 'embolden' for existing bold fonts in order to make them even bolder.}}<br />
<br />
===Change rule overriding===<br />
<br />
Fontconfig processes files in {{ic|/etc/fonts/conf.d}} in numerical order. This enables rules or files to override one another, but often confuses users about what file gets parsed last.<br />
<br />
To guarantee that personal settings take precedence over any other rules, change their ordering:<br />
# cd /etc/fonts/conf.d<br />
# mv 50-user.conf 99-user.conf<br />
<br />
This change seems however to be unnecessary for the most of the cases, because a user is given enough control by default to set up own font preferences, hinting and antialiasing properties, alias new fonts to generic font families, etc.<br />
<br />
===Example fontconfig configurations===<br />
<br />
Example fontconfig configurations can be found on this [[Font_Configuration/fontconfig_Examples|page]].<br />
<br />
A simple starting point:<br />
<br />
{{hc|/etc/fonts/local.conf|<nowiki><br />
<?xml version='1.0'?><br />
<!DOCTYPE fontconfig SYSTEM 'fonts.dtd'><br />
<fontconfig><br />
<match target="font"><br />
<br />
<edit mode="assign" name="rgba"><br />
<const>rgb</const><br />
</edit><br />
<br />
<edit mode="assign" name="hinting"><br />
<bool>true</bool><br />
</edit><br />
<br />
<edit mode="assign" name="hintstyle"><br />
<const>hintslight</const><br />
</edit><br />
<br />
<edit mode="assign" name="antialias"><br />
<bool>true</bool><br />
</edit><br />
<br />
<edit mode="assign" name="lcdfilter"><br />
<const>lcddefault</const><br />
</edit><br />
<br />
</match><br />
</fontconfig><br />
</nowiki>}}<br />
<br />
==Patched packages==<br />
<br />
These patched packages are available in the [[Arch User Repository|AUR]]. A few considerations:<br />
<br />
* Configuration is usually necessary.<br />
* The new font rendering will not kick in until applications restart.<br />
* Applications which [[Wikipedia:Static library|statically link]] to a library will not be affected by patches applied to the system library.<br />
<br />
<div id="#Infinality><div><br />
===Infinality: the generic way===<br />
<br />
The infinality patchset aims to greatly improve freetype2 font rendering. It adds multiple new capabilities.<br />
<br />
*[http://www.infinality.net/blog/infinality-freetype-patches/ Home page].<br />
*[http://www.infinality.net/forum/ Forum].<br />
<br />
Infinality's settings are all configurable at runtime via environment variables in {{ic|/etc/profile.d/infinality-settings.sh}}, and include the following:<br />
<br />
*'''Emboldening Enhancement''': Disables Y emboldening, producing a much nicer result on fonts without bold versions. Works on native TT hinter and autohinter.<br />
*'''Auto-Autohint''': Automatically forces autohint on fonts that contain no TT instructions.<br />
*'''Autohint Enhancement''': Makes autohint snap horizontal stems to pixels. Gives a result that appears like a well-hinted truetype font, but is 100% patent-free (as far as I know).<br />
*'''Customized FIR Filter''': Select your own [http://www.infinality.net/forum/viewtopic.php?f=2&t=19 filter values] at run-time. Works on native TT hinter and autohinter.<br />
*'''Stem Alignment''': Aligns bitmap glyphs to optimized pixel boundaries. Works on native TT hinter and autohinter.<br />
*'''Pseudo Gamma Correction''': Lighten and darken glyphs at a given value, below a given size. Works on native TT hinter and autohinter.<br />
*'''Embolden Thin Fonts''': Embolden thin or light fonts so that they are more visible. Works on autohinter.<br />
*'''Force Slight Hinting''': Force slight hinting even when programs want full hinting. If you use the local.conf I provide (included in infinality-settings fedora package) you will notice nice improvements on @font-face fonts.<br />
*'''ChromeOS Style Sharpening''': ChromeOS uses a patch to sharpen the look of fonts. This is now included in the infinality patchset.<br />
<br />
A number of presets are included and can be used by setting the USE_STYLE variable in {{ic|/etc/profile.d/infinality-settings.sh}}.<br />
<br />
{{Note|1=The user bohoomil maintains a very good configuration in his [https://github.com/bohoomil/fontconf github repo] which is available as a [https://aur.archlinux.org/packages/fontconfig-infinality-ultimate/ package] in the AUR.}}<br />
<br />
{{Note|1=Install {{AUR|grip-git}} from AUR to have a realtime preview.}}<br />
<br />
{{AUR|freetype2-infinality}} can be installed from the [[Arch User Repository|AUR]]. Additionally, if you are using {{pkg|lib32-freetype2}} from [multilib], replace it with {{AUR|lib32-freetype2-infinality}} from the AUR. The AUR also contains a Git version of freetype2 that builds the latest development snapshot of freetype2 with the Infinality patchset: {{AUR|freetype2-git-infinality}}, {{AUR|lib32-freetype2-git-infinality}}.<br />
<br />
It is recommended to also install {{AUR|fontconfig-infinality}} to enable selection of predefined font substitution styles and antialiasing settings, apart from the rendering settings of the engine itself. After doing so, you can select the font style (win7, winxp, osx, linux, ...) with:<br />
# infctl setstyle<br />
<br />
If you set e.g. win7 or osx you need the corresponding fonts installed.<br />
<br />
{{Note|Default infinality settings can cause some programs to display fonts at 72 DPI instead of 96. If you notice a problem open /etc/fonts/infinality/infinality.conf search for the section on DPI and change 72 to 96. This problem can specifically affect conky causing the fonts to appear smaller than they should. Thus not aligning properly with images. }}<br />
<br />
{{Note|''The README for {{AUR|fontconfig-infinality}} says that /etc/fonts/local.conf should either not exist, or have no infinality-related configurations in it. The local.conf is now obsolete and completely replaced by this configuration.''}}<br />
<br />
for more information see this article: http://www.infinality.net/forum/viewtopic.php?f=2&t=77<br />
<br />
*[http://www.infinality.net/blog/infinality-freetype-patches/ Home page].<br />
<br />
===Infinality: the easy way===<br />
<br />
bohoomil also maintains '''infinality-bundle''' repository, offering three basic libraries (freetype2-infinality-ultimate, fontconfig-infinality-ultimate & cairo-infinality-ultimate) as pre-patched, pre-configured and pre-built binaries for all architectures (i686, x86_64, multilib). Using infinality-bundle makes the whole installation & configuration process dramatically simplified: all one has to do is install the three packages with<br />
<br />
{{bc|# pacman -S infinality-bundle}}<br />
<br />
which will replace the corresponding, generic Arch libraries (i.e. freetype2-infinality-ultimate will be used instead of freetype2, fontconfig-infinality-ultimate instead of fontconfig and fontconfig-infinality-ultimate from the AUR, and cairo-infinality-ultimate instead of the regular cairo). The libraries are fully compatible with the Arch packages and are meant to be used as drop-in replacements for them. No post installation/upgrade steps are required for most use scenarios: everything should work out of the box.<br />
<br />
To use the repository, add <br />
<br />
{{bc|1=[infinality-bundle]<br />
SigLevel = Never<br />
Server = http://bohoomil.cu.cc/infinality-bundle/$arch}}<br />
<br />
to your /etc/pacman.conf and issue<br />
<br />
{{bc|# pacman -Syy}}<br />
<br />
If you want to have access to multilib versions, add the following, too:<br />
<br />
{{bc|1=[infinality-bundle-multilib]<br />
SigLevel = Never<br />
Server = http://bohoomil.cu.cc/infinality-bundle-multilib/$arch}}<br />
<br />
In case of server down times, there is always a backup copy of the repository available via [https://www.dropbox.com/sh/ugmxbui00chidox/njDKnTG49W Dropbox].<br />
<br />
When installing some packages (like [https://www.archlinux.org/packages/?sort=&q=libgdiplus&maintainer=&flagged= libgdiplus]), you may encounter an error:<br />
<br />
{{bc|:: cairo and cairo-infinality-ultimate are in conflict. Remove cairo-infinality-ultimate? [y/N] n<br />
error: unresolvable package conflicts detected<br />
error: failed to prepare transaction (conflicting dependencies)}}<br />
<br />
If this happens, install the new package with {{bc|# pacman -Sd foo}} instead.<br />
<br />
For more information, see [http://bohoomil.github.io/ib.html infinality-bundle user notes].<br />
<br />
A support thread in the Forums is available [https://bbs.archlinux.org/viewtopic.php?id=162098 here].<br />
<br />
===Ubuntu===<br />
<br />
Ubuntu adds extra configurations, and occasionally patches to the font rendering libraries.<br />
<br />
Install the patched packages from the [[Arch User Repository|AUR]], the package names are: {{AUR|freetype2-ubuntu}} {{AUR|fontconfig-ubuntu}} {{AUR|cairo-ubuntu}}.<br />
<br />
The global configuration will need to be added. See [[#Example fontconfig configurations]] for a starting point.<br />
Ubuntu rendering works the best with ''hintslight'' option.<br />
<br />
===Reverting to unpatched packages===<br />
<br />
To restore the unpatched packages, reinstall the originals:<br />
<br />
# pacman -S --asdeps freetype2 cairo fontconfig<br />
<br />
==Applications without fontconfig support==<br />
<br />
Some applications like [[URxvt]] will ignore fontconfig settings. This is very apparent when using the infinality patches which are heavily reliant on proper configuration. You can work around this by using {{ic|~/.Xresources}}, but it is not nearly as flexible as fontconfig. Example (see [[#Fontconfig configuration]] for explanations of the options):<br />
<br />
{{hc|~/.Xresources|<nowiki><br />
Xft.autohint: 0<br />
Xft.lcdfilter: lcddefault<br />
Xft.hintstyle: hintfull<br />
Xft.hinting: 1<br />
Xft.antialias: 1<br />
Xft.rgba: rgb<br />
</nowiki>}}<br />
<br />
Make sure the settings are loaded properly when X starts with {{ic|xrdb -q}} (see [[Xresources]] for more information).<br />
<br />
==Troubleshooting==<br />
<br />
=== Distorted fonts ===<br />
<br />
{{Note|96 DPI is not a standard. You should use your monitor's actual DPI to get proper font rendering, especially when using subpixel rendering.}}<br />
<br />
If fonts are still unexpectedly large or small, poorly proportioned or simply rendering poorly, fontconfig may be using the incorrect DPI.<br />
<br />
Fontconfig should be able to detect DPI parameters as discovered by the Xorg server. You can check the automatically discovered DPI with {{ic|xdpyinfo}} (provided by the {{pkg|xorg-xdpyinfo}} package):<br />
<br />
{{hc|<nowiki>$ xdpyinfo | grep dots</nowiki>| resolution: 102x102 dots per inch}}<br />
<br />
If the DPI is detected incorrectly (usually due to an incorrect monitor EDID), you can specify it manually in the Xorg configuration, see [[Xorg#Display Size and DPI]]. This is the recommended solution, but it may not work with buggy drivers.<br />
<br />
Fontconfig will default to the Xft.dpi variable if it is set. Xft.dpi is usually set by desktop environments (usually to Xorg's DPI setting) or manually in {{ic|~/.Xdefaults}} or {{ic|~/.Xresources}}. Use xrdb to query for the value:<br />
<br />
{{hc|<nowiki>$ xrdb -query | grep dpi</nowiki>|Xft.dpi: 102}}<br />
<br />
Those still having problems can fall back to manually setting the DPI used by fontconfig:<br />
<br />
...<br />
<!-- Setup for DPI=96 --><br />
<match target="pattern"><br />
<edit name="dpi" mode="assign"><double>102</double></edit><br />
</match><br />
...<br />
<br />
===Calibri, Cambria, Monaco, etc. not rendering properly===<br />
<br />
Some scalable fonts have embedded bitmap versions which are rendered instead, mainly at smaller sizes. Force using scalable fonts at all sizes by [[#EmbeddedBitmap|#Disabling embedded bitmap]].<br />
<br />
===Older GTK and QT applications===<br />
<br />
Modern GTK apps enable Xft by default but this was not the case before version 2.2. If it is not possible to update these applications, force Xft for old [[GNOME]] applications by adding to {{ic|~/.bashrc}}:<br />
<br />
export GDK_USE_XFT=1<br />
<br />
For older QT applications:<br />
<br />
export QT_XFT=true<br />
<br />
===Applications overriding hinting===<br />
Some applications may override default fontconfig hinting and anti-aliasing settings. This may happen with [[Gnome]] 3, for example. Use the specific configuration program for the application in such cases. For gnome, try {{pkg|gnome-tweak-tool}}.<br />
<br />
==See also==<br />
*[http://www.x.org/X11R6.8.2/doc/fonts.html Fonts in X11R6.8.2] - Official Xorg font information<br />
*[http://freetype.sourceforge.net/freetype2/ FreeType 2 Overview]<br />
*[https://forums.gentoo.org/viewtopic-t-723341.html Gentoo font-rendering thread]</div>Silencerhttps://wiki.archlinux.org/index.php?title=Font_configuration&diff=256594Font configuration2013-05-10T21:31:04Z<p>Silencer: /* Infinality: the generic way */</p>
<hr />
<div>[[Category:Fonts]]<br />
[[it:Font Configuration]]<br />
[[ru:Font Configuration]]<br />
[[sr:Font Configuration]]<br />
[[tr:Yazıtipi_yapılandırması]]<br />
[[zh-CN:Font Configuration]]<br />
{{Article summary start}}<br />
{{Article summary text|An overview of font configuration options and various techniques for improving the readability of fonts}}<br />
{{Article summary heading|Related}}<br />
{{Article summary wiki|Fonts}}: Information on adding fonts and font recommendations<br />
{{Article summary wiki|Font Configuration/fontconfig Examples}}<br />
{{Article summary wiki|Java Runtime Environment Fonts}}: Fonts specific to Sun's Java machine<br />
{{Article summary wiki|MS Fonts}}: Adding Microsoft fonts and mimicking Windows' font settings<br />
{{Article summary wiki|X Logical Font Description}}: The older core font system for X<br />
{{Article summary end}}<br />
<br />
Fontconfig is a library designed to provide a list of available [[fonts]] to applications, and also for configuration for how fonts get rendered. See package {{Pkg|fontconfig}} and [[Wikipedia:Fontconfig]]. The Free type library ({{Pkg|freetype2}} package) renders the fonts, based on this configuration.<br />
<br />
Though Fontconfig is the standard in today's Linux, some applications still rely on the original method of font selection and display, the [[X Logical Font Description]].<br />
<br />
The font rendering packages on Arch Linux includes support for ''freetype2'' with the bytecode interpreter (BCI) enabled. Patched packages exist for better font rendering, especially with an LCD monitor. See [[#Patched packages]] below. The [[#Infinality]] package allows both auto-hinting and subpixel rendering, allows the LCD filter to be tweaked without recompiling, and allows the auto-hinter to work well with bold fonts.<br />
<br />
==Font paths==<br />
<br />
For fonts to be known to applications, they must be cataloged for easy and quick access.<br />
<br />
The font paths initially known to Fontconfig are: {{ic|/usr/share/fonts/}} and {{ic|~/.fonts/}} (of which Fontconfig will scan recursively). For ease of organization and installation, it is recommended to use these font paths when [[Fonts#Installation|adding fonts]].<br />
<br />
To see a list of known Fontconfig fonts:<br />
$ fc-list : file<br />
<br />
See {{ic|man fc-list}} for more out put format.<br />
<br />
Check for Xorg's known font paths by reviewing its log:<br />
$ grep /fonts /var/log/Xorg.0.log<br />
<br />
{{Tip|You can also check the list of [[Xorg]]'s known font paths using the command {{ic|xset q}}.}}<br />
<br />
Keep in mind that Xorg does not search recursively through the {{ic|/usr/share/fonts/}} directory like Fontconfig does. To add a path, the full path must be used:<br />
Section "Files"<br />
FontPath "/usr/share/fonts/local/"<br />
EndSection<br />
<br />
If you want font paths to be set on a per-user basis, you can add and remove font paths from the default by adding the following line(s) to {{ic|~/.xinitrc}}:<br />
xset +fp /usr/share/fonts/local/ # Prepend a custom font path to Xorg's list of known font paths<br />
xset -fp /usr/share/fonts/sucky_fonts/ # Remove the specified font path from Xorg's list of known font paths<br />
<br />
To see a list of known Xorg fonts use {{ic|xlsfonts}}, from the {{Pkg|xorg-xlsfonts}} package.<br />
<br />
==Fontconfig configuration==<br />
<br />
Fontconfig is documented in the [http://fontconfig.org/fontconfig-user.html fonts.conf] man page.<br />
<br />
Configuration can be done per-user through {{ic|$XDG_CONFIG_HOME/fontconfig/fonts.conf}}, and globally with {{ic|/etc/fonts/local.conf}}. The settings in the per-user configuration have precedence over the global configuration. Both these files use the same syntax.<br />
{{Note|Configuration files and directories: {{ic|~/.fonts.conf}}, {{ic|~/.fonts.conf.d}} and {{ic|~/.fontconfig/*.cache-*}} are deprecated since fontconfig 2.10.1 ([http://cgit.freedesktop.org/fontconfig/commit/?id&#61;8c255fb185d5651b57380b0a9443001e8051b29d upstream commit]) and will not be read by default in the future versions of package. Use instead {{ic|$XDG_CONFIG_HOME/fontconfig/fonts.conf}}, {{ic|$XDG_CONFIG_HOME/fontconfig/conf.d}} and {{ic|$XDG_CACHE_HOME/fontconfig/*.cache-*}} respectively. If you use the second directory, the file '''must''' follow the naming convention {{ic|NN-name.conf}} (where NN it's a two digit number like 00, 10, or 99).}}<br />
<br />
Fontconfig gathers all its configurations in a central file ({{ic|/etc/fonts/fonts.conf}}). This file is replaced during fontconfig updates and shouldn't be edited. Fontconfig-aware applications source this file to know available fonts and how they get rendered. This file is a conglomeration of rules from the global configuration ({{ic|/etc/fonts/local.conf}}), the configured presets in {{ic|/etc/fonts/conf.d/}}, and the user configuration file ({{ic|$XDG_CONFIG_HOME/fontconfig/fonts.conf}}).<br />
<br />
{{Note|For some desktop environments (such as [[GNOME]] and [[KDE]]) using the ''Font Control Panel'' will automatically create or overwrite the user font configuration file. For these desktop environments, it is best to match your already defined font configurations to get the expected behavior.}}<br />
<br />
Fontconfig configuration files use [[Wikipedia:XML|XML]] format and need these headers:<br />
<br />
{{bc|<nowiki><br />
<?xml version="1.0"?><br />
<!DOCTYPE fontconfig SYSTEM "fonts.dtd"><br />
<fontconfig><br />
<br />
<!-- settings go here --><br />
<br />
</fontconfig><br />
</nowiki>}}<br />
<br />
The configuration examples in this article omit these tags.<br />
<br />
===Presets===<br />
<br />
There are presets installed in the directory {{ic|/etc/fonts/conf.avail}}. They can be enabled by creating [[Wikipedia:Symbolic link|symbolic link]]s to them, both per-user and globally, as described in {{ic|/etc/fonts/conf.d/README}}. These presets will override matching settings in their respective configuration files.<br />
<br />
For example, to enable sub-pixel RGB rendering globally:<br />
<br />
# cd /etc/fonts/conf.d<br />
# ln -s ../conf.avail/10-sub-pixel-rgb.conf<br />
<br />
To do the same but instead for a per-user configuration:<br />
<br />
$ mkdir $XDG_CONFIG_HOME/fontconfig/conf.d<br />
$ ln -s /etc/fonts/conf.avail/10-sub-pixel-rgb.conf $XDG_CONFIG_HOME/fontconfig/conf.d<br />
<br />
===Anti-aliasing===<br />
<br />
[[Wikipedia:Font rasterization|Font rasterization]] converts vector font data to bitmap data so that it can be displayed. The result can appear jagged due to [[Wikipedia:Aliasing|aliasing]]. [[Wikipedia:Anti-aliasing|anti-aliasing]] is enabled by default and increases the apparent resolution of font edges.<br />
<br />
{{bc|<nowiki><br />
<match target="font"><br />
<edit name="antialias" mode="assign"><br />
<bool>true</bool><br />
</edit><br />
</match><br />
</nowiki>}}<br />
<br />
Note: some applications, like [[Gnome|Gnome 3]] may [[#Troubleshooting|override default anti-alias settings]].<br />
<br />
===Hinting===<br />
<br />
[[Wikipedia:Font hinting|Font hinting]] (also known as instructing) is the use of mathematical instructions to adjust the display of an outline font so that it lines up with a rasterized grid, such as the pixel grid in a display. Fonts will not line up correctly without hinting until displays have 300 [[Wikipedia:Dots per inch|DPI]] or greater. Two types of hinting are available.<br />
<br />
====Byte-Code Interpreter (BCI)====<br />
Using normal hinting, TrueType hinting instructions in the font are interpreted by freetype's Byte-Code Interpreter. This works best for fonts with good hinting instructions.<br />
<br />
To enable normal hinting:<br />
<br />
{{bc|<nowiki><br />
<match target="font"><br />
<edit name="hinting" mode="assign"><br />
<bool>true</bool><br />
</edit><br />
</match><br />
</nowiki>}}<br />
<br />
====Autohinter====<br />
Auto-discovery for hinting. This looks worse than normal hinting for fonts with good instructions, but better for those with poor or no instructions. The autohinter and subpixel rendering are not designed to work together and should not be used in combination.<br />
<br />
To enable auto-hinting:<br />
<br />
{{bc|<nowiki><br />
<match target="font"><br />
<edit name="autohint" mode="assign"><br />
<bool>true</bool><br />
</edit><br />
</match><br />
</nowiki>}}<br />
<br />
====Hint style====<br />
<br />
Hint style is the amount of influence the hinting mode has. Hinting can be set to: {{ic|hintfull}}, {{ic|hintmedium}}, {{ic|hintslight}} and {{ic|hintnone}}. With BCI hinting, hintfull should work best for most fonts. With the autohinter, hintslight is recommended.<br />
<br />
{{bc|<nowiki><br />
<match target="font"><br />
<edit name="hintstyle" mode="assign"><br />
<const>hintfull</const><br />
</edit><br />
</match><br />
</nowiki>}}<br />
<br />
Note: some applications, like [[Gnome|Gnome 3]] may [[#Troubleshooting|override default hinting settings]].<br />
<br />
===Subpixel rendering===<br />
<br />
Subpixel rendering effectively triples the horizontal (or vertical) resolution for fonts by making use of subpixels. The autohinter and subpixel rendering are not designed to work together and should not be used in combination without the [[#Infinality]] patch set.<br />
<br />
Most monitors manufactured today use the Red, Green, Blue (RGB) specification. Fontconfig will need to know your monitor type to be able to display your fonts correctly.<br />
<br />
''RGB (most common), BGR, V-RGB (vertical), or V-BGR''<br />
<br />
To enable subpixel rendering:<br />
<br />
{{bc|<nowiki><br />
<match target="font"><br />
<edit name="rgba" mode="assign"><br />
<const>rgb</const><br />
</edit><br />
</match><br />
</nowiki>}}<br />
<br />
If you notice unusual colors around font's borders, the wrong subpixel arrangement might be configured. The [http://www.lagom.nl/lcd-test/subpixel.php Lagom subpixel layout test] web page can help identify it.<br />
<br />
====LCD filter====<br />
<br />
When using subpixel rendering, you should enable the LCD filter, which is designed to reduce colour fringing. This is described under [http://www.freetype.org/freetype2/docs/reference/ft2-lcd_filtering.html LCD filtering] in the FreeType 2 API reference. Different options are described under [http://www.freetype.org/freetype2/docs/reference/ft2-lcd_filtering.html#FT_LcdFilter FT_LcdFilter], and are illustrated by this [http://www.spasche.net/files/lcdfiltering/ LCD filter test] page.<br />
<br />
The {{ic|lcddefault}} filter will work for most users. Other filters are available that can be used in special situations: {{ic|lcdlight}}; a lighter filter ideal for fonts that look too bold or fuzzy, {{ic|lcdlegacy}}, the original Cairo filter; and {{ic|lcdnone}} to disable it entirely.<br />
<br />
{{bc|<nowiki><br />
<match target="font"><br />
<edit mode="assign" name="lcdfilter"><br />
<const>lcddefault</const><br />
</edit><br />
</match><br />
</nowiki>}}<br />
<br />
====Advanced LCD filter specification====<br />
<br />
If the available, built-in LCD filters are not satisfactory, it is possible to tweak the font rendering very specifically by building a custom freetype2 package and modifying the hardcoded filters. The [[Arch Build System]] can be used to build and install packages from source.<br />
<br />
First, refresh the freetype2 PKGBUILD as root:<br />
<br />
# abs extra/freetype2<br />
<br />
This example uses {{ic|/var/abs/build}} as the build directory, substitute it according to your personal ABS setup. Download and extract the freetype2 package as a regular user:<br />
<br />
$ cd /var/abs/build<br />
$ cp -r ../extra/freetype2 .<br />
$ cd freetype2<br />
$ makepkg -o<br />
<br />
Edit the file {{ic|src/freetype-VERSION/src/base/ftlcdfil.c}} and look up the definition of the constant {{ic|default_filter[5]}}:<br />
<br />
static const FT_Byte default_filter[5] =<br />
{ 0x10, 0x40, 0x70, 0x40, 0x10 };<br />
<br />
This constant defines a low-pass filter applied to the rendered glyph. Modify it as needed. Save the file, build and install the custom package:<br />
<br />
$ makepkg -e<br />
$ sudo pacman -Rd freetype2<br />
$ sudo pacman -U freetype2-VERSION-ARCH.pkg.tar.xz<br />
<br />
Reboot or restart X. The lcddefault filter should now render fonts differently.<br />
<br />
===Disable auto-hinter for bold fonts===<br />
<br />
The auto-hinter uses sophisticated methods for font rendering, but often makes bold fonts too wide. Fortunately, a solution can be turning off the autohinter for bold fonts while leaving it on for the rest:<br />
...<br />
<match target="font"><br />
<test name="weight" compare="more"><br />
<const>medium</const><br />
</test><br />
<edit name="autohint" mode="assign"><br />
<bool>false</bool><br />
</edit><br />
</match><br />
...<br />
<br />
=== Enable anti-aliasing only for bigger fonts ===<br />
<br />
''See also [http://sharpfonts.co.cc/ sharpfonts.co.cc] for related information.''<br />
<br />
Some users prefer the sharper rendering that anti-aliasing does not offer:<br />
<br />
{{bc|<nowiki><br />
...<br />
<match target="font"><br />
<edit name="antialias" mode="assign"><br />
<bool>false</bool><br />
</edit><br />
</match><br />
<br />
<match target="font" ><br />
<test name="size" qual="any" compare="more"><br />
<double>12</double><br />
</test><br />
<edit name="antialias" mode="assign"><br />
<bool>true</bool><br />
</edit><br />
</match><br />
<br />
<match target="font" ><br />
<test name="pixelsize" qual="any" compare="more"><br />
<double>16</double><br />
</test><br />
<edit name="antialias" mode="assign"><br />
<bool>true</bool><br />
</edit><br />
</match><br />
...<br />
</nowiki>}}<br />
<br />
===Replace fonts===<br />
<br />
The most reliable way to do this is to add an XML fragment similar to the one below. ''Using the "binding" attribute will give you better results'', for example, in Firefox where you may not want to change properties of font being replaced. This will cause Ubuntu to be used in place of Georgia:<br />
...<br />
<match target="pattern"><br />
<test qual="any" name="family"><string>georgia</string></test><br />
<edit name="family" mode="assign" binding="same"><string>Ubuntu</string></edit><br />
</match><br />
...<br />
An alternate approach is to set the "preferred" font, but ''this only works if the original font is not on the system'', in which case the one specified will be substituted:<br />
...<br />
< !-- Replace Helvetica with Bitstream Vera Sans Mono --><br />
< !-- Note, an alias for Helvetica should already exist in default conf files --><br />
<alias><br />
<family>Helvetica</family><br />
<prefer><family>Bitstream Vera Sans Mono</family></prefer><br />
<default><family>fixed</family></default><br />
</alias><br />
...<br />
<br />
===Disable bitmap fonts===<br />
<br />
To disable bitmap fonts in fontconfig, use {{ic|70-no-bitmaps.conf}} (which is not placed by fontconfig by default):<br />
<br />
# cd /etc/fonts/conf.d<br />
# rm 70-yes-bitmaps.conf<br />
# ln -s ../conf.avail/70-no-bitmaps.conf<br />
<br />
You may not need to remove {{ic|70-yes-bitmaps.conf}} if it does not exist. You can choose which fonts to replace bitmaps fonts with (Helvetica, Courier and Times bitmap mapts to TTF fonts) by:<br />
<br />
# cd /etc/fonts/conf.d<br />
# ln -s ../conf.avail/29-replace-bitmap-fonts.conf<br />
<br />
<div id="EmbeddedBitmap">To disable embedded bitmap for all fonts:<div><br />
<br />
{{hc|~/.config/fontconfig/conf.d/20-no-embeded.conf|<nowiki><br />
<?xml version="1.0"?><br />
<!DOCTYPE fontconfig SYSTEM "fonts.dtd"><br />
<fontconfig><br />
<match target="font"><br />
<edit name="embeddedbitmap" mode="assign"><br />
<bool>false</bool><br />
</edit><br />
</match><br />
</fontconfig><br />
</nowiki>}}<br />
<br />
To disable embedded bitmap fonts for a specific font:<br />
<br />
<match target="font"><br />
<test qual="any" name="family"><br />
<string>Monaco</string><br />
</test><br />
<edit name="embeddedbitmap"><bool>false</bool></edit><br />
</match><br />
<br />
===Disable scaling of bitmap fonts===<br />
<br />
To disable scaling of bitmap fonts (which often makes them blurry), remove {{ic|/etc/fonts/conf.d/10-scale-bitmap-fonts.conf}}.<br />
<br />
===Create bold and italic styles for incomplete fonts===<br />
<br />
Freetype has the ability to automatically create ''italic'' and '''bold''' styles for fonts that do not have them, but only if explicitly required by the application. Given programs rarely send these requests, this section covers manually forcing generation of missing styles.<br />
<br />
Start by editing {{ic|/usr/share/fonts/fonts.cache-1}} as explained below. Store a copy of the modifications on another file, because a font update with {{ic|fc-cache}} will overwrite {{ic|/usr/share/fonts/fonts.cache-1}}.<br />
<br />
Assuming the Dupree font is installed:<br />
"dupree.ttf" 0 "Dupree:style=Regular:slant=0:weight=80:width=100:foundry=unknown:index=0:outline=True:''etc...''<br />
<br />
Duplicate the line, change {{ic|<nowiki>style=Regular</nowiki>}} to {{ic|<nowiki>style=Bold</nowiki>}} or any other style. Also change {{ic|<nowiki>slant=0</nowiki>}} to {{ic|<nowiki>slant=100</nowiki>}} for italic, {{ic|<nowiki>weight=80</nowiki>}} to {{ic|<nowiki>weight=200</nowiki>}} for bold, or combine them for '''''bold italic''''':<br />
"dupree.ttf" 0 "Dupree:style=Bold Italic:slant=100:weight=200:width=100:foundry=unknown:index=0:outline=True:''etc...''<br />
<br />
Now add necessary modifications to {{ic|$XDG_CONFIG_HOME/fontconfig/fonts.conf}}:<br />
{{bc|<nowiki><br />
...<br />
<match target="font"><br />
<test name="family" qual="any"><br />
<string>Dupree</string><br />
&lt;!-- other fonts here .... --&gt;<br />
</test><br />
<test name="weight" compare="more_eq"><int>140</int></test><br />
<edit name="embolden" mode="assign"><bool>true</bool></edit><br />
</match><br />
<br />
<match target="font"><br />
<test name="family" qual="any"><br />
<string>Dupree</string><br />
&lt;!-- other fonts here .... --&gt;<br />
</test><br />
<test name="slant" compare="more_eq"><int>80</int></test><br />
<edit name="matrix" mode="assign"><br />
<times><br />
<name>matrix</name><br />
<matrix><br />
<double>1</double><double>0.2</double><br />
<double>0</double><double>1</double><br />
</matrix><br />
</times><br />
</edit><br />
</match><br />
...<br />
</nowiki>}}<br />
{{Tip| Use the value 'embolden' for existing bold fonts in order to make them even bolder.}}<br />
<br />
===Change rule overriding===<br />
<br />
Fontconfig processes files in {{ic|/etc/fonts/conf.d}} in numerical order. This enables rules or files to override one another, but often confuses users about what file gets parsed last.<br />
<br />
To guarantee that personal settings take precedence over any other rules, change their ordering:<br />
# cd /etc/fonts/conf.d<br />
# mv 50-user.conf 99-user.conf<br />
<br />
This change seems however to be unnecessary for the most of the cases, because a user is given enough control by default to set up own font preferences, hinting and antialiasing properties, alias new fonts to generic font families, etc.<br />
<br />
===Example fontconfig configurations===<br />
<br />
Example fontconfig configurations can be found on this [[Font_Configuration/fontconfig_Examples|page]].<br />
<br />
A simple starting point:<br />
<br />
{{hc|/etc/fonts/local.conf|<nowiki><br />
<?xml version='1.0'?><br />
<!DOCTYPE fontconfig SYSTEM 'fonts.dtd'><br />
<fontconfig><br />
<match target="font"><br />
<br />
<edit mode="assign" name="rgba"><br />
<const>rgb</const><br />
</edit><br />
<br />
<edit mode="assign" name="hinting"><br />
<bool>true</bool><br />
</edit><br />
<br />
<edit mode="assign" name="hintstyle"><br />
<const>hintslight</const><br />
</edit><br />
<br />
<edit mode="assign" name="antialias"><br />
<bool>true</bool><br />
</edit><br />
<br />
<edit mode="assign" name="lcdfilter"><br />
<const>lcddefault</const><br />
</edit><br />
<br />
</match><br />
</fontconfig><br />
</nowiki>}}<br />
<br />
==Patched packages==<br />
<br />
These patched packages are available in the [[Arch User Repository|AUR]]. A few considerations:<br />
<br />
* Configuration is usually necessary.<br />
* The new font rendering will not kick in until applications restart.<br />
* Applications which [[Wikipedia:Static library|statically link]] to a library will not be affected by patches applied to the system library.<br />
<br />
<div id="Infinality><div><br />
===Infinality: the generic way===<br />
<br />
The infinality patchset aims to greatly improve freetype2 font rendering. It adds multiple new capabilities.<br />
<br />
*[http://www.infinality.net/blog/infinality-freetype-patches/ Home page].<br />
*[http://www.infinality.net/forum/ Forum].<br />
<br />
Infinality's settings are all configurable at runtime via environment variables in {{ic|/etc/profile.d/infinality-settings.sh}}, and include the following:<br />
<br />
*'''Emboldening Enhancement''': Disables Y emboldening, producing a much nicer result on fonts without bold versions. Works on native TT hinter and autohinter.<br />
*'''Auto-Autohint''': Automatically forces autohint on fonts that contain no TT instructions.<br />
*'''Autohint Enhancement''': Makes autohint snap horizontal stems to pixels. Gives a result that appears like a well-hinted truetype font, but is 100% patent-free (as far as I know).<br />
*'''Customized FIR Filter''': Select your own [http://www.infinality.net/forum/viewtopic.php?f=2&t=19 filter values] at run-time. Works on native TT hinter and autohinter.<br />
*'''Stem Alignment''': Aligns bitmap glyphs to optimized pixel boundaries. Works on native TT hinter and autohinter.<br />
*'''Pseudo Gamma Correction''': Lighten and darken glyphs at a given value, below a given size. Works on native TT hinter and autohinter.<br />
*'''Embolden Thin Fonts''': Embolden thin or light fonts so that they are more visible. Works on autohinter.<br />
*'''Force Slight Hinting''': Force slight hinting even when programs want full hinting. If you use the local.conf I provide (included in infinality-settings fedora package) you will notice nice improvements on @font-face fonts.<br />
*'''ChromeOS Style Sharpening''': ChromeOS uses a patch to sharpen the look of fonts. This is now included in the infinality patchset.<br />
<br />
A number of presets are included and can be used by setting the USE_STYLE variable in {{ic|/etc/profile.d/infinality-settings.sh}}.<br />
<br />
{{Note|1=The user bohoomil maintains a very good configuration in his [https://github.com/bohoomil/fontconf github repo] which is available as a [https://aur.archlinux.org/packages/fontconfig-infinality-ultimate/ package] in the AUR.}}<br />
<br />
{{Note|1=Install {{AUR|grip-git}} from AUR to have a realtime preview.}}<br />
<br />
{{AUR|freetype2-infinality}} can be installed from the [[Arch User Repository|AUR]]. Additionally, if you are using {{pkg|lib32-freetype2}} from [multilib], replace it with {{AUR|lib32-freetype2-infinality}} from the AUR. The AUR also contains a Git version of freetype2 that builds the latest development snapshot of freetype2 with the Infinality patchset: {{AUR|freetype2-git-infinality}}, {{AUR|lib32-freetype2-git-infinality}}.<br />
<br />
It is recommended to also install {{AUR|fontconfig-infinality}} to enable selection of predefined font substitution styles and antialiasing settings, apart from the rendering settings of the engine itself. After doing so, you can select the font style (win7, winxp, osx, linux, ...) with:<br />
# infctl setstyle<br />
<br />
If you set e.g. win7 or osx you need the corresponding fonts installed.<br />
<br />
{{Note|Default infinality settings can cause some programs to display fonts at 72 DPI instead of 96. If you notice a problem open /etc/fonts/infinality/infinality.conf search for the section on DPI and change 72 to 96. This problem can specifically affect conky causing the fonts to appear smaller than they should. Thus not aligning properly with images. }}<br />
<br />
{{Note|''The README for {{AUR|fontconfig-infinality}} says that /etc/fonts/local.conf should either not exist, or have no infinality-related configurations in it. The local.conf is now obsolete and completely replaced by this configuration.''}}<br />
<br />
for more information see this article: http://www.infinality.net/forum/viewtopic.php?f=2&t=77<br />
<br />
*[http://www.infinality.net/blog/infinality-freetype-patches/ Home page].<br />
<br />
===Infinality: the easy way===<br />
<br />
bohoomil also maintains '''infinality-bundle''' repository, offering three basic libraries (freetype2-infinality-ultimate, fontconfig-infinality-ultimate & cairo-infinality-ultimate) as pre-patched, pre-configured and pre-built binaries for all architectures (i686, x86_64, multilib). Using infinality-bundle makes the whole installation & configuration process dramatically simplified: all one has to do is install the three packages with<br />
<br />
{{bc|# pacman -S infinality-bundle}}<br />
<br />
which will replace the corresponding, generic Arch libraries (i.e. freetype2-infinality-ultimate will be used instead of freetype2, fontconfig-infinality-ultimate instead of fontconfig and fontconfig-infinality-ultimate from the AUR, and cairo-infinality-ultimate instead of the regular cairo). The libraries are fully compatible with the Arch packages and are meant to be used as drop-in replacements for them. No post installation/upgrade steps are required for most use scenarios: everything should work out of the box.<br />
<br />
To use the repository, add <br />
<br />
{{bc|1=[infinality-bundle]<br />
SigLevel = Never<br />
Server = http://bohoomil.cu.cc/infinality-bundle/$arch}}<br />
<br />
to your /etc/pacman.conf and issue<br />
<br />
{{bc|# pacman -Syy}}<br />
<br />
If you want to have access to multilib versions, add the following, too:<br />
<br />
{{bc|1=[infinality-bundle-multilib]<br />
SigLevel = Never<br />
Server = http://bohoomil.cu.cc/infinality-bundle-multilib/$arch}}<br />
<br />
In case of server down times, there is always a backup copy of the repository available via [https://www.dropbox.com/sh/ugmxbui00chidox/njDKnTG49W Dropbox].<br />
<br />
When installing some packages (like [https://www.archlinux.org/packages/?sort=&q=libgdiplus&maintainer=&flagged= libgdiplus]), you may encounter an error:<br />
<br />
{{bc|:: cairo and cairo-infinality-ultimate are in conflict. Remove cairo-infinality-ultimate? [y/N] n<br />
error: unresolvable package conflicts detected<br />
error: failed to prepare transaction (conflicting dependencies)}}<br />
<br />
If this happens, install the new package with {{bc|# pacman -Sd foo}} instead.<br />
<br />
For more information, see [http://bohoomil.github.io/ib.html infinality-bundle user notes].<br />
<br />
A support thread in the Forums is available [https://bbs.archlinux.org/viewtopic.php?id=162098 here].<br />
<br />
===Ubuntu===<br />
<br />
Ubuntu adds extra configurations, and occasionally patches to the font rendering libraries.<br />
<br />
Install the patched packages from the [[Arch User Repository|AUR]], the package names are: {{AUR|freetype2-ubuntu}} {{AUR|fontconfig-ubuntu}} {{AUR|cairo-ubuntu}}.<br />
<br />
The global configuration will need to be added. See [[#Example fontconfig configurations]] for a starting point.<br />
Ubuntu rendering works the best with ''hintslight'' option.<br />
<br />
===Reverting to unpatched packages===<br />
<br />
To restore the unpatched packages, reinstall the originals:<br />
<br />
# pacman -S --asdeps freetype2 cairo fontconfig<br />
<br />
==Applications without fontconfig support==<br />
<br />
Some applications like [[URxvt]] will ignore fontconfig settings. This is very apparent when using the infinality patches which are heavily reliant on proper configuration. You can work around this by using {{ic|~/.Xresources}}, but it is not nearly as flexible as fontconfig. Example (see [[#Fontconfig configuration]] for explanations of the options):<br />
<br />
{{hc|~/.Xresources|<nowiki><br />
Xft.autohint: 0<br />
Xft.lcdfilter: lcddefault<br />
Xft.hintstyle: hintfull<br />
Xft.hinting: 1<br />
Xft.antialias: 1<br />
Xft.rgba: rgb<br />
</nowiki>}}<br />
<br />
Make sure the settings are loaded properly when X starts with {{ic|xrdb -q}} (see [[Xresources]] for more information).<br />
<br />
==Troubleshooting==<br />
<br />
=== Distorted fonts ===<br />
<br />
{{Note|96 DPI is not a standard. You should use your monitor's actual DPI to get proper font rendering, especially when using subpixel rendering.}}<br />
<br />
If fonts are still unexpectedly large or small, poorly proportioned or simply rendering poorly, fontconfig may be using the incorrect DPI.<br />
<br />
Fontconfig should be able to detect DPI parameters as discovered by the Xorg server. You can check the automatically discovered DPI with {{ic|xdpyinfo}} (provided by the {{pkg|xorg-xdpyinfo}} package):<br />
<br />
{{hc|<nowiki>$ xdpyinfo | grep dots</nowiki>| resolution: 102x102 dots per inch}}<br />
<br />
If the DPI is detected incorrectly (usually due to an incorrect monitor EDID), you can specify it manually in the Xorg configuration, see [[Xorg#Display Size and DPI]]. This is the recommended solution, but it may not work with buggy drivers.<br />
<br />
Fontconfig will default to the Xft.dpi variable if it is set. Xft.dpi is usually set by desktop environments (usually to Xorg's DPI setting) or manually in {{ic|~/.Xdefaults}} or {{ic|~/.Xresources}}. Use xrdb to query for the value:<br />
<br />
{{hc|<nowiki>$ xrdb -query | grep dpi</nowiki>|Xft.dpi: 102}}<br />
<br />
Those still having problems can fall back to manually setting the DPI used by fontconfig:<br />
<br />
...<br />
<!-- Setup for DPI=96 --><br />
<match target="pattern"><br />
<edit name="dpi" mode="assign"><double>102</double></edit><br />
</match><br />
...<br />
<br />
===Calibri, Cambria, Monaco, etc. not rendering properly===<br />
<br />
Some scalable fonts have embedded bitmap versions which are rendered instead, mainly at smaller sizes. Force using scalable fonts at all sizes by [[#EmbeddedBitmap|#Disabling embedded bitmap]].<br />
<br />
===Older GTK and QT applications===<br />
<br />
Modern GTK apps enable Xft by default but this was not the case before version 2.2. If it is not possible to update these applications, force Xft for old [[GNOME]] applications by adding to {{ic|~/.bashrc}}:<br />
<br />
export GDK_USE_XFT=1<br />
<br />
For older QT applications:<br />
<br />
export QT_XFT=true<br />
<br />
===Applications overriding hinting===<br />
Some applications may override default fontconfig hinting and anti-aliasing settings. This may happen with [[Gnome]] 3, for example. Use the specific configuration program for the application in such cases. For gnome, try {{pkg|gnome-tweak-tool}}.<br />
<br />
==See also==<br />
*[http://www.x.org/X11R6.8.2/doc/fonts.html Fonts in X11R6.8.2] - Official Xorg font information<br />
*[http://freetype.sourceforge.net/freetype2/ FreeType 2 Overview]<br />
*[https://forums.gentoo.org/viewtopic-t-723341.html Gentoo font-rendering thread]</div>Silencerhttps://wiki.archlinux.org/index.php?title=Font_configuration&diff=256593Font configuration2013-05-10T21:26:50Z<p>Silencer: /* Infinality: the easy way */</p>
<hr />
<div>[[Category:Fonts]]<br />
[[it:Font Configuration]]<br />
[[ru:Font Configuration]]<br />
[[sr:Font Configuration]]<br />
[[tr:Yazıtipi_yapılandırması]]<br />
[[zh-CN:Font Configuration]]<br />
{{Article summary start}}<br />
{{Article summary text|An overview of font configuration options and various techniques for improving the readability of fonts}}<br />
{{Article summary heading|Related}}<br />
{{Article summary wiki|Fonts}}: Information on adding fonts and font recommendations<br />
{{Article summary wiki|Font Configuration/fontconfig Examples}}<br />
{{Article summary wiki|Java Runtime Environment Fonts}}: Fonts specific to Sun's Java machine<br />
{{Article summary wiki|MS Fonts}}: Adding Microsoft fonts and mimicking Windows' font settings<br />
{{Article summary wiki|X Logical Font Description}}: The older core font system for X<br />
{{Article summary end}}<br />
<br />
Fontconfig is a library designed to provide a list of available [[fonts]] to applications, and also for configuration for how fonts get rendered. See package {{Pkg|fontconfig}} and [[Wikipedia:Fontconfig]]. The Free type library ({{Pkg|freetype2}} package) renders the fonts, based on this configuration.<br />
<br />
Though Fontconfig is the standard in today's Linux, some applications still rely on the original method of font selection and display, the [[X Logical Font Description]].<br />
<br />
The font rendering packages on Arch Linux includes support for ''freetype2'' with the bytecode interpreter (BCI) enabled. Patched packages exist for better font rendering, especially with an LCD monitor. See [[#Patched packages]] below. The [[#Infinality]] package allows both auto-hinting and subpixel rendering, allows the LCD filter to be tweaked without recompiling, and allows the auto-hinter to work well with bold fonts.<br />
<br />
==Font paths==<br />
<br />
For fonts to be known to applications, they must be cataloged for easy and quick access.<br />
<br />
The font paths initially known to Fontconfig are: {{ic|/usr/share/fonts/}} and {{ic|~/.fonts/}} (of which Fontconfig will scan recursively). For ease of organization and installation, it is recommended to use these font paths when [[Fonts#Installation|adding fonts]].<br />
<br />
To see a list of known Fontconfig fonts:<br />
$ fc-list : file<br />
<br />
See {{ic|man fc-list}} for more out put format.<br />
<br />
Check for Xorg's known font paths by reviewing its log:<br />
$ grep /fonts /var/log/Xorg.0.log<br />
<br />
{{Tip|You can also check the list of [[Xorg]]'s known font paths using the command {{ic|xset q}}.}}<br />
<br />
Keep in mind that Xorg does not search recursively through the {{ic|/usr/share/fonts/}} directory like Fontconfig does. To add a path, the full path must be used:<br />
Section "Files"<br />
FontPath "/usr/share/fonts/local/"<br />
EndSection<br />
<br />
If you want font paths to be set on a per-user basis, you can add and remove font paths from the default by adding the following line(s) to {{ic|~/.xinitrc}}:<br />
xset +fp /usr/share/fonts/local/ # Prepend a custom font path to Xorg's list of known font paths<br />
xset -fp /usr/share/fonts/sucky_fonts/ # Remove the specified font path from Xorg's list of known font paths<br />
<br />
To see a list of known Xorg fonts use {{ic|xlsfonts}}, from the {{Pkg|xorg-xlsfonts}} package.<br />
<br />
==Fontconfig configuration==<br />
<br />
Fontconfig is documented in the [http://fontconfig.org/fontconfig-user.html fonts.conf] man page.<br />
<br />
Configuration can be done per-user through {{ic|$XDG_CONFIG_HOME/fontconfig/fonts.conf}}, and globally with {{ic|/etc/fonts/local.conf}}. The settings in the per-user configuration have precedence over the global configuration. Both these files use the same syntax.<br />
{{Note|Configuration files and directories: {{ic|~/.fonts.conf}}, {{ic|~/.fonts.conf.d}} and {{ic|~/.fontconfig/*.cache-*}} are deprecated since fontconfig 2.10.1 ([http://cgit.freedesktop.org/fontconfig/commit/?id&#61;8c255fb185d5651b57380b0a9443001e8051b29d upstream commit]) and will not be read by default in the future versions of package. Use instead {{ic|$XDG_CONFIG_HOME/fontconfig/fonts.conf}}, {{ic|$XDG_CONFIG_HOME/fontconfig/conf.d}} and {{ic|$XDG_CACHE_HOME/fontconfig/*.cache-*}} respectively. If you use the second directory, the file '''must''' follow the naming convention {{ic|NN-name.conf}} (where NN it's a two digit number like 00, 10, or 99).}}<br />
<br />
Fontconfig gathers all its configurations in a central file ({{ic|/etc/fonts/fonts.conf}}). This file is replaced during fontconfig updates and shouldn't be edited. Fontconfig-aware applications source this file to know available fonts and how they get rendered. This file is a conglomeration of rules from the global configuration ({{ic|/etc/fonts/local.conf}}), the configured presets in {{ic|/etc/fonts/conf.d/}}, and the user configuration file ({{ic|$XDG_CONFIG_HOME/fontconfig/fonts.conf}}).<br />
<br />
{{Note|For some desktop environments (such as [[GNOME]] and [[KDE]]) using the ''Font Control Panel'' will automatically create or overwrite the user font configuration file. For these desktop environments, it is best to match your already defined font configurations to get the expected behavior.}}<br />
<br />
Fontconfig configuration files use [[Wikipedia:XML|XML]] format and need these headers:<br />
<br />
{{bc|<nowiki><br />
<?xml version="1.0"?><br />
<!DOCTYPE fontconfig SYSTEM "fonts.dtd"><br />
<fontconfig><br />
<br />
<!-- settings go here --><br />
<br />
</fontconfig><br />
</nowiki>}}<br />
<br />
The configuration examples in this article omit these tags.<br />
<br />
===Presets===<br />
<br />
There are presets installed in the directory {{ic|/etc/fonts/conf.avail}}. They can be enabled by creating [[Wikipedia:Symbolic link|symbolic link]]s to them, both per-user and globally, as described in {{ic|/etc/fonts/conf.d/README}}. These presets will override matching settings in their respective configuration files.<br />
<br />
For example, to enable sub-pixel RGB rendering globally:<br />
<br />
# cd /etc/fonts/conf.d<br />
# ln -s ../conf.avail/10-sub-pixel-rgb.conf<br />
<br />
To do the same but instead for a per-user configuration:<br />
<br />
$ mkdir $XDG_CONFIG_HOME/fontconfig/conf.d<br />
$ ln -s /etc/fonts/conf.avail/10-sub-pixel-rgb.conf $XDG_CONFIG_HOME/fontconfig/conf.d<br />
<br />
===Anti-aliasing===<br />
<br />
[[Wikipedia:Font rasterization|Font rasterization]] converts vector font data to bitmap data so that it can be displayed. The result can appear jagged due to [[Wikipedia:Aliasing|aliasing]]. [[Wikipedia:Anti-aliasing|anti-aliasing]] is enabled by default and increases the apparent resolution of font edges.<br />
<br />
{{bc|<nowiki><br />
<match target="font"><br />
<edit name="antialias" mode="assign"><br />
<bool>true</bool><br />
</edit><br />
</match><br />
</nowiki>}}<br />
<br />
Note: some applications, like [[Gnome|Gnome 3]] may [[#Troubleshooting|override default anti-alias settings]].<br />
<br />
===Hinting===<br />
<br />
[[Wikipedia:Font hinting|Font hinting]] (also known as instructing) is the use of mathematical instructions to adjust the display of an outline font so that it lines up with a rasterized grid, such as the pixel grid in a display. Fonts will not line up correctly without hinting until displays have 300 [[Wikipedia:Dots per inch|DPI]] or greater. Two types of hinting are available.<br />
<br />
====Byte-Code Interpreter (BCI)====<br />
Using normal hinting, TrueType hinting instructions in the font are interpreted by freetype's Byte-Code Interpreter. This works best for fonts with good hinting instructions.<br />
<br />
To enable normal hinting:<br />
<br />
{{bc|<nowiki><br />
<match target="font"><br />
<edit name="hinting" mode="assign"><br />
<bool>true</bool><br />
</edit><br />
</match><br />
</nowiki>}}<br />
<br />
====Autohinter====<br />
Auto-discovery for hinting. This looks worse than normal hinting for fonts with good instructions, but better for those with poor or no instructions. The autohinter and subpixel rendering are not designed to work together and should not be used in combination.<br />
<br />
To enable auto-hinting:<br />
<br />
{{bc|<nowiki><br />
<match target="font"><br />
<edit name="autohint" mode="assign"><br />
<bool>true</bool><br />
</edit><br />
</match><br />
</nowiki>}}<br />
<br />
====Hint style====<br />
<br />
Hint style is the amount of influence the hinting mode has. Hinting can be set to: {{ic|hintfull}}, {{ic|hintmedium}}, {{ic|hintslight}} and {{ic|hintnone}}. With BCI hinting, hintfull should work best for most fonts. With the autohinter, hintslight is recommended.<br />
<br />
{{bc|<nowiki><br />
<match target="font"><br />
<edit name="hintstyle" mode="assign"><br />
<const>hintfull</const><br />
</edit><br />
</match><br />
</nowiki>}}<br />
<br />
Note: some applications, like [[Gnome|Gnome 3]] may [[#Troubleshooting|override default hinting settings]].<br />
<br />
===Subpixel rendering===<br />
<br />
Subpixel rendering effectively triples the horizontal (or vertical) resolution for fonts by making use of subpixels. The autohinter and subpixel rendering are not designed to work together and should not be used in combination without the [[#Infinality]] patch set.<br />
<br />
Most monitors manufactured today use the Red, Green, Blue (RGB) specification. Fontconfig will need to know your monitor type to be able to display your fonts correctly.<br />
<br />
''RGB (most common), BGR, V-RGB (vertical), or V-BGR''<br />
<br />
To enable subpixel rendering:<br />
<br />
{{bc|<nowiki><br />
<match target="font"><br />
<edit name="rgba" mode="assign"><br />
<const>rgb</const><br />
</edit><br />
</match><br />
</nowiki>}}<br />
<br />
If you notice unusual colors around font's borders, the wrong subpixel arrangement might be configured. The [http://www.lagom.nl/lcd-test/subpixel.php Lagom subpixel layout test] web page can help identify it.<br />
<br />
====LCD filter====<br />
<br />
When using subpixel rendering, you should enable the LCD filter, which is designed to reduce colour fringing. This is described under [http://www.freetype.org/freetype2/docs/reference/ft2-lcd_filtering.html LCD filtering] in the FreeType 2 API reference. Different options are described under [http://www.freetype.org/freetype2/docs/reference/ft2-lcd_filtering.html#FT_LcdFilter FT_LcdFilter], and are illustrated by this [http://www.spasche.net/files/lcdfiltering/ LCD filter test] page.<br />
<br />
The {{ic|lcddefault}} filter will work for most users. Other filters are available that can be used in special situations: {{ic|lcdlight}}; a lighter filter ideal for fonts that look too bold or fuzzy, {{ic|lcdlegacy}}, the original Cairo filter; and {{ic|lcdnone}} to disable it entirely.<br />
<br />
{{bc|<nowiki><br />
<match target="font"><br />
<edit mode="assign" name="lcdfilter"><br />
<const>lcddefault</const><br />
</edit><br />
</match><br />
</nowiki>}}<br />
<br />
====Advanced LCD filter specification====<br />
<br />
If the available, built-in LCD filters are not satisfactory, it is possible to tweak the font rendering very specifically by building a custom freetype2 package and modifying the hardcoded filters. The [[Arch Build System]] can be used to build and install packages from source.<br />
<br />
First, refresh the freetype2 PKGBUILD as root:<br />
<br />
# abs extra/freetype2<br />
<br />
This example uses {{ic|/var/abs/build}} as the build directory, substitute it according to your personal ABS setup. Download and extract the freetype2 package as a regular user:<br />
<br />
$ cd /var/abs/build<br />
$ cp -r ../extra/freetype2 .<br />
$ cd freetype2<br />
$ makepkg -o<br />
<br />
Edit the file {{ic|src/freetype-VERSION/src/base/ftlcdfil.c}} and look up the definition of the constant {{ic|default_filter[5]}}:<br />
<br />
static const FT_Byte default_filter[5] =<br />
{ 0x10, 0x40, 0x70, 0x40, 0x10 };<br />
<br />
This constant defines a low-pass filter applied to the rendered glyph. Modify it as needed. Save the file, build and install the custom package:<br />
<br />
$ makepkg -e<br />
$ sudo pacman -Rd freetype2<br />
$ sudo pacman -U freetype2-VERSION-ARCH.pkg.tar.xz<br />
<br />
Reboot or restart X. The lcddefault filter should now render fonts differently.<br />
<br />
===Disable auto-hinter for bold fonts===<br />
<br />
The auto-hinter uses sophisticated methods for font rendering, but often makes bold fonts too wide. Fortunately, a solution can be turning off the autohinter for bold fonts while leaving it on for the rest:<br />
...<br />
<match target="font"><br />
<test name="weight" compare="more"><br />
<const>medium</const><br />
</test><br />
<edit name="autohint" mode="assign"><br />
<bool>false</bool><br />
</edit><br />
</match><br />
...<br />
<br />
=== Enable anti-aliasing only for bigger fonts ===<br />
<br />
''See also [http://sharpfonts.co.cc/ sharpfonts.co.cc] for related information.''<br />
<br />
Some users prefer the sharper rendering that anti-aliasing does not offer:<br />
<br />
{{bc|<nowiki><br />
...<br />
<match target="font"><br />
<edit name="antialias" mode="assign"><br />
<bool>false</bool><br />
</edit><br />
</match><br />
<br />
<match target="font" ><br />
<test name="size" qual="any" compare="more"><br />
<double>12</double><br />
</test><br />
<edit name="antialias" mode="assign"><br />
<bool>true</bool><br />
</edit><br />
</match><br />
<br />
<match target="font" ><br />
<test name="pixelsize" qual="any" compare="more"><br />
<double>16</double><br />
</test><br />
<edit name="antialias" mode="assign"><br />
<bool>true</bool><br />
</edit><br />
</match><br />
...<br />
</nowiki>}}<br />
<br />
===Replace fonts===<br />
<br />
The most reliable way to do this is to add an XML fragment similar to the one below. ''Using the "binding" attribute will give you better results'', for example, in Firefox where you may not want to change properties of font being replaced. This will cause Ubuntu to be used in place of Georgia:<br />
...<br />
<match target="pattern"><br />
<test qual="any" name="family"><string>georgia</string></test><br />
<edit name="family" mode="assign" binding="same"><string>Ubuntu</string></edit><br />
</match><br />
...<br />
An alternate approach is to set the "preferred" font, but ''this only works if the original font is not on the system'', in which case the one specified will be substituted:<br />
...<br />
< !-- Replace Helvetica with Bitstream Vera Sans Mono --><br />
< !-- Note, an alias for Helvetica should already exist in default conf files --><br />
<alias><br />
<family>Helvetica</family><br />
<prefer><family>Bitstream Vera Sans Mono</family></prefer><br />
<default><family>fixed</family></default><br />
</alias><br />
...<br />
<br />
===Disable bitmap fonts===<br />
<br />
To disable bitmap fonts in fontconfig, use {{ic|70-no-bitmaps.conf}} (which is not placed by fontconfig by default):<br />
<br />
# cd /etc/fonts/conf.d<br />
# rm 70-yes-bitmaps.conf<br />
# ln -s ../conf.avail/70-no-bitmaps.conf<br />
<br />
You may not need to remove {{ic|70-yes-bitmaps.conf}} if it does not exist. You can choose which fonts to replace bitmaps fonts with (Helvetica, Courier and Times bitmap mapts to TTF fonts) by:<br />
<br />
# cd /etc/fonts/conf.d<br />
# ln -s ../conf.avail/29-replace-bitmap-fonts.conf<br />
<br />
<div id="EmbeddedBitmap">To disable embedded bitmap for all fonts:<div><br />
<br />
{{hc|~/.config/fontconfig/conf.d/20-no-embeded.conf|<nowiki><br />
<?xml version="1.0"?><br />
<!DOCTYPE fontconfig SYSTEM "fonts.dtd"><br />
<fontconfig><br />
<match target="font"><br />
<edit name="embeddedbitmap" mode="assign"><br />
<bool>false</bool><br />
</edit><br />
</match><br />
</fontconfig><br />
</nowiki>}}<br />
<br />
To disable embedded bitmap fonts for a specific font:<br />
<br />
<match target="font"><br />
<test qual="any" name="family"><br />
<string>Monaco</string><br />
</test><br />
<edit name="embeddedbitmap"><bool>false</bool></edit><br />
</match><br />
<br />
===Disable scaling of bitmap fonts===<br />
<br />
To disable scaling of bitmap fonts (which often makes them blurry), remove {{ic|/etc/fonts/conf.d/10-scale-bitmap-fonts.conf}}.<br />
<br />
===Create bold and italic styles for incomplete fonts===<br />
<br />
Freetype has the ability to automatically create ''italic'' and '''bold''' styles for fonts that do not have them, but only if explicitly required by the application. Given programs rarely send these requests, this section covers manually forcing generation of missing styles.<br />
<br />
Start by editing {{ic|/usr/share/fonts/fonts.cache-1}} as explained below. Store a copy of the modifications on another file, because a font update with {{ic|fc-cache}} will overwrite {{ic|/usr/share/fonts/fonts.cache-1}}.<br />
<br />
Assuming the Dupree font is installed:<br />
"dupree.ttf" 0 "Dupree:style=Regular:slant=0:weight=80:width=100:foundry=unknown:index=0:outline=True:''etc...''<br />
<br />
Duplicate the line, change {{ic|<nowiki>style=Regular</nowiki>}} to {{ic|<nowiki>style=Bold</nowiki>}} or any other style. Also change {{ic|<nowiki>slant=0</nowiki>}} to {{ic|<nowiki>slant=100</nowiki>}} for italic, {{ic|<nowiki>weight=80</nowiki>}} to {{ic|<nowiki>weight=200</nowiki>}} for bold, or combine them for '''''bold italic''''':<br />
"dupree.ttf" 0 "Dupree:style=Bold Italic:slant=100:weight=200:width=100:foundry=unknown:index=0:outline=True:''etc...''<br />
<br />
Now add necessary modifications to {{ic|$XDG_CONFIG_HOME/fontconfig/fonts.conf}}:<br />
{{bc|<nowiki><br />
...<br />
<match target="font"><br />
<test name="family" qual="any"><br />
<string>Dupree</string><br />
&lt;!-- other fonts here .... --&gt;<br />
</test><br />
<test name="weight" compare="more_eq"><int>140</int></test><br />
<edit name="embolden" mode="assign"><bool>true</bool></edit><br />
</match><br />
<br />
<match target="font"><br />
<test name="family" qual="any"><br />
<string>Dupree</string><br />
&lt;!-- other fonts here .... --&gt;<br />
</test><br />
<test name="slant" compare="more_eq"><int>80</int></test><br />
<edit name="matrix" mode="assign"><br />
<times><br />
<name>matrix</name><br />
<matrix><br />
<double>1</double><double>0.2</double><br />
<double>0</double><double>1</double><br />
</matrix><br />
</times><br />
</edit><br />
</match><br />
...<br />
</nowiki>}}<br />
{{Tip| Use the value 'embolden' for existing bold fonts in order to make them even bolder.}}<br />
<br />
===Change rule overriding===<br />
<br />
Fontconfig processes files in {{ic|/etc/fonts/conf.d}} in numerical order. This enables rules or files to override one another, but often confuses users about what file gets parsed last.<br />
<br />
To guarantee that personal settings take precedence over any other rules, change their ordering:<br />
# cd /etc/fonts/conf.d<br />
# mv 50-user.conf 99-user.conf<br />
<br />
This change seems however to be unnecessary for the most of the cases, because a user is given enough control by default to set up own font preferences, hinting and antialiasing properties, alias new fonts to generic font families, etc.<br />
<br />
===Example fontconfig configurations===<br />
<br />
Example fontconfig configurations can be found on this [[Font_Configuration/fontconfig_Examples|page]].<br />
<br />
A simple starting point:<br />
<br />
{{hc|/etc/fonts/local.conf|<nowiki><br />
<?xml version='1.0'?><br />
<!DOCTYPE fontconfig SYSTEM 'fonts.dtd'><br />
<fontconfig><br />
<match target="font"><br />
<br />
<edit mode="assign" name="rgba"><br />
<const>rgb</const><br />
</edit><br />
<br />
<edit mode="assign" name="hinting"><br />
<bool>true</bool><br />
</edit><br />
<br />
<edit mode="assign" name="hintstyle"><br />
<const>hintslight</const><br />
</edit><br />
<br />
<edit mode="assign" name="antialias"><br />
<bool>true</bool><br />
</edit><br />
<br />
<edit mode="assign" name="lcdfilter"><br />
<const>lcddefault</const><br />
</edit><br />
<br />
</match><br />
</fontconfig><br />
</nowiki>}}<br />
<br />
==Patched packages==<br />
<br />
These patched packages are available in the [[Arch User Repository|AUR]]. A few considerations:<br />
<br />
* Configuration is usually necessary.<br />
* The new font rendering will not kick in until applications restart.<br />
* Applications which [[Wikipedia:Static library|statically link]] to a library will not be affected by patches applied to the system library.<br />
<br />
===Infinality: the generic way===<br />
<br />
The infinality patchset aims to greatly improve freetype2 font rendering. It adds multiple new capabilities.<br />
<br />
*[http://www.infinality.net/blog/infinality-freetype-patches/ Home page].<br />
*[http://www.infinality.net/forum/ Forum].<br />
<br />
Infinality's settings are all configurable at runtime via environment variables in {{ic|/etc/profile.d/infinality-settings.sh}}, and include the following:<br />
<br />
*'''Emboldening Enhancement''': Disables Y emboldening, producing a much nicer result on fonts without bold versions. Works on native TT hinter and autohinter.<br />
*'''Auto-Autohint''': Automatically forces autohint on fonts that contain no TT instructions.<br />
*'''Autohint Enhancement''': Makes autohint snap horizontal stems to pixels. Gives a result that appears like a well-hinted truetype font, but is 100% patent-free (as far as I know).<br />
*'''Customized FIR Filter''': Select your own [http://www.infinality.net/forum/viewtopic.php?f=2&t=19 filter values] at run-time. Works on native TT hinter and autohinter.<br />
*'''Stem Alignment''': Aligns bitmap glyphs to optimized pixel boundaries. Works on native TT hinter and autohinter.<br />
*'''Pseudo Gamma Correction''': Lighten and darken glyphs at a given value, below a given size. Works on native TT hinter and autohinter.<br />
*'''Embolden Thin Fonts''': Embolden thin or light fonts so that they are more visible. Works on autohinter.<br />
*'''Force Slight Hinting''': Force slight hinting even when programs want full hinting. If you use the local.conf I provide (included in infinality-settings fedora package) you will notice nice improvements on @font-face fonts.<br />
*'''ChromeOS Style Sharpening''': ChromeOS uses a patch to sharpen the look of fonts. This is now included in the infinality patchset.<br />
<br />
A number of presets are included and can be used by setting the USE_STYLE variable in {{ic|/etc/profile.d/infinality-settings.sh}}.<br />
<br />
{{Note|1=The user bohoomil maintains a very good configuration in his [https://github.com/bohoomil/fontconf github repo] which is available as a [https://aur.archlinux.org/packages/fontconfig-infinality-ultimate/ package] in the AUR.}}<br />
<br />
{{Note|1=Install {{AUR|grip-git}} from AUR to have a realtime preview.}}<br />
<br />
{{AUR|freetype2-infinality}} can be installed from the [[Arch User Repository|AUR]]. Additionally, if you are using {{pkg|lib32-freetype2}} from [multilib], replace it with {{AUR|lib32-freetype2-infinality}} from the AUR. The AUR also contains a Git version of freetype2 that builds the latest development snapshot of freetype2 with the Infinality patchset: {{AUR|freetype2-git-infinality}}, {{AUR|lib32-freetype2-git-infinality}}.<br />
<br />
It is recommended to also install {{AUR|fontconfig-infinality}} to enable selection of predefined font substitution styles and antialiasing settings, apart from the rendering settings of the engine itself. After doing so, you can select the font style (win7, winxp, osx, linux, ...) with:<br />
# infctl setstyle<br />
<br />
If you set e.g. win7 or osx you need the corresponding fonts installed.<br />
<br />
{{Note|Default infinality settings can cause some programs to display fonts at 72 DPI instead of 96. If you notice a problem open /etc/fonts/infinality/infinality.conf search for the section on DPI and change 72 to 96. This problem can specifically affect conky causing the fonts to appear smaller than they should. Thus not aligning properly with images. }}<br />
<br />
{{Note|''The README for {{AUR|fontconfig-infinality}} says that /etc/fonts/local.conf should either not exist, or have no infinality-related configurations in it. The local.conf is now obsolete and completely replaced by this configuration.''}}<br />
<br />
for more information see this article: http://www.infinality.net/forum/viewtopic.php?f=2&t=77<br />
<br />
*[http://www.infinality.net/blog/infinality-freetype-patches/ Home page].<br />
<br />
===Infinality: the easy way===<br />
<br />
bohoomil also maintains '''infinality-bundle''' repository, offering three basic libraries (freetype2-infinality-ultimate, fontconfig-infinality-ultimate & cairo-infinality-ultimate) as pre-patched, pre-configured and pre-built binaries for all architectures (i686, x86_64, multilib). Using infinality-bundle makes the whole installation & configuration process dramatically simplified: all one has to do is install the three packages with<br />
<br />
{{bc|# pacman -S infinality-bundle}}<br />
<br />
which will replace the corresponding, generic Arch libraries (i.e. freetype2-infinality-ultimate will be used instead of freetype2, fontconfig-infinality-ultimate instead of fontconfig and fontconfig-infinality-ultimate from the AUR, and cairo-infinality-ultimate instead of the regular cairo). The libraries are fully compatible with the Arch packages and are meant to be used as drop-in replacements for them. No post installation/upgrade steps are required for most use scenarios: everything should work out of the box.<br />
<br />
To use the repository, add <br />
<br />
{{bc|1=[infinality-bundle]<br />
SigLevel = Never<br />
Server = http://bohoomil.cu.cc/infinality-bundle/$arch}}<br />
<br />
to your /etc/pacman.conf and issue<br />
<br />
{{bc|# pacman -Syy}}<br />
<br />
If you want to have access to multilib versions, add the following, too:<br />
<br />
{{bc|1=[infinality-bundle-multilib]<br />
SigLevel = Never<br />
Server = http://bohoomil.cu.cc/infinality-bundle-multilib/$arch}}<br />
<br />
In case of server down times, there is always a backup copy of the repository available via [https://www.dropbox.com/sh/ugmxbui00chidox/njDKnTG49W Dropbox].<br />
<br />
When installing some packages (like [https://www.archlinux.org/packages/?sort=&q=libgdiplus&maintainer=&flagged= libgdiplus]), you may encounter an error:<br />
<br />
{{bc|:: cairo and cairo-infinality-ultimate are in conflict. Remove cairo-infinality-ultimate? [y/N] n<br />
error: unresolvable package conflicts detected<br />
error: failed to prepare transaction (conflicting dependencies)}}<br />
<br />
If this happens, install the new package with {{bc|# pacman -Sd foo}} instead.<br />
<br />
For more information, see [http://bohoomil.github.io/ib.html infinality-bundle user notes].<br />
<br />
A support thread in the Forums is available [https://bbs.archlinux.org/viewtopic.php?id=162098 here].<br />
<br />
===Ubuntu===<br />
<br />
Ubuntu adds extra configurations, and occasionally patches to the font rendering libraries.<br />
<br />
Install the patched packages from the [[Arch User Repository|AUR]], the package names are: {{AUR|freetype2-ubuntu}} {{AUR|fontconfig-ubuntu}} {{AUR|cairo-ubuntu}}.<br />
<br />
The global configuration will need to be added. See [[#Example fontconfig configurations]] for a starting point.<br />
Ubuntu rendering works the best with ''hintslight'' option.<br />
<br />
===Reverting to unpatched packages===<br />
<br />
To restore the unpatched packages, reinstall the originals:<br />
<br />
# pacman -S --asdeps freetype2 cairo fontconfig<br />
<br />
==Applications without fontconfig support==<br />
<br />
Some applications like [[URxvt]] will ignore fontconfig settings. This is very apparent when using the infinality patches which are heavily reliant on proper configuration. You can work around this by using {{ic|~/.Xresources}}, but it is not nearly as flexible as fontconfig. Example (see [[#Fontconfig configuration]] for explanations of the options):<br />
<br />
{{hc|~/.Xresources|<nowiki><br />
Xft.autohint: 0<br />
Xft.lcdfilter: lcddefault<br />
Xft.hintstyle: hintfull<br />
Xft.hinting: 1<br />
Xft.antialias: 1<br />
Xft.rgba: rgb<br />
</nowiki>}}<br />
<br />
Make sure the settings are loaded properly when X starts with {{ic|xrdb -q}} (see [[Xresources]] for more information).<br />
<br />
==Troubleshooting==<br />
<br />
=== Distorted fonts ===<br />
<br />
{{Note|96 DPI is not a standard. You should use your monitor's actual DPI to get proper font rendering, especially when using subpixel rendering.}}<br />
<br />
If fonts are still unexpectedly large or small, poorly proportioned or simply rendering poorly, fontconfig may be using the incorrect DPI.<br />
<br />
Fontconfig should be able to detect DPI parameters as discovered by the Xorg server. You can check the automatically discovered DPI with {{ic|xdpyinfo}} (provided by the {{pkg|xorg-xdpyinfo}} package):<br />
<br />
{{hc|<nowiki>$ xdpyinfo | grep dots</nowiki>| resolution: 102x102 dots per inch}}<br />
<br />
If the DPI is detected incorrectly (usually due to an incorrect monitor EDID), you can specify it manually in the Xorg configuration, see [[Xorg#Display Size and DPI]]. This is the recommended solution, but it may not work with buggy drivers.<br />
<br />
Fontconfig will default to the Xft.dpi variable if it is set. Xft.dpi is usually set by desktop environments (usually to Xorg's DPI setting) or manually in {{ic|~/.Xdefaults}} or {{ic|~/.Xresources}}. Use xrdb to query for the value:<br />
<br />
{{hc|<nowiki>$ xrdb -query | grep dpi</nowiki>|Xft.dpi: 102}}<br />
<br />
Those still having problems can fall back to manually setting the DPI used by fontconfig:<br />
<br />
...<br />
<!-- Setup for DPI=96 --><br />
<match target="pattern"><br />
<edit name="dpi" mode="assign"><double>102</double></edit><br />
</match><br />
...<br />
<br />
===Calibri, Cambria, Monaco, etc. not rendering properly===<br />
<br />
Some scalable fonts have embedded bitmap versions which are rendered instead, mainly at smaller sizes. Force using scalable fonts at all sizes by [[#EmbeddedBitmap|#Disabling embedded bitmap]].<br />
<br />
===Older GTK and QT applications===<br />
<br />
Modern GTK apps enable Xft by default but this was not the case before version 2.2. If it is not possible to update these applications, force Xft for old [[GNOME]] applications by adding to {{ic|~/.bashrc}}:<br />
<br />
export GDK_USE_XFT=1<br />
<br />
For older QT applications:<br />
<br />
export QT_XFT=true<br />
<br />
===Applications overriding hinting===<br />
Some applications may override default fontconfig hinting and anti-aliasing settings. This may happen with [[Gnome]] 3, for example. Use the specific configuration program for the application in such cases. For gnome, try {{pkg|gnome-tweak-tool}}.<br />
<br />
==See also==<br />
*[http://www.x.org/X11R6.8.2/doc/fonts.html Fonts in X11R6.8.2] - Official Xorg font information<br />
*[http://freetype.sourceforge.net/freetype2/ FreeType 2 Overview]<br />
*[https://forums.gentoo.org/viewtopic-t-723341.html Gentoo font-rendering thread]</div>Silencerhttps://wiki.archlinux.org/index.php?title=Font_configuration&diff=256592Font configuration2013-05-10T21:18:39Z<p>Silencer: /* Calibri, Cambria, Monaco, etc. not rendering properly */</p>
<hr />
<div>[[Category:Fonts]]<br />
[[it:Font Configuration]]<br />
[[ru:Font Configuration]]<br />
[[sr:Font Configuration]]<br />
[[tr:Yazıtipi_yapılandırması]]<br />
[[zh-CN:Font Configuration]]<br />
{{Article summary start}}<br />
{{Article summary text|An overview of font configuration options and various techniques for improving the readability of fonts}}<br />
{{Article summary heading|Related}}<br />
{{Article summary wiki|Fonts}}: Information on adding fonts and font recommendations<br />
{{Article summary wiki|Font Configuration/fontconfig Examples}}<br />
{{Article summary wiki|Java Runtime Environment Fonts}}: Fonts specific to Sun's Java machine<br />
{{Article summary wiki|MS Fonts}}: Adding Microsoft fonts and mimicking Windows' font settings<br />
{{Article summary wiki|X Logical Font Description}}: The older core font system for X<br />
{{Article summary end}}<br />
<br />
Fontconfig is a library designed to provide a list of available [[fonts]] to applications, and also for configuration for how fonts get rendered. See package {{Pkg|fontconfig}} and [[Wikipedia:Fontconfig]]. The Free type library ({{Pkg|freetype2}} package) renders the fonts, based on this configuration.<br />
<br />
Though Fontconfig is the standard in today's Linux, some applications still rely on the original method of font selection and display, the [[X Logical Font Description]].<br />
<br />
The font rendering packages on Arch Linux includes support for ''freetype2'' with the bytecode interpreter (BCI) enabled. Patched packages exist for better font rendering, especially with an LCD monitor. See [[#Patched packages]] below. The [[#Infinality]] package allows both auto-hinting and subpixel rendering, allows the LCD filter to be tweaked without recompiling, and allows the auto-hinter to work well with bold fonts.<br />
<br />
==Font paths==<br />
<br />
For fonts to be known to applications, they must be cataloged for easy and quick access.<br />
<br />
The font paths initially known to Fontconfig are: {{ic|/usr/share/fonts/}} and {{ic|~/.fonts/}} (of which Fontconfig will scan recursively). For ease of organization and installation, it is recommended to use these font paths when [[Fonts#Installation|adding fonts]].<br />
<br />
To see a list of known Fontconfig fonts:<br />
$ fc-list : file<br />
<br />
See {{ic|man fc-list}} for more out put format.<br />
<br />
Check for Xorg's known font paths by reviewing its log:<br />
$ grep /fonts /var/log/Xorg.0.log<br />
<br />
{{Tip|You can also check the list of [[Xorg]]'s known font paths using the command {{ic|xset q}}.}}<br />
<br />
Keep in mind that Xorg does not search recursively through the {{ic|/usr/share/fonts/}} directory like Fontconfig does. To add a path, the full path must be used:<br />
Section "Files"<br />
FontPath "/usr/share/fonts/local/"<br />
EndSection<br />
<br />
If you want font paths to be set on a per-user basis, you can add and remove font paths from the default by adding the following line(s) to {{ic|~/.xinitrc}}:<br />
xset +fp /usr/share/fonts/local/ # Prepend a custom font path to Xorg's list of known font paths<br />
xset -fp /usr/share/fonts/sucky_fonts/ # Remove the specified font path from Xorg's list of known font paths<br />
<br />
To see a list of known Xorg fonts use {{ic|xlsfonts}}, from the {{Pkg|xorg-xlsfonts}} package.<br />
<br />
==Fontconfig configuration==<br />
<br />
Fontconfig is documented in the [http://fontconfig.org/fontconfig-user.html fonts.conf] man page.<br />
<br />
Configuration can be done per-user through {{ic|$XDG_CONFIG_HOME/fontconfig/fonts.conf}}, and globally with {{ic|/etc/fonts/local.conf}}. The settings in the per-user configuration have precedence over the global configuration. Both these files use the same syntax.<br />
{{Note|Configuration files and directories: {{ic|~/.fonts.conf}}, {{ic|~/.fonts.conf.d}} and {{ic|~/.fontconfig/*.cache-*}} are deprecated since fontconfig 2.10.1 ([http://cgit.freedesktop.org/fontconfig/commit/?id&#61;8c255fb185d5651b57380b0a9443001e8051b29d upstream commit]) and will not be read by default in the future versions of package. Use instead {{ic|$XDG_CONFIG_HOME/fontconfig/fonts.conf}}, {{ic|$XDG_CONFIG_HOME/fontconfig/conf.d}} and {{ic|$XDG_CACHE_HOME/fontconfig/*.cache-*}} respectively. If you use the second directory, the file '''must''' follow the naming convention {{ic|NN-name.conf}} (where NN it's a two digit number like 00, 10, or 99).}}<br />
<br />
Fontconfig gathers all its configurations in a central file ({{ic|/etc/fonts/fonts.conf}}). This file is replaced during fontconfig updates and shouldn't be edited. Fontconfig-aware applications source this file to know available fonts and how they get rendered. This file is a conglomeration of rules from the global configuration ({{ic|/etc/fonts/local.conf}}), the configured presets in {{ic|/etc/fonts/conf.d/}}, and the user configuration file ({{ic|$XDG_CONFIG_HOME/fontconfig/fonts.conf}}).<br />
<br />
{{Note|For some desktop environments (such as [[GNOME]] and [[KDE]]) using the ''Font Control Panel'' will automatically create or overwrite the user font configuration file. For these desktop environments, it is best to match your already defined font configurations to get the expected behavior.}}<br />
<br />
Fontconfig configuration files use [[Wikipedia:XML|XML]] format and need these headers:<br />
<br />
{{bc|<nowiki><br />
<?xml version="1.0"?><br />
<!DOCTYPE fontconfig SYSTEM "fonts.dtd"><br />
<fontconfig><br />
<br />
<!-- settings go here --><br />
<br />
</fontconfig><br />
</nowiki>}}<br />
<br />
The configuration examples in this article omit these tags.<br />
<br />
===Presets===<br />
<br />
There are presets installed in the directory {{ic|/etc/fonts/conf.avail}}. They can be enabled by creating [[Wikipedia:Symbolic link|symbolic link]]s to them, both per-user and globally, as described in {{ic|/etc/fonts/conf.d/README}}. These presets will override matching settings in their respective configuration files.<br />
<br />
For example, to enable sub-pixel RGB rendering globally:<br />
<br />
# cd /etc/fonts/conf.d<br />
# ln -s ../conf.avail/10-sub-pixel-rgb.conf<br />
<br />
To do the same but instead for a per-user configuration:<br />
<br />
$ mkdir $XDG_CONFIG_HOME/fontconfig/conf.d<br />
$ ln -s /etc/fonts/conf.avail/10-sub-pixel-rgb.conf $XDG_CONFIG_HOME/fontconfig/conf.d<br />
<br />
===Anti-aliasing===<br />
<br />
[[Wikipedia:Font rasterization|Font rasterization]] converts vector font data to bitmap data so that it can be displayed. The result can appear jagged due to [[Wikipedia:Aliasing|aliasing]]. [[Wikipedia:Anti-aliasing|anti-aliasing]] is enabled by default and increases the apparent resolution of font edges.<br />
<br />
{{bc|<nowiki><br />
<match target="font"><br />
<edit name="antialias" mode="assign"><br />
<bool>true</bool><br />
</edit><br />
</match><br />
</nowiki>}}<br />
<br />
Note: some applications, like [[Gnome|Gnome 3]] may [[#Troubleshooting|override default anti-alias settings]].<br />
<br />
===Hinting===<br />
<br />
[[Wikipedia:Font hinting|Font hinting]] (also known as instructing) is the use of mathematical instructions to adjust the display of an outline font so that it lines up with a rasterized grid, such as the pixel grid in a display. Fonts will not line up correctly without hinting until displays have 300 [[Wikipedia:Dots per inch|DPI]] or greater. Two types of hinting are available.<br />
<br />
====Byte-Code Interpreter (BCI)====<br />
Using normal hinting, TrueType hinting instructions in the font are interpreted by freetype's Byte-Code Interpreter. This works best for fonts with good hinting instructions.<br />
<br />
To enable normal hinting:<br />
<br />
{{bc|<nowiki><br />
<match target="font"><br />
<edit name="hinting" mode="assign"><br />
<bool>true</bool><br />
</edit><br />
</match><br />
</nowiki>}}<br />
<br />
====Autohinter====<br />
Auto-discovery for hinting. This looks worse than normal hinting for fonts with good instructions, but better for those with poor or no instructions. The autohinter and subpixel rendering are not designed to work together and should not be used in combination.<br />
<br />
To enable auto-hinting:<br />
<br />
{{bc|<nowiki><br />
<match target="font"><br />
<edit name="autohint" mode="assign"><br />
<bool>true</bool><br />
</edit><br />
</match><br />
</nowiki>}}<br />
<br />
====Hint style====<br />
<br />
Hint style is the amount of influence the hinting mode has. Hinting can be set to: {{ic|hintfull}}, {{ic|hintmedium}}, {{ic|hintslight}} and {{ic|hintnone}}. With BCI hinting, hintfull should work best for most fonts. With the autohinter, hintslight is recommended.<br />
<br />
{{bc|<nowiki><br />
<match target="font"><br />
<edit name="hintstyle" mode="assign"><br />
<const>hintfull</const><br />
</edit><br />
</match><br />
</nowiki>}}<br />
<br />
Note: some applications, like [[Gnome|Gnome 3]] may [[#Troubleshooting|override default hinting settings]].<br />
<br />
===Subpixel rendering===<br />
<br />
Subpixel rendering effectively triples the horizontal (or vertical) resolution for fonts by making use of subpixels. The autohinter and subpixel rendering are not designed to work together and should not be used in combination without the [[#Infinality]] patch set.<br />
<br />
Most monitors manufactured today use the Red, Green, Blue (RGB) specification. Fontconfig will need to know your monitor type to be able to display your fonts correctly.<br />
<br />
''RGB (most common), BGR, V-RGB (vertical), or V-BGR''<br />
<br />
To enable subpixel rendering:<br />
<br />
{{bc|<nowiki><br />
<match target="font"><br />
<edit name="rgba" mode="assign"><br />
<const>rgb</const><br />
</edit><br />
</match><br />
</nowiki>}}<br />
<br />
If you notice unusual colors around font's borders, the wrong subpixel arrangement might be configured. The [http://www.lagom.nl/lcd-test/subpixel.php Lagom subpixel layout test] web page can help identify it.<br />
<br />
====LCD filter====<br />
<br />
When using subpixel rendering, you should enable the LCD filter, which is designed to reduce colour fringing. This is described under [http://www.freetype.org/freetype2/docs/reference/ft2-lcd_filtering.html LCD filtering] in the FreeType 2 API reference. Different options are described under [http://www.freetype.org/freetype2/docs/reference/ft2-lcd_filtering.html#FT_LcdFilter FT_LcdFilter], and are illustrated by this [http://www.spasche.net/files/lcdfiltering/ LCD filter test] page.<br />
<br />
The {{ic|lcddefault}} filter will work for most users. Other filters are available that can be used in special situations: {{ic|lcdlight}}; a lighter filter ideal for fonts that look too bold or fuzzy, {{ic|lcdlegacy}}, the original Cairo filter; and {{ic|lcdnone}} to disable it entirely.<br />
<br />
{{bc|<nowiki><br />
<match target="font"><br />
<edit mode="assign" name="lcdfilter"><br />
<const>lcddefault</const><br />
</edit><br />
</match><br />
</nowiki>}}<br />
<br />
====Advanced LCD filter specification====<br />
<br />
If the available, built-in LCD filters are not satisfactory, it is possible to tweak the font rendering very specifically by building a custom freetype2 package and modifying the hardcoded filters. The [[Arch Build System]] can be used to build and install packages from source.<br />
<br />
First, refresh the freetype2 PKGBUILD as root:<br />
<br />
# abs extra/freetype2<br />
<br />
This example uses {{ic|/var/abs/build}} as the build directory, substitute it according to your personal ABS setup. Download and extract the freetype2 package as a regular user:<br />
<br />
$ cd /var/abs/build<br />
$ cp -r ../extra/freetype2 .<br />
$ cd freetype2<br />
$ makepkg -o<br />
<br />
Edit the file {{ic|src/freetype-VERSION/src/base/ftlcdfil.c}} and look up the definition of the constant {{ic|default_filter[5]}}:<br />
<br />
static const FT_Byte default_filter[5] =<br />
{ 0x10, 0x40, 0x70, 0x40, 0x10 };<br />
<br />
This constant defines a low-pass filter applied to the rendered glyph. Modify it as needed. Save the file, build and install the custom package:<br />
<br />
$ makepkg -e<br />
$ sudo pacman -Rd freetype2<br />
$ sudo pacman -U freetype2-VERSION-ARCH.pkg.tar.xz<br />
<br />
Reboot or restart X. The lcddefault filter should now render fonts differently.<br />
<br />
===Disable auto-hinter for bold fonts===<br />
<br />
The auto-hinter uses sophisticated methods for font rendering, but often makes bold fonts too wide. Fortunately, a solution can be turning off the autohinter for bold fonts while leaving it on for the rest:<br />
...<br />
<match target="font"><br />
<test name="weight" compare="more"><br />
<const>medium</const><br />
</test><br />
<edit name="autohint" mode="assign"><br />
<bool>false</bool><br />
</edit><br />
</match><br />
...<br />
<br />
=== Enable anti-aliasing only for bigger fonts ===<br />
<br />
''See also [http://sharpfonts.co.cc/ sharpfonts.co.cc] for related information.''<br />
<br />
Some users prefer the sharper rendering that anti-aliasing does not offer:<br />
<br />
{{bc|<nowiki><br />
...<br />
<match target="font"><br />
<edit name="antialias" mode="assign"><br />
<bool>false</bool><br />
</edit><br />
</match><br />
<br />
<match target="font" ><br />
<test name="size" qual="any" compare="more"><br />
<double>12</double><br />
</test><br />
<edit name="antialias" mode="assign"><br />
<bool>true</bool><br />
</edit><br />
</match><br />
<br />
<match target="font" ><br />
<test name="pixelsize" qual="any" compare="more"><br />
<double>16</double><br />
</test><br />
<edit name="antialias" mode="assign"><br />
<bool>true</bool><br />
</edit><br />
</match><br />
...<br />
</nowiki>}}<br />
<br />
===Replace fonts===<br />
<br />
The most reliable way to do this is to add an XML fragment similar to the one below. ''Using the "binding" attribute will give you better results'', for example, in Firefox where you may not want to change properties of font being replaced. This will cause Ubuntu to be used in place of Georgia:<br />
...<br />
<match target="pattern"><br />
<test qual="any" name="family"><string>georgia</string></test><br />
<edit name="family" mode="assign" binding="same"><string>Ubuntu</string></edit><br />
</match><br />
...<br />
An alternate approach is to set the "preferred" font, but ''this only works if the original font is not on the system'', in which case the one specified will be substituted:<br />
...<br />
< !-- Replace Helvetica with Bitstream Vera Sans Mono --><br />
< !-- Note, an alias for Helvetica should already exist in default conf files --><br />
<alias><br />
<family>Helvetica</family><br />
<prefer><family>Bitstream Vera Sans Mono</family></prefer><br />
<default><family>fixed</family></default><br />
</alias><br />
...<br />
<br />
===Disable bitmap fonts===<br />
<br />
To disable bitmap fonts in fontconfig, use {{ic|70-no-bitmaps.conf}} (which is not placed by fontconfig by default):<br />
<br />
# cd /etc/fonts/conf.d<br />
# rm 70-yes-bitmaps.conf<br />
# ln -s ../conf.avail/70-no-bitmaps.conf<br />
<br />
You may not need to remove {{ic|70-yes-bitmaps.conf}} if it does not exist. You can choose which fonts to replace bitmaps fonts with (Helvetica, Courier and Times bitmap mapts to TTF fonts) by:<br />
<br />
# cd /etc/fonts/conf.d<br />
# ln -s ../conf.avail/29-replace-bitmap-fonts.conf<br />
<br />
<div id="EmbeddedBitmap">To disable embedded bitmap for all fonts:<div><br />
<br />
{{hc|~/.config/fontconfig/conf.d/20-no-embeded.conf|<nowiki><br />
<?xml version="1.0"?><br />
<!DOCTYPE fontconfig SYSTEM "fonts.dtd"><br />
<fontconfig><br />
<match target="font"><br />
<edit name="embeddedbitmap" mode="assign"><br />
<bool>false</bool><br />
</edit><br />
</match><br />
</fontconfig><br />
</nowiki>}}<br />
<br />
To disable embedded bitmap fonts for a specific font:<br />
<br />
<match target="font"><br />
<test qual="any" name="family"><br />
<string>Monaco</string><br />
</test><br />
<edit name="embeddedbitmap"><bool>false</bool></edit><br />
</match><br />
<br />
===Disable scaling of bitmap fonts===<br />
<br />
To disable scaling of bitmap fonts (which often makes them blurry), remove {{ic|/etc/fonts/conf.d/10-scale-bitmap-fonts.conf}}.<br />
<br />
===Create bold and italic styles for incomplete fonts===<br />
<br />
Freetype has the ability to automatically create ''italic'' and '''bold''' styles for fonts that do not have them, but only if explicitly required by the application. Given programs rarely send these requests, this section covers manually forcing generation of missing styles.<br />
<br />
Start by editing {{ic|/usr/share/fonts/fonts.cache-1}} as explained below. Store a copy of the modifications on another file, because a font update with {{ic|fc-cache}} will overwrite {{ic|/usr/share/fonts/fonts.cache-1}}.<br />
<br />
Assuming the Dupree font is installed:<br />
"dupree.ttf" 0 "Dupree:style=Regular:slant=0:weight=80:width=100:foundry=unknown:index=0:outline=True:''etc...''<br />
<br />
Duplicate the line, change {{ic|<nowiki>style=Regular</nowiki>}} to {{ic|<nowiki>style=Bold</nowiki>}} or any other style. Also change {{ic|<nowiki>slant=0</nowiki>}} to {{ic|<nowiki>slant=100</nowiki>}} for italic, {{ic|<nowiki>weight=80</nowiki>}} to {{ic|<nowiki>weight=200</nowiki>}} for bold, or combine them for '''''bold italic''''':<br />
"dupree.ttf" 0 "Dupree:style=Bold Italic:slant=100:weight=200:width=100:foundry=unknown:index=0:outline=True:''etc...''<br />
<br />
Now add necessary modifications to {{ic|$XDG_CONFIG_HOME/fontconfig/fonts.conf}}:<br />
{{bc|<nowiki><br />
...<br />
<match target="font"><br />
<test name="family" qual="any"><br />
<string>Dupree</string><br />
&lt;!-- other fonts here .... --&gt;<br />
</test><br />
<test name="weight" compare="more_eq"><int>140</int></test><br />
<edit name="embolden" mode="assign"><bool>true</bool></edit><br />
</match><br />
<br />
<match target="font"><br />
<test name="family" qual="any"><br />
<string>Dupree</string><br />
&lt;!-- other fonts here .... --&gt;<br />
</test><br />
<test name="slant" compare="more_eq"><int>80</int></test><br />
<edit name="matrix" mode="assign"><br />
<times><br />
<name>matrix</name><br />
<matrix><br />
<double>1</double><double>0.2</double><br />
<double>0</double><double>1</double><br />
</matrix><br />
</times><br />
</edit><br />
</match><br />
...<br />
</nowiki>}}<br />
{{Tip| Use the value 'embolden' for existing bold fonts in order to make them even bolder.}}<br />
<br />
===Change rule overriding===<br />
<br />
Fontconfig processes files in {{ic|/etc/fonts/conf.d}} in numerical order. This enables rules or files to override one another, but often confuses users about what file gets parsed last.<br />
<br />
To guarantee that personal settings take precedence over any other rules, change their ordering:<br />
# cd /etc/fonts/conf.d<br />
# mv 50-user.conf 99-user.conf<br />
<br />
This change seems however to be unnecessary for the most of the cases, because a user is given enough control by default to set up own font preferences, hinting and antialiasing properties, alias new fonts to generic font families, etc.<br />
<br />
===Example fontconfig configurations===<br />
<br />
Example fontconfig configurations can be found on this [[Font_Configuration/fontconfig_Examples|page]].<br />
<br />
A simple starting point:<br />
<br />
{{hc|/etc/fonts/local.conf|<nowiki><br />
<?xml version='1.0'?><br />
<!DOCTYPE fontconfig SYSTEM 'fonts.dtd'><br />
<fontconfig><br />
<match target="font"><br />
<br />
<edit mode="assign" name="rgba"><br />
<const>rgb</const><br />
</edit><br />
<br />
<edit mode="assign" name="hinting"><br />
<bool>true</bool><br />
</edit><br />
<br />
<edit mode="assign" name="hintstyle"><br />
<const>hintslight</const><br />
</edit><br />
<br />
<edit mode="assign" name="antialias"><br />
<bool>true</bool><br />
</edit><br />
<br />
<edit mode="assign" name="lcdfilter"><br />
<const>lcddefault</const><br />
</edit><br />
<br />
</match><br />
</fontconfig><br />
</nowiki>}}<br />
<br />
==Patched packages==<br />
<br />
These patched packages are available in the [[Arch User Repository|AUR]]. A few considerations:<br />
<br />
* Configuration is usually necessary.<br />
* The new font rendering will not kick in until applications restart.<br />
* Applications which [[Wikipedia:Static library|statically link]] to a library will not be affected by patches applied to the system library.<br />
<br />
===Infinality: the generic way===<br />
<br />
The infinality patchset aims to greatly improve freetype2 font rendering. It adds multiple new capabilities.<br />
<br />
*[http://www.infinality.net/blog/infinality-freetype-patches/ Home page].<br />
*[http://www.infinality.net/forum/ Forum].<br />
<br />
Infinality's settings are all configurable at runtime via environment variables in {{ic|/etc/profile.d/infinality-settings.sh}}, and include the following:<br />
<br />
*'''Emboldening Enhancement''': Disables Y emboldening, producing a much nicer result on fonts without bold versions. Works on native TT hinter and autohinter.<br />
*'''Auto-Autohint''': Automatically forces autohint on fonts that contain no TT instructions.<br />
*'''Autohint Enhancement''': Makes autohint snap horizontal stems to pixels. Gives a result that appears like a well-hinted truetype font, but is 100% patent-free (as far as I know).<br />
*'''Customized FIR Filter''': Select your own [http://www.infinality.net/forum/viewtopic.php?f=2&t=19 filter values] at run-time. Works on native TT hinter and autohinter.<br />
*'''Stem Alignment''': Aligns bitmap glyphs to optimized pixel boundaries. Works on native TT hinter and autohinter.<br />
*'''Pseudo Gamma Correction''': Lighten and darken glyphs at a given value, below a given size. Works on native TT hinter and autohinter.<br />
*'''Embolden Thin Fonts''': Embolden thin or light fonts so that they are more visible. Works on autohinter.<br />
*'''Force Slight Hinting''': Force slight hinting even when programs want full hinting. If you use the local.conf I provide (included in infinality-settings fedora package) you will notice nice improvements on @font-face fonts.<br />
*'''ChromeOS Style Sharpening''': ChromeOS uses a patch to sharpen the look of fonts. This is now included in the infinality patchset.<br />
<br />
A number of presets are included and can be used by setting the USE_STYLE variable in {{ic|/etc/profile.d/infinality-settings.sh}}.<br />
<br />
{{Note|1=The user bohoomil maintains a very good configuration in his [https://github.com/bohoomil/fontconf github repo] which is available as a [https://aur.archlinux.org/packages/fontconfig-infinality-ultimate/ package] in the AUR.}}<br />
<br />
{{Note|1=Install {{AUR|grip-git}} from AUR to have a realtime preview.}}<br />
<br />
{{AUR|freetype2-infinality}} can be installed from the [[Arch User Repository|AUR]]. Additionally, if you are using {{pkg|lib32-freetype2}} from [multilib], replace it with {{AUR|lib32-freetype2-infinality}} from the AUR. The AUR also contains a Git version of freetype2 that builds the latest development snapshot of freetype2 with the Infinality patchset: {{AUR|freetype2-git-infinality}}, {{AUR|lib32-freetype2-git-infinality}}.<br />
<br />
It is recommended to also install {{AUR|fontconfig-infinality}} to enable selection of predefined font substitution styles and antialiasing settings, apart from the rendering settings of the engine itself. After doing so, you can select the font style (win7, winxp, osx, linux, ...) with:<br />
# infctl setstyle<br />
<br />
If you set e.g. win7 or osx you need the corresponding fonts installed.<br />
<br />
{{Note|Default infinality settings can cause some programs to display fonts at 72 DPI instead of 96. If you notice a problem open /etc/fonts/infinality/infinality.conf search for the section on DPI and change 72 to 96. This problem can specifically affect conky causing the fonts to appear smaller than they should. Thus not aligning properly with images. }}<br />
<br />
{{Note|''The README for {{AUR|fontconfig-infinality}} says that /etc/fonts/local.conf should either not exist, or have no infinality-related configurations in it. The local.conf is now obsolete and completely replaced by this configuration.''}}<br />
<br />
for more information see this article: http://www.infinality.net/forum/viewtopic.php?f=2&t=77<br />
<br />
*[http://www.infinality.net/blog/infinality-freetype-patches/ Home page].<br />
<br />
===Infinality: the easy way===<br />
<br />
bohoomil also maintains '''infinality-bundle''' repository, offering three basic libraries (freetype2-infinality-ultimate, fontconfig-infinality-ultimate & cairo-infinality-ultimate) as pre-patched, pre-configured and pre-built binaries for all architectures (i686, x86_64, multilib). Using infinality-bundle makes the whole installation & configuration process dramatically simplified: all one has to do is install the three packages with<br />
<br />
{{bc|# pacman -S foo-infinality-ultimate}}<br />
<br />
which will replace the corresponding, generic Arch libraries (i.e. freetype2-infinality-ultimate will be used instead of freetype2, fontconfig-infinality-ultimate instead of fontconfig and fontconfig-infinality-ultimate from the AUR, and cairo-infinality-ultimate instead of the regular cairo). The libraries are fully compatible with the Arch packages and are meant to be used as drop-in replacements for them. No post installation/upgrade steps are required for most use scenarios: everything should work out of the box.<br />
<br />
To use the repository, add <br />
<br />
{{bc|1=[infinality-bundle]<br />
SigLevel = Never<br />
Server = http://bohoomil.cu.cc/infinality-bundle/$arch}}<br />
<br />
to your /etc/pacman.conf and issue<br />
<br />
{{bc|# pacman -Syy}}<br />
<br />
If you want to have access to multilib versions, add the following, too:<br />
<br />
{{bc|1=[infinality-bundle-multilib]<br />
SigLevel = Never<br />
Server = http://bohoomil.cu.cc/infinality-bundle-multilib/$arch}}<br />
<br />
In case of server down times, there is always a backup copy of the repository available via [https://www.dropbox.com/sh/ugmxbui00chidox/njDKnTG49W Dropbox].<br />
<br />
When installing some packages (like [https://www.archlinux.org/packages/?sort=&q=libgdiplus&maintainer=&flagged= libgdiplus]), you may encounter an error:<br />
<br />
{{bc|:: cairo and cairo-infinality-ultimate are in conflict. Remove cairo-infinality-ultimate? [y/N] n<br />
error: unresolvable package conflicts detected<br />
error: failed to prepare transaction (conflicting dependencies)}}<br />
<br />
If this happens, install the new package with {{bc|# pacman -Sd foo}} instead.<br />
<br />
For more information, see [http://bohoomil.github.io/ib.html infinality-bundle user notes].<br />
<br />
A support thread in the Forums is available [https://bbs.archlinux.org/viewtopic.php?id=162098 here].<br />
<br />
===Ubuntu===<br />
<br />
Ubuntu adds extra configurations, and occasionally patches to the font rendering libraries.<br />
<br />
Install the patched packages from the [[Arch User Repository|AUR]], the package names are: {{AUR|freetype2-ubuntu}} {{AUR|fontconfig-ubuntu}} {{AUR|cairo-ubuntu}}.<br />
<br />
The global configuration will need to be added. See [[#Example fontconfig configurations]] for a starting point.<br />
Ubuntu rendering works the best with ''hintslight'' option.<br />
<br />
===Reverting to unpatched packages===<br />
<br />
To restore the unpatched packages, reinstall the originals:<br />
<br />
# pacman -S --asdeps freetype2 cairo fontconfig<br />
<br />
==Applications without fontconfig support==<br />
<br />
Some applications like [[URxvt]] will ignore fontconfig settings. This is very apparent when using the infinality patches which are heavily reliant on proper configuration. You can work around this by using {{ic|~/.Xresources}}, but it is not nearly as flexible as fontconfig. Example (see [[#Fontconfig configuration]] for explanations of the options):<br />
<br />
{{hc|~/.Xresources|<nowiki><br />
Xft.autohint: 0<br />
Xft.lcdfilter: lcddefault<br />
Xft.hintstyle: hintfull<br />
Xft.hinting: 1<br />
Xft.antialias: 1<br />
Xft.rgba: rgb<br />
</nowiki>}}<br />
<br />
Make sure the settings are loaded properly when X starts with {{ic|xrdb -q}} (see [[Xresources]] for more information).<br />
<br />
==Troubleshooting==<br />
<br />
=== Distorted fonts ===<br />
<br />
{{Note|96 DPI is not a standard. You should use your monitor's actual DPI to get proper font rendering, especially when using subpixel rendering.}}<br />
<br />
If fonts are still unexpectedly large or small, poorly proportioned or simply rendering poorly, fontconfig may be using the incorrect DPI.<br />
<br />
Fontconfig should be able to detect DPI parameters as discovered by the Xorg server. You can check the automatically discovered DPI with {{ic|xdpyinfo}} (provided by the {{pkg|xorg-xdpyinfo}} package):<br />
<br />
{{hc|<nowiki>$ xdpyinfo | grep dots</nowiki>| resolution: 102x102 dots per inch}}<br />
<br />
If the DPI is detected incorrectly (usually due to an incorrect monitor EDID), you can specify it manually in the Xorg configuration, see [[Xorg#Display Size and DPI]]. This is the recommended solution, but it may not work with buggy drivers.<br />
<br />
Fontconfig will default to the Xft.dpi variable if it is set. Xft.dpi is usually set by desktop environments (usually to Xorg's DPI setting) or manually in {{ic|~/.Xdefaults}} or {{ic|~/.Xresources}}. Use xrdb to query for the value:<br />
<br />
{{hc|<nowiki>$ xrdb -query | grep dpi</nowiki>|Xft.dpi: 102}}<br />
<br />
Those still having problems can fall back to manually setting the DPI used by fontconfig:<br />
<br />
...<br />
<!-- Setup for DPI=96 --><br />
<match target="pattern"><br />
<edit name="dpi" mode="assign"><double>102</double></edit><br />
</match><br />
...<br />
<br />
===Calibri, Cambria, Monaco, etc. not rendering properly===<br />
<br />
Some scalable fonts have embedded bitmap versions which are rendered instead, mainly at smaller sizes. Force using scalable fonts at all sizes by [[#EmbeddedBitmap|#Disabling embedded bitmap]].<br />
<br />
===Older GTK and QT applications===<br />
<br />
Modern GTK apps enable Xft by default but this was not the case before version 2.2. If it is not possible to update these applications, force Xft for old [[GNOME]] applications by adding to {{ic|~/.bashrc}}:<br />
<br />
export GDK_USE_XFT=1<br />
<br />
For older QT applications:<br />
<br />
export QT_XFT=true<br />
<br />
===Applications overriding hinting===<br />
Some applications may override default fontconfig hinting and anti-aliasing settings. This may happen with [[Gnome]] 3, for example. Use the specific configuration program for the application in such cases. For gnome, try {{pkg|gnome-tweak-tool}}.<br />
<br />
==See also==<br />
*[http://www.x.org/X11R6.8.2/doc/fonts.html Fonts in X11R6.8.2] - Official Xorg font information<br />
*[http://freetype.sourceforge.net/freetype2/ FreeType 2 Overview]<br />
*[https://forums.gentoo.org/viewtopic-t-723341.html Gentoo font-rendering thread]</div>Silencerhttps://wiki.archlinux.org/index.php?title=Font_configuration&diff=256591Font configuration2013-05-10T21:18:13Z<p>Silencer: /* Calibri, Cambria, Monaco, etc. not rendering properly at some sizes */</p>
<hr />
<div>[[Category:Fonts]]<br />
[[it:Font Configuration]]<br />
[[ru:Font Configuration]]<br />
[[sr:Font Configuration]]<br />
[[tr:Yazıtipi_yapılandırması]]<br />
[[zh-CN:Font Configuration]]<br />
{{Article summary start}}<br />
{{Article summary text|An overview of font configuration options and various techniques for improving the readability of fonts}}<br />
{{Article summary heading|Related}}<br />
{{Article summary wiki|Fonts}}: Information on adding fonts and font recommendations<br />
{{Article summary wiki|Font Configuration/fontconfig Examples}}<br />
{{Article summary wiki|Java Runtime Environment Fonts}}: Fonts specific to Sun's Java machine<br />
{{Article summary wiki|MS Fonts}}: Adding Microsoft fonts and mimicking Windows' font settings<br />
{{Article summary wiki|X Logical Font Description}}: The older core font system for X<br />
{{Article summary end}}<br />
<br />
Fontconfig is a library designed to provide a list of available [[fonts]] to applications, and also for configuration for how fonts get rendered. See package {{Pkg|fontconfig}} and [[Wikipedia:Fontconfig]]. The Free type library ({{Pkg|freetype2}} package) renders the fonts, based on this configuration.<br />
<br />
Though Fontconfig is the standard in today's Linux, some applications still rely on the original method of font selection and display, the [[X Logical Font Description]].<br />
<br />
The font rendering packages on Arch Linux includes support for ''freetype2'' with the bytecode interpreter (BCI) enabled. Patched packages exist for better font rendering, especially with an LCD monitor. See [[#Patched packages]] below. The [[#Infinality]] package allows both auto-hinting and subpixel rendering, allows the LCD filter to be tweaked without recompiling, and allows the auto-hinter to work well with bold fonts.<br />
<br />
==Font paths==<br />
<br />
For fonts to be known to applications, they must be cataloged for easy and quick access.<br />
<br />
The font paths initially known to Fontconfig are: {{ic|/usr/share/fonts/}} and {{ic|~/.fonts/}} (of which Fontconfig will scan recursively). For ease of organization and installation, it is recommended to use these font paths when [[Fonts#Installation|adding fonts]].<br />
<br />
To see a list of known Fontconfig fonts:<br />
$ fc-list : file<br />
<br />
See {{ic|man fc-list}} for more out put format.<br />
<br />
Check for Xorg's known font paths by reviewing its log:<br />
$ grep /fonts /var/log/Xorg.0.log<br />
<br />
{{Tip|You can also check the list of [[Xorg]]'s known font paths using the command {{ic|xset q}}.}}<br />
<br />
Keep in mind that Xorg does not search recursively through the {{ic|/usr/share/fonts/}} directory like Fontconfig does. To add a path, the full path must be used:<br />
Section "Files"<br />
FontPath "/usr/share/fonts/local/"<br />
EndSection<br />
<br />
If you want font paths to be set on a per-user basis, you can add and remove font paths from the default by adding the following line(s) to {{ic|~/.xinitrc}}:<br />
xset +fp /usr/share/fonts/local/ # Prepend a custom font path to Xorg's list of known font paths<br />
xset -fp /usr/share/fonts/sucky_fonts/ # Remove the specified font path from Xorg's list of known font paths<br />
<br />
To see a list of known Xorg fonts use {{ic|xlsfonts}}, from the {{Pkg|xorg-xlsfonts}} package.<br />
<br />
==Fontconfig configuration==<br />
<br />
Fontconfig is documented in the [http://fontconfig.org/fontconfig-user.html fonts.conf] man page.<br />
<br />
Configuration can be done per-user through {{ic|$XDG_CONFIG_HOME/fontconfig/fonts.conf}}, and globally with {{ic|/etc/fonts/local.conf}}. The settings in the per-user configuration have precedence over the global configuration. Both these files use the same syntax.<br />
{{Note|Configuration files and directories: {{ic|~/.fonts.conf}}, {{ic|~/.fonts.conf.d}} and {{ic|~/.fontconfig/*.cache-*}} are deprecated since fontconfig 2.10.1 ([http://cgit.freedesktop.org/fontconfig/commit/?id&#61;8c255fb185d5651b57380b0a9443001e8051b29d upstream commit]) and will not be read by default in the future versions of package. Use instead {{ic|$XDG_CONFIG_HOME/fontconfig/fonts.conf}}, {{ic|$XDG_CONFIG_HOME/fontconfig/conf.d}} and {{ic|$XDG_CACHE_HOME/fontconfig/*.cache-*}} respectively. If you use the second directory, the file '''must''' follow the naming convention {{ic|NN-name.conf}} (where NN it's a two digit number like 00, 10, or 99).}}<br />
<br />
Fontconfig gathers all its configurations in a central file ({{ic|/etc/fonts/fonts.conf}}). This file is replaced during fontconfig updates and shouldn't be edited. Fontconfig-aware applications source this file to know available fonts and how they get rendered. This file is a conglomeration of rules from the global configuration ({{ic|/etc/fonts/local.conf}}), the configured presets in {{ic|/etc/fonts/conf.d/}}, and the user configuration file ({{ic|$XDG_CONFIG_HOME/fontconfig/fonts.conf}}).<br />
<br />
{{Note|For some desktop environments (such as [[GNOME]] and [[KDE]]) using the ''Font Control Panel'' will automatically create or overwrite the user font configuration file. For these desktop environments, it is best to match your already defined font configurations to get the expected behavior.}}<br />
<br />
Fontconfig configuration files use [[Wikipedia:XML|XML]] format and need these headers:<br />
<br />
{{bc|<nowiki><br />
<?xml version="1.0"?><br />
<!DOCTYPE fontconfig SYSTEM "fonts.dtd"><br />
<fontconfig><br />
<br />
<!-- settings go here --><br />
<br />
</fontconfig><br />
</nowiki>}}<br />
<br />
The configuration examples in this article omit these tags.<br />
<br />
===Presets===<br />
<br />
There are presets installed in the directory {{ic|/etc/fonts/conf.avail}}. They can be enabled by creating [[Wikipedia:Symbolic link|symbolic link]]s to them, both per-user and globally, as described in {{ic|/etc/fonts/conf.d/README}}. These presets will override matching settings in their respective configuration files.<br />
<br />
For example, to enable sub-pixel RGB rendering globally:<br />
<br />
# cd /etc/fonts/conf.d<br />
# ln -s ../conf.avail/10-sub-pixel-rgb.conf<br />
<br />
To do the same but instead for a per-user configuration:<br />
<br />
$ mkdir $XDG_CONFIG_HOME/fontconfig/conf.d<br />
$ ln -s /etc/fonts/conf.avail/10-sub-pixel-rgb.conf $XDG_CONFIG_HOME/fontconfig/conf.d<br />
<br />
===Anti-aliasing===<br />
<br />
[[Wikipedia:Font rasterization|Font rasterization]] converts vector font data to bitmap data so that it can be displayed. The result can appear jagged due to [[Wikipedia:Aliasing|aliasing]]. [[Wikipedia:Anti-aliasing|anti-aliasing]] is enabled by default and increases the apparent resolution of font edges.<br />
<br />
{{bc|<nowiki><br />
<match target="font"><br />
<edit name="antialias" mode="assign"><br />
<bool>true</bool><br />
</edit><br />
</match><br />
</nowiki>}}<br />
<br />
Note: some applications, like [[Gnome|Gnome 3]] may [[#Troubleshooting|override default anti-alias settings]].<br />
<br />
===Hinting===<br />
<br />
[[Wikipedia:Font hinting|Font hinting]] (also known as instructing) is the use of mathematical instructions to adjust the display of an outline font so that it lines up with a rasterized grid, such as the pixel grid in a display. Fonts will not line up correctly without hinting until displays have 300 [[Wikipedia:Dots per inch|DPI]] or greater. Two types of hinting are available.<br />
<br />
====Byte-Code Interpreter (BCI)====<br />
Using normal hinting, TrueType hinting instructions in the font are interpreted by freetype's Byte-Code Interpreter. This works best for fonts with good hinting instructions.<br />
<br />
To enable normal hinting:<br />
<br />
{{bc|<nowiki><br />
<match target="font"><br />
<edit name="hinting" mode="assign"><br />
<bool>true</bool><br />
</edit><br />
</match><br />
</nowiki>}}<br />
<br />
====Autohinter====<br />
Auto-discovery for hinting. This looks worse than normal hinting for fonts with good instructions, but better for those with poor or no instructions. The autohinter and subpixel rendering are not designed to work together and should not be used in combination.<br />
<br />
To enable auto-hinting:<br />
<br />
{{bc|<nowiki><br />
<match target="font"><br />
<edit name="autohint" mode="assign"><br />
<bool>true</bool><br />
</edit><br />
</match><br />
</nowiki>}}<br />
<br />
====Hint style====<br />
<br />
Hint style is the amount of influence the hinting mode has. Hinting can be set to: {{ic|hintfull}}, {{ic|hintmedium}}, {{ic|hintslight}} and {{ic|hintnone}}. With BCI hinting, hintfull should work best for most fonts. With the autohinter, hintslight is recommended.<br />
<br />
{{bc|<nowiki><br />
<match target="font"><br />
<edit name="hintstyle" mode="assign"><br />
<const>hintfull</const><br />
</edit><br />
</match><br />
</nowiki>}}<br />
<br />
Note: some applications, like [[Gnome|Gnome 3]] may [[#Troubleshooting|override default hinting settings]].<br />
<br />
===Subpixel rendering===<br />
<br />
Subpixel rendering effectively triples the horizontal (or vertical) resolution for fonts by making use of subpixels. The autohinter and subpixel rendering are not designed to work together and should not be used in combination without the [[#Infinality]] patch set.<br />
<br />
Most monitors manufactured today use the Red, Green, Blue (RGB) specification. Fontconfig will need to know your monitor type to be able to display your fonts correctly.<br />
<br />
''RGB (most common), BGR, V-RGB (vertical), or V-BGR''<br />
<br />
To enable subpixel rendering:<br />
<br />
{{bc|<nowiki><br />
<match target="font"><br />
<edit name="rgba" mode="assign"><br />
<const>rgb</const><br />
</edit><br />
</match><br />
</nowiki>}}<br />
<br />
If you notice unusual colors around font's borders, the wrong subpixel arrangement might be configured. The [http://www.lagom.nl/lcd-test/subpixel.php Lagom subpixel layout test] web page can help identify it.<br />
<br />
====LCD filter====<br />
<br />
When using subpixel rendering, you should enable the LCD filter, which is designed to reduce colour fringing. This is described under [http://www.freetype.org/freetype2/docs/reference/ft2-lcd_filtering.html LCD filtering] in the FreeType 2 API reference. Different options are described under [http://www.freetype.org/freetype2/docs/reference/ft2-lcd_filtering.html#FT_LcdFilter FT_LcdFilter], and are illustrated by this [http://www.spasche.net/files/lcdfiltering/ LCD filter test] page.<br />
<br />
The {{ic|lcddefault}} filter will work for most users. Other filters are available that can be used in special situations: {{ic|lcdlight}}; a lighter filter ideal for fonts that look too bold or fuzzy, {{ic|lcdlegacy}}, the original Cairo filter; and {{ic|lcdnone}} to disable it entirely.<br />
<br />
{{bc|<nowiki><br />
<match target="font"><br />
<edit mode="assign" name="lcdfilter"><br />
<const>lcddefault</const><br />
</edit><br />
</match><br />
</nowiki>}}<br />
<br />
====Advanced LCD filter specification====<br />
<br />
If the available, built-in LCD filters are not satisfactory, it is possible to tweak the font rendering very specifically by building a custom freetype2 package and modifying the hardcoded filters. The [[Arch Build System]] can be used to build and install packages from source.<br />
<br />
First, refresh the freetype2 PKGBUILD as root:<br />
<br />
# abs extra/freetype2<br />
<br />
This example uses {{ic|/var/abs/build}} as the build directory, substitute it according to your personal ABS setup. Download and extract the freetype2 package as a regular user:<br />
<br />
$ cd /var/abs/build<br />
$ cp -r ../extra/freetype2 .<br />
$ cd freetype2<br />
$ makepkg -o<br />
<br />
Edit the file {{ic|src/freetype-VERSION/src/base/ftlcdfil.c}} and look up the definition of the constant {{ic|default_filter[5]}}:<br />
<br />
static const FT_Byte default_filter[5] =<br />
{ 0x10, 0x40, 0x70, 0x40, 0x10 };<br />
<br />
This constant defines a low-pass filter applied to the rendered glyph. Modify it as needed. Save the file, build and install the custom package:<br />
<br />
$ makepkg -e<br />
$ sudo pacman -Rd freetype2<br />
$ sudo pacman -U freetype2-VERSION-ARCH.pkg.tar.xz<br />
<br />
Reboot or restart X. The lcddefault filter should now render fonts differently.<br />
<br />
===Disable auto-hinter for bold fonts===<br />
<br />
The auto-hinter uses sophisticated methods for font rendering, but often makes bold fonts too wide. Fortunately, a solution can be turning off the autohinter for bold fonts while leaving it on for the rest:<br />
...<br />
<match target="font"><br />
<test name="weight" compare="more"><br />
<const>medium</const><br />
</test><br />
<edit name="autohint" mode="assign"><br />
<bool>false</bool><br />
</edit><br />
</match><br />
...<br />
<br />
=== Enable anti-aliasing only for bigger fonts ===<br />
<br />
''See also [http://sharpfonts.co.cc/ sharpfonts.co.cc] for related information.''<br />
<br />
Some users prefer the sharper rendering that anti-aliasing does not offer:<br />
<br />
{{bc|<nowiki><br />
...<br />
<match target="font"><br />
<edit name="antialias" mode="assign"><br />
<bool>false</bool><br />
</edit><br />
</match><br />
<br />
<match target="font" ><br />
<test name="size" qual="any" compare="more"><br />
<double>12</double><br />
</test><br />
<edit name="antialias" mode="assign"><br />
<bool>true</bool><br />
</edit><br />
</match><br />
<br />
<match target="font" ><br />
<test name="pixelsize" qual="any" compare="more"><br />
<double>16</double><br />
</test><br />
<edit name="antialias" mode="assign"><br />
<bool>true</bool><br />
</edit><br />
</match><br />
...<br />
</nowiki>}}<br />
<br />
===Replace fonts===<br />
<br />
The most reliable way to do this is to add an XML fragment similar to the one below. ''Using the "binding" attribute will give you better results'', for example, in Firefox where you may not want to change properties of font being replaced. This will cause Ubuntu to be used in place of Georgia:<br />
...<br />
<match target="pattern"><br />
<test qual="any" name="family"><string>georgia</string></test><br />
<edit name="family" mode="assign" binding="same"><string>Ubuntu</string></edit><br />
</match><br />
...<br />
An alternate approach is to set the "preferred" font, but ''this only works if the original font is not on the system'', in which case the one specified will be substituted:<br />
...<br />
< !-- Replace Helvetica with Bitstream Vera Sans Mono --><br />
< !-- Note, an alias for Helvetica should already exist in default conf files --><br />
<alias><br />
<family>Helvetica</family><br />
<prefer><family>Bitstream Vera Sans Mono</family></prefer><br />
<default><family>fixed</family></default><br />
</alias><br />
...<br />
<br />
===Disable bitmap fonts===<br />
<br />
To disable bitmap fonts in fontconfig, use {{ic|70-no-bitmaps.conf}} (which is not placed by fontconfig by default):<br />
<br />
# cd /etc/fonts/conf.d<br />
# rm 70-yes-bitmaps.conf<br />
# ln -s ../conf.avail/70-no-bitmaps.conf<br />
<br />
You may not need to remove {{ic|70-yes-bitmaps.conf}} if it does not exist. You can choose which fonts to replace bitmaps fonts with (Helvetica, Courier and Times bitmap mapts to TTF fonts) by:<br />
<br />
# cd /etc/fonts/conf.d<br />
# ln -s ../conf.avail/29-replace-bitmap-fonts.conf<br />
<br />
<div id="EmbeddedBitmap">To disable embedded bitmap for all fonts:<div><br />
<br />
{{hc|~/.config/fontconfig/conf.d/20-no-embeded.conf|<nowiki><br />
<?xml version="1.0"?><br />
<!DOCTYPE fontconfig SYSTEM "fonts.dtd"><br />
<fontconfig><br />
<match target="font"><br />
<edit name="embeddedbitmap" mode="assign"><br />
<bool>false</bool><br />
</edit><br />
</match><br />
</fontconfig><br />
</nowiki>}}<br />
<br />
To disable embedded bitmap fonts for a specific font:<br />
<br />
<match target="font"><br />
<test qual="any" name="family"><br />
<string>Monaco</string><br />
</test><br />
<edit name="embeddedbitmap"><bool>false</bool></edit><br />
</match><br />
<br />
===Disable scaling of bitmap fonts===<br />
<br />
To disable scaling of bitmap fonts (which often makes them blurry), remove {{ic|/etc/fonts/conf.d/10-scale-bitmap-fonts.conf}}.<br />
<br />
===Create bold and italic styles for incomplete fonts===<br />
<br />
Freetype has the ability to automatically create ''italic'' and '''bold''' styles for fonts that do not have them, but only if explicitly required by the application. Given programs rarely send these requests, this section covers manually forcing generation of missing styles.<br />
<br />
Start by editing {{ic|/usr/share/fonts/fonts.cache-1}} as explained below. Store a copy of the modifications on another file, because a font update with {{ic|fc-cache}} will overwrite {{ic|/usr/share/fonts/fonts.cache-1}}.<br />
<br />
Assuming the Dupree font is installed:<br />
"dupree.ttf" 0 "Dupree:style=Regular:slant=0:weight=80:width=100:foundry=unknown:index=0:outline=True:''etc...''<br />
<br />
Duplicate the line, change {{ic|<nowiki>style=Regular</nowiki>}} to {{ic|<nowiki>style=Bold</nowiki>}} or any other style. Also change {{ic|<nowiki>slant=0</nowiki>}} to {{ic|<nowiki>slant=100</nowiki>}} for italic, {{ic|<nowiki>weight=80</nowiki>}} to {{ic|<nowiki>weight=200</nowiki>}} for bold, or combine them for '''''bold italic''''':<br />
"dupree.ttf" 0 "Dupree:style=Bold Italic:slant=100:weight=200:width=100:foundry=unknown:index=0:outline=True:''etc...''<br />
<br />
Now add necessary modifications to {{ic|$XDG_CONFIG_HOME/fontconfig/fonts.conf}}:<br />
{{bc|<nowiki><br />
...<br />
<match target="font"><br />
<test name="family" qual="any"><br />
<string>Dupree</string><br />
&lt;!-- other fonts here .... --&gt;<br />
</test><br />
<test name="weight" compare="more_eq"><int>140</int></test><br />
<edit name="embolden" mode="assign"><bool>true</bool></edit><br />
</match><br />
<br />
<match target="font"><br />
<test name="family" qual="any"><br />
<string>Dupree</string><br />
&lt;!-- other fonts here .... --&gt;<br />
</test><br />
<test name="slant" compare="more_eq"><int>80</int></test><br />
<edit name="matrix" mode="assign"><br />
<times><br />
<name>matrix</name><br />
<matrix><br />
<double>1</double><double>0.2</double><br />
<double>0</double><double>1</double><br />
</matrix><br />
</times><br />
</edit><br />
</match><br />
...<br />
</nowiki>}}<br />
{{Tip| Use the value 'embolden' for existing bold fonts in order to make them even bolder.}}<br />
<br />
===Change rule overriding===<br />
<br />
Fontconfig processes files in {{ic|/etc/fonts/conf.d}} in numerical order. This enables rules or files to override one another, but often confuses users about what file gets parsed last.<br />
<br />
To guarantee that personal settings take precedence over any other rules, change their ordering:<br />
# cd /etc/fonts/conf.d<br />
# mv 50-user.conf 99-user.conf<br />
<br />
This change seems however to be unnecessary for the most of the cases, because a user is given enough control by default to set up own font preferences, hinting and antialiasing properties, alias new fonts to generic font families, etc.<br />
<br />
===Example fontconfig configurations===<br />
<br />
Example fontconfig configurations can be found on this [[Font_Configuration/fontconfig_Examples|page]].<br />
<br />
A simple starting point:<br />
<br />
{{hc|/etc/fonts/local.conf|<nowiki><br />
<?xml version='1.0'?><br />
<!DOCTYPE fontconfig SYSTEM 'fonts.dtd'><br />
<fontconfig><br />
<match target="font"><br />
<br />
<edit mode="assign" name="rgba"><br />
<const>rgb</const><br />
</edit><br />
<br />
<edit mode="assign" name="hinting"><br />
<bool>true</bool><br />
</edit><br />
<br />
<edit mode="assign" name="hintstyle"><br />
<const>hintslight</const><br />
</edit><br />
<br />
<edit mode="assign" name="antialias"><br />
<bool>true</bool><br />
</edit><br />
<br />
<edit mode="assign" name="lcdfilter"><br />
<const>lcddefault</const><br />
</edit><br />
<br />
</match><br />
</fontconfig><br />
</nowiki>}}<br />
<br />
==Patched packages==<br />
<br />
These patched packages are available in the [[Arch User Repository|AUR]]. A few considerations:<br />
<br />
* Configuration is usually necessary.<br />
* The new font rendering will not kick in until applications restart.<br />
* Applications which [[Wikipedia:Static library|statically link]] to a library will not be affected by patches applied to the system library.<br />
<br />
===Infinality: the generic way===<br />
<br />
The infinality patchset aims to greatly improve freetype2 font rendering. It adds multiple new capabilities.<br />
<br />
*[http://www.infinality.net/blog/infinality-freetype-patches/ Home page].<br />
*[http://www.infinality.net/forum/ Forum].<br />
<br />
Infinality's settings are all configurable at runtime via environment variables in {{ic|/etc/profile.d/infinality-settings.sh}}, and include the following:<br />
<br />
*'''Emboldening Enhancement''': Disables Y emboldening, producing a much nicer result on fonts without bold versions. Works on native TT hinter and autohinter.<br />
*'''Auto-Autohint''': Automatically forces autohint on fonts that contain no TT instructions.<br />
*'''Autohint Enhancement''': Makes autohint snap horizontal stems to pixels. Gives a result that appears like a well-hinted truetype font, but is 100% patent-free (as far as I know).<br />
*'''Customized FIR Filter''': Select your own [http://www.infinality.net/forum/viewtopic.php?f=2&t=19 filter values] at run-time. Works on native TT hinter and autohinter.<br />
*'''Stem Alignment''': Aligns bitmap glyphs to optimized pixel boundaries. Works on native TT hinter and autohinter.<br />
*'''Pseudo Gamma Correction''': Lighten and darken glyphs at a given value, below a given size. Works on native TT hinter and autohinter.<br />
*'''Embolden Thin Fonts''': Embolden thin or light fonts so that they are more visible. Works on autohinter.<br />
*'''Force Slight Hinting''': Force slight hinting even when programs want full hinting. If you use the local.conf I provide (included in infinality-settings fedora package) you will notice nice improvements on @font-face fonts.<br />
*'''ChromeOS Style Sharpening''': ChromeOS uses a patch to sharpen the look of fonts. This is now included in the infinality patchset.<br />
<br />
A number of presets are included and can be used by setting the USE_STYLE variable in {{ic|/etc/profile.d/infinality-settings.sh}}.<br />
<br />
{{Note|1=The user bohoomil maintains a very good configuration in his [https://github.com/bohoomil/fontconf github repo] which is available as a [https://aur.archlinux.org/packages/fontconfig-infinality-ultimate/ package] in the AUR.}}<br />
<br />
{{Note|1=Install {{AUR|grip-git}} from AUR to have a realtime preview.}}<br />
<br />
{{AUR|freetype2-infinality}} can be installed from the [[Arch User Repository|AUR]]. Additionally, if you are using {{pkg|lib32-freetype2}} from [multilib], replace it with {{AUR|lib32-freetype2-infinality}} from the AUR. The AUR also contains a Git version of freetype2 that builds the latest development snapshot of freetype2 with the Infinality patchset: {{AUR|freetype2-git-infinality}}, {{AUR|lib32-freetype2-git-infinality}}.<br />
<br />
It is recommended to also install {{AUR|fontconfig-infinality}} to enable selection of predefined font substitution styles and antialiasing settings, apart from the rendering settings of the engine itself. After doing so, you can select the font style (win7, winxp, osx, linux, ...) with:<br />
# infctl setstyle<br />
<br />
If you set e.g. win7 or osx you need the corresponding fonts installed.<br />
<br />
{{Note|Default infinality settings can cause some programs to display fonts at 72 DPI instead of 96. If you notice a problem open /etc/fonts/infinality/infinality.conf search for the section on DPI and change 72 to 96. This problem can specifically affect conky causing the fonts to appear smaller than they should. Thus not aligning properly with images. }}<br />
<br />
{{Note|''The README for {{AUR|fontconfig-infinality}} says that /etc/fonts/local.conf should either not exist, or have no infinality-related configurations in it. The local.conf is now obsolete and completely replaced by this configuration.''}}<br />
<br />
for more information see this article: http://www.infinality.net/forum/viewtopic.php?f=2&t=77<br />
<br />
*[http://www.infinality.net/blog/infinality-freetype-patches/ Home page].<br />
<br />
===Infinality: the easy way===<br />
<br />
bohoomil also maintains '''infinality-bundle''' repository, offering three basic libraries (freetype2-infinality-ultimate, fontconfig-infinality-ultimate & cairo-infinality-ultimate) as pre-patched, pre-configured and pre-built binaries for all architectures (i686, x86_64, multilib). Using infinality-bundle makes the whole installation & configuration process dramatically simplified: all one has to do is install the three packages with<br />
<br />
{{bc|# pacman -S foo-infinality-ultimate}}<br />
<br />
which will replace the corresponding, generic Arch libraries (i.e. freetype2-infinality-ultimate will be used instead of freetype2, fontconfig-infinality-ultimate instead of fontconfig and fontconfig-infinality-ultimate from the AUR, and cairo-infinality-ultimate instead of the regular cairo). The libraries are fully compatible with the Arch packages and are meant to be used as drop-in replacements for them. No post installation/upgrade steps are required for most use scenarios: everything should work out of the box.<br />
<br />
To use the repository, add <br />
<br />
{{bc|1=[infinality-bundle]<br />
SigLevel = Never<br />
Server = http://bohoomil.cu.cc/infinality-bundle/$arch}}<br />
<br />
to your /etc/pacman.conf and issue<br />
<br />
{{bc|# pacman -Syy}}<br />
<br />
If you want to have access to multilib versions, add the following, too:<br />
<br />
{{bc|1=[infinality-bundle-multilib]<br />
SigLevel = Never<br />
Server = http://bohoomil.cu.cc/infinality-bundle-multilib/$arch}}<br />
<br />
In case of server down times, there is always a backup copy of the repository available via [https://www.dropbox.com/sh/ugmxbui00chidox/njDKnTG49W Dropbox].<br />
<br />
When installing some packages (like [https://www.archlinux.org/packages/?sort=&q=libgdiplus&maintainer=&flagged= libgdiplus]), you may encounter an error:<br />
<br />
{{bc|:: cairo and cairo-infinality-ultimate are in conflict. Remove cairo-infinality-ultimate? [y/N] n<br />
error: unresolvable package conflicts detected<br />
error: failed to prepare transaction (conflicting dependencies)}}<br />
<br />
If this happens, install the new package with {{bc|# pacman -Sd foo}} instead.<br />
<br />
For more information, see [http://bohoomil.github.io/ib.html infinality-bundle user notes].<br />
<br />
A support thread in the Forums is available [https://bbs.archlinux.org/viewtopic.php?id=162098 here].<br />
<br />
===Ubuntu===<br />
<br />
Ubuntu adds extra configurations, and occasionally patches to the font rendering libraries.<br />
<br />
Install the patched packages from the [[Arch User Repository|AUR]], the package names are: {{AUR|freetype2-ubuntu}} {{AUR|fontconfig-ubuntu}} {{AUR|cairo-ubuntu}}.<br />
<br />
The global configuration will need to be added. See [[#Example fontconfig configurations]] for a starting point.<br />
Ubuntu rendering works the best with ''hintslight'' option.<br />
<br />
===Reverting to unpatched packages===<br />
<br />
To restore the unpatched packages, reinstall the originals:<br />
<br />
# pacman -S --asdeps freetype2 cairo fontconfig<br />
<br />
==Applications without fontconfig support==<br />
<br />
Some applications like [[URxvt]] will ignore fontconfig settings. This is very apparent when using the infinality patches which are heavily reliant on proper configuration. You can work around this by using {{ic|~/.Xresources}}, but it is not nearly as flexible as fontconfig. Example (see [[#Fontconfig configuration]] for explanations of the options):<br />
<br />
{{hc|~/.Xresources|<nowiki><br />
Xft.autohint: 0<br />
Xft.lcdfilter: lcddefault<br />
Xft.hintstyle: hintfull<br />
Xft.hinting: 1<br />
Xft.antialias: 1<br />
Xft.rgba: rgb<br />
</nowiki>}}<br />
<br />
Make sure the settings are loaded properly when X starts with {{ic|xrdb -q}} (see [[Xresources]] for more information).<br />
<br />
==Troubleshooting==<br />
<br />
=== Distorted fonts ===<br />
<br />
{{Note|96 DPI is not a standard. You should use your monitor's actual DPI to get proper font rendering, especially when using subpixel rendering.}}<br />
<br />
If fonts are still unexpectedly large or small, poorly proportioned or simply rendering poorly, fontconfig may be using the incorrect DPI.<br />
<br />
Fontconfig should be able to detect DPI parameters as discovered by the Xorg server. You can check the automatically discovered DPI with {{ic|xdpyinfo}} (provided by the {{pkg|xorg-xdpyinfo}} package):<br />
<br />
{{hc|<nowiki>$ xdpyinfo | grep dots</nowiki>| resolution: 102x102 dots per inch}}<br />
<br />
If the DPI is detected incorrectly (usually due to an incorrect monitor EDID), you can specify it manually in the Xorg configuration, see [[Xorg#Display Size and DPI]]. This is the recommended solution, but it may not work with buggy drivers.<br />
<br />
Fontconfig will default to the Xft.dpi variable if it is set. Xft.dpi is usually set by desktop environments (usually to Xorg's DPI setting) or manually in {{ic|~/.Xdefaults}} or {{ic|~/.Xresources}}. Use xrdb to query for the value:<br />
<br />
{{hc|<nowiki>$ xrdb -query | grep dpi</nowiki>|Xft.dpi: 102}}<br />
<br />
Those still having problems can fall back to manually setting the DPI used by fontconfig:<br />
<br />
...<br />
<!-- Setup for DPI=96 --><br />
<match target="pattern"><br />
<edit name="dpi" mode="assign"><double>102</double></edit><br />
</match><br />
...<br />
<br />
===Calibri, Cambria, Monaco, etc. not rendering properly===<br />
<br />
Some scalable fonts have embedded bitmap versions which are rendered instead mainly at smaller sizes. Force using scalable fonts at all sizes by [[#EmbeddedBitmap|#Disabling embedded bitmap]].<br />
<br />
===Older GTK and QT applications===<br />
<br />
Modern GTK apps enable Xft by default but this was not the case before version 2.2. If it is not possible to update these applications, force Xft for old [[GNOME]] applications by adding to {{ic|~/.bashrc}}:<br />
<br />
export GDK_USE_XFT=1<br />
<br />
For older QT applications:<br />
<br />
export QT_XFT=true<br />
<br />
===Applications overriding hinting===<br />
Some applications may override default fontconfig hinting and anti-aliasing settings. This may happen with [[Gnome]] 3, for example. Use the specific configuration program for the application in such cases. For gnome, try {{pkg|gnome-tweak-tool}}.<br />
<br />
==See also==<br />
*[http://www.x.org/X11R6.8.2/doc/fonts.html Fonts in X11R6.8.2] - Official Xorg font information<br />
*[http://freetype.sourceforge.net/freetype2/ FreeType 2 Overview]<br />
*[https://forums.gentoo.org/viewtopic-t-723341.html Gentoo font-rendering thread]</div>Silencerhttps://wiki.archlinux.org/index.php?title=Font_configuration&diff=256590Font configuration2013-05-10T21:10:11Z<p>Silencer: /* Ubuntu */</p>
<hr />
<div>[[Category:Fonts]]<br />
[[it:Font Configuration]]<br />
[[ru:Font Configuration]]<br />
[[sr:Font Configuration]]<br />
[[tr:Yazıtipi_yapılandırması]]<br />
[[zh-CN:Font Configuration]]<br />
{{Article summary start}}<br />
{{Article summary text|An overview of font configuration options and various techniques for improving the readability of fonts}}<br />
{{Article summary heading|Related}}<br />
{{Article summary wiki|Fonts}}: Information on adding fonts and font recommendations<br />
{{Article summary wiki|Font Configuration/fontconfig Examples}}<br />
{{Article summary wiki|Java Runtime Environment Fonts}}: Fonts specific to Sun's Java machine<br />
{{Article summary wiki|MS Fonts}}: Adding Microsoft fonts and mimicking Windows' font settings<br />
{{Article summary wiki|X Logical Font Description}}: The older core font system for X<br />
{{Article summary end}}<br />
<br />
Fontconfig is a library designed to provide a list of available [[fonts]] to applications, and also for configuration for how fonts get rendered. See package {{Pkg|fontconfig}} and [[Wikipedia:Fontconfig]]. The Free type library ({{Pkg|freetype2}} package) renders the fonts, based on this configuration.<br />
<br />
Though Fontconfig is the standard in today's Linux, some applications still rely on the original method of font selection and display, the [[X Logical Font Description]].<br />
<br />
The font rendering packages on Arch Linux includes support for ''freetype2'' with the bytecode interpreter (BCI) enabled. Patched packages exist for better font rendering, especially with an LCD monitor. See [[#Patched packages]] below. The [[#Infinality]] package allows both auto-hinting and subpixel rendering, allows the LCD filter to be tweaked without recompiling, and allows the auto-hinter to work well with bold fonts.<br />
<br />
==Font paths==<br />
<br />
For fonts to be known to applications, they must be cataloged for easy and quick access.<br />
<br />
The font paths initially known to Fontconfig are: {{ic|/usr/share/fonts/}} and {{ic|~/.fonts/}} (of which Fontconfig will scan recursively). For ease of organization and installation, it is recommended to use these font paths when [[Fonts#Installation|adding fonts]].<br />
<br />
To see a list of known Fontconfig fonts:<br />
$ fc-list : file<br />
<br />
See {{ic|man fc-list}} for more out put format.<br />
<br />
Check for Xorg's known font paths by reviewing its log:<br />
$ grep /fonts /var/log/Xorg.0.log<br />
<br />
{{Tip|You can also check the list of [[Xorg]]'s known font paths using the command {{ic|xset q}}.}}<br />
<br />
Keep in mind that Xorg does not search recursively through the {{ic|/usr/share/fonts/}} directory like Fontconfig does. To add a path, the full path must be used:<br />
Section "Files"<br />
FontPath "/usr/share/fonts/local/"<br />
EndSection<br />
<br />
If you want font paths to be set on a per-user basis, you can add and remove font paths from the default by adding the following line(s) to {{ic|~/.xinitrc}}:<br />
xset +fp /usr/share/fonts/local/ # Prepend a custom font path to Xorg's list of known font paths<br />
xset -fp /usr/share/fonts/sucky_fonts/ # Remove the specified font path from Xorg's list of known font paths<br />
<br />
To see a list of known Xorg fonts use {{ic|xlsfonts}}, from the {{Pkg|xorg-xlsfonts}} package.<br />
<br />
==Fontconfig configuration==<br />
<br />
Fontconfig is documented in the [http://fontconfig.org/fontconfig-user.html fonts.conf] man page.<br />
<br />
Configuration can be done per-user through {{ic|$XDG_CONFIG_HOME/fontconfig/fonts.conf}}, and globally with {{ic|/etc/fonts/local.conf}}. The settings in the per-user configuration have precedence over the global configuration. Both these files use the same syntax.<br />
{{Note|Configuration files and directories: {{ic|~/.fonts.conf}}, {{ic|~/.fonts.conf.d}} and {{ic|~/.fontconfig/*.cache-*}} are deprecated since fontconfig 2.10.1 ([http://cgit.freedesktop.org/fontconfig/commit/?id&#61;8c255fb185d5651b57380b0a9443001e8051b29d upstream commit]) and will not be read by default in the future versions of package. Use instead {{ic|$XDG_CONFIG_HOME/fontconfig/fonts.conf}}, {{ic|$XDG_CONFIG_HOME/fontconfig/conf.d}} and {{ic|$XDG_CACHE_HOME/fontconfig/*.cache-*}} respectively. If you use the second directory, the file '''must''' follow the naming convention {{ic|NN-name.conf}} (where NN it's a two digit number like 00, 10, or 99).}}<br />
<br />
Fontconfig gathers all its configurations in a central file ({{ic|/etc/fonts/fonts.conf}}). This file is replaced during fontconfig updates and shouldn't be edited. Fontconfig-aware applications source this file to know available fonts and how they get rendered. This file is a conglomeration of rules from the global configuration ({{ic|/etc/fonts/local.conf}}), the configured presets in {{ic|/etc/fonts/conf.d/}}, and the user configuration file ({{ic|$XDG_CONFIG_HOME/fontconfig/fonts.conf}}).<br />
<br />
{{Note|For some desktop environments (such as [[GNOME]] and [[KDE]]) using the ''Font Control Panel'' will automatically create or overwrite the user font configuration file. For these desktop environments, it is best to match your already defined font configurations to get the expected behavior.}}<br />
<br />
Fontconfig configuration files use [[Wikipedia:XML|XML]] format and need these headers:<br />
<br />
{{bc|<nowiki><br />
<?xml version="1.0"?><br />
<!DOCTYPE fontconfig SYSTEM "fonts.dtd"><br />
<fontconfig><br />
<br />
<!-- settings go here --><br />
<br />
</fontconfig><br />
</nowiki>}}<br />
<br />
The configuration examples in this article omit these tags.<br />
<br />
===Presets===<br />
<br />
There are presets installed in the directory {{ic|/etc/fonts/conf.avail}}. They can be enabled by creating [[Wikipedia:Symbolic link|symbolic link]]s to them, both per-user and globally, as described in {{ic|/etc/fonts/conf.d/README}}. These presets will override matching settings in their respective configuration files.<br />
<br />
For example, to enable sub-pixel RGB rendering globally:<br />
<br />
# cd /etc/fonts/conf.d<br />
# ln -s ../conf.avail/10-sub-pixel-rgb.conf<br />
<br />
To do the same but instead for a per-user configuration:<br />
<br />
$ mkdir $XDG_CONFIG_HOME/fontconfig/conf.d<br />
$ ln -s /etc/fonts/conf.avail/10-sub-pixel-rgb.conf $XDG_CONFIG_HOME/fontconfig/conf.d<br />
<br />
===Anti-aliasing===<br />
<br />
[[Wikipedia:Font rasterization|Font rasterization]] converts vector font data to bitmap data so that it can be displayed. The result can appear jagged due to [[Wikipedia:Aliasing|aliasing]]. [[Wikipedia:Anti-aliasing|anti-aliasing]] is enabled by default and increases the apparent resolution of font edges.<br />
<br />
{{bc|<nowiki><br />
<match target="font"><br />
<edit name="antialias" mode="assign"><br />
<bool>true</bool><br />
</edit><br />
</match><br />
</nowiki>}}<br />
<br />
Note: some applications, like [[Gnome|Gnome 3]] may [[#Troubleshooting|override default anti-alias settings]].<br />
<br />
===Hinting===<br />
<br />
[[Wikipedia:Font hinting|Font hinting]] (also known as instructing) is the use of mathematical instructions to adjust the display of an outline font so that it lines up with a rasterized grid, such as the pixel grid in a display. Fonts will not line up correctly without hinting until displays have 300 [[Wikipedia:Dots per inch|DPI]] or greater. Two types of hinting are available.<br />
<br />
====Byte-Code Interpreter (BCI)====<br />
Using normal hinting, TrueType hinting instructions in the font are interpreted by freetype's Byte-Code Interpreter. This works best for fonts with good hinting instructions.<br />
<br />
To enable normal hinting:<br />
<br />
{{bc|<nowiki><br />
<match target="font"><br />
<edit name="hinting" mode="assign"><br />
<bool>true</bool><br />
</edit><br />
</match><br />
</nowiki>}}<br />
<br />
====Autohinter====<br />
Auto-discovery for hinting. This looks worse than normal hinting for fonts with good instructions, but better for those with poor or no instructions. The autohinter and subpixel rendering are not designed to work together and should not be used in combination.<br />
<br />
To enable auto-hinting:<br />
<br />
{{bc|<nowiki><br />
<match target="font"><br />
<edit name="autohint" mode="assign"><br />
<bool>true</bool><br />
</edit><br />
</match><br />
</nowiki>}}<br />
<br />
====Hint style====<br />
<br />
Hint style is the amount of influence the hinting mode has. Hinting can be set to: {{ic|hintfull}}, {{ic|hintmedium}}, {{ic|hintslight}} and {{ic|hintnone}}. With BCI hinting, hintfull should work best for most fonts. With the autohinter, hintslight is recommended.<br />
<br />
{{bc|<nowiki><br />
<match target="font"><br />
<edit name="hintstyle" mode="assign"><br />
<const>hintfull</const><br />
</edit><br />
</match><br />
</nowiki>}}<br />
<br />
Note: some applications, like [[Gnome|Gnome 3]] may [[#Troubleshooting|override default hinting settings]].<br />
<br />
===Subpixel rendering===<br />
<br />
Subpixel rendering effectively triples the horizontal (or vertical) resolution for fonts by making use of subpixels. The autohinter and subpixel rendering are not designed to work together and should not be used in combination without the [[#Infinality]] patch set.<br />
<br />
Most monitors manufactured today use the Red, Green, Blue (RGB) specification. Fontconfig will need to know your monitor type to be able to display your fonts correctly.<br />
<br />
''RGB (most common), BGR, V-RGB (vertical), or V-BGR''<br />
<br />
To enable subpixel rendering:<br />
<br />
{{bc|<nowiki><br />
<match target="font"><br />
<edit name="rgba" mode="assign"><br />
<const>rgb</const><br />
</edit><br />
</match><br />
</nowiki>}}<br />
<br />
If you notice unusual colors around font's borders, the wrong subpixel arrangement might be configured. The [http://www.lagom.nl/lcd-test/subpixel.php Lagom subpixel layout test] web page can help identify it.<br />
<br />
====LCD filter====<br />
<br />
When using subpixel rendering, you should enable the LCD filter, which is designed to reduce colour fringing. This is described under [http://www.freetype.org/freetype2/docs/reference/ft2-lcd_filtering.html LCD filtering] in the FreeType 2 API reference. Different options are described under [http://www.freetype.org/freetype2/docs/reference/ft2-lcd_filtering.html#FT_LcdFilter FT_LcdFilter], and are illustrated by this [http://www.spasche.net/files/lcdfiltering/ LCD filter test] page.<br />
<br />
The {{ic|lcddefault}} filter will work for most users. Other filters are available that can be used in special situations: {{ic|lcdlight}}; a lighter filter ideal for fonts that look too bold or fuzzy, {{ic|lcdlegacy}}, the original Cairo filter; and {{ic|lcdnone}} to disable it entirely.<br />
<br />
{{bc|<nowiki><br />
<match target="font"><br />
<edit mode="assign" name="lcdfilter"><br />
<const>lcddefault</const><br />
</edit><br />
</match><br />
</nowiki>}}<br />
<br />
====Advanced LCD filter specification====<br />
<br />
If the available, built-in LCD filters are not satisfactory, it is possible to tweak the font rendering very specifically by building a custom freetype2 package and modifying the hardcoded filters. The [[Arch Build System]] can be used to build and install packages from source.<br />
<br />
First, refresh the freetype2 PKGBUILD as root:<br />
<br />
# abs extra/freetype2<br />
<br />
This example uses {{ic|/var/abs/build}} as the build directory, substitute it according to your personal ABS setup. Download and extract the freetype2 package as a regular user:<br />
<br />
$ cd /var/abs/build<br />
$ cp -r ../extra/freetype2 .<br />
$ cd freetype2<br />
$ makepkg -o<br />
<br />
Edit the file {{ic|src/freetype-VERSION/src/base/ftlcdfil.c}} and look up the definition of the constant {{ic|default_filter[5]}}:<br />
<br />
static const FT_Byte default_filter[5] =<br />
{ 0x10, 0x40, 0x70, 0x40, 0x10 };<br />
<br />
This constant defines a low-pass filter applied to the rendered glyph. Modify it as needed. Save the file, build and install the custom package:<br />
<br />
$ makepkg -e<br />
$ sudo pacman -Rd freetype2<br />
$ sudo pacman -U freetype2-VERSION-ARCH.pkg.tar.xz<br />
<br />
Reboot or restart X. The lcddefault filter should now render fonts differently.<br />
<br />
===Disable auto-hinter for bold fonts===<br />
<br />
The auto-hinter uses sophisticated methods for font rendering, but often makes bold fonts too wide. Fortunately, a solution can be turning off the autohinter for bold fonts while leaving it on for the rest:<br />
...<br />
<match target="font"><br />
<test name="weight" compare="more"><br />
<const>medium</const><br />
</test><br />
<edit name="autohint" mode="assign"><br />
<bool>false</bool><br />
</edit><br />
</match><br />
...<br />
<br />
=== Enable anti-aliasing only for bigger fonts ===<br />
<br />
''See also [http://sharpfonts.co.cc/ sharpfonts.co.cc] for related information.''<br />
<br />
Some users prefer the sharper rendering that anti-aliasing does not offer:<br />
<br />
{{bc|<nowiki><br />
...<br />
<match target="font"><br />
<edit name="antialias" mode="assign"><br />
<bool>false</bool><br />
</edit><br />
</match><br />
<br />
<match target="font" ><br />
<test name="size" qual="any" compare="more"><br />
<double>12</double><br />
</test><br />
<edit name="antialias" mode="assign"><br />
<bool>true</bool><br />
</edit><br />
</match><br />
<br />
<match target="font" ><br />
<test name="pixelsize" qual="any" compare="more"><br />
<double>16</double><br />
</test><br />
<edit name="antialias" mode="assign"><br />
<bool>true</bool><br />
</edit><br />
</match><br />
...<br />
</nowiki>}}<br />
<br />
===Replace fonts===<br />
<br />
The most reliable way to do this is to add an XML fragment similar to the one below. ''Using the "binding" attribute will give you better results'', for example, in Firefox where you may not want to change properties of font being replaced. This will cause Ubuntu to be used in place of Georgia:<br />
...<br />
<match target="pattern"><br />
<test qual="any" name="family"><string>georgia</string></test><br />
<edit name="family" mode="assign" binding="same"><string>Ubuntu</string></edit><br />
</match><br />
...<br />
An alternate approach is to set the "preferred" font, but ''this only works if the original font is not on the system'', in which case the one specified will be substituted:<br />
...<br />
< !-- Replace Helvetica with Bitstream Vera Sans Mono --><br />
< !-- Note, an alias for Helvetica should already exist in default conf files --><br />
<alias><br />
<family>Helvetica</family><br />
<prefer><family>Bitstream Vera Sans Mono</family></prefer><br />
<default><family>fixed</family></default><br />
</alias><br />
...<br />
<br />
===Disable bitmap fonts===<br />
<br />
To disable bitmap fonts in fontconfig, use {{ic|70-no-bitmaps.conf}} (which is not placed by fontconfig by default):<br />
<br />
# cd /etc/fonts/conf.d<br />
# rm 70-yes-bitmaps.conf<br />
# ln -s ../conf.avail/70-no-bitmaps.conf<br />
<br />
You may not need to remove {{ic|70-yes-bitmaps.conf}} if it does not exist. You can choose which fonts to replace bitmaps fonts with (Helvetica, Courier and Times bitmap mapts to TTF fonts) by:<br />
<br />
# cd /etc/fonts/conf.d<br />
# ln -s ../conf.avail/29-replace-bitmap-fonts.conf<br />
<br />
<div id="EmbeddedBitmap">To disable embedded bitmap for all fonts:<div><br />
<br />
{{hc|~/.config/fontconfig/conf.d/20-no-embeded.conf|<nowiki><br />
<?xml version="1.0"?><br />
<!DOCTYPE fontconfig SYSTEM "fonts.dtd"><br />
<fontconfig><br />
<match target="font"><br />
<edit name="embeddedbitmap" mode="assign"><br />
<bool>false</bool><br />
</edit><br />
</match><br />
</fontconfig><br />
</nowiki>}}<br />
<br />
To disable embedded bitmap fonts for a specific font:<br />
<br />
<match target="font"><br />
<test qual="any" name="family"><br />
<string>Monaco</string><br />
</test><br />
<edit name="embeddedbitmap"><bool>false</bool></edit><br />
</match><br />
<br />
===Disable scaling of bitmap fonts===<br />
<br />
To disable scaling of bitmap fonts (which often makes them blurry), remove {{ic|/etc/fonts/conf.d/10-scale-bitmap-fonts.conf}}.<br />
<br />
===Create bold and italic styles for incomplete fonts===<br />
<br />
Freetype has the ability to automatically create ''italic'' and '''bold''' styles for fonts that do not have them, but only if explicitly required by the application. Given programs rarely send these requests, this section covers manually forcing generation of missing styles.<br />
<br />
Start by editing {{ic|/usr/share/fonts/fonts.cache-1}} as explained below. Store a copy of the modifications on another file, because a font update with {{ic|fc-cache}} will overwrite {{ic|/usr/share/fonts/fonts.cache-1}}.<br />
<br />
Assuming the Dupree font is installed:<br />
"dupree.ttf" 0 "Dupree:style=Regular:slant=0:weight=80:width=100:foundry=unknown:index=0:outline=True:''etc...''<br />
<br />
Duplicate the line, change {{ic|<nowiki>style=Regular</nowiki>}} to {{ic|<nowiki>style=Bold</nowiki>}} or any other style. Also change {{ic|<nowiki>slant=0</nowiki>}} to {{ic|<nowiki>slant=100</nowiki>}} for italic, {{ic|<nowiki>weight=80</nowiki>}} to {{ic|<nowiki>weight=200</nowiki>}} for bold, or combine them for '''''bold italic''''':<br />
"dupree.ttf" 0 "Dupree:style=Bold Italic:slant=100:weight=200:width=100:foundry=unknown:index=0:outline=True:''etc...''<br />
<br />
Now add necessary modifications to {{ic|$XDG_CONFIG_HOME/fontconfig/fonts.conf}}:<br />
{{bc|<nowiki><br />
...<br />
<match target="font"><br />
<test name="family" qual="any"><br />
<string>Dupree</string><br />
&lt;!-- other fonts here .... --&gt;<br />
</test><br />
<test name="weight" compare="more_eq"><int>140</int></test><br />
<edit name="embolden" mode="assign"><bool>true</bool></edit><br />
</match><br />
<br />
<match target="font"><br />
<test name="family" qual="any"><br />
<string>Dupree</string><br />
&lt;!-- other fonts here .... --&gt;<br />
</test><br />
<test name="slant" compare="more_eq"><int>80</int></test><br />
<edit name="matrix" mode="assign"><br />
<times><br />
<name>matrix</name><br />
<matrix><br />
<double>1</double><double>0.2</double><br />
<double>0</double><double>1</double><br />
</matrix><br />
</times><br />
</edit><br />
</match><br />
...<br />
</nowiki>}}<br />
{{Tip| Use the value 'embolden' for existing bold fonts in order to make them even bolder.}}<br />
<br />
===Change rule overriding===<br />
<br />
Fontconfig processes files in {{ic|/etc/fonts/conf.d}} in numerical order. This enables rules or files to override one another, but often confuses users about what file gets parsed last.<br />
<br />
To guarantee that personal settings take precedence over any other rules, change their ordering:<br />
# cd /etc/fonts/conf.d<br />
# mv 50-user.conf 99-user.conf<br />
<br />
This change seems however to be unnecessary for the most of the cases, because a user is given enough control by default to set up own font preferences, hinting and antialiasing properties, alias new fonts to generic font families, etc.<br />
<br />
===Example fontconfig configurations===<br />
<br />
Example fontconfig configurations can be found on this [[Font_Configuration/fontconfig_Examples|page]].<br />
<br />
A simple starting point:<br />
<br />
{{hc|/etc/fonts/local.conf|<nowiki><br />
<?xml version='1.0'?><br />
<!DOCTYPE fontconfig SYSTEM 'fonts.dtd'><br />
<fontconfig><br />
<match target="font"><br />
<br />
<edit mode="assign" name="rgba"><br />
<const>rgb</const><br />
</edit><br />
<br />
<edit mode="assign" name="hinting"><br />
<bool>true</bool><br />
</edit><br />
<br />
<edit mode="assign" name="hintstyle"><br />
<const>hintslight</const><br />
</edit><br />
<br />
<edit mode="assign" name="antialias"><br />
<bool>true</bool><br />
</edit><br />
<br />
<edit mode="assign" name="lcdfilter"><br />
<const>lcddefault</const><br />
</edit><br />
<br />
</match><br />
</fontconfig><br />
</nowiki>}}<br />
<br />
==Patched packages==<br />
<br />
These patched packages are available in the [[Arch User Repository|AUR]]. A few considerations:<br />
<br />
* Configuration is usually necessary.<br />
* The new font rendering will not kick in until applications restart.<br />
* Applications which [[Wikipedia:Static library|statically link]] to a library will not be affected by patches applied to the system library.<br />
<br />
===Infinality: the generic way===<br />
<br />
The infinality patchset aims to greatly improve freetype2 font rendering. It adds multiple new capabilities.<br />
<br />
*[http://www.infinality.net/blog/infinality-freetype-patches/ Home page].<br />
*[http://www.infinality.net/forum/ Forum].<br />
<br />
Infinality's settings are all configurable at runtime via environment variables in {{ic|/etc/profile.d/infinality-settings.sh}}, and include the following:<br />
<br />
*'''Emboldening Enhancement''': Disables Y emboldening, producing a much nicer result on fonts without bold versions. Works on native TT hinter and autohinter.<br />
*'''Auto-Autohint''': Automatically forces autohint on fonts that contain no TT instructions.<br />
*'''Autohint Enhancement''': Makes autohint snap horizontal stems to pixels. Gives a result that appears like a well-hinted truetype font, but is 100% patent-free (as far as I know).<br />
*'''Customized FIR Filter''': Select your own [http://www.infinality.net/forum/viewtopic.php?f=2&t=19 filter values] at run-time. Works on native TT hinter and autohinter.<br />
*'''Stem Alignment''': Aligns bitmap glyphs to optimized pixel boundaries. Works on native TT hinter and autohinter.<br />
*'''Pseudo Gamma Correction''': Lighten and darken glyphs at a given value, below a given size. Works on native TT hinter and autohinter.<br />
*'''Embolden Thin Fonts''': Embolden thin or light fonts so that they are more visible. Works on autohinter.<br />
*'''Force Slight Hinting''': Force slight hinting even when programs want full hinting. If you use the local.conf I provide (included in infinality-settings fedora package) you will notice nice improvements on @font-face fonts.<br />
*'''ChromeOS Style Sharpening''': ChromeOS uses a patch to sharpen the look of fonts. This is now included in the infinality patchset.<br />
<br />
A number of presets are included and can be used by setting the USE_STYLE variable in {{ic|/etc/profile.d/infinality-settings.sh}}.<br />
<br />
{{Note|1=The user bohoomil maintains a very good configuration in his [https://github.com/bohoomil/fontconf github repo] which is available as a [https://aur.archlinux.org/packages/fontconfig-infinality-ultimate/ package] in the AUR.}}<br />
<br />
{{Note|1=Install {{AUR|grip-git}} from AUR to have a realtime preview.}}<br />
<br />
{{AUR|freetype2-infinality}} can be installed from the [[Arch User Repository|AUR]]. Additionally, if you are using {{pkg|lib32-freetype2}} from [multilib], replace it with {{AUR|lib32-freetype2-infinality}} from the AUR. The AUR also contains a Git version of freetype2 that builds the latest development snapshot of freetype2 with the Infinality patchset: {{AUR|freetype2-git-infinality}}, {{AUR|lib32-freetype2-git-infinality}}.<br />
<br />
It is recommended to also install {{AUR|fontconfig-infinality}} to enable selection of predefined font substitution styles and antialiasing settings, apart from the rendering settings of the engine itself. After doing so, you can select the font style (win7, winxp, osx, linux, ...) with:<br />
# infctl setstyle<br />
<br />
If you set e.g. win7 or osx you need the corresponding fonts installed.<br />
<br />
{{Note|Default infinality settings can cause some programs to display fonts at 72 DPI instead of 96. If you notice a problem open /etc/fonts/infinality/infinality.conf search for the section on DPI and change 72 to 96. This problem can specifically affect conky causing the fonts to appear smaller than they should. Thus not aligning properly with images. }}<br />
<br />
{{Note|''The README for {{AUR|fontconfig-infinality}} says that /etc/fonts/local.conf should either not exist, or have no infinality-related configurations in it. The local.conf is now obsolete and completely replaced by this configuration.''}}<br />
<br />
for more information see this article: http://www.infinality.net/forum/viewtopic.php?f=2&t=77<br />
<br />
*[http://www.infinality.net/blog/infinality-freetype-patches/ Home page].<br />
<br />
===Infinality: the easy way===<br />
<br />
bohoomil also maintains '''infinality-bundle''' repository, offering three basic libraries (freetype2-infinality-ultimate, fontconfig-infinality-ultimate & cairo-infinality-ultimate) as pre-patched, pre-configured and pre-built binaries for all architectures (i686, x86_64, multilib). Using infinality-bundle makes the whole installation & configuration process dramatically simplified: all one has to do is install the three packages with<br />
<br />
{{bc|# pacman -S foo-infinality-ultimate}}<br />
<br />
which will replace the corresponding, generic Arch libraries (i.e. freetype2-infinality-ultimate will be used instead of freetype2, fontconfig-infinality-ultimate instead of fontconfig and fontconfig-infinality-ultimate from the AUR, and cairo-infinality-ultimate instead of the regular cairo). The libraries are fully compatible with the Arch packages and are meant to be used as drop-in replacements for them. No post installation/upgrade steps are required for most use scenarios: everything should work out of the box.<br />
<br />
To use the repository, add <br />
<br />
{{bc|1=[infinality-bundle]<br />
SigLevel = Never<br />
Server = http://bohoomil.cu.cc/infinality-bundle/$arch}}<br />
<br />
to your /etc/pacman.conf and issue<br />
<br />
{{bc|# pacman -Syy}}<br />
<br />
If you want to have access to multilib versions, add the following, too:<br />
<br />
{{bc|1=[infinality-bundle-multilib]<br />
SigLevel = Never<br />
Server = http://bohoomil.cu.cc/infinality-bundle-multilib/$arch}}<br />
<br />
In case of server down times, there is always a backup copy of the repository available via [https://www.dropbox.com/sh/ugmxbui00chidox/njDKnTG49W Dropbox].<br />
<br />
When installing some packages (like [https://www.archlinux.org/packages/?sort=&q=libgdiplus&maintainer=&flagged= libgdiplus]), you may encounter an error:<br />
<br />
{{bc|:: cairo and cairo-infinality-ultimate are in conflict. Remove cairo-infinality-ultimate? [y/N] n<br />
error: unresolvable package conflicts detected<br />
error: failed to prepare transaction (conflicting dependencies)}}<br />
<br />
If this happens, install the new package with {{bc|# pacman -Sd foo}} instead.<br />
<br />
For more information, see [http://bohoomil.github.io/ib.html infinality-bundle user notes].<br />
<br />
A support thread in the Forums is available [https://bbs.archlinux.org/viewtopic.php?id=162098 here].<br />
<br />
===Ubuntu===<br />
<br />
Ubuntu adds extra configurations, and occasionally patches to the font rendering libraries.<br />
<br />
Install the patched packages from the [[Arch User Repository|AUR]], the package names are: {{AUR|freetype2-ubuntu}} {{AUR|fontconfig-ubuntu}} {{AUR|cairo-ubuntu}}.<br />
<br />
The global configuration will need to be added. See [[#Example fontconfig configurations]] for a starting point.<br />
Ubuntu rendering works the best with ''hintslight'' option.<br />
<br />
===Reverting to unpatched packages===<br />
<br />
To restore the unpatched packages, reinstall the originals:<br />
<br />
# pacman -S --asdeps freetype2 cairo fontconfig<br />
<br />
==Applications without fontconfig support==<br />
<br />
Some applications like [[URxvt]] will ignore fontconfig settings. This is very apparent when using the infinality patches which are heavily reliant on proper configuration. You can work around this by using {{ic|~/.Xresources}}, but it is not nearly as flexible as fontconfig. Example (see [[#Fontconfig configuration]] for explanations of the options):<br />
<br />
{{hc|~/.Xresources|<nowiki><br />
Xft.autohint: 0<br />
Xft.lcdfilter: lcddefault<br />
Xft.hintstyle: hintfull<br />
Xft.hinting: 1<br />
Xft.antialias: 1<br />
Xft.rgba: rgb<br />
</nowiki>}}<br />
<br />
Make sure the settings are loaded properly when X starts with {{ic|xrdb -q}} (see [[Xresources]] for more information).<br />
<br />
==Troubleshooting==<br />
<br />
=== Distorted fonts ===<br />
<br />
{{Note|96 DPI is not a standard. You should use your monitor's actual DPI to get proper font rendering, especially when using subpixel rendering.}}<br />
<br />
If fonts are still unexpectedly large or small, poorly proportioned or simply rendering poorly, fontconfig may be using the incorrect DPI.<br />
<br />
Fontconfig should be able to detect DPI parameters as discovered by the Xorg server. You can check the automatically discovered DPI with {{ic|xdpyinfo}} (provided by the {{pkg|xorg-xdpyinfo}} package):<br />
<br />
{{hc|<nowiki>$ xdpyinfo | grep dots</nowiki>| resolution: 102x102 dots per inch}}<br />
<br />
If the DPI is detected incorrectly (usually due to an incorrect monitor EDID), you can specify it manually in the Xorg configuration, see [[Xorg#Display Size and DPI]]. This is the recommended solution, but it may not work with buggy drivers.<br />
<br />
Fontconfig will default to the Xft.dpi variable if it is set. Xft.dpi is usually set by desktop environments (usually to Xorg's DPI setting) or manually in {{ic|~/.Xdefaults}} or {{ic|~/.Xresources}}. Use xrdb to query for the value:<br />
<br />
{{hc|<nowiki>$ xrdb -query | grep dpi</nowiki>|Xft.dpi: 102}}<br />
<br />
Those still having problems can fall back to manually setting the DPI used by fontconfig:<br />
<br />
...<br />
<!-- Setup for DPI=96 --><br />
<match target="pattern"><br />
<edit name="dpi" mode="assign"><double>102</double></edit><br />
</match><br />
...<br />
<br />
===Calibri, Cambria, Monaco, etc. not rendering properly at some sizes===<br />
<br />
Some scalable fonts have embedded bitmap versions which are rendered instead mainly at smaller sizes. Force using scalable fonts at all sizes by [[#EmbeddedBitmap|#Disabling embedded bitmap]].<br />
<br />
===Older GTK and QT applications===<br />
<br />
Modern GTK apps enable Xft by default but this was not the case before version 2.2. If it is not possible to update these applications, force Xft for old [[GNOME]] applications by adding to {{ic|~/.bashrc}}:<br />
<br />
export GDK_USE_XFT=1<br />
<br />
For older QT applications:<br />
<br />
export QT_XFT=true<br />
<br />
===Applications overriding hinting===<br />
Some applications may override default fontconfig hinting and anti-aliasing settings. This may happen with [[Gnome]] 3, for example. Use the specific configuration program for the application in such cases. For gnome, try {{pkg|gnome-tweak-tool}}.<br />
<br />
==See also==<br />
*[http://www.x.org/X11R6.8.2/doc/fonts.html Fonts in X11R6.8.2] - Official Xorg font information<br />
*[http://freetype.sourceforge.net/freetype2/ FreeType 2 Overview]<br />
*[https://forums.gentoo.org/viewtopic-t-723341.html Gentoo font-rendering thread]</div>Silencerhttps://wiki.archlinux.org/index.php?title=Font_configuration&diff=256589Font configuration2013-05-10T21:06:47Z<p>Silencer: /* Troubleshooting */</p>
<hr />
<div>[[Category:Fonts]]<br />
[[it:Font Configuration]]<br />
[[ru:Font Configuration]]<br />
[[sr:Font Configuration]]<br />
[[tr:Yazıtipi_yapılandırması]]<br />
[[zh-CN:Font Configuration]]<br />
{{Article summary start}}<br />
{{Article summary text|An overview of font configuration options and various techniques for improving the readability of fonts}}<br />
{{Article summary heading|Related}}<br />
{{Article summary wiki|Fonts}}: Information on adding fonts and font recommendations<br />
{{Article summary wiki|Font Configuration/fontconfig Examples}}<br />
{{Article summary wiki|Java Runtime Environment Fonts}}: Fonts specific to Sun's Java machine<br />
{{Article summary wiki|MS Fonts}}: Adding Microsoft fonts and mimicking Windows' font settings<br />
{{Article summary wiki|X Logical Font Description}}: The older core font system for X<br />
{{Article summary end}}<br />
<br />
Fontconfig is a library designed to provide a list of available [[fonts]] to applications, and also for configuration for how fonts get rendered. See package {{Pkg|fontconfig}} and [[Wikipedia:Fontconfig]]. The Free type library ({{Pkg|freetype2}} package) renders the fonts, based on this configuration.<br />
<br />
Though Fontconfig is the standard in today's Linux, some applications still rely on the original method of font selection and display, the [[X Logical Font Description]].<br />
<br />
The font rendering packages on Arch Linux includes support for ''freetype2'' with the bytecode interpreter (BCI) enabled. Patched packages exist for better font rendering, especially with an LCD monitor. See [[#Patched packages]] below. The [[#Infinality]] package allows both auto-hinting and subpixel rendering, allows the LCD filter to be tweaked without recompiling, and allows the auto-hinter to work well with bold fonts.<br />
<br />
==Font paths==<br />
<br />
For fonts to be known to applications, they must be cataloged for easy and quick access.<br />
<br />
The font paths initially known to Fontconfig are: {{ic|/usr/share/fonts/}} and {{ic|~/.fonts/}} (of which Fontconfig will scan recursively). For ease of organization and installation, it is recommended to use these font paths when [[Fonts#Installation|adding fonts]].<br />
<br />
To see a list of known Fontconfig fonts:<br />
$ fc-list : file<br />
<br />
See {{ic|man fc-list}} for more out put format.<br />
<br />
Check for Xorg's known font paths by reviewing its log:<br />
$ grep /fonts /var/log/Xorg.0.log<br />
<br />
{{Tip|You can also check the list of [[Xorg]]'s known font paths using the command {{ic|xset q}}.}}<br />
<br />
Keep in mind that Xorg does not search recursively through the {{ic|/usr/share/fonts/}} directory like Fontconfig does. To add a path, the full path must be used:<br />
Section "Files"<br />
FontPath "/usr/share/fonts/local/"<br />
EndSection<br />
<br />
If you want font paths to be set on a per-user basis, you can add and remove font paths from the default by adding the following line(s) to {{ic|~/.xinitrc}}:<br />
xset +fp /usr/share/fonts/local/ # Prepend a custom font path to Xorg's list of known font paths<br />
xset -fp /usr/share/fonts/sucky_fonts/ # Remove the specified font path from Xorg's list of known font paths<br />
<br />
To see a list of known Xorg fonts use {{ic|xlsfonts}}, from the {{Pkg|xorg-xlsfonts}} package.<br />
<br />
==Fontconfig configuration==<br />
<br />
Fontconfig is documented in the [http://fontconfig.org/fontconfig-user.html fonts.conf] man page.<br />
<br />
Configuration can be done per-user through {{ic|$XDG_CONFIG_HOME/fontconfig/fonts.conf}}, and globally with {{ic|/etc/fonts/local.conf}}. The settings in the per-user configuration have precedence over the global configuration. Both these files use the same syntax.<br />
{{Note|Configuration files and directories: {{ic|~/.fonts.conf}}, {{ic|~/.fonts.conf.d}} and {{ic|~/.fontconfig/*.cache-*}} are deprecated since fontconfig 2.10.1 ([http://cgit.freedesktop.org/fontconfig/commit/?id&#61;8c255fb185d5651b57380b0a9443001e8051b29d upstream commit]) and will not be read by default in the future versions of package. Use instead {{ic|$XDG_CONFIG_HOME/fontconfig/fonts.conf}}, {{ic|$XDG_CONFIG_HOME/fontconfig/conf.d}} and {{ic|$XDG_CACHE_HOME/fontconfig/*.cache-*}} respectively. If you use the second directory, the file '''must''' follow the naming convention {{ic|NN-name.conf}} (where NN it's a two digit number like 00, 10, or 99).}}<br />
<br />
Fontconfig gathers all its configurations in a central file ({{ic|/etc/fonts/fonts.conf}}). This file is replaced during fontconfig updates and shouldn't be edited. Fontconfig-aware applications source this file to know available fonts and how they get rendered. This file is a conglomeration of rules from the global configuration ({{ic|/etc/fonts/local.conf}}), the configured presets in {{ic|/etc/fonts/conf.d/}}, and the user configuration file ({{ic|$XDG_CONFIG_HOME/fontconfig/fonts.conf}}).<br />
<br />
{{Note|For some desktop environments (such as [[GNOME]] and [[KDE]]) using the ''Font Control Panel'' will automatically create or overwrite the user font configuration file. For these desktop environments, it is best to match your already defined font configurations to get the expected behavior.}}<br />
<br />
Fontconfig configuration files use [[Wikipedia:XML|XML]] format and need these headers:<br />
<br />
{{bc|<nowiki><br />
<?xml version="1.0"?><br />
<!DOCTYPE fontconfig SYSTEM "fonts.dtd"><br />
<fontconfig><br />
<br />
<!-- settings go here --><br />
<br />
</fontconfig><br />
</nowiki>}}<br />
<br />
The configuration examples in this article omit these tags.<br />
<br />
===Presets===<br />
<br />
There are presets installed in the directory {{ic|/etc/fonts/conf.avail}}. They can be enabled by creating [[Wikipedia:Symbolic link|symbolic link]]s to them, both per-user and globally, as described in {{ic|/etc/fonts/conf.d/README}}. These presets will override matching settings in their respective configuration files.<br />
<br />
For example, to enable sub-pixel RGB rendering globally:<br />
<br />
# cd /etc/fonts/conf.d<br />
# ln -s ../conf.avail/10-sub-pixel-rgb.conf<br />
<br />
To do the same but instead for a per-user configuration:<br />
<br />
$ mkdir $XDG_CONFIG_HOME/fontconfig/conf.d<br />
$ ln -s /etc/fonts/conf.avail/10-sub-pixel-rgb.conf $XDG_CONFIG_HOME/fontconfig/conf.d<br />
<br />
===Anti-aliasing===<br />
<br />
[[Wikipedia:Font rasterization|Font rasterization]] converts vector font data to bitmap data so that it can be displayed. The result can appear jagged due to [[Wikipedia:Aliasing|aliasing]]. [[Wikipedia:Anti-aliasing|anti-aliasing]] is enabled by default and increases the apparent resolution of font edges.<br />
<br />
{{bc|<nowiki><br />
<match target="font"><br />
<edit name="antialias" mode="assign"><br />
<bool>true</bool><br />
</edit><br />
</match><br />
</nowiki>}}<br />
<br />
Note: some applications, like [[Gnome|Gnome 3]] may [[#Troubleshooting|override default anti-alias settings]].<br />
<br />
===Hinting===<br />
<br />
[[Wikipedia:Font hinting|Font hinting]] (also known as instructing) is the use of mathematical instructions to adjust the display of an outline font so that it lines up with a rasterized grid, such as the pixel grid in a display. Fonts will not line up correctly without hinting until displays have 300 [[Wikipedia:Dots per inch|DPI]] or greater. Two types of hinting are available.<br />
<br />
====Byte-Code Interpreter (BCI)====<br />
Using normal hinting, TrueType hinting instructions in the font are interpreted by freetype's Byte-Code Interpreter. This works best for fonts with good hinting instructions.<br />
<br />
To enable normal hinting:<br />
<br />
{{bc|<nowiki><br />
<match target="font"><br />
<edit name="hinting" mode="assign"><br />
<bool>true</bool><br />
</edit><br />
</match><br />
</nowiki>}}<br />
<br />
====Autohinter====<br />
Auto-discovery for hinting. This looks worse than normal hinting for fonts with good instructions, but better for those with poor or no instructions. The autohinter and subpixel rendering are not designed to work together and should not be used in combination.<br />
<br />
To enable auto-hinting:<br />
<br />
{{bc|<nowiki><br />
<match target="font"><br />
<edit name="autohint" mode="assign"><br />
<bool>true</bool><br />
</edit><br />
</match><br />
</nowiki>}}<br />
<br />
====Hint style====<br />
<br />
Hint style is the amount of influence the hinting mode has. Hinting can be set to: {{ic|hintfull}}, {{ic|hintmedium}}, {{ic|hintslight}} and {{ic|hintnone}}. With BCI hinting, hintfull should work best for most fonts. With the autohinter, hintslight is recommended.<br />
<br />
{{bc|<nowiki><br />
<match target="font"><br />
<edit name="hintstyle" mode="assign"><br />
<const>hintfull</const><br />
</edit><br />
</match><br />
</nowiki>}}<br />
<br />
Note: some applications, like [[Gnome|Gnome 3]] may [[#Troubleshooting|override default hinting settings]].<br />
<br />
===Subpixel rendering===<br />
<br />
Subpixel rendering effectively triples the horizontal (or vertical) resolution for fonts by making use of subpixels. The autohinter and subpixel rendering are not designed to work together and should not be used in combination without the [[#Infinality]] patch set.<br />
<br />
Most monitors manufactured today use the Red, Green, Blue (RGB) specification. Fontconfig will need to know your monitor type to be able to display your fonts correctly.<br />
<br />
''RGB (most common), BGR, V-RGB (vertical), or V-BGR''<br />
<br />
To enable subpixel rendering:<br />
<br />
{{bc|<nowiki><br />
<match target="font"><br />
<edit name="rgba" mode="assign"><br />
<const>rgb</const><br />
</edit><br />
</match><br />
</nowiki>}}<br />
<br />
If you notice unusual colors around font's borders, the wrong subpixel arrangement might be configured. The [http://www.lagom.nl/lcd-test/subpixel.php Lagom subpixel layout test] web page can help identify it.<br />
<br />
====LCD filter====<br />
<br />
When using subpixel rendering, you should enable the LCD filter, which is designed to reduce colour fringing. This is described under [http://www.freetype.org/freetype2/docs/reference/ft2-lcd_filtering.html LCD filtering] in the FreeType 2 API reference. Different options are described under [http://www.freetype.org/freetype2/docs/reference/ft2-lcd_filtering.html#FT_LcdFilter FT_LcdFilter], and are illustrated by this [http://www.spasche.net/files/lcdfiltering/ LCD filter test] page.<br />
<br />
The {{ic|lcddefault}} filter will work for most users. Other filters are available that can be used in special situations: {{ic|lcdlight}}; a lighter filter ideal for fonts that look too bold or fuzzy, {{ic|lcdlegacy}}, the original Cairo filter; and {{ic|lcdnone}} to disable it entirely.<br />
<br />
{{bc|<nowiki><br />
<match target="font"><br />
<edit mode="assign" name="lcdfilter"><br />
<const>lcddefault</const><br />
</edit><br />
</match><br />
</nowiki>}}<br />
<br />
====Advanced LCD filter specification====<br />
<br />
If the available, built-in LCD filters are not satisfactory, it is possible to tweak the font rendering very specifically by building a custom freetype2 package and modifying the hardcoded filters. The [[Arch Build System]] can be used to build and install packages from source.<br />
<br />
First, refresh the freetype2 PKGBUILD as root:<br />
<br />
# abs extra/freetype2<br />
<br />
This example uses {{ic|/var/abs/build}} as the build directory, substitute it according to your personal ABS setup. Download and extract the freetype2 package as a regular user:<br />
<br />
$ cd /var/abs/build<br />
$ cp -r ../extra/freetype2 .<br />
$ cd freetype2<br />
$ makepkg -o<br />
<br />
Edit the file {{ic|src/freetype-VERSION/src/base/ftlcdfil.c}} and look up the definition of the constant {{ic|default_filter[5]}}:<br />
<br />
static const FT_Byte default_filter[5] =<br />
{ 0x10, 0x40, 0x70, 0x40, 0x10 };<br />
<br />
This constant defines a low-pass filter applied to the rendered glyph. Modify it as needed. Save the file, build and install the custom package:<br />
<br />
$ makepkg -e<br />
$ sudo pacman -Rd freetype2<br />
$ sudo pacman -U freetype2-VERSION-ARCH.pkg.tar.xz<br />
<br />
Reboot or restart X. The lcddefault filter should now render fonts differently.<br />
<br />
===Disable auto-hinter for bold fonts===<br />
<br />
The auto-hinter uses sophisticated methods for font rendering, but often makes bold fonts too wide. Fortunately, a solution can be turning off the autohinter for bold fonts while leaving it on for the rest:<br />
...<br />
<match target="font"><br />
<test name="weight" compare="more"><br />
<const>medium</const><br />
</test><br />
<edit name="autohint" mode="assign"><br />
<bool>false</bool><br />
</edit><br />
</match><br />
...<br />
<br />
=== Enable anti-aliasing only for bigger fonts ===<br />
<br />
''See also [http://sharpfonts.co.cc/ sharpfonts.co.cc] for related information.''<br />
<br />
Some users prefer the sharper rendering that anti-aliasing does not offer:<br />
<br />
{{bc|<nowiki><br />
...<br />
<match target="font"><br />
<edit name="antialias" mode="assign"><br />
<bool>false</bool><br />
</edit><br />
</match><br />
<br />
<match target="font" ><br />
<test name="size" qual="any" compare="more"><br />
<double>12</double><br />
</test><br />
<edit name="antialias" mode="assign"><br />
<bool>true</bool><br />
</edit><br />
</match><br />
<br />
<match target="font" ><br />
<test name="pixelsize" qual="any" compare="more"><br />
<double>16</double><br />
</test><br />
<edit name="antialias" mode="assign"><br />
<bool>true</bool><br />
</edit><br />
</match><br />
...<br />
</nowiki>}}<br />
<br />
===Replace fonts===<br />
<br />
The most reliable way to do this is to add an XML fragment similar to the one below. ''Using the "binding" attribute will give you better results'', for example, in Firefox where you may not want to change properties of font being replaced. This will cause Ubuntu to be used in place of Georgia:<br />
...<br />
<match target="pattern"><br />
<test qual="any" name="family"><string>georgia</string></test><br />
<edit name="family" mode="assign" binding="same"><string>Ubuntu</string></edit><br />
</match><br />
...<br />
An alternate approach is to set the "preferred" font, but ''this only works if the original font is not on the system'', in which case the one specified will be substituted:<br />
...<br />
< !-- Replace Helvetica with Bitstream Vera Sans Mono --><br />
< !-- Note, an alias for Helvetica should already exist in default conf files --><br />
<alias><br />
<family>Helvetica</family><br />
<prefer><family>Bitstream Vera Sans Mono</family></prefer><br />
<default><family>fixed</family></default><br />
</alias><br />
...<br />
<br />
===Disable bitmap fonts===<br />
<br />
To disable bitmap fonts in fontconfig, use {{ic|70-no-bitmaps.conf}} (which is not placed by fontconfig by default):<br />
<br />
# cd /etc/fonts/conf.d<br />
# rm 70-yes-bitmaps.conf<br />
# ln -s ../conf.avail/70-no-bitmaps.conf<br />
<br />
You may not need to remove {{ic|70-yes-bitmaps.conf}} if it does not exist. You can choose which fonts to replace bitmaps fonts with (Helvetica, Courier and Times bitmap mapts to TTF fonts) by:<br />
<br />
# cd /etc/fonts/conf.d<br />
# ln -s ../conf.avail/29-replace-bitmap-fonts.conf<br />
<br />
<div id="EmbeddedBitmap">To disable embedded bitmap for all fonts:<div><br />
<br />
{{hc|~/.config/fontconfig/conf.d/20-no-embeded.conf|<nowiki><br />
<?xml version="1.0"?><br />
<!DOCTYPE fontconfig SYSTEM "fonts.dtd"><br />
<fontconfig><br />
<match target="font"><br />
<edit name="embeddedbitmap" mode="assign"><br />
<bool>false</bool><br />
</edit><br />
</match><br />
</fontconfig><br />
</nowiki>}}<br />
<br />
To disable embedded bitmap fonts for a specific font:<br />
<br />
<match target="font"><br />
<test qual="any" name="family"><br />
<string>Monaco</string><br />
</test><br />
<edit name="embeddedbitmap"><bool>false</bool></edit><br />
</match><br />
<br />
===Disable scaling of bitmap fonts===<br />
<br />
To disable scaling of bitmap fonts (which often makes them blurry), remove {{ic|/etc/fonts/conf.d/10-scale-bitmap-fonts.conf}}.<br />
<br />
===Create bold and italic styles for incomplete fonts===<br />
<br />
Freetype has the ability to automatically create ''italic'' and '''bold''' styles for fonts that do not have them, but only if explicitly required by the application. Given programs rarely send these requests, this section covers manually forcing generation of missing styles.<br />
<br />
Start by editing {{ic|/usr/share/fonts/fonts.cache-1}} as explained below. Store a copy of the modifications on another file, because a font update with {{ic|fc-cache}} will overwrite {{ic|/usr/share/fonts/fonts.cache-1}}.<br />
<br />
Assuming the Dupree font is installed:<br />
"dupree.ttf" 0 "Dupree:style=Regular:slant=0:weight=80:width=100:foundry=unknown:index=0:outline=True:''etc...''<br />
<br />
Duplicate the line, change {{ic|<nowiki>style=Regular</nowiki>}} to {{ic|<nowiki>style=Bold</nowiki>}} or any other style. Also change {{ic|<nowiki>slant=0</nowiki>}} to {{ic|<nowiki>slant=100</nowiki>}} for italic, {{ic|<nowiki>weight=80</nowiki>}} to {{ic|<nowiki>weight=200</nowiki>}} for bold, or combine them for '''''bold italic''''':<br />
"dupree.ttf" 0 "Dupree:style=Bold Italic:slant=100:weight=200:width=100:foundry=unknown:index=0:outline=True:''etc...''<br />
<br />
Now add necessary modifications to {{ic|$XDG_CONFIG_HOME/fontconfig/fonts.conf}}:<br />
{{bc|<nowiki><br />
...<br />
<match target="font"><br />
<test name="family" qual="any"><br />
<string>Dupree</string><br />
&lt;!-- other fonts here .... --&gt;<br />
</test><br />
<test name="weight" compare="more_eq"><int>140</int></test><br />
<edit name="embolden" mode="assign"><bool>true</bool></edit><br />
</match><br />
<br />
<match target="font"><br />
<test name="family" qual="any"><br />
<string>Dupree</string><br />
&lt;!-- other fonts here .... --&gt;<br />
</test><br />
<test name="slant" compare="more_eq"><int>80</int></test><br />
<edit name="matrix" mode="assign"><br />
<times><br />
<name>matrix</name><br />
<matrix><br />
<double>1</double><double>0.2</double><br />
<double>0</double><double>1</double><br />
</matrix><br />
</times><br />
</edit><br />
</match><br />
...<br />
</nowiki>}}<br />
{{Tip| Use the value 'embolden' for existing bold fonts in order to make them even bolder.}}<br />
<br />
===Change rule overriding===<br />
<br />
Fontconfig processes files in {{ic|/etc/fonts/conf.d}} in numerical order. This enables rules or files to override one another, but often confuses users about what file gets parsed last.<br />
<br />
To guarantee that personal settings take precedence over any other rules, change their ordering:<br />
# cd /etc/fonts/conf.d<br />
# mv 50-user.conf 99-user.conf<br />
<br />
This change seems however to be unnecessary for the most of the cases, because a user is given enough control by default to set up own font preferences, hinting and antialiasing properties, alias new fonts to generic font families, etc.<br />
<br />
===Example fontconfig configurations===<br />
<br />
Example fontconfig configurations can be found on this [[Font_Configuration/fontconfig_Examples|page]].<br />
<br />
A simple starting point:<br />
<br />
{{hc|/etc/fonts/local.conf|<nowiki><br />
<?xml version='1.0'?><br />
<!DOCTYPE fontconfig SYSTEM 'fonts.dtd'><br />
<fontconfig><br />
<match target="font"><br />
<br />
<edit mode="assign" name="rgba"><br />
<const>rgb</const><br />
</edit><br />
<br />
<edit mode="assign" name="hinting"><br />
<bool>true</bool><br />
</edit><br />
<br />
<edit mode="assign" name="hintstyle"><br />
<const>hintslight</const><br />
</edit><br />
<br />
<edit mode="assign" name="antialias"><br />
<bool>true</bool><br />
</edit><br />
<br />
<edit mode="assign" name="lcdfilter"><br />
<const>lcddefault</const><br />
</edit><br />
<br />
</match><br />
</fontconfig><br />
</nowiki>}}<br />
<br />
==Patched packages==<br />
<br />
These patched packages are available in the [[Arch User Repository|AUR]]. A few considerations:<br />
<br />
* Configuration is usually necessary.<br />
* The new font rendering will not kick in until applications restart.<br />
* Applications which [[Wikipedia:Static library|statically link]] to a library will not be affected by patches applied to the system library.<br />
<br />
===Infinality: the generic way===<br />
<br />
The infinality patchset aims to greatly improve freetype2 font rendering. It adds multiple new capabilities.<br />
<br />
*[http://www.infinality.net/blog/infinality-freetype-patches/ Home page].<br />
*[http://www.infinality.net/forum/ Forum].<br />
<br />
Infinality's settings are all configurable at runtime via environment variables in {{ic|/etc/profile.d/infinality-settings.sh}}, and include the following:<br />
<br />
*'''Emboldening Enhancement''': Disables Y emboldening, producing a much nicer result on fonts without bold versions. Works on native TT hinter and autohinter.<br />
*'''Auto-Autohint''': Automatically forces autohint on fonts that contain no TT instructions.<br />
*'''Autohint Enhancement''': Makes autohint snap horizontal stems to pixels. Gives a result that appears like a well-hinted truetype font, but is 100% patent-free (as far as I know).<br />
*'''Customized FIR Filter''': Select your own [http://www.infinality.net/forum/viewtopic.php?f=2&t=19 filter values] at run-time. Works on native TT hinter and autohinter.<br />
*'''Stem Alignment''': Aligns bitmap glyphs to optimized pixel boundaries. Works on native TT hinter and autohinter.<br />
*'''Pseudo Gamma Correction''': Lighten and darken glyphs at a given value, below a given size. Works on native TT hinter and autohinter.<br />
*'''Embolden Thin Fonts''': Embolden thin or light fonts so that they are more visible. Works on autohinter.<br />
*'''Force Slight Hinting''': Force slight hinting even when programs want full hinting. If you use the local.conf I provide (included in infinality-settings fedora package) you will notice nice improvements on @font-face fonts.<br />
*'''ChromeOS Style Sharpening''': ChromeOS uses a patch to sharpen the look of fonts. This is now included in the infinality patchset.<br />
<br />
A number of presets are included and can be used by setting the USE_STYLE variable in {{ic|/etc/profile.d/infinality-settings.sh}}.<br />
<br />
{{Note|1=The user bohoomil maintains a very good configuration in his [https://github.com/bohoomil/fontconf github repo] which is available as a [https://aur.archlinux.org/packages/fontconfig-infinality-ultimate/ package] in the AUR.}}<br />
<br />
{{Note|1=Install {{AUR|grip-git}} from AUR to have a realtime preview.}}<br />
<br />
{{AUR|freetype2-infinality}} can be installed from the [[Arch User Repository|AUR]]. Additionally, if you are using {{pkg|lib32-freetype2}} from [multilib], replace it with {{AUR|lib32-freetype2-infinality}} from the AUR. The AUR also contains a Git version of freetype2 that builds the latest development snapshot of freetype2 with the Infinality patchset: {{AUR|freetype2-git-infinality}}, {{AUR|lib32-freetype2-git-infinality}}.<br />
<br />
It is recommended to also install {{AUR|fontconfig-infinality}} to enable selection of predefined font substitution styles and antialiasing settings, apart from the rendering settings of the engine itself. After doing so, you can select the font style (win7, winxp, osx, linux, ...) with:<br />
# infctl setstyle<br />
<br />
If you set e.g. win7 or osx you need the corresponding fonts installed.<br />
<br />
{{Note|Default infinality settings can cause some programs to display fonts at 72 DPI instead of 96. If you notice a problem open /etc/fonts/infinality/infinality.conf search for the section on DPI and change 72 to 96. This problem can specifically affect conky causing the fonts to appear smaller than they should. Thus not aligning properly with images. }}<br />
<br />
{{Note|''The README for {{AUR|fontconfig-infinality}} says that /etc/fonts/local.conf should either not exist, or have no infinality-related configurations in it. The local.conf is now obsolete and completely replaced by this configuration.''}}<br />
<br />
for more information see this article: http://www.infinality.net/forum/viewtopic.php?f=2&t=77<br />
<br />
*[http://www.infinality.net/blog/infinality-freetype-patches/ Home page].<br />
<br />
===Infinality: the easy way===<br />
<br />
bohoomil also maintains '''infinality-bundle''' repository, offering three basic libraries (freetype2-infinality-ultimate, fontconfig-infinality-ultimate & cairo-infinality-ultimate) as pre-patched, pre-configured and pre-built binaries for all architectures (i686, x86_64, multilib). Using infinality-bundle makes the whole installation & configuration process dramatically simplified: all one has to do is install the three packages with<br />
<br />
{{bc|# pacman -S foo-infinality-ultimate}}<br />
<br />
which will replace the corresponding, generic Arch libraries (i.e. freetype2-infinality-ultimate will be used instead of freetype2, fontconfig-infinality-ultimate instead of fontconfig and fontconfig-infinality-ultimate from the AUR, and cairo-infinality-ultimate instead of the regular cairo). The libraries are fully compatible with the Arch packages and are meant to be used as drop-in replacements for them. No post installation/upgrade steps are required for most use scenarios: everything should work out of the box.<br />
<br />
To use the repository, add <br />
<br />
{{bc|1=[infinality-bundle]<br />
SigLevel = Never<br />
Server = http://bohoomil.cu.cc/infinality-bundle/$arch}}<br />
<br />
to your /etc/pacman.conf and issue<br />
<br />
{{bc|# pacman -Syy}}<br />
<br />
If you want to have access to multilib versions, add the following, too:<br />
<br />
{{bc|1=[infinality-bundle-multilib]<br />
SigLevel = Never<br />
Server = http://bohoomil.cu.cc/infinality-bundle-multilib/$arch}}<br />
<br />
In case of server down times, there is always a backup copy of the repository available via [https://www.dropbox.com/sh/ugmxbui00chidox/njDKnTG49W Dropbox].<br />
<br />
When installing some packages (like [https://www.archlinux.org/packages/?sort=&q=libgdiplus&maintainer=&flagged= libgdiplus]), you may encounter an error:<br />
<br />
{{bc|:: cairo and cairo-infinality-ultimate are in conflict. Remove cairo-infinality-ultimate? [y/N] n<br />
error: unresolvable package conflicts detected<br />
error: failed to prepare transaction (conflicting dependencies)}}<br />
<br />
If this happens, install the new package with {{bc|# pacman -Sd foo}} instead.<br />
<br />
For more information, see [http://bohoomil.github.io/ib.html infinality-bundle user notes].<br />
<br />
A support thread in the Forums is available [https://bbs.archlinux.org/viewtopic.php?id=162098 here].<br />
<br />
===Ubuntu===<br />
<br />
Ubuntu adds extra configurations, and occasionally patches to the font rendering libraries.<br />
<br />
Install the patched packages from the [[Arch User Repository|AUR]], the package names are: {{AUR|freetype2-ubuntu}} {{AUR|fontconfig-ubuntu}} {{AUR|cairo-ubuntu}}.<br />
<br />
The global configuration will need to be added. See [[#Example fontconfig configurations]] for a starting point.<br />
<br />
===Reverting to unpatched packages===<br />
<br />
To restore the unpatched packages, reinstall the originals:<br />
<br />
# pacman -S --asdeps freetype2 cairo fontconfig<br />
<br />
==Applications without fontconfig support==<br />
<br />
Some applications like [[URxvt]] will ignore fontconfig settings. This is very apparent when using the infinality patches which are heavily reliant on proper configuration. You can work around this by using {{ic|~/.Xresources}}, but it is not nearly as flexible as fontconfig. Example (see [[#Fontconfig configuration]] for explanations of the options):<br />
<br />
{{hc|~/.Xresources|<nowiki><br />
Xft.autohint: 0<br />
Xft.lcdfilter: lcddefault<br />
Xft.hintstyle: hintfull<br />
Xft.hinting: 1<br />
Xft.antialias: 1<br />
Xft.rgba: rgb<br />
</nowiki>}}<br />
<br />
Make sure the settings are loaded properly when X starts with {{ic|xrdb -q}} (see [[Xresources]] for more information).<br />
<br />
==Troubleshooting==<br />
<br />
=== Distorted fonts ===<br />
<br />
{{Note|96 DPI is not a standard. You should use your monitor's actual DPI to get proper font rendering, especially when using subpixel rendering.}}<br />
<br />
If fonts are still unexpectedly large or small, poorly proportioned or simply rendering poorly, fontconfig may be using the incorrect DPI.<br />
<br />
Fontconfig should be able to detect DPI parameters as discovered by the Xorg server. You can check the automatically discovered DPI with {{ic|xdpyinfo}} (provided by the {{pkg|xorg-xdpyinfo}} package):<br />
<br />
{{hc|<nowiki>$ xdpyinfo | grep dots</nowiki>| resolution: 102x102 dots per inch}}<br />
<br />
If the DPI is detected incorrectly (usually due to an incorrect monitor EDID), you can specify it manually in the Xorg configuration, see [[Xorg#Display Size and DPI]]. This is the recommended solution, but it may not work with buggy drivers.<br />
<br />
Fontconfig will default to the Xft.dpi variable if it is set. Xft.dpi is usually set by desktop environments (usually to Xorg's DPI setting) or manually in {{ic|~/.Xdefaults}} or {{ic|~/.Xresources}}. Use xrdb to query for the value:<br />
<br />
{{hc|<nowiki>$ xrdb -query | grep dpi</nowiki>|Xft.dpi: 102}}<br />
<br />
Those still having problems can fall back to manually setting the DPI used by fontconfig:<br />
<br />
...<br />
<!-- Setup for DPI=96 --><br />
<match target="pattern"><br />
<edit name="dpi" mode="assign"><double>102</double></edit><br />
</match><br />
...<br />
<br />
===Calibri, Cambria, Monaco, etc. not rendering properly at some sizes===<br />
<br />
Some scalable fonts have embedded bitmap versions which are rendered instead mainly at smaller sizes. Force using scalable fonts at all sizes by [[#EmbeddedBitmap|#Disabling embedded bitmap]].<br />
<br />
===Older GTK and QT applications===<br />
<br />
Modern GTK apps enable Xft by default but this was not the case before version 2.2. If it is not possible to update these applications, force Xft for old [[GNOME]] applications by adding to {{ic|~/.bashrc}}:<br />
<br />
export GDK_USE_XFT=1<br />
<br />
For older QT applications:<br />
<br />
export QT_XFT=true<br />
<br />
===Applications overriding hinting===<br />
Some applications may override default fontconfig hinting and anti-aliasing settings. This may happen with [[Gnome]] 3, for example. Use the specific configuration program for the application in such cases. For gnome, try {{pkg|gnome-tweak-tool}}.<br />
<br />
==See also==<br />
*[http://www.x.org/X11R6.8.2/doc/fonts.html Fonts in X11R6.8.2] - Official Xorg font information<br />
*[http://freetype.sourceforge.net/freetype2/ FreeType 2 Overview]<br />
*[https://forums.gentoo.org/viewtopic-t-723341.html Gentoo font-rendering thread]</div>Silencerhttps://wiki.archlinux.org/index.php?title=Font_configuration&diff=256588Font configuration2013-05-10T20:55:23Z<p>Silencer: /* Disable bitmap fonts */</p>
<hr />
<div>[[Category:Fonts]]<br />
[[it:Font Configuration]]<br />
[[ru:Font Configuration]]<br />
[[sr:Font Configuration]]<br />
[[tr:Yazıtipi_yapılandırması]]<br />
[[zh-CN:Font Configuration]]<br />
{{Article summary start}}<br />
{{Article summary text|An overview of font configuration options and various techniques for improving the readability of fonts}}<br />
{{Article summary heading|Related}}<br />
{{Article summary wiki|Fonts}}: Information on adding fonts and font recommendations<br />
{{Article summary wiki|Font Configuration/fontconfig Examples}}<br />
{{Article summary wiki|Java Runtime Environment Fonts}}: Fonts specific to Sun's Java machine<br />
{{Article summary wiki|MS Fonts}}: Adding Microsoft fonts and mimicking Windows' font settings<br />
{{Article summary wiki|X Logical Font Description}}: The older core font system for X<br />
{{Article summary end}}<br />
<br />
Fontconfig is a library designed to provide a list of available [[fonts]] to applications, and also for configuration for how fonts get rendered. See package {{Pkg|fontconfig}} and [[Wikipedia:Fontconfig]]. The Free type library ({{Pkg|freetype2}} package) renders the fonts, based on this configuration.<br />
<br />
Though Fontconfig is the standard in today's Linux, some applications still rely on the original method of font selection and display, the [[X Logical Font Description]].<br />
<br />
The font rendering packages on Arch Linux includes support for ''freetype2'' with the bytecode interpreter (BCI) enabled. Patched packages exist for better font rendering, especially with an LCD monitor. See [[#Patched packages]] below. The [[#Infinality]] package allows both auto-hinting and subpixel rendering, allows the LCD filter to be tweaked without recompiling, and allows the auto-hinter to work well with bold fonts.<br />
<br />
==Font paths==<br />
<br />
For fonts to be known to applications, they must be cataloged for easy and quick access.<br />
<br />
The font paths initially known to Fontconfig are: {{ic|/usr/share/fonts/}} and {{ic|~/.fonts/}} (of which Fontconfig will scan recursively). For ease of organization and installation, it is recommended to use these font paths when [[Fonts#Installation|adding fonts]].<br />
<br />
To see a list of known Fontconfig fonts:<br />
$ fc-list : file<br />
<br />
See {{ic|man fc-list}} for more out put format.<br />
<br />
Check for Xorg's known font paths by reviewing its log:<br />
$ grep /fonts /var/log/Xorg.0.log<br />
<br />
{{Tip|You can also check the list of [[Xorg]]'s known font paths using the command {{ic|xset q}}.}}<br />
<br />
Keep in mind that Xorg does not search recursively through the {{ic|/usr/share/fonts/}} directory like Fontconfig does. To add a path, the full path must be used:<br />
Section "Files"<br />
FontPath "/usr/share/fonts/local/"<br />
EndSection<br />
<br />
If you want font paths to be set on a per-user basis, you can add and remove font paths from the default by adding the following line(s) to {{ic|~/.xinitrc}}:<br />
xset +fp /usr/share/fonts/local/ # Prepend a custom font path to Xorg's list of known font paths<br />
xset -fp /usr/share/fonts/sucky_fonts/ # Remove the specified font path from Xorg's list of known font paths<br />
<br />
To see a list of known Xorg fonts use {{ic|xlsfonts}}, from the {{Pkg|xorg-xlsfonts}} package.<br />
<br />
==Fontconfig configuration==<br />
<br />
Fontconfig is documented in the [http://fontconfig.org/fontconfig-user.html fonts.conf] man page.<br />
<br />
Configuration can be done per-user through {{ic|$XDG_CONFIG_HOME/fontconfig/fonts.conf}}, and globally with {{ic|/etc/fonts/local.conf}}. The settings in the per-user configuration have precedence over the global configuration. Both these files use the same syntax.<br />
{{Note|Configuration files and directories: {{ic|~/.fonts.conf}}, {{ic|~/.fonts.conf.d}} and {{ic|~/.fontconfig/*.cache-*}} are deprecated since fontconfig 2.10.1 ([http://cgit.freedesktop.org/fontconfig/commit/?id&#61;8c255fb185d5651b57380b0a9443001e8051b29d upstream commit]) and will not be read by default in the future versions of package. Use instead {{ic|$XDG_CONFIG_HOME/fontconfig/fonts.conf}}, {{ic|$XDG_CONFIG_HOME/fontconfig/conf.d}} and {{ic|$XDG_CACHE_HOME/fontconfig/*.cache-*}} respectively. If you use the second directory, the file '''must''' follow the naming convention {{ic|NN-name.conf}} (where NN it's a two digit number like 00, 10, or 99).}}<br />
<br />
Fontconfig gathers all its configurations in a central file ({{ic|/etc/fonts/fonts.conf}}). This file is replaced during fontconfig updates and shouldn't be edited. Fontconfig-aware applications source this file to know available fonts and how they get rendered. This file is a conglomeration of rules from the global configuration ({{ic|/etc/fonts/local.conf}}), the configured presets in {{ic|/etc/fonts/conf.d/}}, and the user configuration file ({{ic|$XDG_CONFIG_HOME/fontconfig/fonts.conf}}).<br />
<br />
{{Note|For some desktop environments (such as [[GNOME]] and [[KDE]]) using the ''Font Control Panel'' will automatically create or overwrite the user font configuration file. For these desktop environments, it is best to match your already defined font configurations to get the expected behavior.}}<br />
<br />
Fontconfig configuration files use [[Wikipedia:XML|XML]] format and need these headers:<br />
<br />
{{bc|<nowiki><br />
<?xml version="1.0"?><br />
<!DOCTYPE fontconfig SYSTEM "fonts.dtd"><br />
<fontconfig><br />
<br />
<!-- settings go here --><br />
<br />
</fontconfig><br />
</nowiki>}}<br />
<br />
The configuration examples in this article omit these tags.<br />
<br />
===Presets===<br />
<br />
There are presets installed in the directory {{ic|/etc/fonts/conf.avail}}. They can be enabled by creating [[Wikipedia:Symbolic link|symbolic link]]s to them, both per-user and globally, as described in {{ic|/etc/fonts/conf.d/README}}. These presets will override matching settings in their respective configuration files.<br />
<br />
For example, to enable sub-pixel RGB rendering globally:<br />
<br />
# cd /etc/fonts/conf.d<br />
# ln -s ../conf.avail/10-sub-pixel-rgb.conf<br />
<br />
To do the same but instead for a per-user configuration:<br />
<br />
$ mkdir $XDG_CONFIG_HOME/fontconfig/conf.d<br />
$ ln -s /etc/fonts/conf.avail/10-sub-pixel-rgb.conf $XDG_CONFIG_HOME/fontconfig/conf.d<br />
<br />
===Anti-aliasing===<br />
<br />
[[Wikipedia:Font rasterization|Font rasterization]] converts vector font data to bitmap data so that it can be displayed. The result can appear jagged due to [[Wikipedia:Aliasing|aliasing]]. [[Wikipedia:Anti-aliasing|anti-aliasing]] is enabled by default and increases the apparent resolution of font edges.<br />
<br />
{{bc|<nowiki><br />
<match target="font"><br />
<edit name="antialias" mode="assign"><br />
<bool>true</bool><br />
</edit><br />
</match><br />
</nowiki>}}<br />
<br />
Note: some applications, like [[Gnome|Gnome 3]] may [[#Troubleshooting|override default anti-alias settings]].<br />
<br />
===Hinting===<br />
<br />
[[Wikipedia:Font hinting|Font hinting]] (also known as instructing) is the use of mathematical instructions to adjust the display of an outline font so that it lines up with a rasterized grid, such as the pixel grid in a display. Fonts will not line up correctly without hinting until displays have 300 [[Wikipedia:Dots per inch|DPI]] or greater. Two types of hinting are available.<br />
<br />
====Byte-Code Interpreter (BCI)====<br />
Using normal hinting, TrueType hinting instructions in the font are interpreted by freetype's Byte-Code Interpreter. This works best for fonts with good hinting instructions.<br />
<br />
To enable normal hinting:<br />
<br />
{{bc|<nowiki><br />
<match target="font"><br />
<edit name="hinting" mode="assign"><br />
<bool>true</bool><br />
</edit><br />
</match><br />
</nowiki>}}<br />
<br />
====Autohinter====<br />
Auto-discovery for hinting. This looks worse than normal hinting for fonts with good instructions, but better for those with poor or no instructions. The autohinter and subpixel rendering are not designed to work together and should not be used in combination.<br />
<br />
To enable auto-hinting:<br />
<br />
{{bc|<nowiki><br />
<match target="font"><br />
<edit name="autohint" mode="assign"><br />
<bool>true</bool><br />
</edit><br />
</match><br />
</nowiki>}}<br />
<br />
====Hint style====<br />
<br />
Hint style is the amount of influence the hinting mode has. Hinting can be set to: {{ic|hintfull}}, {{ic|hintmedium}}, {{ic|hintslight}} and {{ic|hintnone}}. With BCI hinting, hintfull should work best for most fonts. With the autohinter, hintslight is recommended.<br />
<br />
{{bc|<nowiki><br />
<match target="font"><br />
<edit name="hintstyle" mode="assign"><br />
<const>hintfull</const><br />
</edit><br />
</match><br />
</nowiki>}}<br />
<br />
Note: some applications, like [[Gnome|Gnome 3]] may [[#Troubleshooting|override default hinting settings]].<br />
<br />
===Subpixel rendering===<br />
<br />
Subpixel rendering effectively triples the horizontal (or vertical) resolution for fonts by making use of subpixels. The autohinter and subpixel rendering are not designed to work together and should not be used in combination without the [[#Infinality]] patch set.<br />
<br />
Most monitors manufactured today use the Red, Green, Blue (RGB) specification. Fontconfig will need to know your monitor type to be able to display your fonts correctly.<br />
<br />
''RGB (most common), BGR, V-RGB (vertical), or V-BGR''<br />
<br />
To enable subpixel rendering:<br />
<br />
{{bc|<nowiki><br />
<match target="font"><br />
<edit name="rgba" mode="assign"><br />
<const>rgb</const><br />
</edit><br />
</match><br />
</nowiki>}}<br />
<br />
If you notice unusual colors around font's borders, the wrong subpixel arrangement might be configured. The [http://www.lagom.nl/lcd-test/subpixel.php Lagom subpixel layout test] web page can help identify it.<br />
<br />
====LCD filter====<br />
<br />
When using subpixel rendering, you should enable the LCD filter, which is designed to reduce colour fringing. This is described under [http://www.freetype.org/freetype2/docs/reference/ft2-lcd_filtering.html LCD filtering] in the FreeType 2 API reference. Different options are described under [http://www.freetype.org/freetype2/docs/reference/ft2-lcd_filtering.html#FT_LcdFilter FT_LcdFilter], and are illustrated by this [http://www.spasche.net/files/lcdfiltering/ LCD filter test] page.<br />
<br />
The {{ic|lcddefault}} filter will work for most users. Other filters are available that can be used in special situations: {{ic|lcdlight}}; a lighter filter ideal for fonts that look too bold or fuzzy, {{ic|lcdlegacy}}, the original Cairo filter; and {{ic|lcdnone}} to disable it entirely.<br />
<br />
{{bc|<nowiki><br />
<match target="font"><br />
<edit mode="assign" name="lcdfilter"><br />
<const>lcddefault</const><br />
</edit><br />
</match><br />
</nowiki>}}<br />
<br />
====Advanced LCD filter specification====<br />
<br />
If the available, built-in LCD filters are not satisfactory, it is possible to tweak the font rendering very specifically by building a custom freetype2 package and modifying the hardcoded filters. The [[Arch Build System]] can be used to build and install packages from source.<br />
<br />
First, refresh the freetype2 PKGBUILD as root:<br />
<br />
# abs extra/freetype2<br />
<br />
This example uses {{ic|/var/abs/build}} as the build directory, substitute it according to your personal ABS setup. Download and extract the freetype2 package as a regular user:<br />
<br />
$ cd /var/abs/build<br />
$ cp -r ../extra/freetype2 .<br />
$ cd freetype2<br />
$ makepkg -o<br />
<br />
Edit the file {{ic|src/freetype-VERSION/src/base/ftlcdfil.c}} and look up the definition of the constant {{ic|default_filter[5]}}:<br />
<br />
static const FT_Byte default_filter[5] =<br />
{ 0x10, 0x40, 0x70, 0x40, 0x10 };<br />
<br />
This constant defines a low-pass filter applied to the rendered glyph. Modify it as needed. Save the file, build and install the custom package:<br />
<br />
$ makepkg -e<br />
$ sudo pacman -Rd freetype2<br />
$ sudo pacman -U freetype2-VERSION-ARCH.pkg.tar.xz<br />
<br />
Reboot or restart X. The lcddefault filter should now render fonts differently.<br />
<br />
===Disable auto-hinter for bold fonts===<br />
<br />
The auto-hinter uses sophisticated methods for font rendering, but often makes bold fonts too wide. Fortunately, a solution can be turning off the autohinter for bold fonts while leaving it on for the rest:<br />
...<br />
<match target="font"><br />
<test name="weight" compare="more"><br />
<const>medium</const><br />
</test><br />
<edit name="autohint" mode="assign"><br />
<bool>false</bool><br />
</edit><br />
</match><br />
...<br />
<br />
=== Enable anti-aliasing only for bigger fonts ===<br />
<br />
''See also [http://sharpfonts.co.cc/ sharpfonts.co.cc] for related information.''<br />
<br />
Some users prefer the sharper rendering that anti-aliasing does not offer:<br />
<br />
{{bc|<nowiki><br />
...<br />
<match target="font"><br />
<edit name="antialias" mode="assign"><br />
<bool>false</bool><br />
</edit><br />
</match><br />
<br />
<match target="font" ><br />
<test name="size" qual="any" compare="more"><br />
<double>12</double><br />
</test><br />
<edit name="antialias" mode="assign"><br />
<bool>true</bool><br />
</edit><br />
</match><br />
<br />
<match target="font" ><br />
<test name="pixelsize" qual="any" compare="more"><br />
<double>16</double><br />
</test><br />
<edit name="antialias" mode="assign"><br />
<bool>true</bool><br />
</edit><br />
</match><br />
...<br />
</nowiki>}}<br />
<br />
===Replace fonts===<br />
<br />
The most reliable way to do this is to add an XML fragment similar to the one below. ''Using the "binding" attribute will give you better results'', for example, in Firefox where you may not want to change properties of font being replaced. This will cause Ubuntu to be used in place of Georgia:<br />
...<br />
<match target="pattern"><br />
<test qual="any" name="family"><string>georgia</string></test><br />
<edit name="family" mode="assign" binding="same"><string>Ubuntu</string></edit><br />
</match><br />
...<br />
An alternate approach is to set the "preferred" font, but ''this only works if the original font is not on the system'', in which case the one specified will be substituted:<br />
...<br />
< !-- Replace Helvetica with Bitstream Vera Sans Mono --><br />
< !-- Note, an alias for Helvetica should already exist in default conf files --><br />
<alias><br />
<family>Helvetica</family><br />
<prefer><family>Bitstream Vera Sans Mono</family></prefer><br />
<default><family>fixed</family></default><br />
</alias><br />
...<br />
<br />
===Disable bitmap fonts===<br />
<br />
To disable bitmap fonts in fontconfig, use {{ic|70-no-bitmaps.conf}} (which is not placed by fontconfig by default):<br />
<br />
# cd /etc/fonts/conf.d<br />
# rm 70-yes-bitmaps.conf<br />
# ln -s ../conf.avail/70-no-bitmaps.conf<br />
<br />
You may not need to remove {{ic|70-yes-bitmaps.conf}} if it does not exist. You can choose which fonts to replace bitmaps fonts with (Helvetica, Courier and Times bitmap mapts to TTF fonts) by:<br />
<br />
# cd /etc/fonts/conf.d<br />
# ln -s ../conf.avail/29-replace-bitmap-fonts.conf<br />
<br />
<div id="EmbeddedBitmap">To disable embedded bitmap for all fonts:<div><br />
<br />
{{hc|~/.config/fontconfig/conf.d/20-no-embeded.conf|<nowiki><br />
<?xml version="1.0"?><br />
<!DOCTYPE fontconfig SYSTEM "fonts.dtd"><br />
<fontconfig><br />
<match target="font"><br />
<edit name="embeddedbitmap" mode="assign"><br />
<bool>false</bool><br />
</edit><br />
</match><br />
</fontconfig><br />
</nowiki>}}<br />
<br />
To disable embedded bitmap fonts for a specific font:<br />
<br />
<match target="font"><br />
<test qual="any" name="family"><br />
<string>Monaco</string><br />
</test><br />
<edit name="embeddedbitmap"><bool>false</bool></edit><br />
</match><br />
<br />
===Disable scaling of bitmap fonts===<br />
<br />
To disable scaling of bitmap fonts (which often makes them blurry), remove {{ic|/etc/fonts/conf.d/10-scale-bitmap-fonts.conf}}.<br />
<br />
===Create bold and italic styles for incomplete fonts===<br />
<br />
Freetype has the ability to automatically create ''italic'' and '''bold''' styles for fonts that do not have them, but only if explicitly required by the application. Given programs rarely send these requests, this section covers manually forcing generation of missing styles.<br />
<br />
Start by editing {{ic|/usr/share/fonts/fonts.cache-1}} as explained below. Store a copy of the modifications on another file, because a font update with {{ic|fc-cache}} will overwrite {{ic|/usr/share/fonts/fonts.cache-1}}.<br />
<br />
Assuming the Dupree font is installed:<br />
"dupree.ttf" 0 "Dupree:style=Regular:slant=0:weight=80:width=100:foundry=unknown:index=0:outline=True:''etc...''<br />
<br />
Duplicate the line, change {{ic|<nowiki>style=Regular</nowiki>}} to {{ic|<nowiki>style=Bold</nowiki>}} or any other style. Also change {{ic|<nowiki>slant=0</nowiki>}} to {{ic|<nowiki>slant=100</nowiki>}} for italic, {{ic|<nowiki>weight=80</nowiki>}} to {{ic|<nowiki>weight=200</nowiki>}} for bold, or combine them for '''''bold italic''''':<br />
"dupree.ttf" 0 "Dupree:style=Bold Italic:slant=100:weight=200:width=100:foundry=unknown:index=0:outline=True:''etc...''<br />
<br />
Now add necessary modifications to {{ic|$XDG_CONFIG_HOME/fontconfig/fonts.conf}}:<br />
{{bc|<nowiki><br />
...<br />
<match target="font"><br />
<test name="family" qual="any"><br />
<string>Dupree</string><br />
&lt;!-- other fonts here .... --&gt;<br />
</test><br />
<test name="weight" compare="more_eq"><int>140</int></test><br />
<edit name="embolden" mode="assign"><bool>true</bool></edit><br />
</match><br />
<br />
<match target="font"><br />
<test name="family" qual="any"><br />
<string>Dupree</string><br />
&lt;!-- other fonts here .... --&gt;<br />
</test><br />
<test name="slant" compare="more_eq"><int>80</int></test><br />
<edit name="matrix" mode="assign"><br />
<times><br />
<name>matrix</name><br />
<matrix><br />
<double>1</double><double>0.2</double><br />
<double>0</double><double>1</double><br />
</matrix><br />
</times><br />
</edit><br />
</match><br />
...<br />
</nowiki>}}<br />
{{Tip| Use the value 'embolden' for existing bold fonts in order to make them even bolder.}}<br />
<br />
===Change rule overriding===<br />
<br />
Fontconfig processes files in {{ic|/etc/fonts/conf.d}} in numerical order. This enables rules or files to override one another, but often confuses users about what file gets parsed last.<br />
<br />
To guarantee that personal settings take precedence over any other rules, change their ordering:<br />
# cd /etc/fonts/conf.d<br />
# mv 50-user.conf 99-user.conf<br />
<br />
This change seems however to be unnecessary for the most of the cases, because a user is given enough control by default to set up own font preferences, hinting and antialiasing properties, alias new fonts to generic font families, etc.<br />
<br />
===Example fontconfig configurations===<br />
<br />
Example fontconfig configurations can be found on this [[Font_Configuration/fontconfig_Examples|page]].<br />
<br />
A simple starting point:<br />
<br />
{{hc|/etc/fonts/local.conf|<nowiki><br />
<?xml version='1.0'?><br />
<!DOCTYPE fontconfig SYSTEM 'fonts.dtd'><br />
<fontconfig><br />
<match target="font"><br />
<br />
<edit mode="assign" name="rgba"><br />
<const>rgb</const><br />
</edit><br />
<br />
<edit mode="assign" name="hinting"><br />
<bool>true</bool><br />
</edit><br />
<br />
<edit mode="assign" name="hintstyle"><br />
<const>hintslight</const><br />
</edit><br />
<br />
<edit mode="assign" name="antialias"><br />
<bool>true</bool><br />
</edit><br />
<br />
<edit mode="assign" name="lcdfilter"><br />
<const>lcddefault</const><br />
</edit><br />
<br />
</match><br />
</fontconfig><br />
</nowiki>}}<br />
<br />
==Patched packages==<br />
<br />
These patched packages are available in the [[Arch User Repository|AUR]]. A few considerations:<br />
<br />
* Configuration is usually necessary.<br />
* The new font rendering will not kick in until applications restart.<br />
* Applications which [[Wikipedia:Static library|statically link]] to a library will not be affected by patches applied to the system library.<br />
<br />
===Infinality: the generic way===<br />
<br />
The infinality patchset aims to greatly improve freetype2 font rendering. It adds multiple new capabilities.<br />
<br />
*[http://www.infinality.net/blog/infinality-freetype-patches/ Home page].<br />
*[http://www.infinality.net/forum/ Forum].<br />
<br />
Infinality's settings are all configurable at runtime via environment variables in {{ic|/etc/profile.d/infinality-settings.sh}}, and include the following:<br />
<br />
*'''Emboldening Enhancement''': Disables Y emboldening, producing a much nicer result on fonts without bold versions. Works on native TT hinter and autohinter.<br />
*'''Auto-Autohint''': Automatically forces autohint on fonts that contain no TT instructions.<br />
*'''Autohint Enhancement''': Makes autohint snap horizontal stems to pixels. Gives a result that appears like a well-hinted truetype font, but is 100% patent-free (as far as I know).<br />
*'''Customized FIR Filter''': Select your own [http://www.infinality.net/forum/viewtopic.php?f=2&t=19 filter values] at run-time. Works on native TT hinter and autohinter.<br />
*'''Stem Alignment''': Aligns bitmap glyphs to optimized pixel boundaries. Works on native TT hinter and autohinter.<br />
*'''Pseudo Gamma Correction''': Lighten and darken glyphs at a given value, below a given size. Works on native TT hinter and autohinter.<br />
*'''Embolden Thin Fonts''': Embolden thin or light fonts so that they are more visible. Works on autohinter.<br />
*'''Force Slight Hinting''': Force slight hinting even when programs want full hinting. If you use the local.conf I provide (included in infinality-settings fedora package) you will notice nice improvements on @font-face fonts.<br />
*'''ChromeOS Style Sharpening''': ChromeOS uses a patch to sharpen the look of fonts. This is now included in the infinality patchset.<br />
<br />
A number of presets are included and can be used by setting the USE_STYLE variable in {{ic|/etc/profile.d/infinality-settings.sh}}.<br />
<br />
{{Note|1=The user bohoomil maintains a very good configuration in his [https://github.com/bohoomil/fontconf github repo] which is available as a [https://aur.archlinux.org/packages/fontconfig-infinality-ultimate/ package] in the AUR.}}<br />
<br />
{{Note|1=Install {{AUR|grip-git}} from AUR to have a realtime preview.}}<br />
<br />
{{AUR|freetype2-infinality}} can be installed from the [[Arch User Repository|AUR]]. Additionally, if you are using {{pkg|lib32-freetype2}} from [multilib], replace it with {{AUR|lib32-freetype2-infinality}} from the AUR. The AUR also contains a Git version of freetype2 that builds the latest development snapshot of freetype2 with the Infinality patchset: {{AUR|freetype2-git-infinality}}, {{AUR|lib32-freetype2-git-infinality}}.<br />
<br />
It is recommended to also install {{AUR|fontconfig-infinality}} to enable selection of predefined font substitution styles and antialiasing settings, apart from the rendering settings of the engine itself. After doing so, you can select the font style (win7, winxp, osx, linux, ...) with:<br />
# infctl setstyle<br />
<br />
If you set e.g. win7 or osx you need the corresponding fonts installed.<br />
<br />
{{Note|Default infinality settings can cause some programs to display fonts at 72 DPI instead of 96. If you notice a problem open /etc/fonts/infinality/infinality.conf search for the section on DPI and change 72 to 96. This problem can specifically affect conky causing the fonts to appear smaller than they should. Thus not aligning properly with images. }}<br />
<br />
{{Note|''The README for {{AUR|fontconfig-infinality}} says that /etc/fonts/local.conf should either not exist, or have no infinality-related configurations in it. The local.conf is now obsolete and completely replaced by this configuration.''}}<br />
<br />
for more information see this article: http://www.infinality.net/forum/viewtopic.php?f=2&t=77<br />
<br />
*[http://www.infinality.net/blog/infinality-freetype-patches/ Home page].<br />
<br />
===Infinality: the easy way===<br />
<br />
bohoomil also maintains '''infinality-bundle''' repository, offering three basic libraries (freetype2-infinality-ultimate, fontconfig-infinality-ultimate & cairo-infinality-ultimate) as pre-patched, pre-configured and pre-built binaries for all architectures (i686, x86_64, multilib). Using infinality-bundle makes the whole installation & configuration process dramatically simplified: all one has to do is install the three packages with<br />
<br />
{{bc|# pacman -S foo-infinality-ultimate}}<br />
<br />
which will replace the corresponding, generic Arch libraries (i.e. freetype2-infinality-ultimate will be used instead of freetype2, fontconfig-infinality-ultimate instead of fontconfig and fontconfig-infinality-ultimate from the AUR, and cairo-infinality-ultimate instead of the regular cairo). The libraries are fully compatible with the Arch packages and are meant to be used as drop-in replacements for them. No post installation/upgrade steps are required for most use scenarios: everything should work out of the box.<br />
<br />
To use the repository, add <br />
<br />
{{bc|1=[infinality-bundle]<br />
SigLevel = Never<br />
Server = http://bohoomil.cu.cc/infinality-bundle/$arch}}<br />
<br />
to your /etc/pacman.conf and issue<br />
<br />
{{bc|# pacman -Syy}}<br />
<br />
If you want to have access to multilib versions, add the following, too:<br />
<br />
{{bc|1=[infinality-bundle-multilib]<br />
SigLevel = Never<br />
Server = http://bohoomil.cu.cc/infinality-bundle-multilib/$arch}}<br />
<br />
In case of server down times, there is always a backup copy of the repository available via [https://www.dropbox.com/sh/ugmxbui00chidox/njDKnTG49W Dropbox].<br />
<br />
When installing some packages (like [https://www.archlinux.org/packages/?sort=&q=libgdiplus&maintainer=&flagged= libgdiplus]), you may encounter an error:<br />
<br />
{{bc|:: cairo and cairo-infinality-ultimate are in conflict. Remove cairo-infinality-ultimate? [y/N] n<br />
error: unresolvable package conflicts detected<br />
error: failed to prepare transaction (conflicting dependencies)}}<br />
<br />
If this happens, install the new package with {{bc|# pacman -Sd foo}} instead.<br />
<br />
For more information, see [http://bohoomil.github.io/ib.html infinality-bundle user notes].<br />
<br />
A support thread in the Forums is available [https://bbs.archlinux.org/viewtopic.php?id=162098 here].<br />
<br />
===Ubuntu===<br />
<br />
Ubuntu adds extra configurations, and occasionally patches to the font rendering libraries.<br />
<br />
Install the patched packages from the [[Arch User Repository|AUR]], the package names are: {{AUR|freetype2-ubuntu}} {{AUR|fontconfig-ubuntu}} {{AUR|cairo-ubuntu}}.<br />
<br />
The global configuration will need to be added. See [[#Example fontconfig configurations]] for a starting point.<br />
<br />
===Reverting to unpatched packages===<br />
<br />
To restore the unpatched packages, reinstall the originals:<br />
<br />
# pacman -S --asdeps freetype2 cairo fontconfig<br />
<br />
==Applications without fontconfig support==<br />
<br />
Some applications like [[URxvt]] will ignore fontconfig settings. This is very apparent when using the infinality patches which are heavily reliant on proper configuration. You can work around this by using {{ic|~/.Xresources}}, but it is not nearly as flexible as fontconfig. Example (see [[#Fontconfig configuration]] for explanations of the options):<br />
<br />
{{hc|~/.Xresources|<nowiki><br />
Xft.autohint: 0<br />
Xft.lcdfilter: lcddefault<br />
Xft.hintstyle: hintfull<br />
Xft.hinting: 1<br />
Xft.antialias: 1<br />
Xft.rgba: rgb<br />
</nowiki>}}<br />
<br />
Make sure the settings are loaded properly when X starts with {{ic|xrdb -q}} (see [[Xresources]] for more information).<br />
<br />
==Troubleshooting==<br />
<br />
=== Distorted fonts ===<br />
<br />
{{Note|96 DPI is not a standard. You should use your monitor's actual DPI to get proper font rendering, especially when using subpixel rendering.}}<br />
<br />
If fonts are still unexpectedly large or small, poorly proportioned or simply rendering poorly, fontconfig may be using the incorrect DPI.<br />
<br />
Fontconfig should be able to detect DPI parameters as discovered by the Xorg server. You can check the automatically discovered DPI with {{ic|xdpyinfo}} (provided by the {{pkg|xorg-xdpyinfo}} package):<br />
<br />
{{hc|<nowiki>$ xdpyinfo | grep dots</nowiki>| resolution: 102x102 dots per inch}}<br />
<br />
If the DPI is detected incorrectly (usually due to an incorrect monitor EDID), you can specify it manually in the Xorg configuration, see [[Xorg#Display Size and DPI]]. This is the recommended solution, but it may not work with buggy drivers.<br />
<br />
Fontconfig will default to the Xft.dpi variable if it is set. Xft.dpi is usually set by desktop environments (usually to Xorg's DPI setting) or manually in {{ic|~/.Xdefaults}} or {{ic|~/.Xresources}}. Use xrdb to query for the value:<br />
<br />
{{hc|<nowiki>$ xrdb -query | grep dpi</nowiki>|Xft.dpi: 102}}<br />
<br />
Those still having problems can fall back to manually setting the DPI used by fontconfig:<br />
<br />
...<br />
<!-- Setup for DPI=96 --><br />
<match target="pattern"><br />
<edit name="dpi" mode="assign"><double>102</double></edit><br />
</match><br />
...<br />
<br />
===Older GTK and QT applications===<br />
<br />
Modern GTK apps enable Xft by default but this was not the case before version 2.2. If it is not possible to update these applications, force Xft for old [[GNOME]] applications by adding to {{ic|~/.bashrc}}:<br />
<br />
export GDK_USE_XFT=1<br />
<br />
For older QT applications:<br />
<br />
export QT_XFT=true<br />
<br />
===Applications overriding hinting===<br />
Some applications may override default fontconfig hinting and anti-aliasing settings. This may happen with [[Gnome]] 3, for example. Use the specific configuration program for the application in such cases. For gnome, try {{pkg|gnome-tweak-tool}}.<br />
<br />
==See also==<br />
*[http://www.x.org/X11R6.8.2/doc/fonts.html Fonts in X11R6.8.2] - Official Xorg font information<br />
*[http://freetype.sourceforge.net/freetype2/ FreeType 2 Overview]<br />
*[https://forums.gentoo.org/viewtopic-t-723341.html Gentoo font-rendering thread]</div>Silencerhttps://wiki.archlinux.org/index.php?title=Font_configuration&diff=256585Font configuration2013-05-10T20:44:13Z<p>Silencer: Added disable embedded bitmap for all fonts</p>
<hr />
<div>[[Category:Fonts]]<br />
[[it:Font Configuration]]<br />
[[ru:Font Configuration]]<br />
[[sr:Font Configuration]]<br />
[[tr:Yazıtipi_yapılandırması]]<br />
[[zh-CN:Font Configuration]]<br />
{{Article summary start}}<br />
{{Article summary text|An overview of font configuration options and various techniques for improving the readability of fonts}}<br />
{{Article summary heading|Related}}<br />
{{Article summary wiki|Fonts}}: Information on adding fonts and font recommendations<br />
{{Article summary wiki|Font Configuration/fontconfig Examples}}<br />
{{Article summary wiki|Java Runtime Environment Fonts}}: Fonts specific to Sun's Java machine<br />
{{Article summary wiki|MS Fonts}}: Adding Microsoft fonts and mimicking Windows' font settings<br />
{{Article summary wiki|X Logical Font Description}}: The older core font system for X<br />
{{Article summary end}}<br />
<br />
Fontconfig is a library designed to provide a list of available [[fonts]] to applications, and also for configuration for how fonts get rendered. See package {{Pkg|fontconfig}} and [[Wikipedia:Fontconfig]]. The Free type library ({{Pkg|freetype2}} package) renders the fonts, based on this configuration.<br />
<br />
Though Fontconfig is the standard in today's Linux, some applications still rely on the original method of font selection and display, the [[X Logical Font Description]].<br />
<br />
The font rendering packages on Arch Linux includes support for ''freetype2'' with the bytecode interpreter (BCI) enabled. Patched packages exist for better font rendering, especially with an LCD monitor. See [[#Patched packages]] below. The [[#Infinality]] package allows both auto-hinting and subpixel rendering, allows the LCD filter to be tweaked without recompiling, and allows the auto-hinter to work well with bold fonts.<br />
<br />
==Font paths==<br />
<br />
For fonts to be known to applications, they must be cataloged for easy and quick access.<br />
<br />
The font paths initially known to Fontconfig are: {{ic|/usr/share/fonts/}} and {{ic|~/.fonts/}} (of which Fontconfig will scan recursively). For ease of organization and installation, it is recommended to use these font paths when [[Fonts#Installation|adding fonts]].<br />
<br />
To see a list of known Fontconfig fonts:<br />
$ fc-list : file<br />
<br />
See {{ic|man fc-list}} for more out put format.<br />
<br />
Check for Xorg's known font paths by reviewing its log:<br />
$ grep /fonts /var/log/Xorg.0.log<br />
<br />
{{Tip|You can also check the list of [[Xorg]]'s known font paths using the command {{ic|xset q}}.}}<br />
<br />
Keep in mind that Xorg does not search recursively through the {{ic|/usr/share/fonts/}} directory like Fontconfig does. To add a path, the full path must be used:<br />
Section "Files"<br />
FontPath "/usr/share/fonts/local/"<br />
EndSection<br />
<br />
If you want font paths to be set on a per-user basis, you can add and remove font paths from the default by adding the following line(s) to {{ic|~/.xinitrc}}:<br />
xset +fp /usr/share/fonts/local/ # Prepend a custom font path to Xorg's list of known font paths<br />
xset -fp /usr/share/fonts/sucky_fonts/ # Remove the specified font path from Xorg's list of known font paths<br />
<br />
To see a list of known Xorg fonts use {{ic|xlsfonts}}, from the {{Pkg|xorg-xlsfonts}} package.<br />
<br />
==Fontconfig configuration==<br />
<br />
Fontconfig is documented in the [http://fontconfig.org/fontconfig-user.html fonts.conf] man page.<br />
<br />
Configuration can be done per-user through {{ic|$XDG_CONFIG_HOME/fontconfig/fonts.conf}}, and globally with {{ic|/etc/fonts/local.conf}}. The settings in the per-user configuration have precedence over the global configuration. Both these files use the same syntax.<br />
{{Note|Configuration files and directories: {{ic|~/.fonts.conf}}, {{ic|~/.fonts.conf.d}} and {{ic|~/.fontconfig/*.cache-*}} are deprecated since fontconfig 2.10.1 ([http://cgit.freedesktop.org/fontconfig/commit/?id&#61;8c255fb185d5651b57380b0a9443001e8051b29d upstream commit]) and will not be read by default in the future versions of package. Use instead {{ic|$XDG_CONFIG_HOME/fontconfig/fonts.conf}}, {{ic|$XDG_CONFIG_HOME/fontconfig/conf.d}} and {{ic|$XDG_CACHE_HOME/fontconfig/*.cache-*}} respectively. If you use the second directory, the file '''must''' follow the naming convention {{ic|NN-name.conf}} (where NN it's a two digit number like 00, 10, or 99).}}<br />
<br />
Fontconfig gathers all its configurations in a central file ({{ic|/etc/fonts/fonts.conf}}). This file is replaced during fontconfig updates and shouldn't be edited. Fontconfig-aware applications source this file to know available fonts and how they get rendered. This file is a conglomeration of rules from the global configuration ({{ic|/etc/fonts/local.conf}}), the configured presets in {{ic|/etc/fonts/conf.d/}}, and the user configuration file ({{ic|$XDG_CONFIG_HOME/fontconfig/fonts.conf}}).<br />
<br />
{{Note|For some desktop environments (such as [[GNOME]] and [[KDE]]) using the ''Font Control Panel'' will automatically create or overwrite the user font configuration file. For these desktop environments, it is best to match your already defined font configurations to get the expected behavior.}}<br />
<br />
Fontconfig configuration files use [[Wikipedia:XML|XML]] format and need these headers:<br />
<br />
{{bc|<nowiki><br />
<?xml version="1.0"?><br />
<!DOCTYPE fontconfig SYSTEM "fonts.dtd"><br />
<fontconfig><br />
<br />
<!-- settings go here --><br />
<br />
</fontconfig><br />
</nowiki>}}<br />
<br />
The configuration examples in this article omit these tags.<br />
<br />
===Presets===<br />
<br />
There are presets installed in the directory {{ic|/etc/fonts/conf.avail}}. They can be enabled by creating [[Wikipedia:Symbolic link|symbolic link]]s to them, both per-user and globally, as described in {{ic|/etc/fonts/conf.d/README}}. These presets will override matching settings in their respective configuration files.<br />
<br />
For example, to enable sub-pixel RGB rendering globally:<br />
<br />
# cd /etc/fonts/conf.d<br />
# ln -s ../conf.avail/10-sub-pixel-rgb.conf<br />
<br />
To do the same but instead for a per-user configuration:<br />
<br />
$ mkdir $XDG_CONFIG_HOME/fontconfig/conf.d<br />
$ ln -s /etc/fonts/conf.avail/10-sub-pixel-rgb.conf $XDG_CONFIG_HOME/fontconfig/conf.d<br />
<br />
===Anti-aliasing===<br />
<br />
[[Wikipedia:Font rasterization|Font rasterization]] converts vector font data to bitmap data so that it can be displayed. The result can appear jagged due to [[Wikipedia:Aliasing|aliasing]]. [[Wikipedia:Anti-aliasing|anti-aliasing]] is enabled by default and increases the apparent resolution of font edges.<br />
<br />
{{bc|<nowiki><br />
<match target="font"><br />
<edit name="antialias" mode="assign"><br />
<bool>true</bool><br />
</edit><br />
</match><br />
</nowiki>}}<br />
<br />
Note: some applications, like [[Gnome|Gnome 3]] may [[#Troubleshooting|override default anti-alias settings]].<br />
<br />
===Hinting===<br />
<br />
[[Wikipedia:Font hinting|Font hinting]] (also known as instructing) is the use of mathematical instructions to adjust the display of an outline font so that it lines up with a rasterized grid, such as the pixel grid in a display. Fonts will not line up correctly without hinting until displays have 300 [[Wikipedia:Dots per inch|DPI]] or greater. Two types of hinting are available.<br />
<br />
====Byte-Code Interpreter (BCI)====<br />
Using normal hinting, TrueType hinting instructions in the font are interpreted by freetype's Byte-Code Interpreter. This works best for fonts with good hinting instructions.<br />
<br />
To enable normal hinting:<br />
<br />
{{bc|<nowiki><br />
<match target="font"><br />
<edit name="hinting" mode="assign"><br />
<bool>true</bool><br />
</edit><br />
</match><br />
</nowiki>}}<br />
<br />
====Autohinter====<br />
Auto-discovery for hinting. This looks worse than normal hinting for fonts with good instructions, but better for those with poor or no instructions. The autohinter and subpixel rendering are not designed to work together and should not be used in combination.<br />
<br />
To enable auto-hinting:<br />
<br />
{{bc|<nowiki><br />
<match target="font"><br />
<edit name="autohint" mode="assign"><br />
<bool>true</bool><br />
</edit><br />
</match><br />
</nowiki>}}<br />
<br />
====Hint style====<br />
<br />
Hint style is the amount of influence the hinting mode has. Hinting can be set to: {{ic|hintfull}}, {{ic|hintmedium}}, {{ic|hintslight}} and {{ic|hintnone}}. With BCI hinting, hintfull should work best for most fonts. With the autohinter, hintslight is recommended.<br />
<br />
{{bc|<nowiki><br />
<match target="font"><br />
<edit name="hintstyle" mode="assign"><br />
<const>hintfull</const><br />
</edit><br />
</match><br />
</nowiki>}}<br />
<br />
Note: some applications, like [[Gnome|Gnome 3]] may [[#Troubleshooting|override default hinting settings]].<br />
<br />
===Subpixel rendering===<br />
<br />
Subpixel rendering effectively triples the horizontal (or vertical) resolution for fonts by making use of subpixels. The autohinter and subpixel rendering are not designed to work together and should not be used in combination without the [[#Infinality]] patch set.<br />
<br />
Most monitors manufactured today use the Red, Green, Blue (RGB) specification. Fontconfig will need to know your monitor type to be able to display your fonts correctly.<br />
<br />
''RGB (most common), BGR, V-RGB (vertical), or V-BGR''<br />
<br />
To enable subpixel rendering:<br />
<br />
{{bc|<nowiki><br />
<match target="font"><br />
<edit name="rgba" mode="assign"><br />
<const>rgb</const><br />
</edit><br />
</match><br />
</nowiki>}}<br />
<br />
If you notice unusual colors around font's borders, the wrong subpixel arrangement might be configured. The [http://www.lagom.nl/lcd-test/subpixel.php Lagom subpixel layout test] web page can help identify it.<br />
<br />
====LCD filter====<br />
<br />
When using subpixel rendering, you should enable the LCD filter, which is designed to reduce colour fringing. This is described under [http://www.freetype.org/freetype2/docs/reference/ft2-lcd_filtering.html LCD filtering] in the FreeType 2 API reference. Different options are described under [http://www.freetype.org/freetype2/docs/reference/ft2-lcd_filtering.html#FT_LcdFilter FT_LcdFilter], and are illustrated by this [http://www.spasche.net/files/lcdfiltering/ LCD filter test] page.<br />
<br />
The {{ic|lcddefault}} filter will work for most users. Other filters are available that can be used in special situations: {{ic|lcdlight}}; a lighter filter ideal for fonts that look too bold or fuzzy, {{ic|lcdlegacy}}, the original Cairo filter; and {{ic|lcdnone}} to disable it entirely.<br />
<br />
{{bc|<nowiki><br />
<match target="font"><br />
<edit mode="assign" name="lcdfilter"><br />
<const>lcddefault</const><br />
</edit><br />
</match><br />
</nowiki>}}<br />
<br />
====Advanced LCD filter specification====<br />
<br />
If the available, built-in LCD filters are not satisfactory, it is possible to tweak the font rendering very specifically by building a custom freetype2 package and modifying the hardcoded filters. The [[Arch Build System]] can be used to build and install packages from source.<br />
<br />
First, refresh the freetype2 PKGBUILD as root:<br />
<br />
# abs extra/freetype2<br />
<br />
This example uses {{ic|/var/abs/build}} as the build directory, substitute it according to your personal ABS setup. Download and extract the freetype2 package as a regular user:<br />
<br />
$ cd /var/abs/build<br />
$ cp -r ../extra/freetype2 .<br />
$ cd freetype2<br />
$ makepkg -o<br />
<br />
Edit the file {{ic|src/freetype-VERSION/src/base/ftlcdfil.c}} and look up the definition of the constant {{ic|default_filter[5]}}:<br />
<br />
static const FT_Byte default_filter[5] =<br />
{ 0x10, 0x40, 0x70, 0x40, 0x10 };<br />
<br />
This constant defines a low-pass filter applied to the rendered glyph. Modify it as needed. Save the file, build and install the custom package:<br />
<br />
$ makepkg -e<br />
$ sudo pacman -Rd freetype2<br />
$ sudo pacman -U freetype2-VERSION-ARCH.pkg.tar.xz<br />
<br />
Reboot or restart X. The lcddefault filter should now render fonts differently.<br />
<br />
===Disable auto-hinter for bold fonts===<br />
<br />
The auto-hinter uses sophisticated methods for font rendering, but often makes bold fonts too wide. Fortunately, a solution can be turning off the autohinter for bold fonts while leaving it on for the rest:<br />
...<br />
<match target="font"><br />
<test name="weight" compare="more"><br />
<const>medium</const><br />
</test><br />
<edit name="autohint" mode="assign"><br />
<bool>false</bool><br />
</edit><br />
</match><br />
...<br />
<br />
=== Enable anti-aliasing only for bigger fonts ===<br />
<br />
''See also [http://sharpfonts.co.cc/ sharpfonts.co.cc] for related information.''<br />
<br />
Some users prefer the sharper rendering that anti-aliasing does not offer:<br />
<br />
{{bc|<nowiki><br />
...<br />
<match target="font"><br />
<edit name="antialias" mode="assign"><br />
<bool>false</bool><br />
</edit><br />
</match><br />
<br />
<match target="font" ><br />
<test name="size" qual="any" compare="more"><br />
<double>12</double><br />
</test><br />
<edit name="antialias" mode="assign"><br />
<bool>true</bool><br />
</edit><br />
</match><br />
<br />
<match target="font" ><br />
<test name="pixelsize" qual="any" compare="more"><br />
<double>16</double><br />
</test><br />
<edit name="antialias" mode="assign"><br />
<bool>true</bool><br />
</edit><br />
</match><br />
...<br />
</nowiki>}}<br />
<br />
===Replace fonts===<br />
<br />
The most reliable way to do this is to add an XML fragment similar to the one below. ''Using the "binding" attribute will give you better results'', for example, in Firefox where you may not want to change properties of font being replaced. This will cause Ubuntu to be used in place of Georgia:<br />
...<br />
<match target="pattern"><br />
<test qual="any" name="family"><string>georgia</string></test><br />
<edit name="family" mode="assign" binding="same"><string>Ubuntu</string></edit><br />
</match><br />
...<br />
An alternate approach is to set the "preferred" font, but ''this only works if the original font is not on the system'', in which case the one specified will be substituted:<br />
...<br />
< !-- Replace Helvetica with Bitstream Vera Sans Mono --><br />
< !-- Note, an alias for Helvetica should already exist in default conf files --><br />
<alias><br />
<family>Helvetica</family><br />
<prefer><family>Bitstream Vera Sans Mono</family></prefer><br />
<default><family>fixed</family></default><br />
</alias><br />
...<br />
<br />
===Disable bitmap fonts===<br />
<br />
To disable bitmap fonts in fontconfig, use {{ic|70-no-bitmaps.conf}} (which is not placed by fontconfig by default):<br />
<br />
# cd /etc/fonts/conf.d<br />
# rm 70-yes-bitmaps.conf<br />
# ln -s ../conf.avail/70-no-bitmaps.conf<br />
<br />
You may not need to remove {{ic|70-yes-bitmaps.conf}} if it does not exist. You can choose which fonts to replace bitmaps fonts with (Helvetica, Courier and Times bitmap mapts to TTF fonts) by:<br />
<br />
# cd /etc/fonts/conf.d<br />
# ln -s ../conf.avail/29-replace-bitmap-fonts.conf<br />
<br />
To disable embedded bitmap fonts for a specific font:<br />
<br />
<match target="font"><br />
<test qual="any" name="family"><br />
<string>Monaco</string><br />
</test><br />
<edit name="embeddedbitmap"><bool>false</bool></edit><br />
</match><br />
<br />
To disable embedded bitmap for all fonts:<br />
<br />
{{hc|~/.config/fontconfig/conf.d/20-no-embeded.conf|<nowiki><br />
<?xml version="1.0"?><br />
<!DOCTYPE fontconfig SYSTEM "fonts.dtd"><br />
<fontconfig><br />
<match target="font"><br />
<edit name="embeddedbitmap" mode="assign"><br />
<bool>false</bool><br />
</edit><br />
</match><br />
</fontconfig><br />
</nowiki>}}<br />
<br />
===Disable scaling of bitmap fonts===<br />
<br />
To disable scaling of bitmap fonts (which often makes them blurry), remove {{ic|/etc/fonts/conf.d/10-scale-bitmap-fonts.conf}}.<br />
<br />
===Create bold and italic styles for incomplete fonts===<br />
<br />
Freetype has the ability to automatically create ''italic'' and '''bold''' styles for fonts that do not have them, but only if explicitly required by the application. Given programs rarely send these requests, this section covers manually forcing generation of missing styles.<br />
<br />
Start by editing {{ic|/usr/share/fonts/fonts.cache-1}} as explained below. Store a copy of the modifications on another file, because a font update with {{ic|fc-cache}} will overwrite {{ic|/usr/share/fonts/fonts.cache-1}}.<br />
<br />
Assuming the Dupree font is installed:<br />
"dupree.ttf" 0 "Dupree:style=Regular:slant=0:weight=80:width=100:foundry=unknown:index=0:outline=True:''etc...''<br />
<br />
Duplicate the line, change {{ic|<nowiki>style=Regular</nowiki>}} to {{ic|<nowiki>style=Bold</nowiki>}} or any other style. Also change {{ic|<nowiki>slant=0</nowiki>}} to {{ic|<nowiki>slant=100</nowiki>}} for italic, {{ic|<nowiki>weight=80</nowiki>}} to {{ic|<nowiki>weight=200</nowiki>}} for bold, or combine them for '''''bold italic''''':<br />
"dupree.ttf" 0 "Dupree:style=Bold Italic:slant=100:weight=200:width=100:foundry=unknown:index=0:outline=True:''etc...''<br />
<br />
Now add necessary modifications to {{ic|$XDG_CONFIG_HOME/fontconfig/fonts.conf}}:<br />
{{bc|<nowiki><br />
...<br />
<match target="font"><br />
<test name="family" qual="any"><br />
<string>Dupree</string><br />
&lt;!-- other fonts here .... --&gt;<br />
</test><br />
<test name="weight" compare="more_eq"><int>140</int></test><br />
<edit name="embolden" mode="assign"><bool>true</bool></edit><br />
</match><br />
<br />
<match target="font"><br />
<test name="family" qual="any"><br />
<string>Dupree</string><br />
&lt;!-- other fonts here .... --&gt;<br />
</test><br />
<test name="slant" compare="more_eq"><int>80</int></test><br />
<edit name="matrix" mode="assign"><br />
<times><br />
<name>matrix</name><br />
<matrix><br />
<double>1</double><double>0.2</double><br />
<double>0</double><double>1</double><br />
</matrix><br />
</times><br />
</edit><br />
</match><br />
...<br />
</nowiki>}}<br />
{{Tip| Use the value 'embolden' for existing bold fonts in order to make them even bolder.}}<br />
<br />
===Change rule overriding===<br />
<br />
Fontconfig processes files in {{ic|/etc/fonts/conf.d}} in numerical order. This enables rules or files to override one another, but often confuses users about what file gets parsed last.<br />
<br />
To guarantee that personal settings take precedence over any other rules, change their ordering:<br />
# cd /etc/fonts/conf.d<br />
# mv 50-user.conf 99-user.conf<br />
<br />
This change seems however to be unnecessary for the most of the cases, because a user is given enough control by default to set up own font preferences, hinting and antialiasing properties, alias new fonts to generic font families, etc.<br />
<br />
===Example fontconfig configurations===<br />
<br />
Example fontconfig configurations can be found on this [[Font_Configuration/fontconfig_Examples|page]].<br />
<br />
A simple starting point:<br />
<br />
{{hc|/etc/fonts/local.conf|<nowiki><br />
<?xml version='1.0'?><br />
<!DOCTYPE fontconfig SYSTEM 'fonts.dtd'><br />
<fontconfig><br />
<match target="font"><br />
<br />
<edit mode="assign" name="rgba"><br />
<const>rgb</const><br />
</edit><br />
<br />
<edit mode="assign" name="hinting"><br />
<bool>true</bool><br />
</edit><br />
<br />
<edit mode="assign" name="hintstyle"><br />
<const>hintslight</const><br />
</edit><br />
<br />
<edit mode="assign" name="antialias"><br />
<bool>true</bool><br />
</edit><br />
<br />
<edit mode="assign" name="lcdfilter"><br />
<const>lcddefault</const><br />
</edit><br />
<br />
</match><br />
</fontconfig><br />
</nowiki>}}<br />
<br />
==Patched packages==<br />
<br />
These patched packages are available in the [[Arch User Repository|AUR]]. A few considerations:<br />
<br />
* Configuration is usually necessary.<br />
* The new font rendering will not kick in until applications restart.<br />
* Applications which [[Wikipedia:Static library|statically link]] to a library will not be affected by patches applied to the system library.<br />
<br />
===Infinality: the generic way===<br />
<br />
The infinality patchset aims to greatly improve freetype2 font rendering. It adds multiple new capabilities.<br />
<br />
*[http://www.infinality.net/blog/infinality-freetype-patches/ Home page].<br />
*[http://www.infinality.net/forum/ Forum].<br />
<br />
Infinality's settings are all configurable at runtime via environment variables in {{ic|/etc/profile.d/infinality-settings.sh}}, and include the following:<br />
<br />
*'''Emboldening Enhancement''': Disables Y emboldening, producing a much nicer result on fonts without bold versions. Works on native TT hinter and autohinter.<br />
*'''Auto-Autohint''': Automatically forces autohint on fonts that contain no TT instructions.<br />
*'''Autohint Enhancement''': Makes autohint snap horizontal stems to pixels. Gives a result that appears like a well-hinted truetype font, but is 100% patent-free (as far as I know).<br />
*'''Customized FIR Filter''': Select your own [http://www.infinality.net/forum/viewtopic.php?f=2&t=19 filter values] at run-time. Works on native TT hinter and autohinter.<br />
*'''Stem Alignment''': Aligns bitmap glyphs to optimized pixel boundaries. Works on native TT hinter and autohinter.<br />
*'''Pseudo Gamma Correction''': Lighten and darken glyphs at a given value, below a given size. Works on native TT hinter and autohinter.<br />
*'''Embolden Thin Fonts''': Embolden thin or light fonts so that they are more visible. Works on autohinter.<br />
*'''Force Slight Hinting''': Force slight hinting even when programs want full hinting. If you use the local.conf I provide (included in infinality-settings fedora package) you will notice nice improvements on @font-face fonts.<br />
*'''ChromeOS Style Sharpening''': ChromeOS uses a patch to sharpen the look of fonts. This is now included in the infinality patchset.<br />
<br />
A number of presets are included and can be used by setting the USE_STYLE variable in {{ic|/etc/profile.d/infinality-settings.sh}}.<br />
<br />
{{Note|1=The user bohoomil maintains a very good configuration in his [https://github.com/bohoomil/fontconf github repo] which is available as a [https://aur.archlinux.org/packages/fontconfig-infinality-ultimate/ package] in the AUR.}}<br />
<br />
{{Note|1=Install {{AUR|grip-git}} from AUR to have a realtime preview.}}<br />
<br />
{{AUR|freetype2-infinality}} can be installed from the [[Arch User Repository|AUR]]. Additionally, if you are using {{pkg|lib32-freetype2}} from [multilib], replace it with {{AUR|lib32-freetype2-infinality}} from the AUR. The AUR also contains a Git version of freetype2 that builds the latest development snapshot of freetype2 with the Infinality patchset: {{AUR|freetype2-git-infinality}}, {{AUR|lib32-freetype2-git-infinality}}.<br />
<br />
It is recommended to also install {{AUR|fontconfig-infinality}} to enable selection of predefined font substitution styles and antialiasing settings, apart from the rendering settings of the engine itself. After doing so, you can select the font style (win7, winxp, osx, linux, ...) with:<br />
# infctl setstyle<br />
<br />
If you set e.g. win7 or osx you need the corresponding fonts installed.<br />
<br />
{{Note|Default infinality settings can cause some programs to display fonts at 72 DPI instead of 96. If you notice a problem open /etc/fonts/infinality/infinality.conf search for the section on DPI and change 72 to 96. This problem can specifically affect conky causing the fonts to appear smaller than they should. Thus not aligning properly with images. }}<br />
<br />
{{Note|''The README for {{AUR|fontconfig-infinality}} says that /etc/fonts/local.conf should either not exist, or have no infinality-related configurations in it. The local.conf is now obsolete and completely replaced by this configuration.''}}<br />
<br />
for more information see this article: http://www.infinality.net/forum/viewtopic.php?f=2&t=77<br />
<br />
*[http://www.infinality.net/blog/infinality-freetype-patches/ Home page].<br />
<br />
===Infinality: the easy way===<br />
<br />
bohoomil also maintains '''infinality-bundle''' repository, offering three basic libraries (freetype2-infinality-ultimate, fontconfig-infinality-ultimate & cairo-infinality-ultimate) as pre-patched, pre-configured and pre-built binaries for all architectures (i686, x86_64, multilib). Using infinality-bundle makes the whole installation & configuration process dramatically simplified: all one has to do is install the three packages with<br />
<br />
{{bc|# pacman -S foo-infinality-ultimate}}<br />
<br />
which will replace the corresponding, generic Arch libraries (i.e. freetype2-infinality-ultimate will be used instead of freetype2, fontconfig-infinality-ultimate instead of fontconfig and fontconfig-infinality-ultimate from the AUR, and cairo-infinality-ultimate instead of the regular cairo). The libraries are fully compatible with the Arch packages and are meant to be used as drop-in replacements for them. No post installation/upgrade steps are required for most use scenarios: everything should work out of the box.<br />
<br />
To use the repository, add <br />
<br />
{{bc|1=[infinality-bundle]<br />
SigLevel = Never<br />
Server = http://bohoomil.cu.cc/infinality-bundle/$arch}}<br />
<br />
to your /etc/pacman.conf and issue<br />
<br />
{{bc|# pacman -Syy}}<br />
<br />
If you want to have access to multilib versions, add the following, too:<br />
<br />
{{bc|1=[infinality-bundle-multilib]<br />
SigLevel = Never<br />
Server = http://bohoomil.cu.cc/infinality-bundle-multilib/$arch}}<br />
<br />
In case of server down times, there is always a backup copy of the repository available via [https://www.dropbox.com/sh/ugmxbui00chidox/njDKnTG49W Dropbox].<br />
<br />
When installing some packages (like [https://www.archlinux.org/packages/?sort=&q=libgdiplus&maintainer=&flagged= libgdiplus]), you may encounter an error:<br />
<br />
{{bc|:: cairo and cairo-infinality-ultimate are in conflict. Remove cairo-infinality-ultimate? [y/N] n<br />
error: unresolvable package conflicts detected<br />
error: failed to prepare transaction (conflicting dependencies)}}<br />
<br />
If this happens, install the new package with {{bc|# pacman -Sd foo}} instead.<br />
<br />
For more information, see [http://bohoomil.github.io/ib.html infinality-bundle user notes].<br />
<br />
A support thread in the Forums is available [https://bbs.archlinux.org/viewtopic.php?id=162098 here].<br />
<br />
===Ubuntu===<br />
<br />
Ubuntu adds extra configurations, and occasionally patches to the font rendering libraries.<br />
<br />
Install the patched packages from the [[Arch User Repository|AUR]], the package names are: {{AUR|freetype2-ubuntu}} {{AUR|fontconfig-ubuntu}} {{AUR|cairo-ubuntu}}.<br />
<br />
The global configuration will need to be added. See [[#Example fontconfig configurations]] for a starting point.<br />
<br />
===Reverting to unpatched packages===<br />
<br />
To restore the unpatched packages, reinstall the originals:<br />
<br />
# pacman -S --asdeps freetype2 cairo fontconfig<br />
<br />
==Applications without fontconfig support==<br />
<br />
Some applications like [[URxvt]] will ignore fontconfig settings. This is very apparent when using the infinality patches which are heavily reliant on proper configuration. You can work around this by using {{ic|~/.Xresources}}, but it is not nearly as flexible as fontconfig. Example (see [[#Fontconfig configuration]] for explanations of the options):<br />
<br />
{{hc|~/.Xresources|<nowiki><br />
Xft.autohint: 0<br />
Xft.lcdfilter: lcddefault<br />
Xft.hintstyle: hintfull<br />
Xft.hinting: 1<br />
Xft.antialias: 1<br />
Xft.rgba: rgb<br />
</nowiki>}}<br />
<br />
Make sure the settings are loaded properly when X starts with {{ic|xrdb -q}} (see [[Xresources]] for more information).<br />
<br />
==Troubleshooting==<br />
<br />
=== Distorted fonts ===<br />
<br />
{{Note|96 DPI is not a standard. You should use your monitor's actual DPI to get proper font rendering, especially when using subpixel rendering.}}<br />
<br />
If fonts are still unexpectedly large or small, poorly proportioned or simply rendering poorly, fontconfig may be using the incorrect DPI.<br />
<br />
Fontconfig should be able to detect DPI parameters as discovered by the Xorg server. You can check the automatically discovered DPI with {{ic|xdpyinfo}} (provided by the {{pkg|xorg-xdpyinfo}} package):<br />
<br />
{{hc|<nowiki>$ xdpyinfo | grep dots</nowiki>| resolution: 102x102 dots per inch}}<br />
<br />
If the DPI is detected incorrectly (usually due to an incorrect monitor EDID), you can specify it manually in the Xorg configuration, see [[Xorg#Display Size and DPI]]. This is the recommended solution, but it may not work with buggy drivers.<br />
<br />
Fontconfig will default to the Xft.dpi variable if it is set. Xft.dpi is usually set by desktop environments (usually to Xorg's DPI setting) or manually in {{ic|~/.Xdefaults}} or {{ic|~/.Xresources}}. Use xrdb to query for the value:<br />
<br />
{{hc|<nowiki>$ xrdb -query | grep dpi</nowiki>|Xft.dpi: 102}}<br />
<br />
Those still having problems can fall back to manually setting the DPI used by fontconfig:<br />
<br />
...<br />
<!-- Setup for DPI=96 --><br />
<match target="pattern"><br />
<edit name="dpi" mode="assign"><double>102</double></edit><br />
</match><br />
...<br />
<br />
===Older GTK and QT applications===<br />
<br />
Modern GTK apps enable Xft by default but this was not the case before version 2.2. If it is not possible to update these applications, force Xft for old [[GNOME]] applications by adding to {{ic|~/.bashrc}}:<br />
<br />
export GDK_USE_XFT=1<br />
<br />
For older QT applications:<br />
<br />
export QT_XFT=true<br />
<br />
===Applications overriding hinting===<br />
Some applications may override default fontconfig hinting and anti-aliasing settings. This may happen with [[Gnome]] 3, for example. Use the specific configuration program for the application in such cases. For gnome, try {{pkg|gnome-tweak-tool}}.<br />
<br />
==See also==<br />
*[http://www.x.org/X11R6.8.2/doc/fonts.html Fonts in X11R6.8.2] - Official Xorg font information<br />
*[http://freetype.sourceforge.net/freetype2/ FreeType 2 Overview]<br />
*[https://forums.gentoo.org/viewtopic-t-723341.html Gentoo font-rendering thread]</div>Silencerhttps://wiki.archlinux.org/index.php?title=Font_configuration&diff=256582Font configuration2013-05-10T20:21:00Z<p>Silencer: changed 'hintfull' to 'hintslight' in example font configurations as it works better with current state of freetype2</p>
<hr />
<div>[[Category:Fonts]]<br />
[[it:Font Configuration]]<br />
[[ru:Font Configuration]]<br />
[[sr:Font Configuration]]<br />
[[tr:Yazıtipi_yapılandırması]]<br />
[[zh-CN:Font Configuration]]<br />
{{Article summary start}}<br />
{{Article summary text|An overview of font configuration options and various techniques for improving the readability of fonts}}<br />
{{Article summary heading|Related}}<br />
{{Article summary wiki|Fonts}}: Information on adding fonts and font recommendations<br />
{{Article summary wiki|Font Configuration/fontconfig Examples}}<br />
{{Article summary wiki|Java Runtime Environment Fonts}}: Fonts specific to Sun's Java machine<br />
{{Article summary wiki|MS Fonts}}: Adding Microsoft fonts and mimicking Windows' font settings<br />
{{Article summary wiki|X Logical Font Description}}: The older core font system for X<br />
{{Article summary end}}<br />
<br />
Fontconfig is a library designed to provide a list of available [[fonts]] to applications, and also for configuration for how fonts get rendered. See package {{Pkg|fontconfig}} and [[Wikipedia:Fontconfig]]. The Free type library ({{Pkg|freetype2}} package) renders the fonts, based on this configuration.<br />
<br />
Though Fontconfig is the standard in today's Linux, some applications still rely on the original method of font selection and display, the [[X Logical Font Description]].<br />
<br />
The font rendering packages on Arch Linux includes support for ''freetype2'' with the bytecode interpreter (BCI) enabled. Patched packages exist for better font rendering, especially with an LCD monitor. See [[#Patched packages]] below. The [[#Infinality]] package allows both auto-hinting and subpixel rendering, allows the LCD filter to be tweaked without recompiling, and allows the auto-hinter to work well with bold fonts.<br />
<br />
==Font paths==<br />
<br />
For fonts to be known to applications, they must be cataloged for easy and quick access.<br />
<br />
The font paths initially known to Fontconfig are: {{ic|/usr/share/fonts/}} and {{ic|~/.fonts/}} (of which Fontconfig will scan recursively). For ease of organization and installation, it is recommended to use these font paths when [[Fonts#Installation|adding fonts]].<br />
<br />
To see a list of known Fontconfig fonts:<br />
$ fc-list : file<br />
<br />
See {{ic|man fc-list}} for more out put format.<br />
<br />
Check for Xorg's known font paths by reviewing its log:<br />
$ grep /fonts /var/log/Xorg.0.log<br />
<br />
{{Tip|You can also check the list of [[Xorg]]'s known font paths using the command {{ic|xset q}}.}}<br />
<br />
Keep in mind that Xorg does not search recursively through the {{ic|/usr/share/fonts/}} directory like Fontconfig does. To add a path, the full path must be used:<br />
Section "Files"<br />
FontPath "/usr/share/fonts/local/"<br />
EndSection<br />
<br />
If you want font paths to be set on a per-user basis, you can add and remove font paths from the default by adding the following line(s) to {{ic|~/.xinitrc}}:<br />
xset +fp /usr/share/fonts/local/ # Prepend a custom font path to Xorg's list of known font paths<br />
xset -fp /usr/share/fonts/sucky_fonts/ # Remove the specified font path from Xorg's list of known font paths<br />
<br />
To see a list of known Xorg fonts use {{ic|xlsfonts}}, from the {{Pkg|xorg-xlsfonts}} package.<br />
<br />
==Fontconfig configuration==<br />
<br />
Fontconfig is documented in the [http://fontconfig.org/fontconfig-user.html fonts.conf] man page.<br />
<br />
Configuration can be done per-user through {{ic|$XDG_CONFIG_HOME/fontconfig/fonts.conf}}, and globally with {{ic|/etc/fonts/local.conf}}. The settings in the per-user configuration have precedence over the global configuration. Both these files use the same syntax.<br />
{{Note|Configuration files and directories: {{ic|~/.fonts.conf}}, {{ic|~/.fonts.conf.d}} and {{ic|~/.fontconfig/*.cache-*}} are deprecated since fontconfig 2.10.1 ([http://cgit.freedesktop.org/fontconfig/commit/?id&#61;8c255fb185d5651b57380b0a9443001e8051b29d upstream commit]) and will not be read by default in the future versions of package. Use instead {{ic|$XDG_CONFIG_HOME/fontconfig/fonts.conf}}, {{ic|$XDG_CONFIG_HOME/fontconfig/conf.d}} and {{ic|$XDG_CACHE_HOME/fontconfig/*.cache-*}} respectively. If you use the second directory, the file '''must''' follow the naming convention {{ic|NN-name.conf}} (where NN it's a two digit number like 00, 10, or 99).}}<br />
<br />
Fontconfig gathers all its configurations in a central file ({{ic|/etc/fonts/fonts.conf}}). This file is replaced during fontconfig updates and shouldn't be edited. Fontconfig-aware applications source this file to know available fonts and how they get rendered. This file is a conglomeration of rules from the global configuration ({{ic|/etc/fonts/local.conf}}), the configured presets in {{ic|/etc/fonts/conf.d/}}, and the user configuration file ({{ic|$XDG_CONFIG_HOME/fontconfig/fonts.conf}}).<br />
<br />
{{Note|For some desktop environments (such as [[GNOME]] and [[KDE]]) using the ''Font Control Panel'' will automatically create or overwrite the user font configuration file. For these desktop environments, it is best to match your already defined font configurations to get the expected behavior.}}<br />
<br />
Fontconfig configuration files use [[Wikipedia:XML|XML]] format and need these headers:<br />
<br />
{{bc|<nowiki><br />
<?xml version="1.0"?><br />
<!DOCTYPE fontconfig SYSTEM "fonts.dtd"><br />
<fontconfig><br />
<br />
<!-- settings go here --><br />
<br />
</fontconfig><br />
</nowiki>}}<br />
<br />
The configuration examples in this article omit these tags.<br />
<br />
===Presets===<br />
<br />
There are presets installed in the directory {{ic|/etc/fonts/conf.avail}}. They can be enabled by creating [[Wikipedia:Symbolic link|symbolic link]]s to them, both per-user and globally, as described in {{ic|/etc/fonts/conf.d/README}}. These presets will override matching settings in their respective configuration files.<br />
<br />
For example, to enable sub-pixel RGB rendering globally:<br />
<br />
# cd /etc/fonts/conf.d<br />
# ln -s ../conf.avail/10-sub-pixel-rgb.conf<br />
<br />
To do the same but instead for a per-user configuration:<br />
<br />
$ mkdir $XDG_CONFIG_HOME/fontconfig/conf.d<br />
$ ln -s /etc/fonts/conf.avail/10-sub-pixel-rgb.conf $XDG_CONFIG_HOME/fontconfig/conf.d<br />
<br />
===Anti-aliasing===<br />
<br />
[[Wikipedia:Font rasterization|Font rasterization]] converts vector font data to bitmap data so that it can be displayed. The result can appear jagged due to [[Wikipedia:Aliasing|aliasing]]. [[Wikipedia:Anti-aliasing|anti-aliasing]] is enabled by default and increases the apparent resolution of font edges.<br />
<br />
{{bc|<nowiki><br />
<match target="font"><br />
<edit name="antialias" mode="assign"><br />
<bool>true</bool><br />
</edit><br />
</match><br />
</nowiki>}}<br />
<br />
Note: some applications, like [[Gnome|Gnome 3]] may [[#Troubleshooting|override default anti-alias settings]].<br />
<br />
===Hinting===<br />
<br />
[[Wikipedia:Font hinting|Font hinting]] (also known as instructing) is the use of mathematical instructions to adjust the display of an outline font so that it lines up with a rasterized grid, such as the pixel grid in a display. Fonts will not line up correctly without hinting until displays have 300 [[Wikipedia:Dots per inch|DPI]] or greater. Two types of hinting are available.<br />
<br />
====Byte-Code Interpreter (BCI)====<br />
Using normal hinting, TrueType hinting instructions in the font are interpreted by freetype's Byte-Code Interpreter. This works best for fonts with good hinting instructions.<br />
<br />
To enable normal hinting:<br />
<br />
{{bc|<nowiki><br />
<match target="font"><br />
<edit name="hinting" mode="assign"><br />
<bool>true</bool><br />
</edit><br />
</match><br />
</nowiki>}}<br />
<br />
====Autohinter====<br />
Auto-discovery for hinting. This looks worse than normal hinting for fonts with good instructions, but better for those with poor or no instructions. The autohinter and subpixel rendering are not designed to work together and should not be used in combination.<br />
<br />
To enable auto-hinting:<br />
<br />
{{bc|<nowiki><br />
<match target="font"><br />
<edit name="autohint" mode="assign"><br />
<bool>true</bool><br />
</edit><br />
</match><br />
</nowiki>}}<br />
<br />
====Hint style====<br />
<br />
Hint style is the amount of influence the hinting mode has. Hinting can be set to: {{ic|hintfull}}, {{ic|hintmedium}}, {{ic|hintslight}} and {{ic|hintnone}}. With BCI hinting, hintfull should work best for most fonts. With the autohinter, hintslight is recommended.<br />
<br />
{{bc|<nowiki><br />
<match target="font"><br />
<edit name="hintstyle" mode="assign"><br />
<const>hintfull</const><br />
</edit><br />
</match><br />
</nowiki>}}<br />
<br />
Note: some applications, like [[Gnome|Gnome 3]] may [[#Troubleshooting|override default hinting settings]].<br />
<br />
===Subpixel rendering===<br />
<br />
Subpixel rendering effectively triples the horizontal (or vertical) resolution for fonts by making use of subpixels. The autohinter and subpixel rendering are not designed to work together and should not be used in combination without the [[#Infinality]] patch set.<br />
<br />
Most monitors manufactured today use the Red, Green, Blue (RGB) specification. Fontconfig will need to know your monitor type to be able to display your fonts correctly.<br />
<br />
''RGB (most common), BGR, V-RGB (vertical), or V-BGR''<br />
<br />
To enable subpixel rendering:<br />
<br />
{{bc|<nowiki><br />
<match target="font"><br />
<edit name="rgba" mode="assign"><br />
<const>rgb</const><br />
</edit><br />
</match><br />
</nowiki>}}<br />
<br />
If you notice unusual colors around font's borders, the wrong subpixel arrangement might be configured. The [http://www.lagom.nl/lcd-test/subpixel.php Lagom subpixel layout test] web page can help identify it.<br />
<br />
====LCD filter====<br />
<br />
When using subpixel rendering, you should enable the LCD filter, which is designed to reduce colour fringing. This is described under [http://www.freetype.org/freetype2/docs/reference/ft2-lcd_filtering.html LCD filtering] in the FreeType 2 API reference. Different options are described under [http://www.freetype.org/freetype2/docs/reference/ft2-lcd_filtering.html#FT_LcdFilter FT_LcdFilter], and are illustrated by this [http://www.spasche.net/files/lcdfiltering/ LCD filter test] page.<br />
<br />
The {{ic|lcddefault}} filter will work for most users. Other filters are available that can be used in special situations: {{ic|lcdlight}}; a lighter filter ideal for fonts that look too bold or fuzzy, {{ic|lcdlegacy}}, the original Cairo filter; and {{ic|lcdnone}} to disable it entirely.<br />
<br />
{{bc|<nowiki><br />
<match target="font"><br />
<edit mode="assign" name="lcdfilter"><br />
<const>lcddefault</const><br />
</edit><br />
</match><br />
</nowiki>}}<br />
<br />
====Advanced LCD filter specification====<br />
<br />
If the available, built-in LCD filters are not satisfactory, it is possible to tweak the font rendering very specifically by building a custom freetype2 package and modifying the hardcoded filters. The [[Arch Build System]] can be used to build and install packages from source.<br />
<br />
First, refresh the freetype2 PKGBUILD as root:<br />
<br />
# abs extra/freetype2<br />
<br />
This example uses {{ic|/var/abs/build}} as the build directory, substitute it according to your personal ABS setup. Download and extract the freetype2 package as a regular user:<br />
<br />
$ cd /var/abs/build<br />
$ cp -r ../extra/freetype2 .<br />
$ cd freetype2<br />
$ makepkg -o<br />
<br />
Edit the file {{ic|src/freetype-VERSION/src/base/ftlcdfil.c}} and look up the definition of the constant {{ic|default_filter[5]}}:<br />
<br />
static const FT_Byte default_filter[5] =<br />
{ 0x10, 0x40, 0x70, 0x40, 0x10 };<br />
<br />
This constant defines a low-pass filter applied to the rendered glyph. Modify it as needed. Save the file, build and install the custom package:<br />
<br />
$ makepkg -e<br />
$ sudo pacman -Rd freetype2<br />
$ sudo pacman -U freetype2-VERSION-ARCH.pkg.tar.xz<br />
<br />
Reboot or restart X. The lcddefault filter should now render fonts differently.<br />
<br />
===Disable auto-hinter for bold fonts===<br />
<br />
The auto-hinter uses sophisticated methods for font rendering, but often makes bold fonts too wide. Fortunately, a solution can be turning off the autohinter for bold fonts while leaving it on for the rest:<br />
...<br />
<match target="font"><br />
<test name="weight" compare="more"><br />
<const>medium</const><br />
</test><br />
<edit name="autohint" mode="assign"><br />
<bool>false</bool><br />
</edit><br />
</match><br />
...<br />
<br />
=== Enable anti-aliasing only for bigger fonts ===<br />
<br />
''See also [http://sharpfonts.co.cc/ sharpfonts.co.cc] for related information.''<br />
<br />
Some users prefer the sharper rendering that anti-aliasing does not offer:<br />
<br />
{{bc|<nowiki><br />
...<br />
<match target="font"><br />
<edit name="antialias" mode="assign"><br />
<bool>false</bool><br />
</edit><br />
</match><br />
<br />
<match target="font" ><br />
<test name="size" qual="any" compare="more"><br />
<double>12</double><br />
</test><br />
<edit name="antialias" mode="assign"><br />
<bool>true</bool><br />
</edit><br />
</match><br />
<br />
<match target="font" ><br />
<test name="pixelsize" qual="any" compare="more"><br />
<double>16</double><br />
</test><br />
<edit name="antialias" mode="assign"><br />
<bool>true</bool><br />
</edit><br />
</match><br />
...<br />
</nowiki>}}<br />
<br />
===Replace fonts===<br />
<br />
The most reliable way to do this is to add an XML fragment similar to the one below. ''Using the "binding" attribute will give you better results'', for example, in Firefox where you may not want to change properties of font being replaced. This will cause Ubuntu to be used in place of Georgia:<br />
...<br />
<match target="pattern"><br />
<test qual="any" name="family"><string>georgia</string></test><br />
<edit name="family" mode="assign" binding="same"><string>Ubuntu</string></edit><br />
</match><br />
...<br />
An alternate approach is to set the "preferred" font, but ''this only works if the original font is not on the system'', in which case the one specified will be substituted:<br />
...<br />
< !-- Replace Helvetica with Bitstream Vera Sans Mono --><br />
< !-- Note, an alias for Helvetica should already exist in default conf files --><br />
<alias><br />
<family>Helvetica</family><br />
<prefer><family>Bitstream Vera Sans Mono</family></prefer><br />
<default><family>fixed</family></default><br />
</alias><br />
...<br />
<br />
===Disable bitmap fonts===<br />
<br />
To disable bitmap fonts in fontconfig, use {{ic|70-no-bitmaps.conf}} (which is not placed by fontconfig by default):<br />
<br />
# cd /etc/fonts/conf.d<br />
# rm 70-yes-bitmaps.conf<br />
# ln -s ../conf.avail/70-no-bitmaps.conf<br />
<br />
You may not need to remove {{ic|70-yes-bitmaps.conf}} if it does not exist. You can choose which fonts to replace bitmaps fonts with (Helvetica, Courier and Times bitmap mapts to TTF fonts) by:<br />
<br />
# cd /etc/fonts/conf.d<br />
# ln -s ../conf.avail/29-replace-bitmap-fonts.conf<br />
<br />
To disable embedded bitmap fonts for a specific font:<br />
<br />
<match target="font"><br />
<test qual="any" name="family"><br />
<string>Monaco</string><br />
</test><br />
<edit name="embeddedbitmap"><bool>false</bool></edit><br />
</match><br />
<br />
===Disable scaling of bitmap fonts===<br />
<br />
To disable scaling of bitmap fonts (which often makes them blurry), remove {{ic|/etc/fonts/conf.d/10-scale-bitmap-fonts.conf}}.<br />
<br />
===Create bold and italic styles for incomplete fonts===<br />
<br />
Freetype has the ability to automatically create ''italic'' and '''bold''' styles for fonts that do not have them, but only if explicitly required by the application. Given programs rarely send these requests, this section covers manually forcing generation of missing styles.<br />
<br />
Start by editing {{ic|/usr/share/fonts/fonts.cache-1}} as explained below. Store a copy of the modifications on another file, because a font update with {{ic|fc-cache}} will overwrite {{ic|/usr/share/fonts/fonts.cache-1}}.<br />
<br />
Assuming the Dupree font is installed:<br />
"dupree.ttf" 0 "Dupree:style=Regular:slant=0:weight=80:width=100:foundry=unknown:index=0:outline=True:''etc...''<br />
<br />
Duplicate the line, change {{ic|<nowiki>style=Regular</nowiki>}} to {{ic|<nowiki>style=Bold</nowiki>}} or any other style. Also change {{ic|<nowiki>slant=0</nowiki>}} to {{ic|<nowiki>slant=100</nowiki>}} for italic, {{ic|<nowiki>weight=80</nowiki>}} to {{ic|<nowiki>weight=200</nowiki>}} for bold, or combine them for '''''bold italic''''':<br />
"dupree.ttf" 0 "Dupree:style=Bold Italic:slant=100:weight=200:width=100:foundry=unknown:index=0:outline=True:''etc...''<br />
<br />
Now add necessary modifications to {{ic|$XDG_CONFIG_HOME/fontconfig/fonts.conf}}:<br />
{{bc|<nowiki><br />
...<br />
<match target="font"><br />
<test name="family" qual="any"><br />
<string>Dupree</string><br />
&lt;!-- other fonts here .... --&gt;<br />
</test><br />
<test name="weight" compare="more_eq"><int>140</int></test><br />
<edit name="embolden" mode="assign"><bool>true</bool></edit><br />
</match><br />
<br />
<match target="font"><br />
<test name="family" qual="any"><br />
<string>Dupree</string><br />
&lt;!-- other fonts here .... --&gt;<br />
</test><br />
<test name="slant" compare="more_eq"><int>80</int></test><br />
<edit name="matrix" mode="assign"><br />
<times><br />
<name>matrix</name><br />
<matrix><br />
<double>1</double><double>0.2</double><br />
<double>0</double><double>1</double><br />
</matrix><br />
</times><br />
</edit><br />
</match><br />
...<br />
</nowiki>}}<br />
{{Tip| Use the value 'embolden' for existing bold fonts in order to make them even bolder.}}<br />
<br />
===Change rule overriding===<br />
<br />
Fontconfig processes files in {{ic|/etc/fonts/conf.d}} in numerical order. This enables rules or files to override one another, but often confuses users about what file gets parsed last.<br />
<br />
To guarantee that personal settings take precedence over any other rules, change their ordering:<br />
# cd /etc/fonts/conf.d<br />
# mv 50-user.conf 99-user.conf<br />
<br />
This change seems however to be unnecessary for the most of the cases, because a user is given enough control by default to set up own font preferences, hinting and antialiasing properties, alias new fonts to generic font families, etc.<br />
<br />
===Example fontconfig configurations===<br />
<br />
Example fontconfig configurations can be found on this [[Font_Configuration/fontconfig_Examples|page]].<br />
<br />
A simple starting point:<br />
<br />
{{hc|/etc/fonts/local.conf|<nowiki><br />
<?xml version='1.0'?><br />
<!DOCTYPE fontconfig SYSTEM 'fonts.dtd'><br />
<fontconfig><br />
<match target="font"><br />
<br />
<edit mode="assign" name="rgba"><br />
<const>rgb</const><br />
</edit><br />
<br />
<edit mode="assign" name="hinting"><br />
<bool>true</bool><br />
</edit><br />
<br />
<edit mode="assign" name="hintstyle"><br />
<const>hintslight</const><br />
</edit><br />
<br />
<edit mode="assign" name="antialias"><br />
<bool>true</bool><br />
</edit><br />
<br />
<edit mode="assign" name="lcdfilter"><br />
<const>lcddefault</const><br />
</edit><br />
<br />
</match><br />
</fontconfig><br />
</nowiki>}}<br />
<br />
==Patched packages==<br />
<br />
These patched packages are available in the [[Arch User Repository|AUR]]. A few considerations:<br />
<br />
* Configuration is usually necessary.<br />
* The new font rendering will not kick in until applications restart.<br />
* Applications which [[Wikipedia:Static library|statically link]] to a library will not be affected by patches applied to the system library.<br />
<br />
===Infinality: the generic way===<br />
<br />
The infinality patchset aims to greatly improve freetype2 font rendering. It adds multiple new capabilities.<br />
<br />
*[http://www.infinality.net/blog/infinality-freetype-patches/ Home page].<br />
*[http://www.infinality.net/forum/ Forum].<br />
<br />
Infinality's settings are all configurable at runtime via environment variables in {{ic|/etc/profile.d/infinality-settings.sh}}, and include the following:<br />
<br />
*'''Emboldening Enhancement''': Disables Y emboldening, producing a much nicer result on fonts without bold versions. Works on native TT hinter and autohinter.<br />
*'''Auto-Autohint''': Automatically forces autohint on fonts that contain no TT instructions.<br />
*'''Autohint Enhancement''': Makes autohint snap horizontal stems to pixels. Gives a result that appears like a well-hinted truetype font, but is 100% patent-free (as far as I know).<br />
*'''Customized FIR Filter''': Select your own [http://www.infinality.net/forum/viewtopic.php?f=2&t=19 filter values] at run-time. Works on native TT hinter and autohinter.<br />
*'''Stem Alignment''': Aligns bitmap glyphs to optimized pixel boundaries. Works on native TT hinter and autohinter.<br />
*'''Pseudo Gamma Correction''': Lighten and darken glyphs at a given value, below a given size. Works on native TT hinter and autohinter.<br />
*'''Embolden Thin Fonts''': Embolden thin or light fonts so that they are more visible. Works on autohinter.<br />
*'''Force Slight Hinting''': Force slight hinting even when programs want full hinting. If you use the local.conf I provide (included in infinality-settings fedora package) you will notice nice improvements on @font-face fonts.<br />
*'''ChromeOS Style Sharpening''': ChromeOS uses a patch to sharpen the look of fonts. This is now included in the infinality patchset.<br />
<br />
A number of presets are included and can be used by setting the USE_STYLE variable in {{ic|/etc/profile.d/infinality-settings.sh}}.<br />
<br />
{{Note|1=The user bohoomil maintains a very good configuration in his [https://github.com/bohoomil/fontconf github repo] which is available as a [https://aur.archlinux.org/packages/fontconfig-infinality-ultimate/ package] in the AUR.}}<br />
<br />
{{Note|1=Install {{AUR|grip-git}} from AUR to have a realtime preview.}}<br />
<br />
{{AUR|freetype2-infinality}} can be installed from the [[Arch User Repository|AUR]]. Additionally, if you are using {{pkg|lib32-freetype2}} from [multilib], replace it with {{AUR|lib32-freetype2-infinality}} from the AUR. The AUR also contains a Git version of freetype2 that builds the latest development snapshot of freetype2 with the Infinality patchset: {{AUR|freetype2-git-infinality}}, {{AUR|lib32-freetype2-git-infinality}}.<br />
<br />
It is recommended to also install {{AUR|fontconfig-infinality}} to enable selection of predefined font substitution styles and antialiasing settings, apart from the rendering settings of the engine itself. After doing so, you can select the font style (win7, winxp, osx, linux, ...) with:<br />
# infctl setstyle<br />
<br />
If you set e.g. win7 or osx you need the corresponding fonts installed.<br />
<br />
{{Note|Default infinality settings can cause some programs to display fonts at 72 DPI instead of 96. If you notice a problem open /etc/fonts/infinality/infinality.conf search for the section on DPI and change 72 to 96. This problem can specifically affect conky causing the fonts to appear smaller than they should. Thus not aligning properly with images. }}<br />
<br />
{{Note|''The README for {{AUR|fontconfig-infinality}} says that /etc/fonts/local.conf should either not exist, or have no infinality-related configurations in it. The local.conf is now obsolete and completely replaced by this configuration.''}}<br />
<br />
for more information see this article: http://www.infinality.net/forum/viewtopic.php?f=2&t=77<br />
<br />
*[http://www.infinality.net/blog/infinality-freetype-patches/ Home page].<br />
<br />
===Infinality: the easy way===<br />
<br />
bohoomil also maintains '''infinality-bundle''' repository, offering three basic libraries (freetype2-infinality-ultimate, fontconfig-infinality-ultimate & cairo-infinality-ultimate) as pre-patched, pre-configured and pre-built binaries for all architectures (i686, x86_64, multilib). Using infinality-bundle makes the whole installation & configuration process dramatically simplified: all one has to do is install the three packages with<br />
<br />
{{bc|# pacman -S foo-infinality-ultimate}}<br />
<br />
which will replace the corresponding, generic Arch libraries (i.e. freetype2-infinality-ultimate will be used instead of freetype2, fontconfig-infinality-ultimate instead of fontconfig and fontconfig-infinality-ultimate from the AUR, and cairo-infinality-ultimate instead of the regular cairo). The libraries are fully compatible with the Arch packages and are meant to be used as drop-in replacements for them. No post installation/upgrade steps are required for most use scenarios: everything should work out of the box.<br />
<br />
To use the repository, add <br />
<br />
{{bc|1=[infinality-bundle]<br />
SigLevel = Never<br />
Server = http://bohoomil.cu.cc/infinality-bundle/$arch}}<br />
<br />
to your /etc/pacman.conf and issue<br />
<br />
{{bc|# pacman -Syy}}<br />
<br />
If you want to have access to multilib versions, add the following, too:<br />
<br />
{{bc|1=[infinality-bundle-multilib]<br />
SigLevel = Never<br />
Server = http://bohoomil.cu.cc/infinality-bundle-multilib/$arch}}<br />
<br />
In case of server down times, there is always a backup copy of the repository available via [https://www.dropbox.com/sh/ugmxbui00chidox/njDKnTG49W Dropbox].<br />
<br />
When installing some packages (like [https://www.archlinux.org/packages/?sort=&q=libgdiplus&maintainer=&flagged= libgdiplus]), you may encounter an error:<br />
<br />
{{bc|:: cairo and cairo-infinality-ultimate are in conflict. Remove cairo-infinality-ultimate? [y/N] n<br />
error: unresolvable package conflicts detected<br />
error: failed to prepare transaction (conflicting dependencies)}}<br />
<br />
If this happens, install the new package with {{bc|# pacman -Sd foo}} instead.<br />
<br />
For more information, see [http://bohoomil.github.io/ib.html infinality-bundle user notes].<br />
<br />
A support thread in the Forums is available [https://bbs.archlinux.org/viewtopic.php?id=162098 here].<br />
<br />
===Ubuntu===<br />
<br />
Ubuntu adds extra configurations, and occasionally patches to the font rendering libraries.<br />
<br />
Install the patched packages from the [[Arch User Repository|AUR]], the package names are: {{AUR|freetype2-ubuntu}} {{AUR|fontconfig-ubuntu}} {{AUR|cairo-ubuntu}}.<br />
<br />
The global configuration will need to be added. See [[#Example fontconfig configurations]] for a starting point.<br />
<br />
===Reverting to unpatched packages===<br />
<br />
To restore the unpatched packages, reinstall the originals:<br />
<br />
# pacman -S --asdeps freetype2 cairo fontconfig<br />
<br />
==Applications without fontconfig support==<br />
<br />
Some applications like [[URxvt]] will ignore fontconfig settings. This is very apparent when using the infinality patches which are heavily reliant on proper configuration. You can work around this by using {{ic|~/.Xresources}}, but it is not nearly as flexible as fontconfig. Example (see [[#Fontconfig configuration]] for explanations of the options):<br />
<br />
{{hc|~/.Xresources|<nowiki><br />
Xft.autohint: 0<br />
Xft.lcdfilter: lcddefault<br />
Xft.hintstyle: hintfull<br />
Xft.hinting: 1<br />
Xft.antialias: 1<br />
Xft.rgba: rgb<br />
</nowiki>}}<br />
<br />
Make sure the settings are loaded properly when X starts with {{ic|xrdb -q}} (see [[Xresources]] for more information).<br />
<br />
==Troubleshooting==<br />
<br />
=== Distorted fonts ===<br />
<br />
{{Note|96 DPI is not a standard. You should use your monitor's actual DPI to get proper font rendering, especially when using subpixel rendering.}}<br />
<br />
If fonts are still unexpectedly large or small, poorly proportioned or simply rendering poorly, fontconfig may be using the incorrect DPI.<br />
<br />
Fontconfig should be able to detect DPI parameters as discovered by the Xorg server. You can check the automatically discovered DPI with {{ic|xdpyinfo}} (provided by the {{pkg|xorg-xdpyinfo}} package):<br />
<br />
{{hc|<nowiki>$ xdpyinfo | grep dots</nowiki>| resolution: 102x102 dots per inch}}<br />
<br />
If the DPI is detected incorrectly (usually due to an incorrect monitor EDID), you can specify it manually in the Xorg configuration, see [[Xorg#Display Size and DPI]]. This is the recommended solution, but it may not work with buggy drivers.<br />
<br />
Fontconfig will default to the Xft.dpi variable if it is set. Xft.dpi is usually set by desktop environments (usually to Xorg's DPI setting) or manually in {{ic|~/.Xdefaults}} or {{ic|~/.Xresources}}. Use xrdb to query for the value:<br />
<br />
{{hc|<nowiki>$ xrdb -query | grep dpi</nowiki>|Xft.dpi: 102}}<br />
<br />
Those still having problems can fall back to manually setting the DPI used by fontconfig:<br />
<br />
...<br />
<!-- Setup for DPI=96 --><br />
<match target="pattern"><br />
<edit name="dpi" mode="assign"><double>102</double></edit><br />
</match><br />
...<br />
<br />
===Older GTK and QT applications===<br />
<br />
Modern GTK apps enable Xft by default but this was not the case before version 2.2. If it is not possible to update these applications, force Xft for old [[GNOME]] applications by adding to {{ic|~/.bashrc}}:<br />
<br />
export GDK_USE_XFT=1<br />
<br />
For older QT applications:<br />
<br />
export QT_XFT=true<br />
<br />
===Applications overriding hinting===<br />
Some applications may override default fontconfig hinting and anti-aliasing settings. This may happen with [[Gnome]] 3, for example. Use the specific configuration program for the application in such cases. For gnome, try {{pkg|gnome-tweak-tool}}.<br />
<br />
==See also==<br />
*[http://www.x.org/X11R6.8.2/doc/fonts.html Fonts in X11R6.8.2] - Official Xorg font information<br />
*[http://freetype.sourceforge.net/freetype2/ FreeType 2 Overview]<br />
*[https://forums.gentoo.org/viewtopic-t-723341.html Gentoo font-rendering thread]</div>Silencerhttps://wiki.archlinux.org/index.php?title=Improving_performance&diff=256361Improving performance2013-05-08T12:51:03Z<p>Silencer: </p>
<hr />
<div>[[Category:Hardware]]<br />
[[Category:System administration]]<br />
[[es:Maximizing Performance]]<br />
[[ja:Maximizing Performance]]<br />
[[ru:Maximizing Performance]]<br />
[[zh-CN:Maximizing Performance]]<br />
This article is a retrospective analysis and basic rundown about gaining performance in Arch Linux.<br />
<br />
==The basics==<br />
<br />
===Know your system===<br />
The best way to tune a system is to target the bottlenecks, that is the subsystems that limit the overall speed. They usually can be identified by knowing the specifications of the system, but there are some basic indications:<br />
* If the computer becomes slow when big applications, like OpenOffice.org and Firefox, are running at the same time, then there is a good chance the amount of RAM is insufficient. To verify available RAM, use this command, and check for the line beginning with -/+buffers:<br />
$ free -m<br />
* If boot time is really slow, and if applications take a lot of time to load the first time they are launched, but run fine afterwards, then the hard drive is probably too slow. The speed of a hard drive can be measured using the hdparm command:<br />
$ hdparm -t /dev/sdx<br />
This is only the pure read speed of the hard drive, and is not a valid benchmark, but a value superior to 40MB/s (assuming drive tested while idle) can be considered decent on an average system. hdparm can be found in the [[Official Repositories]].<br />
* If the CPU load is consistently high even when RAM is available, then lowering CPU usage should be a priority. CPU load can be monitored in many ways, like using the top command:<br />
$ top<br />
* If the only applications lagging are the ones using direct rendering, meaning they use the graphic card, like video players and games, then improving the graphic performance should help. First step would be to verify if direct rendering simply is not enabled. This is indicated by the glxinfo command:<br />
$ glxinfo | grep direct<br />
glxinfo is part of mesa-demos package.<br />
<br />
===The first thing to do===<br />
The simplest and most efficient way of improving overall performance is to run lightweight environments and applications.<br />
* Use a [[Window Manager|window manager]] instead of a [[Desktop Environment]]. Choices include [[dwm]], [[wmii]], [[Awesome]], [[Openbox]], [[Fluxbox]] and [[JWM]].<br />
* Choose a minimal Desktop Environment over a heavier one like [[GNOME]] or [[KDE]]. Something like [[LXDE]] or [[Xfce]].<br />
* Using lightweight applications. Search [[Common Applications]] for console applications and the Light and Fast Applications Awards threads in the forum: [https://bbs.archlinux.org/viewtopic.php?id=41168 2007], [https://bbs.archlinux.org/viewtopic.php?id=67951 2008], [https://bbs.archlinux.org/viewtopic.php?id=78490 2009], [https://bbs.archlinux.org/viewtopic.php?id=88515 2010], [https://bbs.archlinux.org/viewtopic.php?id=111878 2011], and [https://bbs.archlinux.org/viewtopic.php?id=138281 2012]<br />
* Remove unnecessary [[daemons]].<br />
<br />
===Compromise===<br />
Almost all tuning brings drawbacks. Lighter applications usually come with less features and some tweaks may make a system unstable, or simply require time to implement and maintain. This page tries to highlight those drawbacks, but the final judgment rests on the user.<br />
<br />
===Benchmarking===<br />
The effects of optimization are often difficult to judge. They can however be measured by [[benchmarking]] tools<br />
<br />
==Storage devices==<br />
===Device Layout===<br />
One of the biggest performance gains comes from having multiple storage devices in a layout that spreads the operating system work around. Having {{ic|/}} {{ic|/home}} {{ic|/var}} and {{ic|/usr}} on separate disks is dramatically faster than a single disk layout where they are all on the same hard drive.<br />
<br />
====Swap Files====<br />
Creating your swap files on a separate disk can also help quite a bit, especially if your machine swaps frequently. It happens if you do not have enough RAM for your environment. Using KDE with all the features and applications that come along may require several GiB of memory, whereas a tiny window manager with console applications will perfectly fit in less than 512 MiB of memory.<br />
<br />
====RAID Benefits====<br />
If you have multiple disks (2 or more) available, you can set them up as a software [[RAID]] for serious speed improvements. In a RAID 0 array there is no redundancy in case of drive failure, but for each additional disk you add to the array, the speed of the disk becomes that much faster. The smart choice is to use RAID 5 which offers both speed and data protection.<br />
<br />
====Multiple Hardware Paths====<br />
An internal hardware path is how the storage device is connected to your motherboard. There are different ways to connect to the motherboard such as TCP/IP through a NIC, plugged in directly using PCIe/PCI, Firewire, Raid Card, USB, etc. By spreading your storage devices across these multiple connection points you maximize the capabilities of your motherboard, for example 6 hard-drives connected via USB would be much much slower than 3 over USB and 3 over Firewire. The reason is that each entry path into the motherboard is like a pipe, and there is a set limit to how much can go through that pipe at any one time. The good news is that the motherboard usually has several pipes.<br />
<br />
More Examples<br />
# Directly to the motherboard using pci/PCIe/ata<br />
# Using an external enclosure to house the disk over USB/Firewire<br />
# Turn the device into a network storage device by connecting over tcp/ip<br />
<br />
Note also that if you have a 2 USB ports on the front of your machine, and 4 USB ports on the back, and you have 4 disks, it would probably be fastest to put 2 on front/2 on back or 3 on back/1 on front. This is because internally the front ports are likely a separate Root Hub than the back, meaning you can send twice as much data by using both than just 1. Use the following commands to determine the various paths on your machine.<br />
<br />
{{hc|USB Device Tree|$ lsusb -tv}}<br />
<br />
{{hc|PCI Device Tree|$ lspci -tv}}<br />
<br />
===Partitioning===<br />
The partition layout can influence the system's performance. Sectors at the beginning of the drive (closer to the center of the disk) are faster than those at the end. Also, a smaller partition requires less movements from the drive's head, and so speed up disk operations. Therefore, it is advised to create a small partition (10gb, more or less depending on your needs) only for your system, as near to the beginning of the drive as possible. Other data (pictures, videos) should be kept on a separate partition, and this is usually achieved by separating the home directory (/home/user) from the system (/).<br />
<br />
===Choosing and tuning your filesystem===<br />
Choosing the best filesystem for a specific system is very important because each has its own strengths. The [[Beginner%27s_Guide#Filesystem_types|beginner's guide]] provides a short summary of the most popular ones. You can also find relevant articles [[:Category:File systems|here]].<br />
<br />
====Summary====<br />
*XFS: Excellent performance with large files. Low speed with small files. A good choice for /home.<br />
*Ext3: Average performance, reliable.<br />
*Ext4: Great overall performance, reliable, has performance issues with sqlite and some other databases.<br />
*JFS: Good overall performance, very low CPU usage, extremely fast resume after power failure.<br />
*Btrfs: Probably best overall performance (with compression) and lots of features. Still in heavy development and fully supported, but considered as unstable. Do not use this filesystem yet unless you know what you are doing and are prepared for potential data loss.<br />
<br />
====Mount options====<br />
Mount options offer an easy way to improve speed without reformatting. They can be set using the mount command:<br />
$ mount -o option1,option2 /dev/partition /mnt/partition<br />
To set them permanently, you can modify /etc/fstab to make the relevant line look like this:<br />
/dev/partition /mnt/partition partitiontype option1,option2 0 0<br />
The mount options {{Ic|noatime,nodiratime}} are known for improving performance on almost all file-systems. The former is a superset of the latter (which applies to directories only -- {{Ic|noatime}} applies to both files and directories). In rare cases, for example if you use mutt, it can cause minor problems. You can instead use the {{Ic|relatime}} option (NB relatime is the default in >2.6.30)<br />
<br />
====Ext3====<br />
See [[Ext3]].<br />
<br />
====Ext4====<br />
See [[Ext4#Tips_and_tricks | Ext4]].<br />
<br />
====JFS====<br />
See [[JFS Filesystem#Optimizations| JFS Filesystem]].<br />
<br />
====XFS====<br />
For optimal speed, just create an XFS file-system with:<br />
$ mkfs.xfs /dev/thetargetpartition<br />
Yep, so simple — since all of the [http://xfs.org/index.php/XFS_FAQ#Q:_I_want_to_tune_my_XFS_filesystems_for_.3Csomething.3E "boost knobs" are already "on" by default].<br />
<br />
==== Reiserfs ====<br />
<br />
The {{Ic|<nowiki>data=writeback</nowiki>}} mount option improves speed, but may corrupt data during power loss. The {{Ic|notail}} mount option increases the space used by the filesystem by about 5%, but also improves overall speed. You can also reduce disk load by putting the journal and data on separate drives. This is done when creating the filesystem: <br />
<br />
$ mkreiserfs –j /dev/hda1 /dev/hdb1<br />
<br />
Replace /dev/hda1 with the partition reserved for the journal, and /dev/hdb1 with the partition for data. You can learn more about reiserfs with this [http://www.funtoo.org/en/articles/linux/ffg/2/ article].<br />
<br />
====Btrfs====<br />
See [[Btrfs#Defragmentation|defragmentation]] and [[Btrfs#Compression|compression]].<br />
<br />
===Compressing /usr===<br />
{{Note|As of version 3.0 of the Linux kernel, aufs2 is no longer supported.}}<br />
{{out of date|aufs is no longer in the official repos. Also, read the Note box above.}}<br />
A way to speed up reading from the hard drive is to compress the data, because there is less data to be read. It must however be decompressed, which means a greater CPU load. Some file systems support transparent compression, most notably Btrfs and reiserfs4, but their compression ratio is limited by the 4k block size. A good alternative is to compress {{ic|/usr}} in a squashfs file, with a 64k(128k) block size, as instructed in this [http://forums.gentoo.org/viewtopic-t-646289.html Gentoo forums thread]. What this tutorial does is basically to compress the {{ic|/usr}} folder into a compressed squashfs file-system, then mounts it with aufs. A lot of space is saved, usually two thirds of the original size of {{ic|/usr}}, and applications load faster. However, each time an application is installed or reinstalled, it is written uncompressed, so {{ic|/usr}} must be re-compressed periodically. Squashfs is already in the kernel, and aufs2 is in the official repositories, so no kernel compilation is needed if using the stock kernel.<br />
Since the linked guide is for Gentoo, the next commands outline the steps specifically for Arch. To get it working, [[pacman|install]] the packages {{pkg|aufs2}} and {{pkg|squashfs-tools}}. These packages provide the aufs-modules and some userspace-tools for the squash-filesystem.<br />
<br />
Now we need some extra directories where we can store the archive of {{ic|/usr}} as read-only and another folder where we can store the data changed after the last compression as writeable:<br />
# mkdir -p /squashed/usr/{ro,rw}<br />
Now that we got a rough setup you should perform a complete system-upgrade since every change of content in {{ic|/usr}} after the compression will be excluded from this speedup. If you use prelink you should also perform a complete prelink before creating the archive. Now it is time to invoke the command to compress {{ic|/usr}}:<br />
# mksquashfs /usr /squashed/usr/usr.sfs -b 65536<br />
These parameters/options are the ones suggested by the Gentoo link but there might be some room for improvement using some of the options described [http://www.tldp.org/HOWTO/SquashFS-HOWTO/mksqoverview.html#mksqusing here].<br />
Now to get the archive mounted together with the writeable folder it is necessary to edit {{ic|/etc/fstab}} and add the following lines:<br />
/squashed/usr/usr.sfs /squashed/usr/ro squashfs loop,ro 0 0 <br />
usr /usr aufs udba=reval,br:/squashed/usr/rw:/squashed/usr/ro 0 0<br />
Now you should be done and able to reboot. The original author suggests to delete all the old content of {{ic|/usr}}, but this might cause some problems if anything goes wrong during some later re-compression. It is safer to leave the old files in place.<br />
<br />
A [https://bbs.archlinux.org/viewtopic.php?pid=714052 Bash script] has been created that will automate the process of re-compressing (read updating) the archive since the tutorial is meant for Gentoo and some options do not correlate to what they should be in Arch.<br />
<br />
===Tuning for an SSD===<br />
[[SSD#Tips_for_Maximizing_SSD_Performance]]<br />
<br />
===RAM disks / tuning for really slow disks===<br />
* [http://cs.joensuu.fi/~mmeri/usbraid/ USB stick RAID]<br />
* [https://bbs.archlinux.org/viewtopic.php?pid=493773#p493773 Combine RAM disk with disk in RAID]<br />
<br />
==CPU==<br />
The only way to directly improve CPU speed is overclocking. As it is a complicated and risky task, it is not recommended for anyone except experts. The best way to overclock is through the BIOS. When purchasing your system, keep in mind that most Intel motherboards are notorious for disabling the capacity to overclock.<br />
<br />
Many Intel i5 and i7 chips, even when overclocked properly through the BIOS or UEFI interface, will not report the correct clock frequency to acpi_cpufreq and most other utilities. This will result in excessive messages in dmesg about delays unless the module acpi_cpufreq is unloaded and blacklisted. The only tool known to correctly read the clock speed of these overclocked chips under Linux is i7z. The i7z package is available in the community repo and i7z-svn is available in the AUR.<br />
<br />
A way to modify performance ([http://lkml.org/lkml/2009/9/6/136 ref]) is to use Con Kolivas' desktop-centric kernel patchset, which, among other things, replaces the Completely Fair Scheduler (CFS) with the Brain Fuck Scheduler (BFS).<br />
<br />
Kernel PKGBUILDs that include the BFS patch can be installed from the [[AUR]] or [[Unofficial User Repositories]]. See the respective pages for {{AUR|linux-ck}} and [[Linux-ck]] wiki page, {{AUR|linux-bfs}} or {{AUR|linux-pf}} for more information on their additional patches.<br />
<br />
{{Note|BFS/CK are designed for desktop/laptop use and not servers. They provide low latency and work well for 16 CPUs or less. Also, Con Kolivas suggests setting HZ to 1000. For more information, see the [http://ck.kolivas.org/patches/bfs/bfs-faq.txt BFS FAQ] and [http://users.on.net/~ckolivas/kernel/ Kernel patch homepage of Con Kolivas].}}<br />
<br />
===Verynice===<br />
[[Verynice]] is a daemon, available in the [[AUR]] as {{AUR|verynice}}, for dynamically adjusting the nice levels of executables. The nice level represents the priority of the executable when allocating CPU resources. Simply define executables for which responsiveness is important, like X or multimedia applications, as ''goodexe'' in {{ic|/etc/verynice.conf}}. Similarly, CPU-hungry executables running in the background, like make, can be defined as ''badexe''. This prioritization greatly improves system responsiveness under heavy load.<br />
<br />
===Ulatencyd===<br />
[[Ulatencyd]] is a daemon that controls how the Linux kernel will spend its resources on the running processes. It uses dynamic cgroups to give the kernel hints and limitations on processes. It supports prioritizing processes for disk I/O as well as CPU shares, and uses more clever heuristics than Verynice. In addition, it comes with a good set of configs out of the box.<br />
<br />
One note of warning, by default it changes the default scheduler of all block devices to cfq, to disable behavior see [[Ulatencyd]].<br />
<br />
==Graphics==<br />
<br />
===Xorg.conf configuration===<br />
Graphic performance heavily depends on the settings in {{ic|/etc/X11/xorg.conf}}. There are tutorials for [[Nvidia]], [[ATI]] and [[Intel]] cards. Improper settings may stop Xorg from working, so caution is advised.<br />
<br />
===Driconf===<br />
Driconf is a small utility that can be found in the [[official repositories]] that allows you to change the direct rendering settings for open source drivers. Enabling HyperZ can drastically improve performance.<br />
<br />
===GPU Overclocking===<br />
Overclocking a graphics card is typically more expedient than with a CPU, since there are readily accessible software packages which allow for on-the-fly GPU clock adjustments. For ATI users, get {{AUR|rovclock}}, and Nvidia users should get nvclock in the extra repository. Intel chipsets users can install [http://www.gmabooster.com/ GMABooster] from with the {{AUR|gmabooster}} AUR package.<br />
<br />
The changes can be made permanent by running the appropriate command after X boots, for example by adding it to {{ic|~/.xinitrc}}. A safer approach would be to only apply the overclocked settings when needed.<br />
<br />
==RAM and swap==<br />
=== Relocate files to tmpfs ===<br />
Relocate files, such as your browser profile, to a [[Wikipedia:tmpfs|tmpfs]] file system, including {{ic|/tmp}}, or {{ic|/dev/shm}} for improvements in application response as all the files are now stored in RAM.<br />
<br />
Use an active management script for maximal reliability and ease of use. <br />
<br />
Refer to the [[Profile-sync-daemon]] wiki article for more information on syncing browser profiles.<br />
<br />
Refer to the [[Anything-sync-daemon]] wiki article for more information on syncing any specified folder.<br />
<br />
=== Swappiness ===<br />
<br />
The swappiness represent how much the kernel prefers swap to RAM. Setting it to a very low value, meaning the kernel will almost always use RAM, is known to improve responsiveness on many systems. To do that, simply add these lines to {{ic|/etc/sysctl.conf}}:<br />
<br />
vm.swappiness=20<br />
vm.vfs_cache_pressure=50<br />
<br />
To test and more on why this may work, take a look at this [http://rudd-o.com/en/linux-and-free-software/tales-from-responsivenessland-why-linux-feels-slow-and-how-to-fix-that article].<br />
<br />
===Compcache / Zram ===<br />
[https://code.google.com/p/compcache/ Compcache], nowadays replaced by the '''zram''' kernel module, creates a device in RAM and compresses it. If you use for swap means that part of the RAM can hold much more information but uses more CPU. Still, it is much quicker than swapping to a hard drive. If a system often falls back to swap, this could improve responsiveness. Zram is in mainline staging (therefore its not stable yet, use with caution).<br />
<br />
The AUR package {{aur|zramswap}} provides an automated script fot setting up such swap devices with optimal settings for your system (such as RAM size and CPU core number). The script creates one zram device per CPU core with a total space equivalent to the RAM available. To do this automatically on every boot:<br />
<br />
* If you use [[rc.conf|initscripts]], add {{ic|zramswap}} to the DAEMONS array in {{ic|/etc/rc.conf}}.<br />
* If you use [[systemd]], enable {{ic|zramswap.service}} via systemctl. <br />
<br />
You will have a compressed swap with higher priority than your regular swap which will utilize multiple CPU cores for compessing data.<br />
<br />
{{Tip|Using zram is also a good way to reduce disk read/write cycles due to swap on SSDs.}}<br />
{{Note|The service file (and rc.d script) have been moved to a separate package in the AUR called [https://aur.archlinux.org/packages/zramswap/ zramswap].}}<br />
<br />
===Using the graphic card's RAM===<br />
In the unlikely case that you have very little RAM and a surplus of video RAM, you can use the latter as swap. See [[Swap on video ram]].<br />
<br />
=== Preloading ===<br />
Preloading is the action of putting and keeping target files into the RAM. The benefit is that preloaded applications start more quickly because reading from the RAM is always quicker than from the hard drive. However, part of your RAM will be dedicated to this task, but no more than if you kept the application open. Therefore preloading is best used with large and often-used applications like Firefox and OpenOffice.<br />
==== Go-preload ====<br />
[https://aur.archlinux.org/packages.php?ID=34207 Go-preload] is a small daemon created in the [http://forums.gentoo.org/viewtopic-t-789818-view-next.html?sid=5457cff93039fc7d4a3e445ef90f9821 Gentoo forum]. To use it, first run this command in a terminal for each program you want to preload at boot:<br />
# gopreload-prepare program<br />
Then, as instructed, press Enter when the program is fully loaded. This will add a list of files needed by the program in {{ic|/usr/share/gopreload/enabled}}. To load all lists at boot, add {{ic|gopreload}} to your DAEMONS array in {{ic|/etc/rc.conf}}. To disable the loading of a program, remove the appropriate list in {{ic|/usr/share/gopreload/enabled}} or move it to {{ic|/usr/share/gopreload/disabled}}.<br />
<br />
====Preload====<br />
A more automated approach is used by [[Preload]]. All you have to do is enable it with this command:<br />
# systemctl enable preload<br />
It will monitor the most used files on your system, and with time build its own list of files to preload at boot.<br />
<br />
====Readahead====<br />
[[Readahead]] is a tool that can cache files before they are needed and help accelerate program loading.<br />
<br />
==Boot time==<br />
You can find tutorials with good tips in the article [[Improve Boot Performance]].<br />
<br />
===Suspend to RAM===<br />
The best way to reduce boot time is not booting at all. Consider [[Suspend to RAM|suspending your system to RAM]] instead.<br />
<br />
==Application-specific tips==<br />
===Firefox===<br />
The [[Firefox Tweaks]] article offers good tips; notably [[Firefox Tweaks#Turning off anti-phishing|turning off anti-phishing]] and [[Firefox Tweaks#Defragment the profile's SQLite databases|cleaning the SQlite database]]. See also: [[Firefox Ramdisk|Firefox in Ramdisk]].<br />
<br />
Firefox in the official repositories is built with the profile guided optimization flag enabled. You may want to use it in your custom build.<br />
To do this append<br />
ac_add_options --enable-profile-guided-optimization<br />
to your mozconfig.<br />
<br />
===Gcc/Makepkg===<br />
See [[Ccache]].<br />
<br />
===LibreOffice===<br />
See [[LibreOffice#Speed up LibreOffice|Speed up LibreOffice]].<br />
<br />
===Pacman===<br />
See [[Improve Pacman Performance]].<br />
<br />
===SSH===<br />
See [[SSH#Speeding up SSH|Speed up SSH]].<br />
<br />
==Laptops==<br />
See [[Laptop]].</div>Silencerhttps://wiki.archlinux.org/index.php?title=CD_Burning&diff=106863CD Burning2010-05-22T02:10:19Z<p>Silencer: brasero not finding blank discs solution</p>
<hr />
<div>[[Category:Utilities (English)]]<br />
[[Category:HOWTOs (English)]]<br />
{{i18n|CD Burning}}<br />
{{Article summary start}}<br />
{{Article summary text|This document outlines various methods of burning CDs.}}<br />
{{Article summary heading|Related}}<br />
{{Article summary wiki|DVD Writing}}<br />
{{Article summary end}}<br />
<br />
== Command-line CD-burning == <br />
===Install CD-burning utilities===<br />
From http://www.cdrkit.org/:<br />
<br />
:''<tt>cdrkit</tt> is a suite of programs for recording CDs and DVDs, blanking CD-RW media, creating ISO-9660 filesystem images, extracting audio CD data, and more. The programs included in the <tt>cdrkit</tt> package were originally derived from several sources, most notably <tt>mkisofs</tt> by Eric Youngdale and others, <tt>cdda2wav</tt> by Heiko Eissfeldt, and <tt>cdrecord</tt> by Jörg Schilling. However, <tt>cdrkit</tt> is not affiliated with any of these authors; it is now an independent project.<br />
<br />
The {{Package Official|cdrkit}} package is available in [extra]:<br />
# pacman -S cdrkit<br />
<br />
If you intend to use {{Package Official|cdrdao}} (for writing {{Filename|cue}}/{{Filename|bin}} files to CD)<br />
# pacman -S cdrdao<br />
<br />
{{Note|If you face any issues with <tt>cdrkit</tt>, it is recommended to install {{Package AUR|cdrtools}} from the [[AUR]] (<tt>cdrkit</tt> is a fork of <tt>cdrtools</tt>). <tt>cdrtools</tt> is being actively developed and supports CD, DVD and BluRay burning along with complete CDRWIN {{Filename|cue}}/{{Filename|bin}} support. <tt>cdrtools</tt> does not depend on <tt>cdrdao</tt>.}}<br />
<br />
{{Note|Make sure that you build a package using makepkg and install with pacman. Pacman wrappers like bauerbill may resolve to cdrkit instead.}}<br />
<br />
===Setting permissions===<br />
Users that should be able to use CD/DVD burning devices must have permissions to access the devices. If you are using [[udev]] (which is default in Arch Linux kernels), you only need to add the user(s) to the optical [[group]]:<br />
# gpasswd -a <username> optical<br />
<br />
Log out and back in for the changes to take effect.<br />
<br />
===Modifying the CD-RW===<br />
For the remainder of this section the name of your recording device is assumed to be {{Filename|/dev/cdrw}}. If that is not the case, modify the commands accordingly. In order to write to the CD it needs to be unmounted. If it is not, <tt>wodim</tt> will give you an error message. <br />
<br />
===Erasing CD-RW===<br />
CD-RW media usually need to be erased before you can write new data on it. To blank CD-RW medium use this command:<br />
$ wodim -v dev=/dev/cdrw -blank=fast<br />
<br />
As you might have guessed, this blanks your medium really fast, but you can also use some other options, just replace the word ''fast'' with one of the following:<br />
<br />
;all: blank the entire disk<br />
;disc: blank the entire disk<br />
;disk: blank the entire disk<br />
;fast: minimally blank the entire disk (PMA, TOC, pregap)<br />
;minimal: minimally blank the entire disk (PMA, TOC, pregap)<br />
;track: blank a track<br />
;unreserve: unreserve a track<br />
;trtail: blank a track tail<br />
;unclose: unclose last session<br />
;session: blank last session<br />
<br />
===Burning an iso image===<br />
To burn an iso-image run:<br />
$ wodim -v dev=/dev/cdrw isoimage.iso<br />
<br />
===Burning an audio CD===<br />
# Create your audio tracks and store them as uncompressed, 16-bit stereo {{Filename|wav}} files.<br />
# Name the audio files in a manner that will cause them to be listed in the desired track order when listed alphabetically, such as {{Filename|01.wav}}, {{Filename|02.wav}}, {{Filename|03.wav}}, etc.<br />
# Use the following command to burn the wav files as an audio CD:<br />
$ wodim -v -pad speed=1 dev=/dev/cdrw -dao -swab *.wav<br />
<br />
===Burning a bin/cue===<br />
To burn a bin/cue image run:<br />
$ cdrdao write --device /dev/cdrw image.cue<br />
<br />
===Making an iso image from an existing CD===<br />
To copy an existing CD just type:<br />
$ dd if=/dev/cdrw of=/home/user/isoimage.iso<br />
or even simpler:<br />
$ cat /dev/cdrw > isoimage.iso<br />
<br />
Or use the {{Codeline|readcd}} program, also in the <tt>cdrkit</tt> package<br />
$ readcd -v dev=/dev/cdrw -f isoimage.iso<br />
<br />
If the original CD was bootable it will be a bootable image.<br />
<br />
====TOC/CUE/BIN for mixed-mode disks====<br />
ISO images only store a single data track. If you want to create an image of a mixed-mode disk (data track with multiple audio tracks) then you need to make a TOC/BIN pair:<br />
$ cdrdao read-cd --read-raw --datafile IMAGE.bin --driver generic-mmc:0x20000 --device /dev/cdrom IMAGE.toc<br />
<br />
Some software only likes CUE/BIN pair, you can make a CUE sheet with {{Codeline|toc2cue}} (part of <tt>cdrdao</tt>):<br />
$ toc2cue IMAGE.toc IMAGE.cue<br />
<br />
===Making an iso image from existing files on harddisk===<br />
To make an iso image just copy the needed files to one folder, then do:<br />
$ mkisofs -V volume_name -J -r -o isoimage.iso ~/folder<br />
<br />
===Mounting an iso image===<br />
To test if the iso image is proper, you can mount it (as root):<br />
# mount -t iso9660 -o ro,loop=/dev/loop0 cd_image /cdrom<br />
<br />
You have to first load the loop module:<br />
# modprobe loop<br />
<br />
===Converting to iso image===<br />
To convert an {{Filename|img}}/{{Filename|ccd}} image, you can use {{Codeline|ccd2iso}}: <br />
# pacman -S ccd2iso<br />
$ ccd2iso ~/image.img ~/image.iso<br />
<br />
== Burning CDs with a GUI ==<br />
There are several applications available to burn CDs in a graphical environment. The use of these programs are self-explanatory.<br />
<br />
===Nero Linux===<br />
Just the same as Nero on Windows. <br />
<br />
* [http://www.nero.com/eng/support-linux3.html Official link]<br />
* [http://aur.archlinux.org/packages.php?do_Details=1&ID=2153 AUR package]<br />
<br />
It's not free and the UI is not as good as the Windows version. Also, 3.0.0 beta can't burn bootable CDs from files correctly.<br />
<br />
If you happen to have a DVD-burner unsupported by <tt>dvd+rw-tools</tt> (which also means K3b and all other free GUIs), Nero would be your only choice.<br />
<br />
===K3b===<br />
According to [http://k3b.plainblack.com/, k3b is "The CD/DVD Kreator for Linux - optimized for KDE". K3b uses the [[Wikipedia:Qt (toolkit)|Qt]] toolkit.<br />
<br />
The {{Package Official|k3b}} package is available in [extra]:<br />
# pacman -S k3b<br />
<br />
Run {{Codeline|k3bsetup}} to set up your preferences, permissions, etc.; run {{Codeline|k3b}} to execute the main program.<br />
<br />
====About Locale====<br />
When running K3B, if the following message appears<br />
<br />
System locale charset is ANSI_X3.4-1968<br />
Your system's locale charset (i.e. the charset used to encode filenames) is <br />
set to ANSI_X3.4-1968. It is highly unlikely that this has been done intentionally.<br />
Most likely the locale is not set at all. An invalid setting will result in<br />
problems when creating data projects.Solution: To properly set the locale <br />
charset make sure the LC_* environment variables are set. Normally the distribution <br />
setup tools take care of this.<br />
<br />
It means that your locale is not set well.<br />
<br />
To fix it,<br />
* Remove <code>/etc/locale.gen</code><br />
# rm /etc/locale.gen<br />
* Re-install <code>glibc</code><br />
# pacman -S glibc<br />
* Edit <code>/etc/locale.gen</code>, uncommenting all lines lines that corresponds to your language AND the <code>en_US</code> options, for compatibility.<br />
# nano /etc/locale.gen<br />
<br />
en_US.UTF-8 UTF-8<br />
en_US ISO-8859-1<br />
<br />
* Re-generate the profiles with <code>locale-gen</code><br />
# locale-gen<br />
<br />
Generating locales...<br />
en_US.UTF-8... done<br />
en_US.ISO-8859-1... done<br />
pt_BR.UTF-8... done<br />
pt_BR.ISO-8859-1... done<br />
Generation complete.<br />
<br />
More info [http://bbs.archlinux.org/viewtopic.php?pid=251512%29; here]<br />
<br />
==== K3B says that there's no Burning Devices ====<br />
A common cause of this is the current user have no privileges for that.<br />
You can try to:<br />
* Add the user to the group <code>optical</code> (remember to re-login after this)<br />
# gpasswd -a <user> optical<br />
* Set permissions to devices<br />
# chmod 777 /dev/dvd*<br />
# chmod 777 /dev/cd*<br />
* Make sure HAL is running, because recent k3b is HAL-based. Kindly reported by arnuld@ #archlinux.<br />
# /etc/rc.d/hal status<br />
# /etc/rc.d/hal start<br />
Or perhaps consider adding a hal entry in your <code>/etc/rc.conf</code> so that it automatically loads upon boot.<br />
<br />
Other causes, steps, look on the current guide (;<br />
<br />
===Gnomebaker===<br />
<br />
Gnomebaker is a solution to CD burning if you are using [[Gnome]].<br />
'''Gnomebaker is no longer maintained upstream as the author of the program has indicated. Consider using [http://wiki.archlinux.org/index.php/CD_Burning_Tips#Brasero Brasero] instead.'''<br />
<br />
* Install gnomebaker with pacman.<br />
# pacman -S gnomebaker<br />
<br />
* Run <code>gnomebaker</code> to run the main program.<br />
<br />
===Brasero===<br />
<br />
Brasero is another solution to CD burning if you are using [[Gnome]].<br />
<br />
* Install brasero with pacman.<br />
# pacman -S brasero<br />
<br />
* Run <code>brasero</code> to run the main program.<br />
<br />
====Brasero fails to find blank discs====<br />
<br />
Brasero version 2.30 and above uses gvfs instead of hal to manage CD/DVD burning devices.<br />
<br />
* Install gvfs with pacman.<br />
# pacman -S gvfs<br />
<br />
* Edit your .xinitrc by adding "dbus-launch" before your window manager name, eg.:<br />
# exec dbus-launch openbox-session<br />
<br />
* You don't need to edit .xinitrc if you're using login manager like [http://wiki.archlinux.org/index.php/GDM GDM] or [http://wiki.archlinux.org/index.php/KDM KDM]<br />
<br />
===Graveman===<br />
Graveman is a simple and almost dependency-free application for burning CDs.<br />
<br />
* Install graveman with pacman.<br />
# pacman -S graveman<br />
<br />
* Run <code>graveman</code> as a regular user to create the configuration file in ~/.config/graveman/graveman.conf (if you run graveman as root first, the permissions for this file will be wrong).<br />
* Now, in graveman, go to menu File > Preferences... > Devices and add your CD burners (If necessary, run graveman as root). Devices may already be set up correctly.<br />
* Note that you may have to manually add your own device in Graveman's preferences and point it at /dev/cdrom instead of /dev/hdc<br />
<br />
===Bashburn===<br />
<br />
Alternatively theres also [http://bashburn.sourceforge.net/ Bashburn] in [http://aur.archlinux.org/packages.php?do_Details=1&ID=3658&O=0&L=0&C=0&K=bashburn&SB=n&SO=a&PP=25&do_MyPackages=0&do_Orphans=0&SeB=nd AUR] as a semi-gui solution. BashBurn is the new name for the cd burning shell script Magma. It's not the best looking CD-burning application out there, but it does what you want it to do.<br />
<br />
===Xfburn===<br />
<br />
[http://www.xfce.org/projects/xfburn/ Xfburn] is a simple CD/DVD burning tool based on libburnia libraries. It can blank CD-RWs, burn and create iso images, as well as burn personal compositions of data to either CD or DVD. It Is currently under heavy development.<br />
<br />
It can be found in the Extra Repository.<br />
<br />
* Install Xfburn with pacman.<br />
# pacman -S xfburn<br />
<br />
===Recorder===<br />
[http://code.google.com/p/recorder/ Recorder] is a graphical frontend of cdrkit/cdrtools, cdrdao, mkisofs and growisofs. It aims to be simple and easy to use, free of large configurations and useless options, following the KISS principle and offering a disc burning of quality, nothing more.<br />
<br />
* Install from the [[Community]] repository: [http://aur.archlinux.org/packages.php?ID=16501 Recorder package].<br />
<br />
* Discussion thread: [http://bbs.archlinux.org/viewtopic.php?id=47253 Recorder - A simple GTK+ disc burner]<br />
<br />
==Troubleshooting==<br />
<br />
===PATA and SATA problems around 2.6.20/2.6.21===<br />
<br />
For some kernels on some machines, CD burning works very unreliably. This is not fully diagnosed but appears to be related to DMA and having SATA Hard Drives and older IDE CD/DVD Burners and is possibly more prevalent on PIIX Motherboards. On newer kernels there is a new driver whereby the CD/DVD Burner behaves as if it is a SCSI drive, even though it isn't. <br />
<br />
The symptom for this problem is an almost total refusal to burn anything at all. It 'seems' to work fine, but if you verify the burn it invariably fails. If this is happening to you and you have an IDE burner try this fix.<br />
<br />
You will need to install mkinitcpio as described here,[[Configuring_mkinitcpio]] so you can rebuild the kernel. You now need to reconfigure your /etc/mkinitcpio.conf file to reuse the old IDE drivers.<br />
# gedit /etc/mkinitcpio.conf<br />
<br />
Find the line:<br />
MODULES="ata_generic ata_piix"<br />
<br />
and change it to (insert piix in the front)<br />
MODULES="piix ata_generic ata_piix"<br />
<br />
Then, find the line:<br />
HOOKS="base udev autodetect pata scsi sata usbinput keymap filesystems"<br />
<br />
and change that to: (replace pata with ide)<br />
HOOKS="base udev autodetect ide scsi sata usbinput keymap filesystems"<br />
<br />
Use mkinitcpio to rebuild the kernel as described in it's own wiki page, and reboot. In brief:<br />
# mkinitcpio -g /boot/kernel26.img</div>Silencerhttps://wiki.archlinux.org/index.php?title=GRUB&diff=84769GRUB2009-11-22T20:10:17Z<p>Silencer: </p>
<hr />
<div>[[Category:Boot process (English)]]<br />
[[Category:HOWTOs (English)]]<br />
{{Article summary start}}<br />
{{Article summary text|Covers various aspects of the next generation of the GRand Unified Bootloader (GRUB2).}}<br />
<br />
{{Article summary heading|Available in languages}}<br />
{{i18n_entry|English|GRUB2}}<br />
{{i18n_entry|Česky|GRUB2 (Česky)}}<br />
{{i18n_entry|Español|GRUB2 (Español)}}<br />
{{i18n_entry|Français|GRUB2 (Français)}}<br />
{{i18n_entry|Italiano|GRUB2 (Italiano)}}<br />
{{i18n_entry|Русский|GRUB2 (Русский)}}<br />
{{Article summary end}}<br />
<br />
== Introduction ==<br />
{{Warning | The next generation of the GRand Unified Bootloader (GRUB2) is still under development and therefore all usual points apply. GRUB2 may fry your computer, burn your house, make you breakfast or eat your cat. You've been warned! For most people, except those with more exotic configurations, GRUB2 should just work.}}<br />
<br />
Commands &ndash; changes between GRUB and GRUB2. You may want to familiarise yourself with these before proceeding.<br />
E.g.: "find" has been replaced with "search"<br />
<br />
http://grub.enbug.org/CommandList<br />
<br />
== Installing GRUB2 during Arch Linux installation ==<br />
<br />
You need the network configured.<br />
Skip de '''Install Bootloader''' step and exit. Then<br />
# mount -o bind /dev /mnt/dev<br />
# chroot /mnt bash<br />
And follow the '''Installing GRUB2 package''' and '''Installing or Restoring GRUB to the Master Boot Record''' below.<br />
<br />
== Installing GRUB2 package ==<br />
<br />
First install GRUB2 with pacman:<br />
# pacman -S grub2<br />
<br />
Edit the GRUB2 configuration file with your settings. The 'old' {{Filename|menu.lst}} is replaced by a new file called {{Filename|grub.cfg}}:<br />
# nano /boot/grub/grub.cfg<br />
<br />
{{Note | Use {{Filename|hd[a-z]}} for IDE and {{Filename|sd[a-z]}} for SCSI and SATA.}}<br />
<br />
Here is an example of a simple configuration file:<br />
# Config file for GRUB2 - The GNU GRand Unified Bootloader<br />
# /boot/grub/grub.cfg<br />
<br />
# DEVICE NAME CONVERSIONS<br />
#<br />
# Linux Grub<br />
# -------------------------<br />
# /dev/fd0 (fd0)<br />
# /dev/sda (hd0)<br />
# /dev/sdb2 (hd1,2)<br />
# /dev/sda3 (hd0,3)<br />
#<br />
<br />
# Timeout for menu<br />
set timeout=5<br />
<br />
# Set default boot entry as Entry 0<br />
set default=0<br />
<br />
# (0) Arch Linux<br />
menuentry "Arch Linux" {<br />
set root=(hd0,1)<br />
linux /vmlinuz26 root=/dev/sda1 ro<br />
initrd /kernel26.img<br />
}<br />
<br />
## (1) Windows<br />
#menuentry "Windows" {<br />
#set root=(hd0,3)<br />
#chainloader +1<br />
#}<br />
<br />
If you do not have a seperate boot-partition, {{Codeline|/boot}} must be added to {{Filename|grub.cfg}}. Example:<br />
<br />
# (0) Arch Linux<br />
menuentry "Arch Linux" {<br />
set root=(hd0,1)<br />
linux /boot/vmlinuz26 root=/dev/sda1 ro<br />
initrd /boot/kernel26.img<br />
}<br />
<br />
If you use '''LVM for your /boot''' add following before menuentries:<br />
<br />
insmod lvm<br />
<br />
and specify your root in menuentries as:<br />
<br />
set root=(''your_lvm_group_name''-''your_lvm_logical_boot_partition_name'')<br />
<br />
Example:<br />
<br />
# (0) Arch Linux<br />
menuentry "Arch Linux" {<br />
insmod lvm<br />
set root=(VolumeGroup-lv_boot)<br />
linux /vmlinuz26 root=/dev/mapper/VolumeGroup-lv_root ro<br />
initrd /kernel26.img<br />
}<br />
<br />
== Installing or Restoring GRUB2 to the Master Boot Record ==<br />
GRUB2 may be installed from a live environment, or directly from a running Arch install.<br />
<br />
In most cases, installing GRUB2 would be as easy as running the '''grub-install''' command as root:<br />
# grub-install /dev/sda<br />
where {{Filename|/dev/sda}} is the destination of the installation (in this case the MBR of the first SATA disc). If you use '''LVM for your /boot''' you can install GRUB2 on multiple physical disc.<br />
<br />
If this fails with the error:<br />
grub-probe: error: Cannot get the real path of `/dev/fd0'<br />
Auto-detection of a filesystem module failed.<br />
Please specify the module with the option `--modules' explicitly.<br />
Try adding {{Codeline|--recheck}} to the arguments as follows:<br />
# grub-install --recheck /dev/sda<br />
<br />
Alternatively, you should be able to install GRUB2 by booting the system and running the '''grub''' command as root:<br />
# grub<br />
{this section is still incomplete, some steps should be added!!!}<br />
(GRUB2 doesn't have an interactive prompt)<br />
<br />
== Boot loader configuration ==<br />
The GRUB configuration is done in this file:<br />
/boot/grub/grub.cfg<br />
<br />
Be warned this section is incomplete, feel free to put all missing configuration options here!<br />
<br />
* {{Codeline|(hdn,m)}} is the partition {{Codeline|m}} on disc {{Codeline|n}}, partition numbers starting with 1, disc numbers starting with 0<br />
* {{Codeline|set default&#61;n}} is the default boot entry, that is choosen after timeout for user action<br />
* {{Codeline|set timeout&#61;m}} &ndash; time {{Codeline|m}} to wait in seconds for a user selection, before default is booted<br />
* {{Codeline|menuentry "str"{entry options&#125;}} &ndash; title string {{Codeline|str}} for a boot entry & basic layout<br />
* {{Codeline|set root&#61;(hdn,m)}} &ndash; base partition, where the kernel is stored to<br />
* {{Codeline|linux /path ro root&#61;/dev/device initrd /initrd.img}} &ndash; use the root option, if the kernel not placed in /<br />
* {{Codeline|chainloader +1}} sets {{Codeline|root}} active and gives booting procedure to its boot-loader (for Windows, e.g.)<br />
<br />
For UUID entries:<br />
# blkid<br />
<br />
This gives you the UUID. We were doing the following command to set the root device: <br />
<br />
# root=/dev/device<br />
<br />
Instead, replace it with this:<br />
<br />
# root=/dev/disk/by-uuid/bc285871-413 .... and so on, for your UUID.<br />
<br />
=== Dual booting===<br />
These are the two most common ways of configuring the {{Filename|grub.cfg}} file. For more complex uses, feel free to add descriptions here.<br />
<br />
====With other GNU/Linux distributions====<br />
This is done exactly the same way that Arch linux is loaded. Here we assume that the other distro is on partition {{Filename|[s/h]da2}}.<br />
menuentry "Other Linux" {<br />
set root=(hd0,2)<br />
linux /boot/vmlinuz (add other options here as required)<br />
initrd /boot/initrd.img (if the other kernel uses/needs one)<br />
}<br />
<br />
====With Windows====<br />
Add this at the end of your {{Filename|/boot/grub/grub.cfg}}. This assumes that your Windows partition is {{Filename|[s/h]da3}}.<br />
<br />
# (2) Windows XP<br />
menuentry "Windows XP" {<br />
set root=(hd0,3)<br />
chainloader +1<br />
}<br />
<br />
Note, that although commonly believed to be the case, Windows 2000 and later versions do not need to be on the first partition to boot. If the Windows partition changes number (i.e. if you after install add a partition before the windows partition), you will need to edit the Windows boot.ini file to reflect the change (see [http://vlaurie.com/computers2/Articles/bootini.htm this article] for details on how to do that).<br />
<br />
====With Windows Vista, via EasyBCD and NeoGRUB====<br />
Since EasyBCD's NeoGRUB currently can't understand the GRUB v2 menu format, chain-load to it by replacing the contents of your "C:\NST\menu.lst" file with lines similar to the following:<br />
<br />
default 0<br />
timeout 1<br />
<br />
title Chainload into GRUB v2<br />
root (hd0,7)<br />
kernel /boot/grub/core.img<br />
<br />
==Tips and tricks==<br />
<br />
===Background Image & Bitmap Fonts===<br />
GRUB2 comes with support for background images and bitmap fonts in pf2 format. The unifont font is included in the grub2 package under the filename {{Filename|unicode.pf2}}, or, as only ascii characters under the name {{Filename|ascii.pf2}}. Image formats supported include tga, png and jpeg, providing the correct modules are loaded. The maximum supported resolution depends on your hardware. A configuration sample setting a tga file as background is shown below.<br />
<br />
if loadfont /usr/share/grub/unicode.pf2 ; then<br />
set gfxmode="1024x768x32"<br />
insmod gfxterm<br />
insmod vbe<br />
terminal_output gfxterm<br />
if terminal_output gfxterm; then true ; else<br />
terminal gfxterm<br />
fi<br />
fi<br />
insmod tga<br />
background_image /boot/grub/archlinux.tga<br />
<br />
===Menu Colors===<br />
<br />
To change the colors in GRUB2 you would specify one option in {{Filename|/boot/grub/grub.cfg}}:<br />
<br />
set menu_color_normal=light-blue/black<br />
set menu_color_highlight=light-cyan/blue<br />
<br />
These are the default colors for Arch's release of GRUB-legacy. The available colors for GRUB2 are at http://www.gnu.org/software/grub/manual/html_node/color.html.<br />
<br />
===Hidden menu===<br />
For hiding menu put that code in grub.cfg after picture initialization but before ''menuentries'' (e.g. background_image /boot/grub/archlinux.tga).<br />
<br />
set timeout=5<br />
<br />
echo -n "Press ESC to see the menu... "<br />
if sleep --verbose --interruptible 5 ; then<br />
set timeout=0<br />
fi<br />
<br />
===Setting the Framebuffer Resolution===<br />
<br />
To change the framebuffer resolution in grub2, add a line similar to this to the ''linux'' line in grub.cfg:<br />
<br />
video=vesafb:mode=1024x768-32 vga=790<br />
<br />
In the preceeding statement, the format mode=<resolution>-<colordepth> vga=<fbresolution> is used where fbresolution follows the following scheme:<br />
<br />
+-------------------------------------------------+<br />
| 640x480 800x600 1024x768 1280x1024<br />
----+--------------------------------------------<br />
256 | 0x301=769 0x303=771 0x305=773 0x307=775<br />
32K | 0x310=784 0x313=787 0x316=790 0x319=793<br />
64K | 0x311=785 0x314=788 0x317=791 0x31A=794<br />
16M | 0x312=786 0x315=789 0x318=792 0x31B=795<br />
+-------------------------------------------------+<br />
<br />
Make sure you add the following somewhere, (insmod statements are usually found at the top of the grub.cfg file):<br />
<br />
insmod vbe<br />
<br />
== Troubleshooting ==<br />
Any troubleshooting should be added here.<br />
=== msdos-style Error Message ===<br />
<br />
grub-setup: warn: This msdos-style partition label has no post-MBR gap; embedding won't be possible!<br />
grub-setup: warn: Embedding is not possible. GRUB can only be installed in this setup by using blocklists.<br />
However, blocklists are UNRELIABLE and its use is discouraged.<br />
grub-setup: error: If you really want blocklists, use --force.<br />
This error may occur when you try installing GRUB2 in a VMware container. Read more about it [http://bbs.archlinux.org/viewtopic.php?pid=581760#p581760 here]. Hopefully a fix will be provided soon.<br />
=== Other ===<br />
I couldn't figure out how to uninstall grub1, and install grub2 to the MBR, as it isn't being booted by default. It is still booting grub1. So, an easy work-around, is rename {{Filename|menu.lst.pacsave}} or whatever, to {{Filename|menu.lst}} (in /boot/grub/) and for each menu entry that you would like to use grub2, at the end type {{Codeline|"chainloader +1"}}. This will tell grub1 to forward control to grub2. This is an ugly hack though, so I advise setting the {{Filename|menu.lst}}'s timout as 0, otherwise the total timeout would be grub1's time out + grub2's which, for me would equal more than 18 seconds, which is quite a bit.<br />
<br />
P.S. hopefully someone figures out how to pry grub1's dead fingers off of my MBR, and place grub2 on it :) .<br />
<br />
In my case it had to do with my boot partition. Say boot-partition is {{Codeline|(hd0,1)}} and your root is {{Codeline|(hd0,3)}} (grub2 naming). grub-setup searches for {{Filename|(hd0,3)/boot/grub/core.img}}. Just because it's on {{Filename|(hd0,1)/grub/core.img}}, it is unable to find it. So I copied the grub-folder to my root partition and everything worked fine:<br />
<br />
E.g. (as root:)<br />
# mount /boot<br />
# cp -a /boot/grub /<br />
# umount /boot<br />
# mv /grub /boot/<br />
# grub-install /dev/sda<br />
<br />
== More Resources ==<br />
* [http://www.gnu.org/software/grub/ GRUB Homepage]<br />
* [http://grub.enbug.org/ GRUB wiki]</div>Silencer