Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added FONT_SHORT_NARROWER #5101

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions charmap.txt
Original file line number Diff line number Diff line change
Expand Up @@ -456,6 +456,7 @@ FONT_SMALL_NARROW = FC 06 08
FONT_NARROWER = FC 06 0A
FONT_SMALL_NARROWER = FC 06 0B
FONT_SHORT_NARROW = FC 06 0C
FONT_SHORT_NARROWER = FC 06 0D

@ colors

Expand Down
77 changes: 76 additions & 1 deletion gflib/text.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ 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 u16 FontFunc_ShortNarrower(struct TextPrinter *);
static void DecompressGlyph_Small(u16, bool32);
static void DecompressGlyph_Normal(u16, bool32);
static void DecompressGlyph_Short(u16, bool32);
Expand All @@ -35,6 +36,7 @@ static void DecompressGlyph_Bold(u16);
static void DecompressGlyph_Narrower(u16, bool32);
static void DecompressGlyph_SmallNarrower(u16, bool32);
static void DecompressGlyph_ShortNarrow(u16, bool32);
static void DecompressGlyph_ShortNarrower(u16, bool32);
static u32 GetGlyphWidth_Small(u16, bool32);
static u32 GetGlyphWidth_Normal(u16, bool32);
static u32 GetGlyphWidth_Short(u16, bool32);
Expand All @@ -43,6 +45,7 @@ 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 u32 GetGlyphWidth_ShortNarrower(u16, bool32);

static EWRAM_DATA struct TextPrinter sTempTextPrinter = {0};
static EWRAM_DATA struct TextPrinter sTextPrinters[WINDOWS_MAX] = {0};
Expand Down Expand Up @@ -102,6 +105,7 @@ static const struct GlyphWidthFunc sGlyphWidthFuncs[] =
{ FONT_NARROWER, GetGlyphWidth_Narrower },
{ FONT_SMALL_NARROWER, GetGlyphWidth_SmallNarrower },
{ FONT_SHORT_NARROW, GetGlyphWidth_ShortNarrow },
{ FONT_SHORT_NARROWER, GetGlyphWidth_ShortNarrower },
};

struct
Expand Down Expand Up @@ -260,6 +264,16 @@ static const struct FontInfo sFontInfos[] =
.bgColor = 1,
.shadowColor = 3,
},
[FONT_SHORT_NARROWER] = {
.fontFunction = FontFunc_ShortNarrower,
.maxLetterWidth = 5,
.maxLetterHeight = 14,
.letterSpacing = 0,
.lineSpacing = 0,
.fgColor = 2,
.bgColor = 1,
.shadowColor = 3,
},
};

static const u8 sMenuCursorDimensions[][2] =
Expand All @@ -277,6 +291,7 @@ static const u8 sMenuCursorDimensions[][2] =
[FONT_NARROWER] = { 8, 15 },
[FONT_SMALL_NARROWER] = { 8, 8 },
[FONT_SHORT_NARROW] = { 8, 14 },
[FONT_SHORT_NARROWER] = { 8, 14 },
};

static const u16 sFontBoldJapaneseGlyphs[] = INCBIN_U16("graphics/fonts/bold.hwjpnfont");
Expand Down Expand Up @@ -850,6 +865,18 @@ static u16 FontFunc_ShortNarrow(struct TextPrinter *textPrinter)
return RenderText(textPrinter);
}

static u16 FontFunc_ShortNarrower(struct TextPrinter *textPrinter)
{
struct TextPrinterSubStruct *subStruct = (struct TextPrinterSubStruct *)(&textPrinter->subStructFields);

if (subStruct->hasFontIdBeenSet == FALSE)
{
subStruct->fontId = FONT_SHORT_NARROWER;
subStruct->hasFontIdBeenSet = TRUE;
}
return RenderText(textPrinter);
}

