Skip to content

Instantly share code, notes, and snippets.

@nattster
Created March 1, 2014 09:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nattster/9287563 to your computer and use it in GitHub Desktop.
Save nattster/9287563 to your computer and use it in GitHub Desktop.
snippets from nattster's blog
<?xml version="1.0"?>
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
<fontconfig>
<!--
.fonts.conf
release 6.3.23
================================
LCD optimized 96 dpi
"Sharp'N'Clear" font settings
with emphasis on 'msttcorefonts'
tested on Ubuntu GNU/Linux 5.10
================================
by Obi Bok
Gmail: obibok
http://linuxtuneup.blogspot.com
================================
Why was this conceived?
- some font families look better hinted by Byte Code Interpreter (BCI)
while other fonts look better hinted by Auto-Hinter
- hinting type affects italic and bold fonts differently
- antialiasing needs to be adjusted according to font families and sizes
Essentially, there is no one single rule that works for all fonts.
NOTE:
- Verdana @ 8pt doesn't render '2' and '6' right
- Arial shows 'Z' distorted in Firefox 1.5
-->
<!--
Make font sizes match the dpi set in Xorg.
Increase or decrease this value if fonts are too small or too large
for your screen resolution.
FIXME: this only affects QT-based apps?
-->
<match target="pattern">
<edit name="dpi" mode="assign">
<double>96</double>
</edit>
</match>
<!--
Enable anti-aliasing.
This only works for outline and scalable fonts.
Bitmap and PostScript fonts do not get anti-aliased.
FIXME: is this correct?
-->
<match target="font">
<edit name="antialias" mode="assign">
<bool>true</bool>
</edit>
</match>
<!--
Set sub-pixel order if not detected.
"X knows the sub pixel order already, and if this is enabled as well,
Freetype produces some very strange results. However, if you do still
have problems, consider (...) 'rgb' (the standard for LCD monitors),
'bgr' (unusual), 'vrgb' (vertical rgb, if you have a monitor that
has been rotated by 90 degrees[1]), 'vgbr' (as vrgb, but very rare)."
<http://www.linuxquestions.org/linux/answers/Hardware/\
LCD_TFT_Monitor_Configuration_in_X_Org>
Find out your LCD's sub-pixel order:
<http://grc.com/image/cleartype2c.gif>
-->
<match target="font">
<test qual="all" name="rgba" compare="eq">
<const>unknown</const>
</test>
<edit name="rgba" mode="assign">
<const>rgb</const>
</edit>
</match>
<!--
Sub-pixel hinting via BCI enabled by default if compiled in.
"Whole-pixel anti-aliasing does not represent a useful solution for
improving small point-size type. (...) By 'borrowing' sub-pixels from
adjacent whole pixels, we can fine-tune the placement and width of typeface
features with three times more horizontal accuracy then ever before!"
<http://grc.com/ctwhat.htm>
-->
<!--
Disable anti-aliasing for select fonts based on size and style.
| font | WinXP | Linux |
=========================================
Andale Mono IPA 14 13
Arial 12 13
Arial Black 12 -
Arial Narrow 14 13
Berling Antiqua 12 13
Book Antiqua 12 13
Bookdings 0 ?
Bookman Old Style 22 13
Century Gothic 16 16
Comic Sans MS 11 9/11
Courier New 26 22
Franklin Gothic Medium 12 10/12
Frutiger Linotype 12 10/12
Garamond 18 13/19
Georgia 12 12/13
Impact 16 0
Kartika 12 16
Lucida Console 12 13
Lucida Sans Typewriter 12 12
Lucida Sans Unicode 12 10/13
Marlett ? ?
Microsoft Sans Serif 12 12/13
Palatino Linotype 12 13
SylfaenARM - 13
Symbol 12 ?
Tahoma 12 12/13
Times New Roman 12 13
Trebuchet MS 12 12
Verdana 12 12
Vrinda 12 17
Webdings 20 ?
Wingdings 20 ?
=========================================
"The relationship of pixels to points depends on the number of pixels
per inch, which is typically some 'standard' value corresponding to
default screen fonts. For example, MS Windows has two standard sets of
screen fonts initially designed for IBM display systems: 'small' (VGA)
and 'large' (8514/A). 'Small' fonts are 96 pixels per inch, 'large' are
120. Macintosh systems render type at a nominal 72 pixels per inch, i.e.
one pixel = one point. Some display systems using scalable screen fonts
allow fine tuning of pixels per inch to suit user preferences."
<http://www.hpaa.com/css1/pxnpts.asp>
X pt * 96 dpi / 72 dpi = Y px
-->
<!--
font group #3: normal roman anti-aliased above 12pt/16px
Must use at least 16.1px instead of 16px for this to work in Firefox
-->
<match target="font">
<test qual="any" name="family" compare="eq">
<!-- Tahoma has no italic and uses artificial oblique -->
<string>Tahoma</string>
</test>
<test qual="any" name="pixelsize" compare="less_eq">
<double>16.1</double>
</test>
<test qual="any" name="weight" compare="less_eq">
<const>medium</const>
</test>
<test qual="any" name="slant" compare="eq">
<const>roman</const>
</test>
<edit name="antialias" mode="assign">
<bool>false</bool>
</edit>
</match>
<!--
font group #9: bold roman anti-aliased above 10pt/13.4px
-->
<match target="font">
<test qual="any" name="family" compare="eq">
<string>Tahoma</string>
</test>
<test qual="any" name="pixelsize" compare="less_eq">
<double>13.4</double>
</test>
<test qual="any" name="weight" compare="more">
<const>medium</const>
</test>
<test qual="any" name="slant" compare="eq">
<const>roman</const>
</test>
<edit name="antialias" mode="assign">
<bool>false</bool>
</edit>
</match>
<!--
Enable FreeType Auto-Hinter for select fonts.
Auto-Hinter is disabled by default if Bytecode Interpreter was compiled in.
Some Linux "native" fonts look better hinted by Auto-Hinter,
usually in sizes 11pt-13pt; others look better hinted by BCI.
-->
<!--
Set Auto-Hinter to full hinting style.
'slight' and 'medium' hinting often produce pixel discoloration.
-->
<match target="font">
<edit name="hintstyle" mode="assign">
<const>hintfull</const>
</edit>
</match>
<!--
Set minimum allowed size to avoid illegible fonts.
-->
<!-- 7pt in QT-based apps -->
<match target="pattern">
<test qual="any" name="size" compare="less">
<double>7</double>
</test>
<edit name="size" mode="assign">
<double>7</double>
</edit>
</match>
<!-- 9.4px (7pt) in GTK-based apps -->
<match target="pattern">
<test qual="any" name="pixelsize" compare="less">
<double>9.4</double>
</test>
<edit name="pixelsize" mode="assign">
<double>9.4</double>
</edit>
</match>
<!--
TODO: Create rules limiting minimum sizes for these *bold* fonts:
Andale Mono | Andale Mono IPA
Arial
Arial Narrow
Berling Antiqua
Book Antiqua
Bookman Old Style
Century Gothic
Comic Sans MS
Courier New
Franklin Gothic Medium
Frutiger Linotype
Garamond
Georgia
Kartika
Lucida Console
Lucida Sans Typewriter
Lucida Sans Unicode
Microsoft Sans Serif
Palatino | Palatino Linotype
SylfaenARM
Tahoma
Times New Roman
Trebuchet MS
Verdana
Vrinda
-->
<!--
Anti-alias fonts with "fake" styles.
FIXME: QT only? GTK? Firefox?
-->
<!-- another approach - no errors but freezes Firefox 1.5 -->
<match target="font">
<test qual="any" name="matrix" compare="eq">
<name>matrix</name>
</test>
<edit name="antialias" mode="assign">
<bool>true</bool>
</edit>
</match>
<!--
Substitute unavailable and/or unwanted fonts.
Aliases will not work if the actual fonts are installed.
Replacing font family works in Firefox (FIXME: and other GTK-based apps?)
QT-based apps also need font foundry replaced.
Grouping fonts for substitution doesn't work in Firefox, so we need each
font family replaced individually.
-->
</fontconfig>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment