summaryrefslogtreecommitdiff
path: root/font
diff options
context:
space:
mode:
author3gg <3gg@shellblade.net>2025-05-24 17:01:01 -0700
committer3gg <3gg@shellblade.net>2025-05-24 17:01:01 -0700
commit0ffd63fed9dcfb60be7378b6f53f0f1d011fd26c (patch)
tree4a3b0f541b91349955b5b58f24b47c8b38f287f0 /font
parent68a3532728b55b73d8bcadb8ccfc1d9396346cd2 (diff)
Tweaksmain
Diffstat (limited to 'font')
-rw-r--r--font/font.h8
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
6static const unsigned char FontGlyphStart = 32; // Space. 6static const unsigned char FontGlyphStart = 32; // Space.
7static const unsigned char FontGlyphEnd = 127; // One past tilde. 7static const unsigned char FontGlyphEnd = 127; // One past tilde.
8static const int FontAtlasNumGlyphs = FontGlyphEnd - FontGlyphStart; 8static const unsigned int FontAtlasNumGlyphs = FontGlyphEnd - FontGlyphStart;
9 9
10/// Font atlas header. 10/// Font atlas header.
11typedef struct FontHeader { 11typedef struct FontHeader {
@@ -32,8 +32,10 @@ FontAtlas* LoadFontAtlas(const char* path);
32static inline const unsigned char* FontGetGlyph( 32static 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);