diff --git a/charmap.txt b/charmap.txt index 66b8b5393..cc3902a03 100644 --- a/charmap.txt +++ b/charmap.txt @@ -461,6 +461,11 @@ FONT_NORMAL = FC 06 02 FONT_NORMAL_COPY_2 = FC 06 03 FONT_MALE = FC 06 04 FONT_FEMALE = FC 06 05 +FONT_NARROW = FC 06 07 +FONT_SMALL_NARROW = FC 06 08 +FONT_NARROWER = FC 06 0A +FONT_SMALL_NARROWER = FC 06 0B +FONT_SHORT_NARROW = FC 06 0C @ colors diff --git a/gflib/text.c b/gflib/text.c index cb8c106ab..a9c3c98ed 100644 --- a/gflib/text.c +++ b/gflib/text.c @@ -24,12 +24,22 @@ static void DecompressGlyph_NormalCopy1(u16 glyphId, bool32 isJapanese); static void DecompressGlyph_NormalCopy2(u16 glyphId, bool32 isJapanese); static void DecompressGlyph_Male(u16 glyphId, bool32 isJapanese); static void DecompressGlyph_Bold(u16 glyphId); -static s32 GetGlyphWidth_Small(u16 glyphId, bool32 isJapanese); -static s32 GetGlyphWidth_NormalCopy1(u16 glyphId, bool32 isJapanese); -static s32 GetGlyphWidth_Normal(u16 glyphId, bool32 isJapanese); -static s32 GetGlyphWidth_NormalCopy2(u16 glyphId, bool32 isJapanese); -static s32 GetGlyphWidth_Male(u16 glyphId, bool32 isJapanese); -static s32 GetGlyphWidth_Female(u16 glyphId, bool32 isJapanese); +static void DecompressGlyph_Narrow(u16, bool32); +static void DecompressGlyph_SmallNarrow(u16, bool32); +static void DecompressGlyph_Narrower(u16, bool32); +static void DecompressGlyph_SmallNarrower(u16, bool32); +static void DecompressGlyph_ShortNarrow(u16, bool32); +static u32 GetGlyphWidth_Small(u16 glyphId, bool32 isJapanese); +static u32 GetGlyphWidth_NormalCopy1(u16 glyphId, bool32 isJapanese); +static u32 GetGlyphWidth_Normal(u16 glyphId, bool32 isJapanese); +static u32 GetGlyphWidth_NormalCopy2(u16 glyphId, bool32 isJapanese); +static u32 GetGlyphWidth_Male(u16 glyphId, bool32 isJapanese); +static u32 GetGlyphWidth_Female(u16 glyphId, bool32 isJapanese); +static u32 GetGlyphWidth_Narrow(u16, bool32); +static u32 GetGlyphWidth_SmallNarrow(u16, bool32); +static u32 GetGlyphWidth_Narrower(u16, bool32); +static u32 GetGlyphWidth_SmallNarrower(u16, bool32); +static u32 GetGlyphWidth_ShortNarrow(u16, bool32); static void SpriteCB_TextCursor(struct Sprite *sprite); TextFlags gTextFlags; @@ -55,7 +65,12 @@ static const struct GlyphWidthFunc sGlyphWidthFuncs[] = { { FONT_NORMAL_COPY_2, GetGlyphWidth_NormalCopy2 }, { FONT_MALE, GetGlyphWidth_Male }, { FONT_FEMALE, GetGlyphWidth_Female }, - { FONT_BRAILLE, GetGlyphWidth_Braille } + { FONT_BRAILLE, GetGlyphWidth_Braille }, + { FONT_NARROW, GetGlyphWidth_Narrow }, + { FONT_SMALL_NARROW, GetGlyphWidth_SmallNarrow }, + { FONT_NARROWER, GetGlyphWidth_Narrower }, + { FONT_SMALL_NARROWER, GetGlyphWidth_SmallNarrower }, + { FONT_SHORT_NARROW, GetGlyphWidth_ShortNarrow }, }; static const struct SpriteSheet sSpriteSheets_TextCursor[] = @@ -390,6 +405,187 @@ static const u8 sFontFemaleJapaneseGlyphWidths[] = 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 0 }; +ALIGNED(4) const u16 gFontSmallNarrowLatinGlyphs[] = INCBIN_U16("graphics/fonts/small_narrow.latfont"); +ALIGNED(4) const u8 gFontSmallNarrowLatinGlyphWidths[] = { + 3, 5, 5, 5, 5, 5, 5, 5, 5, 4, 3, 4, 4, 5, 5, 5, + 5, 5, 5, 5, 5, 5, 5, 5, 3, 4, 5, 5, 5, 5, 4, 3, + 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 8, 5, 6, 3, + 3, 3, 3, 3, 8, 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 5, 5,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 5, 5, 5, 5, 5, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 12, 12, 12, 12, 8, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, + 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, + 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 3, +}; + + static const u16 sFontBoldJapaneseGlyphs[] = INCBIN_U16("graphics/fonts/japanese_bold.fwjpnfont"); u16 FontFunc_Small(struct TextPrinter *textPrinter) @@ -464,6 +660,66 @@ u16 FontFunc_Female(struct TextPrinter *textPrinter) return RenderText(textPrinter); } +u16 FontFunc_Narrow(struct TextPrinter *textPrinter) +{ + struct TextPrinterSubStruct *subStruct = &textPrinter->subUnion.sub; + + if (subStruct->hasGlyphIdBeenSet == FALSE) + { + textPrinter->subUnion.sub.glyphId = FONT_NARROW; + subStruct->hasGlyphIdBeenSet = TRUE; + } + return RenderText(textPrinter); +} + +u16 FontFunc_SmallNarrow(struct TextPrinter *textPrinter) +{ + struct TextPrinterSubStruct *subStruct = &textPrinter->subUnion.sub; + + if (subStruct->hasGlyphIdBeenSet == FALSE) + { + textPrinter->subUnion.sub.glyphId = FONT_SMALL_NARROW; + subStruct->hasGlyphIdBeenSet = TRUE; + } + return RenderText(textPrinter); +} + +u16 FontFunc_Narrower(struct TextPrinter *textPrinter) +{ + struct TextPrinterSubStruct *subStruct = &textPrinter->subUnion.sub; + + if (subStruct->hasGlyphIdBeenSet == FALSE) + { + textPrinter->subUnion.sub.glyphId = FONT_NARROWER; + subStruct->hasGlyphIdBeenSet = TRUE; + } + return RenderText(textPrinter); +} + +u16 FontFunc_SmallNarrower(struct TextPrinter *textPrinter) +{ + struct TextPrinterSubStruct *subStruct = &textPrinter->subUnion.sub; + + if (subStruct->hasGlyphIdBeenSet == FALSE) + { + textPrinter->subUnion.sub.glyphId = FONT_SMALL_NARROWER; + subStruct->hasGlyphIdBeenSet = TRUE; + } + return RenderText(textPrinter); +} + +u16 FontFunc_ShortNarrow(struct TextPrinter *textPrinter) +{ + struct TextPrinterSubStruct *subStruct = &textPrinter->subUnion.sub; + + if (subStruct->hasGlyphIdBeenSet == FALSE) + { + textPrinter->subUnion.sub.glyphId = FONT_SHORT_NARROW; + subStruct->hasGlyphIdBeenSet = TRUE; + } + return RenderText(textPrinter); +} + void TextPrinterInitDownArrowCounters(struct TextPrinter *textPrinter) { struct TextPrinterSubStruct *subStruct = &textPrinter->subUnion.sub; @@ -843,6 +1099,21 @@ u16 RenderText(struct TextPrinter *textPrinter) case FONT_FEMALE: DecompressGlyph_Female(currChar, textPrinter->japanese); break; + case FONT_NARROW: + DecompressGlyph_Narrow(currChar, textPrinter->japanese); + break; + case FONT_SMALL_NARROW: + DecompressGlyph_SmallNarrow(currChar, textPrinter->japanese); + break; + case FONT_NARROWER: + DecompressGlyph_Narrower(currChar, textPrinter->japanese); + break; + case FONT_SMALL_NARROWER: + DecompressGlyph_SmallNarrower(currChar, textPrinter->japanese); + break; + case FONT_SHORT_NARROW: + DecompressGlyph_ShortNarrow(currChar, textPrinter->japanese); + break; } CopyGlyphToWindow(textPrinter); @@ -923,7 +1194,7 @@ u16 RenderText(struct TextPrinter *textPrinter) return RENDER_FINISH; } -s32 (*GetFontWidthFunc(u8 glyphId))(u16 _glyphId, bool32 _isJapanese) +u32 (*GetFontWidthFunc(u8 glyphId))(u16 _glyphId, bool32 _isJapanese) { u32 i; @@ -940,7 +1211,7 @@ s32 GetStringWidth(u8 fontId, const u8 *str, s16 letterSpacing) { bool8 isJapanese; int minGlyphWidth; - s32 (*func)(u16 glyphId, bool32 isJapanese); + u32 (*func)(u16 glyphId, bool32 isJapanese); int localLetterSpacing; u32 lineWidth; const u8 *bufferPointer; @@ -1304,7 +1575,7 @@ void DecompressGlyph_Small(u16 glyphId, bool32 isJapanese) } } -static s32 GetGlyphWidth_Small(u16 glyphId, bool32 isJapanese) +static u32 GetGlyphWidth_Small(u16 glyphId, bool32 isJapanese) { if (isJapanese == TRUE) return 8; @@ -1338,7 +1609,7 @@ static void DecompressGlyph_NormalCopy1(u16 glyphId, bool32 isJapanese) } } -static s32 GetGlyphWidth_NormalCopy1(u16 glyphId, bool32 isJapanese) +static u32 GetGlyphWidth_NormalCopy1(u16 glyphId, bool32 isJapanese) { if (isJapanese == TRUE) return 8; @@ -1404,7 +1675,7 @@ void DecompressGlyph_Normal(u16 glyphId, bool32 isJapanese) } } -static s32 GetGlyphWidth_Normal(u16 glyphId, bool32 isJapanese) +static u32 GetGlyphWidth_Normal(u16 glyphId, bool32 isJapanese) { if (isJapanese == TRUE) { @@ -1454,7 +1725,7 @@ static void DecompressGlyph_NormalCopy2(u16 glyphId, bool32 isJapanese) DecompressGlyph_Normal(glyphId, isJapanese); } -static s32 GetGlyphWidth_NormalCopy2(u16 glyphId, bool32 isJapanese) +static u32 GetGlyphWidth_NormalCopy2(u16 glyphId, bool32 isJapanese) { if (isJapanese == TRUE) return 10; @@ -1520,7 +1791,7 @@ static void DecompressGlyph_Male(u16 glyphId, bool32 isJapanese) } } -static s32 GetGlyphWidth_Male(u16 glyphId, bool32 isJapanese) +static u32 GetGlyphWidth_Male(u16 glyphId, bool32 isJapanese) { if (isJapanese == TRUE) { @@ -1591,7 +1862,7 @@ void DecompressGlyph_Female(u16 glyphId, bool32 isJapanese) } } -static s32 GetGlyphWidth_Female(u16 glyphId, bool32 isJapanese) +static u32 GetGlyphWidth_Female(u16 glyphId, bool32 isJapanese) { if (isJapanese == TRUE) { @@ -1613,21 +1884,241 @@ static void DecompressGlyph_Bold(u16 glyphId) gGlyphInfo.height = 12; } +static void DecompressGlyph_Narrow(u16 glyphId, bool32 isJapanese) +{ + const u16 *glyphs; + + if (isJapanese == TRUE) + { + glyphs = sFontNormalJapaneseGlyphs + (0x100 * (glyphId >> 0x4)) + (0x8 * (glyphId % 0x10)); + DecompressGlyphTile(glyphs, (u16 *)gGlyphInfo.pixels); + DecompressGlyphTile(glyphs + 0x8, (u16 *)(gGlyphInfo.pixels + 0x20)); + DecompressGlyphTile(glyphs + 0x10, (u16 *)(gGlyphInfo.pixels + 0x40)); + DecompressGlyphTile(glyphs + 0x18, (u16 *)(gGlyphInfo.pixels + 0x60)); + gGlyphInfo.width = 8; + gGlyphInfo.height = 15; + } + else + { + glyphs = gFontNarrowLatinGlyphs + (0x20 * glyphId); + gGlyphInfo.width = gFontNarrowLatinGlyphWidths[glyphId]; + + if (gGlyphInfo.width <= 8) + { + DecompressGlyphTile(glyphs, (u16 *)gGlyphInfo.pixels); + DecompressGlyphTile(glyphs + 0x10, (u16 *)(gGlyphInfo.pixels + 0x40)); + } + else + { + DecompressGlyphTile(glyphs, (u16 *)gGlyphInfo.pixels); + DecompressGlyphTile(glyphs + 0x8, (u16 *)(gGlyphInfo.pixels + 0x20)); + DecompressGlyphTile(glyphs + 0x10, (u16 *)(gGlyphInfo.pixels + 0x40)); + DecompressGlyphTile(glyphs + 0x18, (u16 *)(gGlyphInfo.pixels + 0x60)); + } + + gGlyphInfo.height = 15; + } +} + +static u32 GetGlyphWidth_Narrow(u16 glyphId, bool32 isJapanese) +{ + if (isJapanese == TRUE) + return 8; + else + return gFontNarrowLatinGlyphWidths[glyphId]; +} + +static void DecompressGlyph_SmallNarrow(u16 glyphId, bool32 isJapanese) +{ + const u16 *glyphs; + + if (isJapanese == TRUE) + { + glyphs = sFontNormalJapaneseGlyphs + (0x100 * (glyphId >> 0x4)) + (0x8 * (glyphId & 0xF)); + DecompressGlyphTile(glyphs, (u16 *)gGlyphInfo.pixels); + DecompressGlyphTile(glyphs + 0x8, (u16 *)(gGlyphInfo.pixels + 0x20)); + DecompressGlyphTile(glyphs + 0x10, (u16 *)(gGlyphInfo.pixels + 0x40)); + DecompressGlyphTile(glyphs + 0x18, (u16 *)(gGlyphInfo.pixels + 0x60)); + gGlyphInfo.width = 8; + gGlyphInfo.height = 12; + } + else + { + glyphs = gFontSmallNarrowLatinGlyphs + (0x20 * glyphId); + gGlyphInfo.width = gFontSmallNarrowLatinGlyphWidths[glyphId]; + + if (gGlyphInfo.width <= 8) + { + DecompressGlyphTile(glyphs, (u16 *)gGlyphInfo.pixels); + DecompressGlyphTile(glyphs + 0x10, (u16 *)(gGlyphInfo.pixels + 0x40)); + } + else + { + DecompressGlyphTile(glyphs, (u16 *)gGlyphInfo.pixels); + DecompressGlyphTile(glyphs + 0x8, (u16 *)(gGlyphInfo.pixels + 0x20)); + DecompressGlyphTile(glyphs + 0x10, (u16 *)(gGlyphInfo.pixels + 0x40)); + DecompressGlyphTile(glyphs + 0x18, (u16 *)(gGlyphInfo.pixels + 0x60)); + } + + gGlyphInfo.height = 12; + } +} + +static u32 GetGlyphWidth_SmallNarrow(u16 glyphId, bool32 isJapanese) +{ + if (isJapanese == TRUE) + return 8; + else + return gFontSmallNarrowLatinGlyphWidths[glyphId]; +} + +static void DecompressGlyph_Narrower(u16 glyphId, bool32 isJapanese) +{ + const u16 *glyphs; + + if (isJapanese == TRUE) + { + glyphs = sFontNormalJapaneseGlyphs + (0x100 * (glyphId >> 0x4)) + (0x8 * (glyphId % 0x10)); + DecompressGlyphTile(glyphs, (u16 *)gGlyphInfo.pixels); + DecompressGlyphTile(glyphs + 0x10, (u16 *)(gGlyphInfo.pixels + 0x40)); + gGlyphInfo.width = 8; + gGlyphInfo.height = 15; + } + else + { + glyphs = gFontNarrowerLatinGlyphs + (0x20 * glyphId); + gGlyphInfo.width = gFontNarrowerLatinGlyphWidths[glyphId]; + + if (gGlyphInfo.width <= 8) + { + DecompressGlyphTile(glyphs, (u16 *)gGlyphInfo.pixels); + DecompressGlyphTile(glyphs + 0x10, (u16 *)(gGlyphInfo.pixels + 0x40)); + } + else + { + DecompressGlyphTile(glyphs, (u16 *)gGlyphInfo.pixels); + DecompressGlyphTile(glyphs + 0x8, (u16 *)(gGlyphInfo.pixels + 0x20)); + DecompressGlyphTile(glyphs + 0x10, (u16 *)(gGlyphInfo.pixels + 0x40)); + DecompressGlyphTile(glyphs + 0x18, (u16 *)(gGlyphInfo.pixels + 0x60)); + } + + gGlyphInfo.height = 15; + } +} + +static u32 GetGlyphWidth_Narrower(u16 glyphId, bool32 isJapanese) +{ + if (isJapanese == TRUE) + return 8; + else + return gFontNarrowerLatinGlyphWidths[glyphId]; +} + +static void DecompressGlyph_SmallNarrower(u16 glyphId, bool32 isJapanese) +{ + const u16 *glyphs; + + if (isJapanese == TRUE) + { + glyphs = sFontNormalJapaneseGlyphs + (0x100 * (glyphId >> 0x4)) + (0x8 * (glyphId % 0x10)); + DecompressGlyphTile(glyphs, (u16 *)gGlyphInfo.pixels); + DecompressGlyphTile(glyphs + 0x8, (u16 *)(gGlyphInfo.pixels + 0x20)); + DecompressGlyphTile(glyphs + 0x10, (u16 *)(gGlyphInfo.pixels + 0x40)); + DecompressGlyphTile(glyphs + 0x18, (u16 *)(gGlyphInfo.pixels + 0x60)); + gGlyphInfo.width = 8; + gGlyphInfo.height = 15; + } + else + { + glyphs = gFontSmallNarrowerLatinGlyphs + (0x20 * glyphId); + gGlyphInfo.width = gFontSmallNarrowerLatinGlyphWidths[glyphId]; + + if (gGlyphInfo.width <= 8) + { + DecompressGlyphTile(glyphs, (u16 *)gGlyphInfo.pixels); + DecompressGlyphTile(glyphs + 0x10, (u16 *)(gGlyphInfo.pixels + 0x40)); + } + else + { + DecompressGlyphTile(glyphs, (u16 *)gGlyphInfo.pixels); + DecompressGlyphTile(glyphs + 0x8, (u16 *)(gGlyphInfo.pixels + 0x20)); + DecompressGlyphTile(glyphs + 0x10, (u16 *)(gGlyphInfo.pixels + 0x40)); + DecompressGlyphTile(glyphs + 0x18, (u16 *)(gGlyphInfo.pixels + 0x60)); + } + + gGlyphInfo.height = 15; + } +} + +static u32 GetGlyphWidth_SmallNarrower(u16 glyphId, bool32 isJapanese) +{ + if (isJapanese == TRUE) + return 8; + else + return gFontSmallNarrowerLatinGlyphWidths[glyphId]; +} + +static void DecompressGlyph_ShortNarrow(u16 glyphId, bool32 isJapanese) +{ + const u16 *glyphs; + + if (isJapanese == TRUE) + { + glyphs = sFontNormalJapaneseGlyphs + (0x100 * (glyphId >> 0x3)) + (0x10 * (glyphId & 0x7)); + DecompressGlyphTile(glyphs, (u16 *)gGlyphInfo.pixels); + DecompressGlyphTile(glyphs + 0x8, (u16 *)(gGlyphInfo.pixels + 0x20)); + DecompressGlyphTile(glyphs + 0x10, (u16 *)(gGlyphInfo.pixels + 0x40)); + DecompressGlyphTile(glyphs + 0x18, (u16 *)(gGlyphInfo.pixels + 0x60)); + gGlyphInfo.width = sFontNormalJapaneseGlyphWidths[glyphId]; + gGlyphInfo.height = 14; + } + else + { + glyphs = gFontShortNarrowLatinGlyphs + (0x20 * glyphId); + gGlyphInfo.width = gFontShortNarrowLatinGlyphWidths[glyphId]; + + if (gGlyphInfo.width <= 8) + { + DecompressGlyphTile(glyphs, (u16 *)gGlyphInfo.pixels); + DecompressGlyphTile(glyphs + 0x10, (u16 *)(gGlyphInfo.pixels + 0x40)); + } + else + { + DecompressGlyphTile(glyphs, (u16 *)gGlyphInfo.pixels); + DecompressGlyphTile(glyphs + 0x8, (u16 *)(gGlyphInfo.pixels + 0x20)); + DecompressGlyphTile(glyphs + 0x10, (u16 *)(gGlyphInfo.pixels + 0x40)); + DecompressGlyphTile(glyphs + 0x18, (u16 *)(gGlyphInfo.pixels + 0x60)); + } + + gGlyphInfo.height = 14; + } +} + +static u32 GetGlyphWidth_ShortNarrow(u16 glyphId, bool32 isJapanese) +{ + if (isJapanese == TRUE) + return sFontNormalJapaneseGlyphWidths[glyphId]; + else + return gFontShortNarrowLatinGlyphWidths[glyphId]; +} + static const s8 sNarrowerFontIds[] = { - [FONT_SMALL] = -1, // FONT_SMALL_NARROW, - [FONT_NORMAL] = -1, // FONT_NARROW, + [FONT_SMALL] = FONT_SMALL_NARROW, // FONT_SMALL_NARROW, + [FONT_NORMAL] = FONT_NARROW, // FONT_NARROW, // [FONT_SHORT] = FONT_SHORT_NARROW, // [FONT_SHORT_COPY_1] = FONT_SHORT_NARROW, // [FONT_SHORT_COPY_2] = FONT_SHORT_NARROW, // [FONT_SHORT_COPY_3] = FONT_SHORT_NARROW, [FONT_BRAILLE] = -1, - // [FONT_NARROW] = FONT_NARROWER, - // [FONT_SMALL_NARROW] = FONT_SMALL_NARROWER, + [FONT_NARROW] = FONT_NARROWER, + [FONT_SMALL_NARROW] = FONT_SMALL_NARROWER, [FONT_BOLD] = -1, - // [FONT_NARROWER] = -1, - // [FONT_SMALL_NARROWER] = -1, - // [FONT_SHORT_NARROW] = -1, + [FONT_NARROWER] = -1, + [FONT_SMALL_NARROWER] = -1, + [FONT_SHORT_NARROW] = -1, + [FONT_MALE] = FONT_NORMAL, + [FONT_FEMALE] = FONT_NORMAL, }; // If the narrowest font ID doesn't fit the text, we still return that diff --git a/gflib/text.h b/gflib/text.h index 2be25986d..bb2ea518a 100644 --- a/gflib/text.h +++ b/gflib/text.h @@ -20,6 +20,11 @@ enum { FONT_FEMALE, FONT_BRAILLE, FONT_BOLD, + FONT_NARROW, + FONT_SMALL_NARROW, // Very similar to FONT_SMALL, some glyphs are narrower + FONT_NARROWER, + FONT_SMALL_NARROWER, + FONT_SHORT_NARROW, }; // Return values for font functions @@ -125,7 +130,7 @@ extern const struct FontInfo *gFonts; struct GlyphWidthFunc { u32 fontId; - s32 (*func)(u16 glyphId, bool32 isJapanese); + u32 (*func)(u16 glyphId, bool32 isJapanese); }; typedef struct { @@ -166,6 +171,11 @@ u16 FontFunc_NormalCopy2(struct TextPrinter *textPrinter); u16 FontFunc_Male(struct TextPrinter *textPrinter); u16 FontFunc_Female(struct TextPrinter *textPrinter); u16 FontFunc_Braille(struct TextPrinter *textPrinter); +u16 FontFunc_Narrow(struct TextPrinter *textPrinter); +u16 FontFunc_SmallNarrow(struct TextPrinter *textPrinter); +u16 FontFunc_Narrower(struct TextPrinter *textPrinter); +u16 FontFunc_SmallNarrower(struct TextPrinter *textPrinter); +u16 FontFunc_ShortNarrow(struct TextPrinter *textPrinter); void TextPrinterInitDownArrowCounters(struct TextPrinter *textPrinter); void TextPrinterDrawDownArrow(struct TextPrinter *textPrinter); @@ -175,7 +185,7 @@ bool16 TextPrinterWaitWithDownArrow(struct TextPrinter *textPrinter); bool16 TextPrinterWait(struct TextPrinter *textPrinter); void DrawDownArrow(u8 windowId, u16 x, u16 y, u8 bgColor, bool8 drawArrow, u8 *counter, u8 *yCoordIndex); u16 RenderText(struct TextPrinter *textPrinter); -s32 (*GetFontWidthFunc(u8 glyphId))(u16, bool32); +u32 (*GetFontWidthFunc(u8 glyphId))(u16, bool32); s32 GetStringWidth(u8 fontId, const u8 *str, s16 letterSpacing); u8 RenderTextHandleBold(u8 *pixels, u8 fontId, u8 *str); u8 DrawKeypadIcon(u8 windowId, u8 keypadIconId, u16 x, u16 y); @@ -187,10 +197,11 @@ u8 GetMenuCursorDimensionByFont(u8 fontId, u8 whichDimension); void DecompressGlyph_Small(u16 glyphId, bool32 isJapanese); void DecompressGlyph_Normal(u16 glyphId, bool32 isJapanese); void DecompressGlyph_Female(u16 glyphId, bool32 isJapanese); -s32 GetGlyphWidth_Braille(u16 font_type, bool32 isJapanese); +u32 GetGlyphWidth_Braille(u16 font_type, bool32 isJapanese); u8 CreateTextCursorSprite(u8 sheetId, u16 x, u16 y, u8 priority, u8 subpriority); void DestroyTextCursorSprite(u8 spriteId); +u32 GetFontIdToFit(const u8 *string, u32 widestFontId, u32 letterSpacing, u32 widthPx); u8 *PrependFontIdToFit(u8 *start, u8 *end, u32 fontId, u32 width); #endif // GUARD_TEXT_H diff --git a/graphics/fonts/latin_narrow.png b/graphics/fonts/latin_narrow.png new file mode 100644 index 000000000..08652d45f Binary files /dev/null and b/graphics/fonts/latin_narrow.png differ diff --git a/graphics/fonts/latin_narrower.png b/graphics/fonts/latin_narrower.png new file mode 100644 index 000000000..22847ef09 Binary files /dev/null and b/graphics/fonts/latin_narrower.png differ diff --git a/graphics/fonts/latin_short_narrow.png b/graphics/fonts/latin_short_narrow.png new file mode 100644 index 000000000..cf4871271 Binary files /dev/null and b/graphics/fonts/latin_short_narrow.png differ diff --git a/graphics/fonts/latin_small_narrow.png b/graphics/fonts/latin_small_narrow.png new file mode 100644 index 000000000..3a88def3a Binary files /dev/null and b/graphics/fonts/latin_small_narrow.png differ diff --git a/graphics/fonts/latin_small_narrower.png b/graphics/fonts/latin_small_narrower.png new file mode 100644 index 000000000..a183bed7c Binary files /dev/null and b/graphics/fonts/latin_small_narrower.png differ diff --git a/graphics_file_rules.mk b/graphics_file_rules.mk index 0ebcb878b..ff9a0109e 100644 --- a/graphics_file_rules.mk +++ b/graphics_file_rules.mk @@ -36,6 +36,23 @@ JPCONTESTGFXDIR := graphics/contest/japanese types := normal fight flying poison ground rock bug ghost steel mystery fire water grass electric psychic ice dragon dark contest_types := cool beauty cute smart tough + +### Fonts ### +$(FONTGFXDIR)/narrow.latfont: $(FONTGFXDIR)/latin_narrow.png + $(GFX) $< $@ + +$(FONTGFXDIR)/small_narrow.latfont: $(FONTGFXDIR)/latin_small_narrow.png + $(GFX) $< $@ + +$(FONTGFXDIR)/narrower.latfont: $(FONTGFXDIR)/latin_narrower.png + $(GFX) $< $@ + +$(FONTGFXDIR)/small_narrower.latfont: $(FONTGFXDIR)/latin_small_narrower.png + $(GFX) $< $@ + +$(FONTGFXDIR)/short_narrow.latfont: $(FONTGFXDIR)/latin_short_narrow.png + $(GFX) $< $@ + $(FONTGFXDIR)/latin_small.latfont: $(FONTGFXDIR)/latin_small.png $(GFX) $< $@ diff --git a/include/item.h b/include/item.h index e2de9cab4..ed57e4b30 100644 --- a/include/item.h +++ b/include/item.h @@ -39,7 +39,7 @@ extern struct BagPocket gBagPockets[]; void GetBerryCountString(u8 *dst, const u8 *berryName, u32 quantity); void CopyItemName(u16 itemId, u8 *string); -void CopyItemNameHandlePlural(u16 itemId, u8 *string, u32 quantity); +u8 *CopyItemNameHandlePlural(u16 itemId, u8 *string, u32 quantity); bool8 IsBagPocketNonEmpty(u8 pocket); bool8 CheckBagHasItem(u16 itemId, u16 count); bool8 CheckBagHasSpace(u16 itemId, u16 count); diff --git a/src/battle_message.c b/src/battle_message.c index 874acc449..0ba12fb70 100644 --- a/src/battle_message.c +++ b/src/battle_message.c @@ -3829,6 +3829,15 @@ void BattlePutTextOnWindow(const u8 *text, u8 windowId) { printerTemplate.fgColor = sTextOnWindowsInfo_Normal[windowId].fgColor; printerTemplate.bgColor = sTextOnWindowsInfo_Normal[windowId].bgColor; printerTemplate.shadowColor = sTextOnWindowsInfo_Normal[windowId].shadowColor; + + if (B_WIN_MOVE_NAME_1 <= windowId && windowId <= B_WIN_MOVE_NAME_4) + { + // We cannot check the actual width of the window because + // B_WIN_MOVE_NAME_1 and B_WIN_MOVE_NAME_3 are 16 wide for + // Z-move details. + printerTemplate.fontId = GetFontIdToFit(text, printerTemplate.fontId, printerTemplate.letterSpacing, 8 * TILE_WIDTH); + } + if (windowId == B_WIN_OAK_OLD_MAN) gTextFlags.useAlternateDownArrow = FALSE; else diff --git a/src/braille_text.c b/src/braille_text.c index d4afdf87f..6a0478678 100644 --- a/src/braille_text.c +++ b/src/braille_text.c @@ -206,7 +206,7 @@ static void DecompressGlyph_Braille(u16 glyph) gGlyphInfo.height = 16; } -s32 GetGlyphWidth_Braille(u16 font_type, bool32 isJapanese) +u32 GetGlyphWidth_Braille(u16 font_type, bool32 isJapanese) { return 16; } diff --git a/src/item.c b/src/item.c index 860cb5574..5158d6031 100644 --- a/src/item.c +++ b/src/item.c @@ -19,6 +19,8 @@ EWRAM_DATA struct BagPocket gBagPockets[NUM_BAG_POCKETS] = {}; void SortAndCompactBagPocket(struct BagPocket * pocket); +static const u8 *ItemId_GetPluralName(u16); +static bool32 DoesItemHavePluralName(u16); // Item descriptions and data #include "constants/moves.h" @@ -83,6 +85,25 @@ void CopyItemName(u16 itemId, u8 * dest) StringCopy(dest, ItemId_GetName(itemId)); } +const u8 sText_s[] =_("s"); + +u8 *CopyItemNameHandlePlural(u16 itemId, u8 *dst, u32 quantity) +{ + if (quantity == 1) + { + return StringCopy(dst, ItemId_GetName(itemId)); + } + else if (DoesItemHavePluralName(itemId)) + { + return StringCopy(dst, ItemId_GetPluralName(itemId)); + } + else + { + u8 *end = StringCopy(dst, ItemId_GetName(itemId)); + return StringCopy(end, sText_s); + } +} + s8 BagPocketGetFirstEmptySlot(u8 pocketId) { u16 i; @@ -617,6 +638,16 @@ u16 ItemId_GetPrice(u16 itemId) return gItemsInfo[SanitizeItemId(itemId)].price; } +static bool32 DoesItemHavePluralName(u16 itemId) +{ + return (gItemsInfo[SanitizeItemId(itemId)].pluralName[0] != '\0'); +} + +static const u8 *ItemId_GetPluralName(u16 itemId) +{ + return gItemsInfo[SanitizeItemId(itemId)].pluralName; +} + u8 ItemId_GetHoldEffect(u16 itemId) { return gItemsInfo[SanitizeItemId(itemId)].holdEffect; diff --git a/src/new_menu_helpers.c b/src/new_menu_helpers.c index c857d7001..57b127801 100644 --- a/src/new_menu_helpers.c +++ b/src/new_menu_helpers.c @@ -137,7 +137,57 @@ static const struct FontInfo gFontInfos[] = .fgColor = 1, .bgColor = 2, .shadowColor = 15, - } + }, + [FONT_NARROW] = { + .fontFunction = FontFunc_Narrow, + .maxLetterWidth = 5, + .maxLetterHeight = 16, + .letterSpacing = 0, + .lineSpacing = 0, + .fgColor = 2, + .bgColor = 1, + .shadowColor = 3, + }, + [FONT_SMALL_NARROW] = { + .fontFunction = FontFunc_SmallNarrow, + .maxLetterWidth = 5, + .maxLetterHeight = 8, + .letterSpacing = 0, + .lineSpacing = 0, + .fgColor = 2, + .bgColor = 1, + .shadowColor = 3, + }, + [FONT_NARROWER] = { + .fontFunction = FontFunc_Narrower, + .maxLetterWidth = 5, + .maxLetterHeight = 16, + .letterSpacing = 0, + .lineSpacing = 0, + .fgColor = 2, + .bgColor = 1, + .shadowColor = 3, + }, + [FONT_SMALL_NARROWER] = { + .fontFunction = FontFunc_SmallNarrower, + .maxLetterWidth = 5, + .maxLetterHeight = 8, + .letterSpacing = 0, + .lineSpacing = 0, + .fgColor = 2, + .bgColor = 1, + .shadowColor = 3, + }, + [FONT_SHORT_NARROW] = { + .fontFunction = FontFunc_ShortNarrow, + .maxLetterWidth = 5, + .maxLetterHeight = 14, + .letterSpacing = 0, + .lineSpacing = 0, + .fgColor = 2, + .bgColor = 1, + .shadowColor = 3, + }, }; static const u8 gMenuCursorDimensions[][2] = diff --git a/test/text.c b/test/text.c index cd182401d..e8eb4f7f2 100644 --- a/test/text.c +++ b/test/text.c @@ -1,550 +1,550 @@ -// #include "global.h" -// #include "test/test.h" -// #include "battle_main.h" -// #include "item.h" -// #include "text.h" -// #include "constants/abilities.h" -// #include "constants/items.h" -// #include "constants/moves.h" +#include "global.h" +#include "test/test.h" +#include "battle_main.h" +#include "item.h" +#include "text.h" +#include "constants/abilities.h" +#include "constants/items.h" +#include "constants/moves.h" -// TEST("Move names fit on Pokemon Summary Screen") -// { -// u32 i; -// const u32 fontId = FONT_NARROWER, widthPx = 72; -// u32 move = MOVE_NONE; -// for (i = 1; i < MOVES_COUNT; i++) -// { -// PARAMETRIZE_LABEL("%S", gMovesInfo[i].name) { move = i; } -// } -// EXPECT_LE(GetStringWidth(fontId, gMovesInfo[move].name, 0), widthPx); -// } +TEST("Move names fit on Pokemon Summary Screen") +{ + u32 i; + const u32 fontId = FONT_NARROWER, widthPx = 72; + u32 move = MOVE_NONE; + for (i = 1; i < MOVES_COUNT; i++) + { + PARAMETRIZE_LABEL("%S", gMovesInfo[i].name) { move = i; } + } + EXPECT_LE(GetStringWidth(fontId, gMovesInfo[move].name, 0), widthPx); +} -// TEST("Move names fit on Battle Screen") -// { -// u32 i; -// const u32 fontId = FONT_NARROWER, widthPx = 64; -// u32 move = MOVE_NONE; -// for (i = 1; i < MOVES_COUNT; i++) -// { -// PARAMETRIZE_LABEL("%S", gMovesInfo[i].name) { move = i; } -// } -// EXPECT_LE(GetStringWidth(fontId, gMovesInfo[move].name, 0), widthPx); -// } +TEST("Move names fit on Battle Screen") +{ + u32 i; + const u32 fontId = FONT_NARROWER, widthPx = 64; + u32 move = MOVE_NONE; + for (i = 1; i < MOVES_COUNT; i++) + { + PARAMETRIZE_LABEL("%S", gMovesInfo[i].name) { move = i; } + } + EXPECT_LE(GetStringWidth(fontId, gMovesInfo[move].name, 0), widthPx); +} -// TEST("Move names fit on Contest Screen") -// { -// u32 i; -// const u32 fontId = FONT_NARROWER, widthPx = 61; -// u32 move = MOVE_NONE; -// for (i = 1; i < MOVES_COUNT; i++) -// { -// PARAMETRIZE_LABEL("%S", gMovesInfo[i].name) { move = i; } -// } -// // All moves explicitly listed here are too big to fit. -// switch (move) -// { -// case MOVE_NATURES_MADNESS: -// EXPECT_GT(GetStringWidth(fontId, gMovesInfo[move].name, 0), widthPx); -// break; -// default: -// EXPECT_LE(GetStringWidth(fontId, gMovesInfo[move].name, 0), widthPx); -// break; -// } -// } +TEST("Move names fit on Contest Screen") +{ + u32 i; + const u32 fontId = FONT_NARROWER, widthPx = 61; + u32 move = MOVE_NONE; + for (i = 1; i < MOVES_COUNT; i++) + { + PARAMETRIZE_LABEL("%S", gMovesInfo[i].name) { move = i; } + } + // All moves explicitly listed here are too big to fit. + switch (move) + { + case MOVE_NATURES_MADNESS: + EXPECT_GT(GetStringWidth(fontId, gMovesInfo[move].name, 0), widthPx); + break; + default: + EXPECT_LE(GetStringWidth(fontId, gMovesInfo[move].name, 0), widthPx); + break; + } +} -// TEST("Move names fit on TMs & HMs Bag Screen") -// { -// u32 i; -// const u32 fontId = FONT_NARROWER, widthPx = 63; -// u32 move = MOVE_NONE; -// for (i = 1; i < ITEMS_COUNT; i++) -// { -// if (gItemsInfo[i].pocket == POCKET_TM_HM) -// { -// PARAMETRIZE_LABEL("%S", gMovesInfo[gItemsInfo[i].secondaryId].name) { move = gItemsInfo[i].secondaryId; } -// } -// } -// EXPECT_LE(GetStringWidth(fontId, gMovesInfo[move].name, 0), widthPx); -// } +TEST("Move names fit on TMs & HMs Bag Screen") +{ + u32 i; + const u32 fontId = FONT_NARROWER, widthPx = 63; + u32 move = MOVE_NONE; + for (i = 1; i < ITEMS_COUNT; i++) + { + if (gItemsInfo[i].pocket == POCKET_TM_HM) + { + PARAMETRIZE_LABEL("%S", gMovesInfo[gItemsInfo[i].secondaryId].name) { move = gItemsInfo[i].secondaryId; } + } + } + EXPECT_LE(GetStringWidth(fontId, gMovesInfo[move].name, 0), widthPx); +} -// TEST("Move names fit on Move Relearner Screen") -// { -// u32 i; -// const u32 fontId = FONT_NARROWER, widthPx = 72; -// u32 move = MOVE_NONE; -// for (i = 1; i < MOVES_COUNT; i++) -// { -// PARAMETRIZE_LABEL("%S", gMovesInfo[i].name) { move = i; } -// } -// EXPECT_LE(GetStringWidth(fontId, gMovesInfo[move].name, 0), widthPx); -// } +TEST("Move names fit on Move Relearner Screen") +{ + u32 i; + const u32 fontId = FONT_NARROWER, widthPx = 72; + u32 move = MOVE_NONE; + for (i = 1; i < MOVES_COUNT; i++) + { + PARAMETRIZE_LABEL("%S", gMovesInfo[i].name) { move = i; } + } + EXPECT_LE(GetStringWidth(fontId, gMovesInfo[move].name, 0), widthPx); +} -// TEST("Item names fit on Bag Screen (list)") -// { -// u32 i; -// const u32 fontId = FONT_NARROWER; -// const u32 tmHmBerryWidthPx = 71, restWidthPx = 88; -// u32 item = ITEM_NONE; -// for (i = 1; i < ITEMS_COUNT; i++) -// { -// PARAMETRIZE_LABEL("%S", gItemsInfo[i].name) { item = i; } -// } -// if (gItemsInfo[item].pocket == POCKET_TM_HM || gItemsInfo[item].pocket == POCKET_BERRIES) -// EXPECT_LE(GetStringWidth(fontId, gItemsInfo[item].name, 0), tmHmBerryWidthPx); -// else -// EXPECT_LE(GetStringWidth(fontId, gItemsInfo[item].name, 0), restWidthPx); -// } +TEST("Item names fit on Bag Screen (list)") +{ + u32 i; + const u32 fontId = FONT_NARROWER; + const u32 tmHmBerryWidthPx = 71, restWidthPx = 88; + u32 item = ITEM_NONE; + for (i = 1; i < ITEMS_COUNT; i++) + { + PARAMETRIZE_LABEL("%S", gItemsInfo[i].name) { item = i; } + } + if (gItemsInfo[item].pocket == POCKET_TM_HM || gItemsInfo[item].pocket == POCKET_BERRIES) + EXPECT_LE(GetStringWidth(fontId, gItemsInfo[item].name, 0), tmHmBerryWidthPx); + else + EXPECT_LE(GetStringWidth(fontId, gItemsInfo[item].name, 0), restWidthPx); +} -// TEST("Item plural names fit on Bag Screen (left box)") -// { -// u32 i; -// // -6 for the question mark in FONT_NORMAL. -// const u32 fontId = FONT_NARROWER, widthPx = 102 - 6; -// u32 item = ITEM_NONE; -// u8 pluralName[ITEM_NAME_PLURAL_LENGTH + 1]; -// for (i = 1; i < ITEMS_COUNT; i++) -// { -// PARAMETRIZE_LABEL("%S", gItemsInfo[i].name) { item = i; } -// } -// CopyItemNameHandlePlural(item, pluralName, 2); -// EXPECT_LE(GetStringWidth(fontId, pluralName, 0), widthPx); -// } +TEST("Item plural names fit on Bag Screen (left box)") +{ + u32 i; + // -6 for the question mark in FONT_NORMAL. + const u32 fontId = FONT_NARROWER, widthPx = 102 - 6; + u32 item = ITEM_NONE; + u8 pluralName[ITEM_NAME_PLURAL_LENGTH + 1]; + for (i = 1; i < ITEMS_COUNT; i++) + { + PARAMETRIZE_LABEL("%S", gItemsInfo[i].name) { item = i; } + } + CopyItemNameHandlePlural(item, pluralName, 2); + EXPECT_LE(GetStringWidth(fontId, pluralName, 0), widthPx); +} -// TEST("Item plural names fit on PC storage (left box)") -// { -// u32 i; -// // -6 for the question mark in FONT_NORMAL. -// const u32 fontId = FONT_NARROWER, widthPx = 104 - 6; -// u32 item = ITEM_NONE; -// u8 pluralName[ITEM_NAME_PLURAL_LENGTH + 1]; -// for (i = 1; i < ITEMS_COUNT; i++) -// { -// PARAMETRIZE_LABEL("%S", gItemsInfo[i].name) { item = i; } -// } -// CopyItemNameHandlePlural(item, pluralName, 2); -// EXPECT_LE(GetStringWidth(fontId, pluralName, 0), widthPx); -// } +TEST("Item plural names fit on PC storage (left box)") +{ + u32 i; + // -6 for the question mark in FONT_NORMAL. + const u32 fontId = FONT_NARROWER, widthPx = 104 - 6; + u32 item = ITEM_NONE; + u8 pluralName[ITEM_NAME_PLURAL_LENGTH + 1]; + for (i = 1; i < ITEMS_COUNT; i++) + { + PARAMETRIZE_LABEL("%S", gItemsInfo[i].name) { item = i; } + } + CopyItemNameHandlePlural(item, pluralName, 2); + EXPECT_LE(GetStringWidth(fontId, pluralName, 0), widthPx); +} -// TEST("Item names fit on Pokemon Storage System") -// { -// u32 i; -// const u32 fontId = FONT_SMALL_NARROWER, widthPx = 50; -// u32 item = ITEM_NONE; -// for (i = 1; i < ITEMS_COUNT; i++) -// { -// if (gItemsInfo[i].importance) continue; -// PARAMETRIZE_LABEL("%S", gItemsInfo[i].name) { item = i; } -// } -// // All items explicitly listed here are too big to fit. The ones -// // with a hold effect are listed at the bottom in case you want to -// // focus on making them fit (they are the most likely to appear on -// // the storage system UI, along with anything that could be held -// // in the wild). -// switch (item) -// { -// case ITEM_ENERGY_POWDER: -// case ITEM_PEWTER_CRUNCHIES: -// case ITEM_RAGE_CANDY_BAR: -// case ITEM_LUMIOSE_GALETTE: -// case ITEM_HEALTH_FEATHER: -// case ITEM_MUSCLE_FEATHER: -// case ITEM_RESIST_FEATHER: -// case ITEM_GENIUS_FEATHER: -// case ITEM_CLEVER_FEATHER: -// case ITEM_ABILITY_CAPSULE: -// case ITEM_DYNAMAX_CANDY: -// case ITEM_MAX_MUSHROOMS: -// case ITEM_GOLD_BOTTLE_CAP: -// case ITEM_PRETTY_FEATHER: -// case ITEM_STRANGE_SOUVENIR: -// case ITEM_FOSSILIZED_BIRD: -// case ITEM_FOSSILIZED_FISH: -// case ITEM_FOSSILIZED_DRAKE: -// case ITEM_FOSSILIZED_DINO: -// case ITEM_SURPRISE_MULCH: -// case ITEM_YELLOW_APRICORN: -// case ITEM_GREEN_APRICORN: -// case ITEM_WHITE_APRICORN: -// case ITEM_BLACK_APRICORN: -// case ITEM_THUNDER_STONE: -// case ITEM_GALARICA_WREATH: -// case ITEM_STRAWBERRY_SWEET: -// case ITEM_AUSPICIOUS_ARMOR: -// case ITEM_BIG_BAMBOO_SHOOT: -// case ITEM_GIMMIGHOUL_COIN: -// case ITEM_LEADERS_CREST: -// case ITEM_MALICIOUS_ARMOR: -// case ITEM_TINY_BAMBOO_SHOOT: -// case ITEM_BUG_TERA_SHARD: -// case ITEM_DARK_TERA_SHARD: -// case ITEM_DRAGON_TERA_SHARD: -// case ITEM_ELECTRIC_TERA_SHARD: -// case ITEM_FAIRY_TERA_SHARD: -// case ITEM_FIGHTING_TERA_SHARD: -// case ITEM_FIRE_TERA_SHARD: -// case ITEM_FLYING_TERA_SHARD: -// case ITEM_GHOST_TERA_SHARD: -// case ITEM_GRASS_TERA_SHARD: -// case ITEM_GROUND_TERA_SHARD: -// case ITEM_ICE_TERA_SHARD: -// case ITEM_NORMAL_TERA_SHARD: -// case ITEM_POISON_TERA_SHARD: -// case ITEM_PSYCHIC_TERA_SHARD: -// case ITEM_ROCK_TERA_SHARD: -// case ITEM_STEEL_TERA_SHARD: -// case ITEM_WATER_TERA_SHARD: -// case ITEM_BLACK_AUGURITE: -// case ITEM_UNREMARKABLE_TEACUP: -// case ITEM_MASTERPIECE_TEACUP: -// case ITEM_FRESH_START_MOCHI: -// case ITEM_STELLAR_TERA_SHARD: -// case ITEM_JUBILIFE_MUFFIN: -// case ITEM_SUPERB_REMEDY: -// case ITEM_AUX_POWERGUARD: -// case ITEM_CHOICE_DUMPLING: -// case ITEM_TWICE_SPICED_RADISH: -// // Items with hold effects: -// case ITEM_ELECTRIC_MEMORY: -// case ITEM_FIGHTING_MEMORY: -// case ITEM_GROUND_MEMORY: -// case ITEM_PSYCHIC_MEMORY: -// case ITEM_DRAGON_MEMORY: -// case ITEM_CHARIZARDITE_X: -// case ITEM_CHARIZARDITE_Y: -// case ITEM_ULTRANECROZIUM_Z: -// case ITEM_DEEP_SEA_SCALE: -// case ITEM_DEEP_SEA_TOOTH: -// case ITEM_NEVER_MELT_ICE: -// case ITEM_WEAKNESS_POLICY: -// case ITEM_SAFETY_GOGGLES: -// case ITEM_ADRENALINE_ORB: -// case ITEM_TERRAIN_EXTENDER: -// case ITEM_PROTECTIVE_PADS: -// case ITEM_HEAVY_DUTY_BOOTS: -// case ITEM_UTILITY_UMBRELLA: -// case ITEM_MARANGA_BERRY: -// case ITEM_PUNCHING_GLOVE: -// case ITEM_BOOSTER_ENERGY: -// case ITEM_ADAMANT_CRYSTAL: -// case ITEM_LUSTROUS_GLOBE: -// case ITEM_CORNERSTONE_MASK: -// case ITEM_WELLSPRING_MASK: -// case ITEM_HEARTHFLAME_MASK: -// EXPECT_GT(GetStringWidth(fontId, gItemsInfo[item].name, 0), widthPx); -// break; -// default: -// EXPECT_LE(GetStringWidth(fontId, gItemsInfo[item].name, 0), widthPx); -// break; -// } -// } +TEST("Item names fit on Pokemon Storage System") +{ + u32 i; + const u32 fontId = FONT_SMALL_NARROWER, widthPx = 50; + u32 item = ITEM_NONE; + for (i = 1; i < ITEMS_COUNT; i++) + { + if (gItemsInfo[i].importance) continue; + PARAMETRIZE_LABEL("%S", gItemsInfo[i].name) { item = i; } + } + // All items explicitly listed here are too big to fit. The ones + // with a hold effect are listed at the bottom in case you want to + // focus on making them fit (they are the most likely to appear on + // the storage system UI, along with anything that could be held + // in the wild). + switch (item) + { + case ITEM_ENERGY_POWDER: + case ITEM_PEWTER_CRUNCHIES: + case ITEM_RAGE_CANDY_BAR: + case ITEM_LUMIOSE_GALETTE: + case ITEM_HEALTH_FEATHER: + case ITEM_MUSCLE_FEATHER: + case ITEM_RESIST_FEATHER: + case ITEM_GENIUS_FEATHER: + case ITEM_CLEVER_FEATHER: + case ITEM_ABILITY_CAPSULE: + case ITEM_DYNAMAX_CANDY: + case ITEM_MAX_MUSHROOMS: + case ITEM_GOLD_BOTTLE_CAP: + case ITEM_PRETTY_FEATHER: + case ITEM_STRANGE_SOUVENIR: + case ITEM_FOSSILIZED_BIRD: + case ITEM_FOSSILIZED_FISH: + case ITEM_FOSSILIZED_DRAKE: + case ITEM_FOSSILIZED_DINO: + case ITEM_SURPRISE_MULCH: + case ITEM_YELLOW_APRICORN: + case ITEM_GREEN_APRICORN: + case ITEM_WHITE_APRICORN: + case ITEM_BLACK_APRICORN: + case ITEM_THUNDER_STONE: + case ITEM_GALARICA_WREATH: + case ITEM_STRAWBERRY_SWEET: + case ITEM_AUSPICIOUS_ARMOR: + case ITEM_BIG_BAMBOO_SHOOT: + case ITEM_GIMMIGHOUL_COIN: + case ITEM_LEADERS_CREST: + case ITEM_MALICIOUS_ARMOR: + case ITEM_TINY_BAMBOO_SHOOT: + case ITEM_BUG_TERA_SHARD: + case ITEM_DARK_TERA_SHARD: + case ITEM_DRAGON_TERA_SHARD: + case ITEM_ELECTRIC_TERA_SHARD: + case ITEM_FAIRY_TERA_SHARD: + case ITEM_FIGHTING_TERA_SHARD: + case ITEM_FIRE_TERA_SHARD: + case ITEM_FLYING_TERA_SHARD: + case ITEM_GHOST_TERA_SHARD: + case ITEM_GRASS_TERA_SHARD: + case ITEM_GROUND_TERA_SHARD: + case ITEM_ICE_TERA_SHARD: + case ITEM_NORMAL_TERA_SHARD: + case ITEM_POISON_TERA_SHARD: + case ITEM_PSYCHIC_TERA_SHARD: + case ITEM_ROCK_TERA_SHARD: + case ITEM_STEEL_TERA_SHARD: + case ITEM_WATER_TERA_SHARD: + case ITEM_BLACK_AUGURITE: + case ITEM_UNREMARKABLE_TEACUP: + case ITEM_MASTERPIECE_TEACUP: + case ITEM_FRESH_START_MOCHI: + case ITEM_STELLAR_TERA_SHARD: + case ITEM_JUBILIFE_MUFFIN: + case ITEM_SUPERB_REMEDY: + case ITEM_AUX_POWERGUARD: + case ITEM_CHOICE_DUMPLING: + case ITEM_TWICE_SPICED_RADISH: + // Items with hold effects: + case ITEM_ELECTRIC_MEMORY: + case ITEM_FIGHTING_MEMORY: + case ITEM_GROUND_MEMORY: + case ITEM_PSYCHIC_MEMORY: + case ITEM_DRAGON_MEMORY: + case ITEM_CHARIZARDITE_X: + case ITEM_CHARIZARDITE_Y: + case ITEM_ULTRANECROZIUM_Z: + case ITEM_DEEP_SEA_SCALE: + case ITEM_DEEP_SEA_TOOTH: + case ITEM_NEVER_MELT_ICE: + case ITEM_WEAKNESS_POLICY: + case ITEM_SAFETY_GOGGLES: + case ITEM_ADRENALINE_ORB: + case ITEM_TERRAIN_EXTENDER: + case ITEM_PROTECTIVE_PADS: + case ITEM_HEAVY_DUTY_BOOTS: + case ITEM_UTILITY_UMBRELLA: + case ITEM_MARANGA_BERRY: + case ITEM_PUNCHING_GLOVE: + case ITEM_BOOSTER_ENERGY: + case ITEM_ADAMANT_CRYSTAL: + case ITEM_LUSTROUS_GLOBE: + case ITEM_CORNERSTONE_MASK: + case ITEM_WELLSPRING_MASK: + case ITEM_HEARTHFLAME_MASK: + EXPECT_GT(GetStringWidth(fontId, gItemsInfo[item].name, 0), widthPx); + break; + default: + EXPECT_LE(GetStringWidth(fontId, gItemsInfo[item].name, 0), widthPx); + break; + } +} -// TEST("Item names fit on Pokemon Summary Screen") -// { -// u32 i; -// const u32 fontId = FONT_NARROWER, widthPx = 72; -// u32 item = ITEM_NONE; -// for (i = 1; i < ITEMS_COUNT; i++) -// { -// if (gItemsInfo[i].importance) continue; -// PARAMETRIZE_LABEL("%S", gItemsInfo[i].name) { item = i; } -// } -// // All items explicitly listed here are too big to fit. -// switch (item) -// { -// case ITEM_UNREMARKABLE_TEACUP: -// EXPECT_GT(GetStringWidth(fontId, gItemsInfo[item].name, 0), widthPx); -// break; -// default: -// EXPECT_LE(GetStringWidth(fontId, gItemsInfo[item].name, 0), widthPx); -// break; -// } -// } +TEST("Item names fit on Pokemon Summary Screen") +{ + u32 i; + const u32 fontId = FONT_NARROWER, widthPx = 72; + u32 item = ITEM_NONE; + for (i = 1; i < ITEMS_COUNT; i++) + { + if (gItemsInfo[i].importance) continue; + PARAMETRIZE_LABEL("%S", gItemsInfo[i].name) { item = i; } + } + // All items explicitly listed here are too big to fit. + switch (item) + { + case ITEM_UNREMARKABLE_TEACUP: + EXPECT_GT(GetStringWidth(fontId, gItemsInfo[item].name, 0), widthPx); + break; + default: + EXPECT_LE(GetStringWidth(fontId, gItemsInfo[item].name, 0), widthPx); + break; + } +} -// TEST("Item names fit on Shop Screen") -// { -// u32 i; -// const u32 fontId = FONT_NARROWER, widthPx = 84; -// u32 item = ITEM_NONE; -// for (i = 1; i < ITEMS_COUNT; i++) -// { -// PARAMETRIZE_LABEL("%S", gItemsInfo[i].name) { item = i; } -// } -// EXPECT_LE(GetStringWidth(fontId, gItemsInfo[item].name, 0), widthPx); -// } +TEST("Item names fit on Shop Screen") +{ + u32 i; + const u32 fontId = FONT_NARROWER, widthPx = 84; + u32 item = ITEM_NONE; + for (i = 1; i < ITEMS_COUNT; i++) + { + PARAMETRIZE_LABEL("%S", gItemsInfo[i].name) { item = i; } + } + EXPECT_LE(GetStringWidth(fontId, gItemsInfo[item].name, 0), widthPx); +} -// TEST("Species names fit on Battle Screen HP box") -// { -// u32 i, genderWidthPx; -// const u32 fontId = FONT_SMALL_NARROWER, widthPx = 54; -// u32 species = SPECIES_NONE; -// genderWidthPx = GetStringWidth(fontId, COMPOUND_STRING("♂"), 0); -// for (i = 1; i < NUM_SPECIES; i++) -// { -// if (IsSpeciesEnabled(i)) -// { -// PARAMETRIZE_LABEL("%S", gSpeciesInfo[i].speciesName) { species = i; } -// } -// } -// if (gSpeciesInfo[i].genderRatio != MON_GENDERLESS) -// EXPECT_LE(GetStringWidth(fontId, gSpeciesInfo[species].speciesName, 0) - genderWidthPx, widthPx); -// else -// EXPECT_LE(GetStringWidth(fontId, gSpeciesInfo[species].speciesName, 0), widthPx); -// } +TEST("Species names fit on Battle Screen HP box") +{ + u32 i, genderWidthPx; + const u32 fontId = FONT_SMALL_NARROWER, widthPx = 54; + u32 species = SPECIES_NONE; + genderWidthPx = GetStringWidth(fontId, COMPOUND_STRING("♂"), 0); + for (i = 1; i < NUM_SPECIES; i++) + { + if (IsSpeciesEnabled(i)) + { + PARAMETRIZE_LABEL("%S", gSpeciesInfo[i].speciesName) { species = i; } + } + } + if (gSpeciesInfo[i].genderRatio != MON_GENDERLESS) + EXPECT_LE(GetStringWidth(fontId, gSpeciesInfo[species].speciesName, 0) - genderWidthPx, widthPx); + else + EXPECT_LE(GetStringWidth(fontId, gSpeciesInfo[species].speciesName, 0), widthPx); +} -// TEST("Species names fit on Party Screen") -// { -// u32 i; -// const u32 fontId = FONT_SMALL_NARROWER, widthPx = 50; -// u32 species = SPECIES_NONE; -// for (i = 1; i < NUM_SPECIES; i++) -// { -// if (IsSpeciesEnabled(i)) -// { -// PARAMETRIZE_LABEL("%S", gSpeciesInfo[i].speciesName) { species = i; } -// } -// } -// EXPECT_LE(GetStringWidth(fontId, gSpeciesInfo[species].speciesName, 0), widthPx); -// } +TEST("Species names fit on Party Screen") +{ + u32 i; + const u32 fontId = FONT_SMALL_NARROWER, widthPx = 50; + u32 species = SPECIES_NONE; + for (i = 1; i < NUM_SPECIES; i++) + { + if (IsSpeciesEnabled(i)) + { + PARAMETRIZE_LABEL("%S", gSpeciesInfo[i].speciesName) { species = i; } + } + } + EXPECT_LE(GetStringWidth(fontId, gSpeciesInfo[species].speciesName, 0), widthPx); +} -// TEST("Species names fit on Pokemon Summary Screen") -// { -// u32 i; -// const u32 fontId = FONT_NARROWER, widthPx = 63; -// u32 species = SPECIES_NONE; -// for (i = 1; i < NUM_SPECIES; i++) -// { -// if (IsSpeciesEnabled(i)) -// { -// PARAMETRIZE_LABEL("%S", gSpeciesInfo[i].speciesName) { species = i; } -// } -// } -// EXPECT_LE(GetStringWidth(fontId, gSpeciesInfo[species].speciesName, 0), widthPx); -// } +TEST("Species names fit on Pokemon Summary Screen") +{ + u32 i; + const u32 fontId = FONT_NARROWER, widthPx = 63; + u32 species = SPECIES_NONE; + for (i = 1; i < NUM_SPECIES; i++) + { + if (IsSpeciesEnabled(i)) + { + PARAMETRIZE_LABEL("%S", gSpeciesInfo[i].speciesName) { species = i; } + } + } + EXPECT_LE(GetStringWidth(fontId, gSpeciesInfo[species].speciesName, 0), widthPx); +} -// TEST("Species names fit on Pokedex Screen") -// { -// u32 i; -// const u32 fontId = FONT_NARROWER, widthPx = 50; -// u32 species = SPECIES_NONE; -// for (i = 1; i < NUM_SPECIES; i++) -// { -// if (IsSpeciesEnabled(i)) -// { -// PARAMETRIZE_LABEL("%S", gSpeciesInfo[i].speciesName) { species = i; } -// } -// } -// EXPECT_LE(GetStringWidth(fontId, gSpeciesInfo[species].speciesName, 0), widthPx); -// } +TEST("Species names fit on Pokedex Screen") +{ + u32 i; + const u32 fontId = FONT_NARROWER, widthPx = 50; + u32 species = SPECIES_NONE; + for (i = 1; i < NUM_SPECIES; i++) + { + if (IsSpeciesEnabled(i)) + { + PARAMETRIZE_LABEL("%S", gSpeciesInfo[i].speciesName) { species = i; } + } + } + EXPECT_LE(GetStringWidth(fontId, gSpeciesInfo[species].speciesName, 0), widthPx); +} -// TEST("Species names fit on Pokedex Screen - Cries") -// { -// u32 i; -// const u32 fontId = FONT_NARROWER, widthPx = 60; -// u32 species = SPECIES_NONE; -// for (i = 1; i < NUM_SPECIES; i++) -// { -// if (IsSpeciesEnabled(i)) -// { -// PARAMETRIZE_LABEL("%S", gSpeciesInfo[i].speciesName) { species = i; } -// } -// } -// EXPECT_LE(GetStringWidth(fontId, gSpeciesInfo[species].speciesName, 0), widthPx); -// } +TEST("Species names fit on Pokedex Screen - Cries") +{ + u32 i; + const u32 fontId = FONT_NARROWER, widthPx = 60; + u32 species = SPECIES_NONE; + for (i = 1; i < NUM_SPECIES; i++) + { + if (IsSpeciesEnabled(i)) + { + PARAMETRIZE_LABEL("%S", gSpeciesInfo[i].speciesName) { species = i; } + } + } + EXPECT_LE(GetStringWidth(fontId, gSpeciesInfo[species].speciesName, 0), widthPx); +} -// TEST("Species names fit on Pokemon Storage System") -// { -// u32 i; -// u32 species = SPECIES_NONE; -// for (i = 1; i < NUM_SPECIES; i++) -// { -// if (IsSpeciesEnabled(i)) -// { -// PARAMETRIZE_LABEL("%S", gSpeciesInfo[i].speciesName) { species = i; } -// } -// } -// EXPECT_LE(GetStringWidth(FONT_NARROWER, gSpeciesInfo[species].speciesName, 0), 66); -// EXPECT_LE(GetStringWidth(FONT_SHORT_NARROW, gSpeciesInfo[species].speciesName, 0), 60); -// } +TEST("Species names fit on Pokemon Storage System") +{ + u32 i; + u32 species = SPECIES_NONE; + for (i = 1; i < NUM_SPECIES; i++) + { + if (IsSpeciesEnabled(i)) + { + PARAMETRIZE_LABEL("%S", gSpeciesInfo[i].speciesName) { species = i; } + } + } + EXPECT_LE(GetStringWidth(FONT_NARROWER, gSpeciesInfo[species].speciesName, 0), 66); + EXPECT_LE(GetStringWidth(FONT_SHORT_NARROW, gSpeciesInfo[species].speciesName, 0), 60); +} -// TEST("Species names fit on Contest Screen") -// { -// u32 i; -// const u32 fontId = FONT_NARROWER, widthPx = 50; -// u32 species = SPECIES_NONE; -// for (i = 1; i < NUM_SPECIES; i++) -// { -// if (IsSpeciesEnabled(i)) -// { -// PARAMETRIZE_LABEL("%S", gSpeciesInfo[i].speciesName) { species = i; } -// } -// } -// EXPECT_LE(GetStringWidth(fontId, gSpeciesInfo[species].speciesName, 0), widthPx); -// } +TEST("Species names fit on Contest Screen") +{ + u32 i; + const u32 fontId = FONT_NARROWER, widthPx = 50; + u32 species = SPECIES_NONE; + for (i = 1; i < NUM_SPECIES; i++) + { + if (IsSpeciesEnabled(i)) + { + PARAMETRIZE_LABEL("%S", gSpeciesInfo[i].speciesName) { species = i; } + } + } + EXPECT_LE(GetStringWidth(fontId, gSpeciesInfo[species].speciesName, 0), widthPx); +} -// TEST("Species names fit on Contest Screen - Rankings") -// { -// u32 i; -// const u32 fontId = FONT_NARROWER, widthPx = 49; -// u32 species = SPECIES_NONE; -// for (i = 1; i < NUM_SPECIES; i++) -// { -// if (IsSpeciesEnabled(i)) -// { -// PARAMETRIZE_LABEL("%S", gSpeciesInfo[i].speciesName) { species = i; } -// } -// } -// EXPECT_LE(GetStringWidth(fontId, gSpeciesInfo[species].speciesName, 0), widthPx); -// } +TEST("Species names fit on Contest Screen - Rankings") +{ + u32 i; + const u32 fontId = FONT_NARROWER, widthPx = 49; + u32 species = SPECIES_NONE; + for (i = 1; i < NUM_SPECIES; i++) + { + if (IsSpeciesEnabled(i)) + { + PARAMETRIZE_LABEL("%S", gSpeciesInfo[i].speciesName) { species = i; } + } + } + EXPECT_LE(GetStringWidth(fontId, gSpeciesInfo[species].speciesName, 0), widthPx); +} -// TEST("Species names fit on Battle Dome Screen") -// { -// u32 i; -// const u32 fontId = FONT_SHORT_NARROW, widthPx = 60; -// u32 species = SPECIES_NONE; -// for (i = 1; i < NUM_SPECIES; i++) -// { -// if (IsSpeciesEnabled(i)) -// { -// PARAMETRIZE_LABEL("%S", gSpeciesInfo[i].speciesName) { species = i; } -// } -// } -// EXPECT_LE(GetStringWidth(fontId, gSpeciesInfo[species].speciesName, 0), widthPx); -// } +TEST("Species names fit on Battle Dome Screen") +{ + u32 i; + const u32 fontId = FONT_SHORT_NARROW, widthPx = 60; + u32 species = SPECIES_NONE; + for (i = 1; i < NUM_SPECIES; i++) + { + if (IsSpeciesEnabled(i)) + { + PARAMETRIZE_LABEL("%S", gSpeciesInfo[i].speciesName) { species = i; } + } + } + EXPECT_LE(GetStringWidth(fontId, gSpeciesInfo[species].speciesName, 0), widthPx); +} -// TEST("Species names fit on Hall of Fame") -// { -// u32 i; -// const u32 fontId = FONT_NARROWER, widthPx = 66; -// u32 species = SPECIES_NONE; -// for (i = 1; i < NUM_SPECIES; i++) -// { -// if (IsSpeciesEnabled(i)) -// { -// PARAMETRIZE_LABEL("%S", gSpeciesInfo[i].speciesName) { species = i; } -// } -// } -// EXPECT_LE(GetStringWidth(fontId, gSpeciesInfo[species].speciesName, 0), widthPx); -// } +TEST("Species names fit on Hall of Fame") +{ + u32 i; + const u32 fontId = FONT_NARROWER, widthPx = 66; + u32 species = SPECIES_NONE; + for (i = 1; i < NUM_SPECIES; i++) + { + if (IsSpeciesEnabled(i)) + { + PARAMETRIZE_LABEL("%S", gSpeciesInfo[i].speciesName) { species = i; } + } + } + EXPECT_LE(GetStringWidth(fontId, gSpeciesInfo[species].speciesName, 0), widthPx); +} -// TEST("Species names fit on Naming Screen") -// { -// u32 i; -// const u32 fontId = FONT_NARROWER, widthPx = 64; -// u32 species = SPECIES_NONE; -// for (i = 1; i < NUM_SPECIES; i++) -// { -// if (IsSpeciesEnabled(i)) -// { -// PARAMETRIZE_LABEL("%S", gSpeciesInfo[i].speciesName) { species = i; } -// } -// } -// EXPECT_LE(GetStringWidth(fontId, gSpeciesInfo[species].speciesName, 0), widthPx); -// } +TEST("Species names fit on Naming Screen") +{ + u32 i; + const u32 fontId = FONT_NARROWER, widthPx = 64; + u32 species = SPECIES_NONE; + for (i = 1; i < NUM_SPECIES; i++) + { + if (IsSpeciesEnabled(i)) + { + PARAMETRIZE_LABEL("%S", gSpeciesInfo[i].speciesName) { species = i; } + } + } + EXPECT_LE(GetStringWidth(fontId, gSpeciesInfo[species].speciesName, 0), widthPx); +} -// TEST("Species names fit on PokeNav Condition Screen") -// { -// u32 i; -// const u32 fontId = FONT_NARROWER, widthPx = 57; -// u32 species = SPECIES_NONE; -// for (i = 1; i < NUM_SPECIES; i++) -// { -// if (IsSpeciesEnabled(i)) -// { -// PARAMETRIZE_LABEL("%S", gSpeciesInfo[i].speciesName) { species = i; } -// } -// } -// EXPECT_LE(GetStringWidth(fontId, gSpeciesInfo[species].speciesName, 0), widthPx); -// } +TEST("Species names fit on PokeNav Condition Screen") +{ + u32 i; + const u32 fontId = FONT_NARROWER, widthPx = 57; + u32 species = SPECIES_NONE; + for (i = 1; i < NUM_SPECIES; i++) + { + if (IsSpeciesEnabled(i)) + { + PARAMETRIZE_LABEL("%S", gSpeciesInfo[i].speciesName) { species = i; } + } + } + EXPECT_LE(GetStringWidth(fontId, gSpeciesInfo[species].speciesName, 0), widthPx); +} -// TEST("Species names fit on PokeNav Condition Search Screen") -// { -// u32 i; -// const u32 fontId = FONT_NARROWER, widthPx = 60; -// u32 species = SPECIES_NONE; -// for (i = 1; i < NUM_SPECIES; i++) -// { -// if (IsSpeciesEnabled(i)) -// { -// PARAMETRIZE_LABEL("%S", gSpeciesInfo[i].speciesName) { species = i; } -// } -// } -// EXPECT_LE(GetStringWidth(fontId, gSpeciesInfo[species].speciesName, 0), widthPx); -// } +TEST("Species names fit on PokeNav Condition Search Screen") +{ + u32 i; + const u32 fontId = FONT_NARROWER, widthPx = 60; + u32 species = SPECIES_NONE; + for (i = 1; i < NUM_SPECIES; i++) + { + if (IsSpeciesEnabled(i)) + { + PARAMETRIZE_LABEL("%S", gSpeciesInfo[i].speciesName) { species = i; } + } + } + EXPECT_LE(GetStringWidth(fontId, gSpeciesInfo[species].speciesName, 0), widthPx); +} -// TEST("Species names fit on PokeNav Ribbon Screen") -// { -// u32 i; -// const u32 fontId = FONT_NARROWER, widthPx = 60; -// u32 species = SPECIES_NONE; -// for (i = 1; i < NUM_SPECIES; i++) -// { -// if (IsSpeciesEnabled(i)) -// { -// PARAMETRIZE_LABEL("%S", gSpeciesInfo[i].speciesName) { species = i; } -// } -// } -// EXPECT_LE(GetStringWidth(fontId, gSpeciesInfo[species].speciesName, 0), widthPx); -// } +TEST("Species names fit on PokeNav Ribbon Screen") +{ + u32 i; + const u32 fontId = FONT_NARROWER, widthPx = 60; + u32 species = SPECIES_NONE; + for (i = 1; i < NUM_SPECIES; i++) + { + if (IsSpeciesEnabled(i)) + { + PARAMETRIZE_LABEL("%S", gSpeciesInfo[i].speciesName) { species = i; } + } + } + EXPECT_LE(GetStringWidth(fontId, gSpeciesInfo[species].speciesName, 0), widthPx); +} -// TEST("Species names fit on PokeNav Ribbon List Screen") -// { -// u32 i; -// const u32 fontId = FONT_NARROWER, widthPx = 60; -// u32 species = SPECIES_NONE; -// for (i = 1; i < NUM_SPECIES; i++) -// { -// if (IsSpeciesEnabled(i)) -// { -// PARAMETRIZE_LABEL("%S", gSpeciesInfo[i].speciesName) { species = i; } -// } -// } -// EXPECT_LE(GetStringWidth(fontId, gSpeciesInfo[species].speciesName, 0), widthPx); -// } +TEST("Species names fit on PokeNav Ribbon List Screen") +{ + u32 i; + const u32 fontId = FONT_NARROWER, widthPx = 60; + u32 species = SPECIES_NONE; + for (i = 1; i < NUM_SPECIES; i++) + { + if (IsSpeciesEnabled(i)) + { + PARAMETRIZE_LABEL("%S", gSpeciesInfo[i].speciesName) { species = i; } + } + } + EXPECT_LE(GetStringWidth(fontId, gSpeciesInfo[species].speciesName, 0), widthPx); +} -// TEST("Ability names fit on Pokemon Summary Screen") -// { -// u32 i; -// const u32 fontId = FONT_NORMAL, widthPx = 144; -// u32 ability = ABILITY_NONE; -// for (i = 1; i < ABILITIES_COUNT; i++) -// { -// PARAMETRIZE_LABEL("%S", gAbilitiesInfo[i].name) { ability = i; } -// } -// EXPECT_LE(GetStringWidth(fontId, gAbilitiesInfo[ability].name, 0), widthPx); -// } +TEST("Ability names fit on Pokemon Summary Screen") +{ + u32 i; + const u32 fontId = FONT_NORMAL, widthPx = 144; + u32 ability = ABILITY_NONE; + for (i = 1; i < ABILITIES_COUNT; i++) + { + PARAMETRIZE_LABEL("%S", gAbilitiesInfo[i].name) { ability = i; } + } + EXPECT_LE(GetStringWidth(fontId, gAbilitiesInfo[ability].name, 0), widthPx); +} -// TEST("Ability names fit on Ability Pop-Up") -// { -// u32 i; -// const u32 fontId = FONT_SMALL_NARROWER, widthPx = 76; -// u32 ability = ABILITY_NONE; -// for (i = 1; i < ABILITIES_COUNT; i++) -// { -// PARAMETRIZE_LABEL("%S", gAbilitiesInfo[i].name) { ability = i; } -// } -// EXPECT_LE(GetStringWidth(fontId, gAbilitiesInfo[ability].name, 0), widthPx); -// } +TEST("Ability names fit on Ability Pop-Up") +{ + u32 i; + const u32 fontId = FONT_SMALL_NARROWER, widthPx = 76; + u32 ability = ABILITY_NONE; + for (i = 1; i < ABILITIES_COUNT; i++) + { + PARAMETRIZE_LABEL("%S", gAbilitiesInfo[i].name) { ability = i; } + } + EXPECT_LE(GetStringWidth(fontId, gAbilitiesInfo[ability].name, 0), widthPx); +} -// TEST("Type names fit on Battle Screen") -// { -// u32 i; -// const u32 fontId = FONT_NARROWER, widthPx = 39; -// u32 type = TYPE_NORMAL; -// for (i = 0; i < NUMBER_OF_MON_TYPES; i++) -// { -// PARAMETRIZE_LABEL("%S", gTypesInfo[i].name) { type = i; } -// } -// EXPECT_LE(GetStringWidth(fontId, gTypesInfo[type].name, 0), widthPx); -// } +TEST("Type names fit on Battle Screen") +{ + u32 i; + const u32 fontId = FONT_NARROWER, widthPx = 39; + u32 type = TYPE_NORMAL; + for (i = 0; i < NUMBER_OF_MON_TYPES; i++) + { + PARAMETRIZE_LABEL("%S", gTypesInfo[i].name) { type = i; } + } + EXPECT_LE(GetStringWidth(fontId, gTypesInfo[type].name, 0), widthPx); +} -// TEST("Type names fit on Pokedex Search Screen") -// { -// u32 i; -// const u32 fontId = FONT_NARROWER, widthPx = 38; -// u32 type = TYPE_NORMAL; -// for (i = 0; i < NUMBER_OF_MON_TYPES; i++) -// { -// PARAMETRIZE_LABEL("%S", gTypesInfo[i].name) { type = i; } -// } -// EXPECT_LE(GetStringWidth(fontId, gTypesInfo[type].name, 0), widthPx); -// } +TEST("Type names fit on Pokedex Search Screen") +{ + u32 i; + const u32 fontId = FONT_NARROWER, widthPx = 38; + u32 type = TYPE_NORMAL; + for (i = 0; i < NUMBER_OF_MON_TYPES; i++) + { + PARAMETRIZE_LABEL("%S", gTypesInfo[i].name) { type = i; } + } + EXPECT_LE(GetStringWidth(fontId, gTypesInfo[type].name, 0), widthPx); +}