Shared fonts

The six fonts of pl:u (FontStandard, the two simplified Chinese fonts, traditional Chinese, Korean and NintendoExtended) live in one shared memory, each behind the 8-byte header the SDK reads its size from. The console's memory is 0x1100000 bytes and the SDK maps exactly that much, as Eden's pl_u.cpp does, so the fonts have to fit in it.

A console font can be placed in the game's data directory first: fonts/FontStandard.ttf for the default title-ID layout is recompiled/<id>/<id>_data/fonts/FontStandard.ttf under the data folder, and the same for FontChineseSimplified, FontExtendedChineseSimplified, FontChineseTraditional, FontKorean and FontNintendoExtended. Named or older deployments use their existing <Game>_data/ directory. .bfttf is accepted too and takes priority over .ttf; both take priority over the stand-ins.

Without one, the runtime uses the stand-ins compiled in (cmake/shared_fonts.cmake): Noto Sans JP, SC, TC and KR subsets the build fetches, one per script, and yuzu's controller button glyphs for FontNintendoExtended. The subsets cover ASCII, Latin-1, common punctuation and the script's standard set (JIS X 0208, GB 2312, Big5, KS X 1001); they total about 11 MB. The console's private-use icon block, U+E000 to U+E1FF (buttons, symbols), is not in any free font, so pl_font.c gives every stand-in blank glyphs there: a game's font map that names one gets a glyph instead of a null pointer, and the icon draws as nothing. A console font is not touched.

Font substitution can change text weight and spacing.

The Noto stand-ins

The console's fonts are the firmware's and cannot be shipped. cmake/shared_fonts.cmake takes yuzu's controller button glyphs from Eden's source, and cmake/dependencies.cmake fetches the four subsets below, pinned by their SHA-512 in cpmfile.json, only in a build with the Switch runtime (SNX_BUILD_NX without SNX_TOOLS_ONLY). cmake/shared_fonts.cmake compiles them into the runtime.

FileSlotCovers
NotoSansJP-Subset.ttfFontStandardASCII, Latin-1, punctuation, JIS X 0208 (kana and kanji)
NotoSansSC-Subset.ttfFontChineseSimplified, FontExtendedChineseSimplifiedASCII, Latin-1, punctuation, GB 2312
NotoSansTC-Subset.ttfFontChineseTraditionalASCII, Latin-1, punctuation, Big5
NotoSansKR-Subset.ttfFontKoreanASCII, Latin-1, punctuation, KS X 1001 (Hangul and Hanja)

The four total about 11 MB, which fits the shared memory. The full Noto Sans JP/SC/TC/KR variable fonts do not fit, and their pan-CJK sibling is CFF, which the SDK's font parser did not load in a test (the game crashed at boot). The subsets are TrueType glyf at the Regular weight, the script's standard character set, with hinting dropped.

Regenerating the subsets

The files the build fetches are the ones commit 777f377013806bc4cdbbc0306eca6e7e9c835df2 of this repository kept in dist/fonts, and the build takes them from there. tools/subset_fonts.py makes them from Google Fonts' Noto Sans JP, SC, TC and KR at commit e7db6ca603fd4862010383ff17ffd6cc4ffac1c0 (ofl/notosansjp, ofl/notosanssc, ofl/notosanstc, ofl/notosanskr, NotoSansXX[wght].ttf). It needs fontTools and network access, neither of which the build needs:

python3 tools/subset_fonts.py --out fonts

It instantiates each variable font at weight 400, keeps ASCII, Latin-1, common punctuation and the script's standard set, drops hinting and the variation tables, and writes the four files above. A new set is published at a fixed URL (a release asset, or a commit that holds the files), and the URL and the four hashes in cmake/dependencies.cmake change with it. The sources are under the SIL Open Font License 1.1; the text is dist/licenses/Noto/OFL.txt.


Made from docs/platforms/nx/filesystem.md at 69237645142c. GPL-3.0-or-later.