summaryrefslogtreecommitdiff
path: root/src/ui
diff options
context:
space:
mode:
authorJaakko Keränen <jaakko.keranen@iki.fi>2020-11-14 18:33:48 +0200
committerJaakko Keränen <jaakko.keranen@iki.fi>2020-11-14 18:33:48 +0200
commitc11e09353ba7558f15958a01a0a4ac8f704d1ba5 (patch)
treeb25f0a38260c4b740dea0b6064b18b41da9fd2b6 /src/ui
parent89539c36c573edf5cb8e3453ef27acd9c82ce3db (diff)
macOS: Font tweak for ⌘ and ⇧ characters
Diffstat (limited to 'src/ui')
-rw-r--r--src/ui/text.c13
-rw-r--r--src/ui/text.h1
2 files changed, 12 insertions, 2 deletions
diff --git a/src/ui/text.c b/src/ui/text.c
index 04bb17a2..1ff3fb12 100644
--- a/src/ui/text.c
+++ b/src/ui/text.c
@@ -211,6 +211,7 @@ static void initFonts_Text_(iText *d) {
211 { &fontSourceSansProRegular_Embedded, fontSize_UI * 1.125f, 1.0f, defaultMediumSymbols_FontId }, 211 { &fontSourceSansProRegular_Embedded, fontSize_UI * 1.125f, 1.0f, defaultMediumSymbols_FontId },
212 { &fontSourceSansProRegular_Embedded, fontSize_UI * 1.666f, 1.0f, defaultLargeSymbols_FontId }, 212 { &fontSourceSansProRegular_Embedded, fontSize_UI * 1.666f, 1.0f, defaultLargeSymbols_FontId },
213 { &fontFiraMonoRegular_Embedded, fontSize_UI * 0.866f, 1.0f, defaultSymbols_FontId }, 213 { &fontFiraMonoRegular_Embedded, fontSize_UI * 0.866f, 1.0f, defaultSymbols_FontId },
214 { &fontSourceSansProRegular_Embedded, textSize, scaling, symbols_FontId },
214 /* content fonts */ 215 /* content fonts */
215 { regularFont, textSize, scaling, symbols_FontId }, 216 { regularFont, textSize, scaling, symbols_FontId },
216 { &fontFiraMonoRegular_Embedded, monoSize, 1.0f, monospaceSymbols_FontId }, 217 { &fontFiraMonoRegular_Embedded, monoSize, 1.0f, monospaceSymbols_FontId },
@@ -467,7 +468,7 @@ static void cache_Font_(iFont *d, iGlyph *glyph, int hoff) {
467 iRect *glRect = &glyph->rect[hoff]; 468 iRect *glRect = &glyph->rect[hoff];
468 /* Rasterize the glyph using stbtt. */ { 469 /* Rasterize the glyph using stbtt. */ {
469 surface = rasterizeGlyph_Font_(d, glyph->glyphIndex, hoff * 0.5f); 470 surface = rasterizeGlyph_Font_(d, glyph->glyphIndex, hoff * 0.5f);
470 if (hoff == 0) { 471 if (hoff == 0) { /* hoff==1 uses same `glyph` */
471 int adv; 472 int adv;
472 const uint32_t gIndex = glyph->glyphIndex; 473 const uint32_t gIndex = glyph->glyphIndex;
473 stbtt_GetGlyphHMetrics(&d->font, gIndex, &adv, NULL); 474 stbtt_GetGlyphHMetrics(&d->font, gIndex, &adv, NULL);
@@ -499,7 +500,7 @@ static void cache_Font_(iFont *d, iGlyph *glyph, int hoff) {
499 } 500 }
500} 501}
501 502
502iLocalDef iFont *characterFont_Font_(iFont *d, iChar ch, uint32_t *glyphIndex) { 503iLocalDef iFont *characterFont_Font_(iFont *d, iChar ch, uint32_t *glyphIndex) {
503 if ((*glyphIndex = glyphIndex_Font_(d, ch)) != 0) { 504 if ((*glyphIndex = glyphIndex_Font_(d, ch)) != 0) {
504 return d; 505 return d;
505 } 506 }
@@ -524,6 +525,14 @@ iLocalDef iFont *characterFont_Font_(iFont *d, iChar ch, uint32_t *glyphIndex) {
524 return japanese; 525 return japanese;
525 } 526 }
526 } 527 }
528#if defined (iPlatformApple)
529 /* White up arrow is used for the Shift key on macOS. Symbola's glyph is not a great
530 match to the other text, so use the UI font instead. */
531 if ((ch == 0x2318 || ch == 0x21e7) && d == font_Text_(regular_FontId)) {
532 *glyphIndex = glyphIndex_Font_(d = font_Text_(defaultContentSized_FontId), ch);
533 return d;
534 }
535#endif
527 /* Fall back to Symbola for anything else. */ 536 /* Fall back to Symbola for anything else. */
528 iFont *font = font_Text_(d->symbolsFont); 537 iFont *font = font_Text_(d->symbolsFont);
529 *glyphIndex = glyphIndex_Font_(font, ch); 538 *glyphIndex = glyphIndex_Font_(font, ch);
diff --git a/src/ui/text.h b/src/ui/text.h
index 3dd949d9..25312973 100644
--- a/src/ui/text.h
+++ b/src/ui/text.h
@@ -34,6 +34,7 @@ enum iFontId {
34 defaultMedium_FontId, 34 defaultMedium_FontId,
35 defaultLarge_FontId, 35 defaultLarge_FontId,
36 defaultMonospace_FontId, 36 defaultMonospace_FontId,
37 defaultContentSized_FontId,
37 /* content fonts */ 38 /* content fonts */
38 regular_FontId, 39 regular_FontId,
39 monospace_FontId, 40 monospace_FontId,