summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJaakko Keränen <jaakko.keranen@iki.fi>2020-07-24 22:01:42 +0300
committerJaakko Keränen <jaakko.keranen@iki.fi>2020-07-24 22:01:42 +0300
commit472a5c97bbe90b615181984fc3919afd94992bb6 (patch)
tree9641681998e53f7c9c5c097d3311ea648701fa73 /src
parent650ab82b91067c35dad967025655e3c58e07c99c (diff)
Text: Tweaking Source Sans Pro baseline
Diffstat (limited to 'src')
-rw-r--r--src/ui/text.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/ui/text.c b/src/ui/text.c
index f1c2c947..6c3d78a1 100644
--- a/src/ui/text.c
+++ b/src/ui/text.c
@@ -26,7 +26,6 @@ struct Impl_Glyph {
26 iHashNode node; 26 iHashNode node;
27 iRect rect[2]; /* zero and half pixel offset */ 27 iRect rect[2]; /* zero and half pixel offset */
28 int advance; 28 int advance;
29 //int dx, dy;
30 iInt2 d[2]; 29 iInt2 d[2];
31}; 30};
32 31
@@ -58,10 +57,12 @@ struct Impl_Font {
58 int height; 57 int height;
59 int baseline; 58 int baseline;
60 iHash glyphs; 59 iHash glyphs;
60 int baselineOffset;
61}; 61};
62 62
63static void init_Font(iFont *d, const iBlock *data, int height) { 63static void init_Font(iFont *d, const iBlock *data, int height, int bloff) {
64 init_Hash(&d->glyphs); 64 init_Hash(&d->glyphs);
65 d->baselineOffset = bloff;
65 d->data = NULL; 66 d->data = NULL;
66 d->height = height; 67 d->height = height;
67 iZap(d->font); 68 iZap(d->font);
@@ -132,7 +133,8 @@ void init_Text(SDL_Renderer *render) {
132 { &fontFiraSansBold_Embedded, fontSize_UI * 2.0f }, 133 { &fontFiraSansBold_Embedded, fontSize_UI * 2.0f },
133 }; 134 };
134 iForIndices(i, fontData) { 135 iForIndices(i, fontData) {
135 init_Font(&d->fonts[i], fontData[i].ttf, fontData[i].size); 136 init_Font(&d->fonts[i], fontData[i].ttf, fontData[i].size,
137 i == 0 ? fontSize_UI / 20 : 0);
136 } 138 }
137 } 139 }
138} 140}
@@ -237,6 +239,7 @@ static void cache_Font_(iFont *d, iGlyph *glyph, int hoff) {
237 &glyph->d[hoff].y, 239 &glyph->d[hoff].y,
238 NULL, 240 NULL,
239 NULL); 241 NULL);
242 glyph->d[hoff].y += d->baselineOffset;
240 fromStb = iTrue; 243 fromStb = iTrue;
241 tex = SDL_CreateTextureFromSurface(render, surface); 244 tex = SDL_CreateTextureFromSurface(render, surface);
242 glRect->size = init_I2(surface->w, surface->h); 245 glRect->size = init_I2(surface->w, surface->h);