2 Implement Missing Text Function RESET_FONT
judicornadamsfoster edited this page 2026-07-04 13:16:22 +01:00

The text printer in Emerald is very versatile and has a lot of control codes. But it seems Game Freak skipped implementing one of the control codes in the release of the game, since it was likely never used. There's a control code that pokeemerald calls the FONT control code, allowing you to change fonts (and thus font size) mid-text. But there's another control code right after that called the RESET_FONT control code that does nothing. Here's how to implement it:

In older versions of pokeemerald, go to gflib/text.c,
Or in updated versions, the file is now located at src/text.c

find the function RenderText (at line 934) and add the following:

            case EXT_CTRL_CODE_FONT:
                subStruct->fontId = *textPrinter->printerTemplate.currentChar;
                textPrinter->printerTemplate.currentChar++;
                return RENDER_REPEAT;
            case EXT_CTRL_CODE_RESET_FONT:
+               subStruct->fontId = textPrinter->printerTemplate.fontId;
                return RENDER_REPEAT;

Further down the same file, find the function GetStringWidth (at line 1329) and add the following as well:

            case EXT_CTRL_CODE_ENG:
                isJapanese = 0;
                break;
            case EXT_CTRL_CODE_RESET_FONT:
+               if (letterSpacing == -1)
+                   localLetterSpacing = GetFontAttribute(fontId, FONTATTR_LETTER_SPACING);
+               else
+                   localLetterSpacing = letterSpacing;
+               break;
            case EXT_CTRL_CODE_PAUSE_UNTIL_PRESS:

Both of these will reset the font to whatever the previous font was when the text printer comes across a RESET_FONT control code.