All Your Fonts ARE...

Behdad Esfahbod
behdad@gnome.org
June 26, 2006
GUADECAll Your Fonts ARE...

Behdad Esfahbod
GUADEC, Spainbehdad@gnome.org
June 26, 2006

What is Pango●

Text rendering engine●

Text layout engine●Unicode-based●

Modular●Internationalized (not localized!)●

Abstract, Portable, Multi-backend●

Efficient!

Pango API●

High-level:–●

PangoLayout

Low-level:– pango_itemize– pango_break– pango_shapePangoLayout

Simple layout object. (Demo)pango_itemize()

Breaks a piece of text into segments withconsistent directional level, font,attributes, and shaping engine.

pango_break()Determines possible line, word, andcharacter breaks for a string of Unicode
text.

pango_shape()

text and the corresponding PangoAnalysis
structure returned from pango_itemize(),convert the characters into glyphs.

Engines●

Defined in modules●

May be built included, or dynamic●

Lang Engines: used in pango_break()●

Shape Engines: used in pango_shape()

Characters vs. Glyphs●●●

Unicode UTR#17: Character Encoding
ModelDistinction required for quality renderingof most scripts, but emphasized in socalled “complex” scripts, i.e. Arabic, Indic,...
OpenType, AAT, SIL GraphitePangoFontDescription●●

Data structure to represent a fontdescription (surprise!)Contains fields like “family name”, “fontsize”, “style”, “variant”, “stretch”.

●

from_string(“DejaVu Sans Bold 24”)●

Or using generic family names: “Sans 12”

Pango Backends
●

X

●

Win32

●

FT2 (FreeType 2)

●Xft

●

Cairo
– CairoFc– CairoWin32– CairoATSUIItemizing●●●

Input: text, font description, attributes
For each character, find the best
matching language
Find the best font and shaping engine touse for the (character, language) pair,using the backend fontmap
implementation

FreeType, fontconfig, Xft, cairo
●

●

●

●

FreeType: Render font glyphs intobitmaps
Fontconfig: Map font descriptions (akapatterns) into available fonts
Xft: Render (and cache) FreeTypegenerated bitmaps into an X server
Cairo: Render (and cache) FreeTypegenerated bitmaps into a cairo surface(among other things)

Fontconfig●Patterns: Pretty similar to a
PangoFontDescription conceptually, but alot more complete(/-x)●Request pattern and font pattern●FcFontMatch():– [behdad@home fonts]$ fc-match sans
– DejaVuSans.ttf: "DejaVu Sans" "Book"

Match Pattern has 16 elts (size 32)
family: "sans"(w)slant: 0(i)(s)weight: 100(i)(s)width: 100(i)(s)size: 12(f)(s)pixelsize: 12.5(f)(s)hintstyle: 3(i)(s)hinting: FcTrue(s)verticallayout: FcFalse(s)autohint: FcFalse(s)globaladvance: FcTrue(s)dpi: 75(f)(s)scale: 1(f)(s)lang: "en-US"(s)fontversion: 2147483647(i)(s)embeddedbitmap: FcTrue(s)Best match (scoring index 9) 0 Pattern has 17 eltsfamily: "DejaVu Sans"(s)familylang: "en"(s)style: "Book"(s)stylelang: "en"(s)slant: 0(i)(s)weight: 80(i)(s)width: 100(i)(s)foundry: "unknown"(s)file: "/home/behdad/.fonts/dejavu-ttf-2.2/Dej
index: 0(i)(s)outline: FcTrue(s)scalable: FcTrue(s)charset: set(s)lang: aa|af|ast|ava|ay|bam|be|bg|bi|bin|br|bs
nds|nl|nn|no|ny|oc|om|os|pl|pt|rm|ro|ru|sah|se|se
fontversion: 144179(i)(s)capability: "otlayout:DFLT otlayout:cyrl otlay
fontformat: "TrueType"(s)The Truth About Fontconfig●Sort●Pruning●

FcFontSort():– [behdad@home fonts]$ fc-match --sort sans
– DejaVuSans.ttf: "DejaVu Sans" "Book"– Vera.ttf: "Bitstream Vera Sans" "Roman"– n019003l.pfb: "Nimbus Sans L" "Regular"– roya.ttf: "Roya" "Regular"

So Why Should I Select a Font?
●You shouldn't!

●Just choose the main font

●Or use a font alias●Font configuration:– /etc/fonts/fonts.conf– /etc/fonts/conf.d– ~/.fonts.conf

<alias><family>sans-serif</family><prefer><family>Luxi Sans</family><family>Albany AMT</family><family>Bitstream Vera Sans</family><family>Verdana</family><family>Arial</family><family>Nimbus Sans L</family><family>Helvetica</family><family>KacstQura</family><family>Nachlieli</family><family>Lohit Bengali</family><family>Lohit Gujarati</family><family>Lohit Hindi</family><family>Lohit Punjabi</family><family>Lohit Tamil</family><family>Sazanami Gothic</family><family>Kochi Gothic</family><family> ＭＭ ＭＭＭＭ </family><family>MgOpen Modata</family><family>FreeSans</family></prefer></alias>Just Works
●●

●

●

...only if the fonts don't have crappy
glyphs...
...or if they do, they don't mix crappy
glyphs with quality glyphs...
...or we're screwed!
Examples: Free Sans, Code2000, <putyour favorite font here>Huh, Done!

Q?!