diff options
author | 3gg <3gg@shellblade.net> | 2025-05-24 17:01:01 -0700 |
---|---|---|
committer | 3gg <3gg@shellblade.net> | 2025-05-24 17:01:01 -0700 |
commit | 0ffd63fed9dcfb60be7378b6f53f0f1d011fd26c (patch) | |
tree | 4a3b0f541b91349955b5b58f24b47c8b38f287f0 /font | |
parent | 68a3532728b55b73d8bcadb8ccfc1d9396346cd2 (diff) |
Tweaksmain
Diffstat (limited to 'font')
-rw-r--r-- | font/font.h | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/font/font.h b/font/font.h index 13ff1c3..9d37e64 100644 --- a/font/font.h +++ b/font/font.h | |||
@@ -5,7 +5,7 @@ | |||
5 | 5 | ||
6 | static const unsigned char FontGlyphStart = 32; // Space. | 6 | static const unsigned char FontGlyphStart = 32; // Space. |
7 | static const unsigned char FontGlyphEnd = 127; // One past tilde. | 7 | static const unsigned char FontGlyphEnd = 127; // One past tilde. |
8 | static const int FontAtlasNumGlyphs = FontGlyphEnd - FontGlyphStart; | 8 | static const unsigned int FontAtlasNumGlyphs = FontGlyphEnd - FontGlyphStart; |
9 | 9 | ||
10 | /// Font atlas header. | 10 | /// Font atlas header. |
11 | typedef struct FontHeader { | 11 | typedef struct FontHeader { |
@@ -32,8 +32,10 @@ FontAtlas* LoadFontAtlas(const char* path); | |||
32 | static inline const unsigned char* FontGetGlyph( | 32 | static inline const unsigned char* FontGetGlyph( |
33 | const FontAtlas* atlas, unsigned char c) { | 33 | const FontAtlas* atlas, unsigned char c) { |
34 | assert(atlas); | 34 | assert(atlas); |
35 | const int index = c - FontGlyphStart; | 35 | unsigned index = c - FontGlyphStart; |
36 | assert(index >= 0); | 36 | if (index >= FontAtlasNumGlyphs) { |
37 | index = '?' - FontGlyphStart; | ||
38 | } | ||
37 | assert(index < FontAtlasNumGlyphs); | 39 | assert(index < FontAtlasNumGlyphs); |
38 | return atlas->pixels + | 40 | return atlas->pixels + |
39 | index * (atlas->header.glyph_width * atlas->header.glyph_height); | 41 | index * (atlas->header.glyph_width * atlas->header.glyph_height); |