How does DirectWrite (CreateTextFormat) pick the fallback font(s)? -
the documentation createtextformat says nothing font fallback selection, if default (null = system) collection chosen, directwrite implements font fallback. example, if add 2 glyphs not found in gabriola font test string used directwrite sdk demo app, directwrite picks missing glyphs segoe ui symbol font. happens basic drawtext call , custom renderer (that nothing custom font fallback) shown below (the modification test string):

the checkmark , wite star come segoe ui symbol, not gabriola, though gabriola specified in demo app. so, know how fallback font(s) is/are selected directwrite (createtextformat)?
update. see there getsystemfontfallback can list fallback fonts, it's available in windows 8.1 (because it's in idwritefactory2). guess they've noticed gap in api respect enumerating fallback fonts. i'm guessing there's no way before windows 8.1, if knows hack/workaround...
update2. quoting msft employee:
directwrite has fallback data not read registry or in way configurable. in windows 8.1, though, apis have been introduced allow app specify own fallback. (it's similar wpf apis creating composite font definition.)
which still doesn't explain hardcoded algorithm/replacement scheme is.
idwritetextlayout calls idwritefontfallback::mapcharacters map each unicode character ordered list of font families tried until character satisfied. think of loop reading each character one-by-one, mapping code point value , language tag unicode range, , stopping @ first font supports character in cmap table. similar font fallback algorithm specified css [http://www.w3.org/tr/css3-fonts/#font-matching-algorithm] , fallback used wpf/xaml/silverlight. see idwritefontfallbackbuilder::addmapping api (win 8.1+), used build custom fallback list, idea of inputs used.
see c:\windows\fonts\globaluserinterface.compositefont example data (note file wpf, not quite same definition dwrite uses).
<fontfamilymap unicode = "3000-30ff, 31f0-31ff" language = "ja" target = "meiryo ui, meiryo, microsoft yahei ui, microsoft yahei, ms gothic, mingliu, arial unicode ms" scale = "1.0" />
Comments
Post a Comment