void TextPrinterInitDownArrowCounters(struct TextPrinter *textPrinter)
{
struct TextPrinterSubStruct *subStruct = (struct TextPrinterSubStruct *)(&textPrinter->subStructFields);
Expand Down Expand Up @@ -1230,6 +1257,9 @@ static u16 RenderText(struct TextPrinter *textPrinter)
case FONT_SHORT_NARROW:
DecompressGlyph_ShortNarrow(currChar, textPrinter->japanese);
break;
case FONT_SHORT_NARROWER:
DecompressGlyph_ShortNarrower(currChar, textPrinter->japanese);
break;
case FONT_BRAILLE:
break;
}
Expand Down Expand Up @@ -2121,6 +2151,50 @@ static u32 GetGlyphWidth_ShortNarrow(u16 glyphId, bool32 isJapanese)
return gFontShortNarrowLatinGlyphWidths[glyphId];
}

static void DecompressGlyph_ShortNarrower(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 = gFontShortNarrowerLatinGlyphs + (0x20 * glyphId);
gCurGlyph.width = gFontShortNarrowerLatinGlyphWidths[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_ShortNarrower(u16 glyphId, bool32 isJapanese)
{
if (isJapanese == TRUE)
return gFontShortJapaneseGlyphWidths[glyphId];
else
return gFontShortNarrowerLatinGlyphWidths[glyphId];
}

static const s8 sNarrowerFontIds[] =
{
[FONT_SMALL] = FONT_SMALL_NARROW,
Expand All @@ -2135,7 +2209,8 @@ static const s8 sNarrowerFontIds[] =
[FONT_BOLD] = -1,
[FONT_NARROWER] = -1,
[FONT_SMALL_NARROWER] = -1,
[FONT_SHORT_NARROW] = -1,
[FONT_SHORT_NARROW] = FONT_SHORT_NARROWER,
[FONT_SHORT_NARROWER] = -1,
};

// If the narrowest font ID doesn't fit the text, we still return that
Expand Down
1 change: 1 addition & 0 deletions gflib/text.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ enum {
FONT_NARROWER,
FONT_SMALL_NARROWER,
FONT_SHORT_NARROW,
FONT_SHORT_NARROWER,
};

// Return values for font functions
Expand Down
Binary file added graphics/fonts/latin_short_narrower.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions graphics_file_rules.mk
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,9 @@ $(FONTGFXDIR)/small_narrower.latfont: $(FONTGFXDIR)/latin_small_narrower.png
$(FONTGFXDIR)/short_narrow.latfont: $(FONTGFXDIR)/latin_short_narrow.png
$(GFX) $< $@

$(FONTGFXDIR)/short_narrower.latfont: $(FONTGFXDIR)/latin_short_narrower.png
$(GFX) $< $@

$(FONTGFXDIR)/small.hwjpnfont: $(FONTGFXDIR)/japanese_small.png
$(GFX) $< $@

Expand Down
2 changes: 2 additions & 0 deletions include/fonts.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,7 @@ extern const u8 gFontSmallNarrowerLatinGlyphWidths[];
extern const u16 gFontSmallNarrowerLatinGlyphs[];
extern const u8 gFontShortNarrowLatinGlyphWidths[];
extern const u16 gFontShortNarrowLatinGlyphs[];
extern const u8 gFontShortNarrowerLatinGlyphWidths[];
extern const u16 gFontShortNarrowerLatinGlyphs[];

#endif // GUARD_FONTS_H
36 changes: 36 additions & 0 deletions src/fonts.c
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,42 @@ ALIGNED(4) const u8 gFontShortNarrowLatinGlyphWidths[] = {
8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 3,
};

ALIGNED(4) const u16 gFontShortNarrowerLatinGlyphs[] = INCBIN_U16("graphics/fonts/short_narrower.latfont");
ALIGNED(4) const u8 gFontShortNarrowerLatinGlyphWidths[] = {
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, 5, 5, 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 gFontSmallJapaneseGlyphs[] = INCBIN_U16("graphics/fonts/small.hwjpnfont");
ALIGNED(4) const u16 gFontNormalJapaneseGlyphs[] = INCBIN_U16("graphics/fonts/normal.hwjpnfont");

Expand Down
Loading