Font export: SWF to TrueType, per language
A book’s markup names a font by a face (<font face='$HandwrittenFont'>). export:books converts
each language’s fonts to TTF, so the site can show the text in the game’s fonts. The SWF parsing and
the TrueType writer are in
SWF font parsing; this page covers the exporter’s
side, Pipelines/Books/Fonts/ and Game/Assets/FontConfig*.cs.
fontconfig
A face isn’t a file: Interface\fontconfig*.txt maps it to a font embedded in a SWF.
fontlib "Interface\fonts_en.swf"
map "$DaedricFont" = "Daedric" Normal
fontlib lines name the SWFs a language’s fonts are embedded in; map lines map a face to a font
name. FontConfigParser.Parse reads both into a FontConfig. The syntax has no published spec:
the parser follows the vanilla files, see
assumptions. The weight word after a
name (Bold, Roman, Demi) is appended to it unless it is Normal, so $EverywhereBoldFont
maps to "Futura Condensed Bold".
Game/Vanilla/FontConfigFiles.cs picks the file per language: Chinese, Japanese, Polish and
Russian have their own (fontconfig_cn.txt, _ja.txt, _pl.txt, _ru.txt), the other languages
share fontconfig.txt.
Every embedded font is exported
FontLibraryExporter converts every DefineFont3 of each fontlib SWF, instead of resolving each
face to one font by name. A face whose map name matches no embedded font still has its font
exported under its real name: vanilla maps $CClub_Font to “Eurostile LT Cyr Std”, while
fonts_cclub.swf embeds “Eurostile LT Std Roman”, see
data problems.
The SWF-to-SWF symbol graph (ImportAssets2, ExportAssets, as in book.swf importing from
gfxfontlib.swf) isn’t implemented: every font a language needs is already embedded in its own
fontlib SWFs.
Fonts are converted per language, unlike textures: each language’s SWFs embed different glyphs.
Output
localized/<language>/fonts/<font name>.ttf per embedded font, listed under fonts in the
language’s index.json, see Book export format:
{
"books": [ ],
"fonts": [
{ "name": "Daedric", "styles": ["$DaedricFont"], "path": "fonts/Daedric.ttf" }
]
}
styles lists the faces mapped to the font. A face maps to the font whose name equals its map
name; failing that, to the font whose name contains it, because fontconfig_ja.txt maps
22_Skyrim_JP_BookFont_0805 while the SWF embeds 22_Skyrim_JP_BookFont_0805 Regular. When
several fonts contain the name, the weight word after it picks one, in the order Regular (also
Roman, Book, Normal), Medium, Light, Demi (also SemiBold), Bold. Two fonts of the same weight, or
suffixes outside this list, leave the face unresolved. styles is empty when no face maps to the
font.