User:Alvinhochun/Localization/Font Engine

From ReactOS Wiki
Jump to: navigation, search

Startup Font Loading

The other day I tried to trace certain API calls in XP (zh-HK) to look at where the fonts get loaded:

  • win32k!NtUserInitialize -> win32k!InitializeGreCSRSS
    • bInitStockFonts -> bInitStockFontsInternal
      • bInitOneStockFont with L"FONTS.FON" and eventually loads L"\SYSTEMROOT\FONTS\CVGASYS.FON"
      • bInitOneStockFont with L"OEMFONT.FON" and eventually loads L"\SYSTEMROOT\FONTS\VGA950.FON"
      • bInitOneStockFont with L"FIXEDFON.FON" and eventually loads L"\SYSTEMROOT\FONTS\CVGAFIX.FON"
    • hfontInitDefaultGuiFont
      • Loads from \Registry\Machine\Software\Microsoft\Windows NT\CurrentVersion\Gre_Initialize, defaults to "MS Shell Dlg"
        • "GUIFont.Facename"
        • "GUIFont.Height"
        • "GUIFont.Weight"
        • "GUIFont.Italic"
        • "GUIFont.Charset"
    • Somewhere later: BuildAndLoadLinkedFontRoutine
  • winsrv!InitializeFonts
    • gdi32!NtGdiAddFontResourceW

It is said that Windows loads startup fonts by looking at the registry HKLM\Software\Microsoft\Windows NT\CurrentVersion\Fonts. Simply placing the font file into %SystemRoot%\Fonts (via cmd / mounted offline) does not register the font at all. TODO: Verify! The subkey name is something like <FACE_NAME> (<FONT_TYPE>) (e.g. Arial (TrueType), 細明體 & 新細明體 (TrueType)), but strictly speaking, the subkey name shouldn't really matter since GDI should load the face name from the font, and also handle the localized name. The value is the path to the font file, or simply the filename if the font is located inside %SystemRoot%\Fonts, TODO: Only the Fonts dir?

Localized Font Name

See also: CORE-9638

The localized font name is loaded depending on the System Locale.

Note: It is not an equality comparison, since, for example, the name for zh-TW (0404) is also used for zh-HK (0c04). It may be similar to resource loading.

It is said that the English font name can still be used to get the font, but I tried testing in wordpad and the behaviour is weird. Perhaps I will need to test using a Win32 GUI program and with GDI directly.