diff --git a/runtime/ov_probe.c b/runtime/ov_probe.c index b5315f08..709fc871 100644 --- a/runtime/ov_probe.c +++ b/runtime/ov_probe.c @@ -1002,11 +1002,14 @@ static void probe_fonts(void) { CHECK(got == sizeof head && size && size + 8 == (uint64_t)len, "shared font 0: size %llu, file %lld bytes", (unsigned long long)size, (long long)len); const uint8_t *p = (const uint8_t *)(uintptr_t)addr; - CHECK(addr && !memcmp(p - 8, head, sizeof head) && ov_bfttf_size(p - 8, size + 8) == size, - "shared font 0: the address is not 8 bytes into the BFTTF file"); + // The pl shared memory layout: the file's BFTTF header unchanged at Address - 8, the decoded sfnt font at Address. + CHECK(addr && !memcmp(p - 8, head, 8) && ov_bfttf_size(head, size + 8) == size, + "shared font 0: the address is not 8 bytes past the file's BFTTF header"); + CHECK(!memcmp(p, "\0\1\0\0", 4) || !memcmp(p, "OTTO", 4), + "shared font 0: the data at the address is not plain sfnt: %02x %02x %02x %02x", p[0], p[1], p[2], p[3]); CHECK(CALL("pl.GetSharedFontAddress", 0) == addr, "shared font 0: the address changed"); - printf("pl: shared font 0 (Standard) at %#llx, %llu bytes, BFTTF header checked (%s)\n", (unsigned long long)addr, - (unsigned long long)size, path); + printf("pl: shared font 0 (Standard) at %#llx, %llu bytes, BFTTF header and decoded sfnt checked (%s)\n", + (unsigned long long)addr, (unsigned long long)size, path); } // The host catalog (ui_text.c): every menu id has its own English, Russian, Brazilian Portuguese and Simplified diff --git a/runtime/ov_system.c b/runtime/ov_system.c index 5aeabed2..ae1f9b17 100644 --- a/runtime/ov_system.c +++ b/runtime/ov_system.c @@ -775,9 +775,14 @@ static void ov_user_difference(Cpu *c) { // ==== nn::pl shared fonts (shared_font.c). TotK asks for them only from its font loader, only with Simplified Chinese, // Korean or Traditional Chinese text, and only for type 0; tools/extract_fonts.py writes -// them from the user's firmware. Each type is read on first use into guest-visible memory as the BFTTF file the pl -// shared memory holds; Address is 8 bytes past the file start (after the BFTTF header) and Size the decoded font size, -// as in MNG. The load state is always Loaded: the game spins until it is, so missing files stop with a named fatal at +// them from the user's firmware. Each type is read on first use into guest-visible memory laid out as the pl shared +// memory holds it: the file's 8-byte BFTTF header as it is, then the font decoded to plain sfnt data. Address is 8 +// bytes past the file start (after the header) and Size the decoded font size, as in MNG. The firmware file keeps the +// font XOR-encoded, and the game cannot read it that way: its font loader takes the data at Address as a font when the +// first word is an sfnt tag and otherwise hands it to nn::fontll::ScalableFontEngineHelper::Decode, which knows only +// a BFTTF header at the start and returns NULL for an encoded payload. The face then gets no name, SetFont fails, and +// the text draws the previous face's glyphs with the failed face's metrics (the CJK ellipsis above the line; MNG +// shared_font.c load decodes the same way since its pull request #2145). The load state is always Loaded: the game spins until it is, so missing files stop with a named fatal at // Address/Size instead of a hang. TOTK_SHARED_FONTS=