Narrower fonts
This commit is contained in:
parent
1fea6b83cc
commit
e42a0a6dbe
13 changed files with 467 additions and 24 deletions
|
@ -464,6 +464,9 @@ FONT_NORMAL = FC 06 01
|
|||
FONT_SHORT = FC 06 02
|
||||
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
|
||||
|
||||
|
|
331
gflib/text.c
331
gflib/text.c
|
@ -23,17 +23,26 @@ static u16 FontFunc_ShortCopy2(struct TextPrinter *);
|
|||
static u16 FontFunc_ShortCopy3(struct TextPrinter *);
|
||||
static u16 FontFunc_Narrow(struct TextPrinter *);
|
||||
static u16 FontFunc_SmallNarrow(struct TextPrinter *);
|
||||
static u16 FontFunc_Narrower(struct TextPrinter *);
|
||||
static u16 FontFunc_SmallNarrower(struct TextPrinter *);
|
||||
static u16 FontFunc_ShortNarrow(struct TextPrinter *);
|
||||
static void DecompressGlyph_Small(u16, bool32);
|
||||
static void DecompressGlyph_Normal(u16, bool32);
|
||||
static void DecompressGlyph_Short(u16, bool32);
|
||||
static void DecompressGlyph_Narrow(u16, bool32);
|
||||
static void DecompressGlyph_SmallNarrow(u16, bool32);
|
||||
static void DecompressGlyph_Bold(u16);
|
||||
static void DecompressGlyph_Narrower(u16, bool32);
|
||||
static void DecompressGlyph_SmallNarrower(u16, bool32);
|
||||
static void DecompressGlyph_ShortNarrow(u16, bool32);
|
||||
static u32 GetGlyphWidth_Small(u16, bool32);
|
||||
static u32 GetGlyphWidth_Normal(u16, bool32);
|
||||
static u32 GetGlyphWidth_Short(u16, bool32);
|
||||
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 EWRAM_DATA struct TextPrinter sTempTextPrinter = {0};
|
||||
static EWRAM_DATA struct TextPrinter sTextPrinters[WINDOWS_MAX] = {0};
|
||||
|
@ -81,15 +90,18 @@ static const u8 sWindowVerticalScrollSpeeds[] = {
|
|||
|
||||
static const struct GlyphWidthFunc sGlyphWidthFuncs[] =
|
||||
{
|
||||
{ FONT_SMALL, GetGlyphWidth_Small },
|
||||
{ FONT_NORMAL, GetGlyphWidth_Normal },
|
||||
{ FONT_SHORT, GetGlyphWidth_Short },
|
||||
{ FONT_SHORT_COPY_1, GetGlyphWidth_Short },
|
||||
{ FONT_SHORT_COPY_2, GetGlyphWidth_Short },
|
||||
{ FONT_SHORT_COPY_3, GetGlyphWidth_Short },
|
||||
{ FONT_BRAILLE, GetGlyphWidth_Braille },
|
||||
{ FONT_NARROW, GetGlyphWidth_Narrow },
|
||||
{ FONT_SMALL_NARROW, GetGlyphWidth_SmallNarrow }
|
||||
{ FONT_SMALL, GetGlyphWidth_Small },
|
||||
{ FONT_NORMAL, GetGlyphWidth_Normal },
|
||||
{ FONT_SHORT, GetGlyphWidth_Short },
|
||||
{ FONT_SHORT_COPY_1, GetGlyphWidth_Short },
|
||||
{ FONT_SHORT_COPY_2, GetGlyphWidth_Short },
|
||||
{ FONT_SHORT_COPY_3, GetGlyphWidth_Short },
|
||||
{ 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 },
|
||||
};
|
||||
|
||||
struct
|
||||
|
@ -217,21 +229,54 @@ static const struct FontInfo sFontInfos[] =
|
|||
.fgColor = 1,
|
||||
.bgColor = 2,
|
||||
.shadowColor = 15,
|
||||
}
|
||||
},
|
||||
[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 sMenuCursorDimensions[][2] =
|
||||
{
|
||||
[FONT_SMALL] = { 8, 12 },
|
||||
[FONT_NORMAL] = { 8, 15 },
|
||||
[FONT_SHORT] = { 8, 14 },
|
||||
[FONT_SHORT_COPY_1] = { 8, 14 },
|
||||
[FONT_SHORT_COPY_2] = { 8, 14 },
|
||||
[FONT_SHORT_COPY_3] = { 8, 14 },
|
||||
[FONT_BRAILLE] = { 8, 16 },
|
||||
[FONT_NARROW] = { 8, 15 },
|
||||
[FONT_SMALL_NARROW] = { 8, 8 },
|
||||
[FONT_BOLD] = {}
|
||||
[FONT_SMALL] = { 8, 12 },
|
||||
[FONT_NORMAL] = { 8, 15 },
|
||||
[FONT_SHORT] = { 8, 14 },
|
||||
[FONT_SHORT_COPY_1] = { 8, 14 },
|
||||
[FONT_SHORT_COPY_2] = { 8, 14 },
|
||||
[FONT_SHORT_COPY_3] = { 8, 14 },
|
||||
[FONT_BRAILLE] = { 8, 16 },
|
||||
[FONT_NARROW] = { 8, 15 },
|
||||
[FONT_SMALL_NARROW] = { 8, 8 },
|
||||
[FONT_BOLD] = {},
|
||||
[FONT_NARROWER] = { 8, 15 },
|
||||
[FONT_SMALL_NARROWER] = { 8, 8 },
|
||||
[FONT_SHORT_NARROW] = { 8, 14 },
|
||||
};
|
||||
|
||||
static const u16 sFontBoldJapaneseGlyphs[] = INCBIN_U16("graphics/fonts/bold.hwjpnfont");
|
||||
|
@ -813,6 +858,42 @@ static u16 FontFunc_SmallNarrow(struct TextPrinter *textPrinter)
|
|||
return RenderText(textPrinter);
|
||||
}
|
||||
|
||||
static u16 FontFunc_Narrower(struct TextPrinter *textPrinter)
|
||||
{
|
||||
struct TextPrinterSubStruct *subStruct = (struct TextPrinterSubStruct *)(&textPrinter->subStructFields);
|
||||
|
||||
if (subStruct->hasFontIdBeenSet == FALSE)
|
||||
{
|
||||
subStruct->fontId = FONT_NARROWER;
|
||||
subStruct->hasFontIdBeenSet = TRUE;
|
||||
}
|
||||
return RenderText(textPrinter);
|
||||
}
|
||||
|
||||
static u16 FontFunc_SmallNarrower(struct TextPrinter *textPrinter)
|
||||
{
|
||||
struct TextPrinterSubStruct *subStruct = (struct TextPrinterSubStruct *)(&textPrinter->subStructFields);
|
||||
|
||||
if (subStruct->hasFontIdBeenSet == FALSE)
|
||||
{
|
||||
subStruct->fontId = FONT_SMALL_NARROWER;
|
||||
subStruct->hasFontIdBeenSet = TRUE;
|
||||
}
|
||||
return RenderText(textPrinter);
|
||||
}
|
||||
|
||||
static u16 FontFunc_ShortNarrow(struct TextPrinter *textPrinter)
|
||||
{
|
||||
struct TextPrinterSubStruct *subStruct = (struct TextPrinterSubStruct *)(&textPrinter->subStructFields);
|
||||
|
||||
if (subStruct->hasFontIdBeenSet == FALSE)
|
||||
{
|
||||
subStruct->fontId = FONT_SHORT_NARROW;
|
||||
subStruct->hasFontIdBeenSet = TRUE;
|
||||
}
|
||||
return RenderText(textPrinter);
|
||||
}
|
||||
|
||||
void TextPrinterInitDownArrowCounters(struct TextPrinter *textPrinter)
|
||||
{
|
||||
struct TextPrinterSubStruct *subStruct = (struct TextPrinterSubStruct *)(&textPrinter->subStructFields);
|
||||
|
@ -1250,6 +1331,15 @@ static u16 RenderText(struct TextPrinter *textPrinter)
|
|||
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;
|
||||
case FONT_BRAILLE:
|
||||
break;
|
||||
}
|
||||
|
@ -2012,3 +2102,204 @@ static void DecompressGlyph_Bold(u16 glyphId)
|
|||
gCurGlyph.width = 8;
|
||||
gCurGlyph.height = 12;
|
||||
}
|
||||
|
||||
static void DecompressGlyph_Narrower(u16 glyphId, bool32 isJapanese)
|
||||
{
|
||||
const u16 *glyphs;
|
||||
|
||||
if (isJapanese == TRUE)
|
||||
{
|
||||
glyphs = gFontNormalJapaneseGlyphs + (0x100 * (glyphId >> 0x4)) + (0x8 * (glyphId % 0x10));
|
||||
DecompressGlyphTile(glyphs, gCurGlyph.gfxBufferTop);
|
||||
DecompressGlyphTile(glyphs + 0x80, gCurGlyph.gfxBufferBottom);
|
||||
gCurGlyph.width = 8;
|
||||
gCurGlyph.height = 15;
|
||||
}
|
||||
else
|
||||
{
|
||||
glyphs = gFontNarrowerLatinGlyphs + (0x20 * glyphId);
|
||||
gCurGlyph.width = gFontNarrowerLatinGlyphWidths[glyphId];
|
||||
|
||||
if (gCurGlyph.width <= 8)
|
||||
{
|
||||
DecompressGlyphTile(glyphs, gCurGlyph.gfxBufferTop);
|
||||
DecompressGlyphTile(glyphs + 0x10, gCurGlyph.gfxBufferBottom);
|
||||
}
|
||||
else
|
||||
{
|
||||
DecompressGlyphTile(glyphs, gCurGlyph.gfxBufferTop);
|
||||
DecompressGlyphTile(glyphs + 0x8, gCurGlyph.gfxBufferTop + 8);
|
||||
DecompressGlyphTile(glyphs + 0x10, gCurGlyph.gfxBufferBottom);
|
||||
DecompressGlyphTile(glyphs + 0x18, gCurGlyph.gfxBufferBottom + 8);
|
||||
}
|
||||
|
||||
gCurGlyph.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 = gFontSmallJapaneseGlyphs + (0x100 * (glyphId >> 0x4)) + (0x8 * (glyphId % 0x10));
|
||||
DecompressGlyphTile(glyphs, gCurGlyph.gfxBufferTop);
|
||||
DecompressGlyphTile(glyphs + 0x80, gCurGlyph.gfxBufferBottom);
|
||||
gCurGlyph.width = 8;
|
||||
gCurGlyph.height = 15;
|
||||
}
|
||||
else
|
||||
{
|
||||
glyphs = gFontSmallNarrowerLatinGlyphs + (0x20 * glyphId);
|
||||
gCurGlyph.width = gFontSmallNarrowerLatinGlyphWidths[glyphId];
|
||||
|
||||
if (gCurGlyph.width <= 8)
|
||||
{
|
||||
DecompressGlyphTile(glyphs, gCurGlyph.gfxBufferTop);
|
||||
DecompressGlyphTile(glyphs + 0x10, gCurGlyph.gfxBufferBottom);
|
||||
}
|
||||
else
|
||||
{
|
||||
DecompressGlyphTile(glyphs, gCurGlyph.gfxBufferTop);
|
||||
DecompressGlyphTile(glyphs + 0x8, gCurGlyph.gfxBufferTop + 8);
|
||||
DecompressGlyphTile(glyphs + 0x10, gCurGlyph.gfxBufferBottom);
|
||||
DecompressGlyphTile(glyphs + 0x18, gCurGlyph.gfxBufferBottom + 8);
|
||||
}
|
||||
|
||||
gCurGlyph.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 = gFontShortJapaneseGlyphs + (0x100 * (glyphId >> 0x3)) + (0x10 * (glyphId & 0x7));
|
||||
DecompressGlyphTile(glyphs, gCurGlyph.gfxBufferTop);
|
||||
DecompressGlyphTile(glyphs + 0x8, gCurGlyph.gfxBufferTop + 8);
|
||||
DecompressGlyphTile(glyphs + 0x80, gCurGlyph.gfxBufferBottom); // gCurGlyph + 0x20
|
||||
DecompressGlyphTile(glyphs + 0x88, gCurGlyph.gfxBufferBottom + 8); // gCurGlyph + 0x60
|
||||
gCurGlyph.width = gFontShortJapaneseGlyphWidths[glyphId];
|
||||
gCurGlyph.height = 14;
|
||||
}
|
||||
else
|
||||
{
|
||||
glyphs = gFontShortNarrowLatinGlyphs + (0x20 * glyphId);
|
||||
gCurGlyph.width = gFontShortNarrowLatinGlyphWidths[glyphId];
|
||||
|
||||
if (gCurGlyph.width <= 8)
|
||||
{
|
||||
DecompressGlyphTile(glyphs, gCurGlyph.gfxBufferTop);
|
||||
DecompressGlyphTile(glyphs + 0x10, gCurGlyph.gfxBufferBottom);
|
||||
}
|
||||
else
|
||||
{
|
||||
DecompressGlyphTile(glyphs, gCurGlyph.gfxBufferTop);
|
||||
DecompressGlyphTile(glyphs + 0x8, gCurGlyph.gfxBufferTop + 8);
|
||||
DecompressGlyphTile(glyphs + 0x10, gCurGlyph.gfxBufferBottom);
|
||||
DecompressGlyphTile(glyphs + 0x18, gCurGlyph.gfxBufferBottom + 8);
|
||||
}
|
||||
|
||||
gCurGlyph.height = 14;
|
||||
}
|
||||
}
|
||||
|
||||
static u32 GetGlyphWidth_ShortNarrow(u16 glyphId, bool32 isJapanese)
|
||||
{
|
||||
if (isJapanese == TRUE)
|
||||
return gFontShortJapaneseGlyphWidths[glyphId];
|
||||
else
|
||||
return gFontShortNarrowLatinGlyphWidths[glyphId];
|
||||
}
|
||||
|
||||
static const s8 sNarrowerFontIds[] =
|
||||
{
|
||||
[FONT_SMALL] = FONT_SMALL_NARROW,
|
||||
[FONT_NORMAL] = 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_BOLD] = -1,
|
||||
[FONT_NARROWER] = -1,
|
||||
[FONT_SMALL_NARROWER] = -1,
|
||||
[FONT_SHORT_NARROW] = -1,
|
||||
};
|
||||
|
||||
// If the narrowest font ID doesn't fit the text, we still return that
|
||||
// ID because clipping is better than crashing.
|
||||
u32 GetFontIdToFit(const u8 *string, u32 fontId, u32 letterSpacing, u32 widthPx)
|
||||
{
|
||||
for (;;)
|
||||
{
|
||||
s32 narrowerFontId = sNarrowerFontIds[fontId];
|
||||
if (narrowerFontId == -1)
|
||||
return fontId;
|
||||
if (GetStringWidth(fontId, string, letterSpacing) <= widthPx)
|
||||
return fontId;
|
||||
fontId = narrowerFontId;
|
||||
}
|
||||
}
|
||||
|
||||
u8 *PrependFontIdToFit(u8 *start, u8 *end, u32 fontId, u32 width)
|
||||
{
|
||||
|
||||
u32 fitFontId = GetFontIdToFit(start, fontId, 0, width);
|
||||
if (fitFontId != fontId)
|
||||
{
|
||||
memmove(&start[3], &start[0], end - start);
|
||||
start[0] = EXT_CTRL_CODE_BEGIN;
|
||||
start[1] = EXT_CTRL_CODE_FONT;
|
||||
start[2] = fitFontId;
|
||||
end[3] = EOS;
|
||||
return end + 3;
|
||||
}
|
||||
else
|
||||
{
|
||||
return end;
|
||||
}
|
||||
}
|
||||
|
||||
u8 *WrapFontIdToFit(u8 *start, u8 *end, u32 fontId, u32 width)
|
||||
{
|
||||
|
||||
u32 fitFontId = GetFontIdToFit(start, fontId, 0, width);
|
||||
if (fitFontId != fontId)
|
||||
{
|
||||
memmove(&start[3], &start[0], end - start);
|
||||
start[0] = EXT_CTRL_CODE_BEGIN;
|
||||
start[1] = EXT_CTRL_CODE_FONT;
|
||||
start[2] = fitFontId;
|
||||
end[3] = EXT_CTRL_CODE_BEGIN;
|
||||
end[4] = EXT_CTRL_CODE_FONT;
|
||||
end[5] = fontId;
|
||||
end[6] = EOS;
|
||||
return end + 6;
|
||||
}
|
||||
else
|
||||
{
|
||||
return end;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,6 +26,9 @@ enum {
|
|||
FONT_NARROW,
|
||||
FONT_SMALL_NARROW, // Very similar to FONT_SMALL, some glyphs are narrower
|
||||
FONT_BOLD, // JP glyph set only
|
||||
FONT_NARROWER,
|
||||
FONT_SMALL_NARROWER,
|
||||
FONT_SHORT_NARROW,
|
||||
};
|
||||
|
||||
// Return values for font functions
|
||||
|
@ -190,4 +193,8 @@ u8 GetMenuCursorDimensionByFont(u8 fontId, u8 whichDimension);
|
|||
u16 FontFunc_Braille(struct TextPrinter *textPrinter);
|
||||
u32 GetGlyphWidth_Braille(u16 glyphId, bool32 isJapanese);
|
||||
|
||||
u32 GetFontIdToFit(const u8 *string, u32 widestFontId, u32 letterSpacing, u32 widthPx);
|
||||
u8 *PrependFontIdToFit(u8 *start, u8 *end, u32 fontId, u32 width);
|
||||
u8 *WrapFontIdToFit(u8 *start, u8 *end, u32 fontId, u32 width);
|
||||
|
||||
#endif // GUARD_TEXT_H
|
||||
|
|
|
@ -712,3 +712,13 @@ static u32 GetNumActiveWindowsOnBg8Bit(u32 bgId)
|
|||
}
|
||||
return windowsNum;
|
||||
}
|
||||
|
||||
u32 WindowWidthPx(u32 windowId)
|
||||
{
|
||||
return gWindows[windowId].window.width * TILE_WIDTH;
|
||||
}
|
||||
|
||||
u32 WindowTemplateWidthPx(const struct WindowTemplate *template)
|
||||
{
|
||||
return template->width * TILE_WIDTH;
|
||||
}
|
||||
|
|
|
@ -73,6 +73,8 @@ void FillWindowPixelBuffer8Bit(u32 windowId, u8 fillValue);
|
|||
void FillWindowPixelRect8Bit(u32 windowId, u8 fillValue, u16 x, u16 y, u16 width, u16 height);
|
||||
void BlitBitmapRectToWindow4BitTo8Bit(u32 windowId, const u8 *pixels, u16 srcX, u16 srcY, u16 srcWidth, int srcHeight, u16 destX, u16 destY, u16 rectWidth, u16 rectHeight, u8 paletteNum);
|
||||
void CopyWindowToVram8Bit(u32 windowId, u8 mode);
|
||||
u32 WindowWidthPx(u32 windowId);
|
||||
u32 WindowTemplateWidthPx(const struct WindowTemplate *template);
|
||||
|
||||
extern struct Window gWindows[];
|
||||
extern void *gWindowBgTilemapBuffers[];
|
||||
|
|
BIN
graphics/fonts/latin_narrower.png
Normal file
BIN
graphics/fonts/latin_narrower.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 7.2 KiB |
BIN
graphics/fonts/latin_short_narrow.png
Normal file
BIN
graphics/fonts/latin_short_narrow.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 7.3 KiB |
BIN
graphics/fonts/latin_small_narrower.png
Normal file
BIN
graphics/fonts/latin_small_narrower.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 6.9 KiB |
|
@ -238,6 +238,15 @@ $(FONTGFXDIR)/narrow.latfont: $(FONTGFXDIR)/latin_narrow.png
|
|||
$(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)/small.hwjpnfont: $(FONTGFXDIR)/japanese_small.png
|
||||
$(GFX) $< $@
|
||||
|
||||
|
|
|
@ -15,5 +15,11 @@ extern const u16 gFontNarrowLatinGlyphs[];
|
|||
extern const u8 gFontNarrowLatinGlyphWidths[];
|
||||
extern const u16 gFontSmallNarrowLatinGlyphs[];
|
||||
extern const u8 gFontSmallNarrowLatinGlyphWidths[];
|
||||
extern const u8 gFontNarrowerLatinGlyphWidths[];
|
||||
extern const u16 gFontNarrowerLatinGlyphs[];
|
||||
extern const u8 gFontSmallNarrowerLatinGlyphWidths[];
|
||||
extern const u16 gFontSmallNarrowerLatinGlyphs[];
|
||||
extern const u8 gFontShortNarrowLatinGlyphWidths[];
|
||||
extern const u16 gFontShortNarrowLatinGlyphs[];
|
||||
|
||||
#endif // GUARD_FONTS_H
|
||||
|
|
|
@ -40,8 +40,9 @@ struct ListMenuTemplate
|
|||
const struct ListMenuItem *items;
|
||||
void (* moveCursorFunc)(s32 itemIndex, bool8 onInit, struct ListMenu *list);
|
||||
void (* itemPrintFunc)(u8 windowId, u32 itemId, u8 y);
|
||||
u16 totalItems;
|
||||
u16 maxShowed;
|
||||
u16 totalItems:12;
|
||||
u16 maxShowed:12;
|
||||
u16 textNarrowWidth:8;
|
||||
u8 windowId;
|
||||
u8 header_X;
|
||||
u8 item_X;
|
||||
|
|
108
src/fonts.c
108
src/fonts.c
|
@ -180,6 +180,114 @@ ALIGNED(4) const u8 gFontNormalLatinGlyphWidths[] = {
|
|||
8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 3,
|
||||
};
|
||||
|
||||
ALIGNED(4) const u16 gFontNarrowerLatinGlyphs[] = INCBIN_U16("graphics/fonts/narrower.latfont");
|
||||
ALIGNED(4) const u8 gFontNarrowerLatinGlyphWidths[] = {
|
||||
3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 3, 4, 4, 4, 4, 4,
|
||||
8, 4, 4, 4, 5, 5, 4, 4, 3, 4, 4, 4, 4, 4, 4, 3,
|
||||
4, 4, 4, 4, 4, 6, 4, 4, 4, 5, 4, 5, 8, 6, 6, 3,
|
||||
3, 3, 3, 3, 8, 8, 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, 4, 8, 8, 8, 7, 8, 8, 4, 4, 6, 4, 4, 3, 3,
|
||||
3, 3, 3, 3, 3, 3, 3, 3, 4, 3, 3, 3, 3, 3, 3, 4,
|
||||
3, 3, 3, 3, 3, 3, 3, 5, 3, 7, 7, 7, 7, 0, 0, 3,
|
||||
4, 5, 6, 7, 4, 6, 6, 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,
|
||||
7, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5, 3, 5, 3,
|
||||
5, 5, 5, 3, 3, 5, 5, 6, 3, 6, 6, 4, 4, 4, 4, 4,
|
||||
4, 4, 4, 4, 4, 4, 4, 5, 5, 4, 4, 4, 4, 4, 4, 4,
|
||||
4, 5, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 2, 4, 4,
|
||||
2, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 8,
|
||||
4, 4, 4, 4, 4, 4, 4, 3, 3, 3, 3, 3, 3, 3, 3, 3,
|
||||
10, 10, 10, 10, 8, 8, 10, 8, 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,
|
||||
};
|
||||
|
||||
ALIGNED(4) const u16 gFontSmallNarrowerLatinGlyphs[] = INCBIN_U16("graphics/fonts/small_narrower.latfont");
|
||||
ALIGNED(4) const u8 gFontSmall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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,
|
||||
};
|
||||
|
||||
ALIGNED(4) const u16 gFontShortNarrowLatinGlyphs[] = INCBIN_U16("graphics/fonts/short_narrow.latfont");
|
||||
ALIGNED(4) const u8 gFontShortNarrowLatinGlyphWidths[] = {
|
||||
3, 5, 5, 5, 5, 5, 5, 5, 5, 4, 3, 4, 4, 5, 5, 5,
|
||||
8, 5, 5, 5, 5, 6, 5, 5, 3, 5, 5, 5, 5, 5, 4, 3,
|
||||
4, 4, 5, 5, 5, 8, 5, 5, 5, 5, 6, 6, 9, 6, 6, 3,
|
||||
3, 3, 3, 3, 10, 8, 5, 3, 3, 3, 3, 3, 3, 3, 3, 3,
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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,
|
||||
};
|
||||
|
||||
ALIGNED(4) const u16 gFontSmallJapaneseGlyphs[] = INCBIN_U16("graphics/fonts/small.hwjpnfont");
|
||||
ALIGNED(4) const u16 gFontNormalJapaneseGlyphs[] = INCBIN_U16("graphics/fonts/normal.hwjpnfont");
|
||||
|
||||
|
|
|
@ -600,11 +600,14 @@ static void ListMenuPrint(struct ListMenu *list, const u8 *str, u8 x, u8 y)
|
|||
u8 colors[3];
|
||||
if (gListMenuOverride.enabled)
|
||||
{
|
||||
u32 fontId = gListMenuOverride.fontId;
|
||||
if (list->template.textNarrowWidth)
|
||||
fontId = GetFontIdToFit(str, fontId, gListMenuOverride.lettersSpacing, list->template.textNarrowWidth);
|
||||
colors[0] = gListMenuOverride.fillValue;
|
||||
colors[1] = gListMenuOverride.cursorPal;
|
||||
colors[2] = gListMenuOverride.cursorShadowPal;
|
||||
AddTextPrinterParameterized4(list->template.windowId,
|
||||
gListMenuOverride.fontId,
|
||||
fontId,
|
||||
x, y,
|
||||
gListMenuOverride.lettersSpacing,
|
||||
0, colors, TEXT_SKIP_DRAW, str);
|
||||
|
@ -613,11 +616,14 @@ static void ListMenuPrint(struct ListMenu *list, const u8 *str, u8 x, u8 y)
|
|||
}
|
||||
else
|
||||
{
|
||||
u32 fontId = list->template.fontId;
|
||||
if (list->template.textNarrowWidth)
|
||||
fontId = GetFontIdToFit(str, fontId, list->template.lettersSpacing, list->template.textNarrowWidth);
|
||||
colors[0] = list->template.fillValue;
|
||||
colors[1] = list->template.cursorPal;
|
||||
colors[2] = list->template.cursorShadowPal;
|
||||
AddTextPrinterParameterized4(list->template.windowId,
|
||||
list->template.fontId,
|
||||
fontId,
|
||||
x, y,
|
||||
list->template.lettersSpacing,
|
||||
0, colors, TEXT_SKIP_DRAW, str);
|
||||
|
|
Loading…
Reference in a new issue