From ea8e703458f801075151b30d001d78ce3ba71ae2 Mon Sep 17 00:00:00 2001 From: Jaakko Keränen Date: Wed, 6 Oct 2021 17:02:28 +0300 Subject: Fixed a couple of font issues Scaling of monospace and symbols; cache reset. --- res/fonts/fontpack.ini | 5 ++--- src/ui/text.c | 22 +++++++++++----------- src/ui/uploadwidget.c | 2 +- 3 files changed, 14 insertions(+), 15 deletions(-) diff --git a/res/fonts/fontpack.ini b/res/fonts/fontpack.ini index 153b7f86..9274155e 100644 --- a/res/fonts/fontpack.ini +++ b/res/fonts/fontpack.ini @@ -11,7 +11,6 @@ bold = "SourceSans3-Bold.ttf" [iosevka] name = "Iosevka Term Extended" monospace = true -scaling = 0.866 regular = "IosevkaTerm-Extended.ttf" [smolemoji] @@ -33,7 +32,7 @@ name = "Noto Sans Symbols 2" auxiliary = true priority = 20 scaling = 1.45 -voffset = 1.2 +voffset = 0.5 regular = "NotoSansSymbols2-Regular.ttf" [notosymbols] @@ -41,5 +40,5 @@ name = "Noto Sans Symbols" auxiliary = true priority = 10 scaling = 2.0 -voffset = 0.5 +voffset = 1.2 regular = "NotoSansSymbols-Regular.ttf" diff --git a/src/ui/text.c b/src/ui/text.c index 86fdc084..65c95ef6 100644 --- a/src/ui/text.c +++ b/src/ui/text.c @@ -132,11 +132,13 @@ struct Impl_GlyphTable { uint32_t indexTable[128 - 32]; /* quick ASCII lookup */ }; -static void clearGlyphs_Font_(iGlyphTable *d) { - iForEach(Hash, i, &d->glyphs) { - delete_Glyph((iGlyph *) i.value); +static void clearGlyphs_GlyphTable_(iGlyphTable *d) { + if (d) { + iForEach(Hash, i, &d->glyphs) { + delete_Glyph((iGlyph *) i.value); + } + clear_Hash(&d->glyphs); } - clear_Hash(&d->glyphs); } static void init_GlyphTable(iGlyphTable *d) { @@ -145,7 +147,7 @@ static void init_GlyphTable(iGlyphTable *d) { } static void deinit_GlyphTable(iGlyphTable *d) { - clearGlyphs_Font_(d); + clearGlyphs_GlyphTable_(d); deinit_Hash(&d->glyphs); } @@ -457,11 +459,6 @@ static void initFonts_Text_(iText *d) { setupFontVariants_Text_(d, spec, fontId); } } - /* test */ { - const iFont *h = font_Text_(preformatted_FontId); // FONT_ID(documentBody_FontId, regular_FontStyle, contentRegular_FontSize)); - printf("{%s} %d sz:%d st:%d\n", cstr_String(&h->fontSpec->name), h->height, sizeId_Text_(h), - styleId_Text_(h)); - } #if 0 iForIndices(i, fontData) { iFont *font = font_Text_(i); @@ -608,7 +605,7 @@ void setContentFontSize_Text(iText *d, float fontSizeFactor) { static void resetCache_Text_(iText *d) { deinitCache_Text_(d); iForEach(Array, i, &d->fonts) { - clearGlyphs_Font_(i.value); + clearGlyphs_GlyphTable_(((iFont *) i.value)->table); } initCache_Text_(d); } @@ -720,6 +717,9 @@ iLocalDef iFont *characterFont_Font_(iFont *d, iChar ch, uint32_t *glyphIndex) { continue; /* already checked this one */ } if ((*glyphIndex = glyphIndex_Font_(font, ch)) != 0) { + printf("using %s[%f] for %lc (%x) => %d\n", + cstr_String(&font->fontSpec->name), font->fontSpec->scaling, + (int) ch, ch, glyphIndex_Font_(font, ch)); return font; } } diff --git a/src/ui/uploadwidget.c b/src/ui/uploadwidget.c index ded8d7f8..3bd11cfb 100644 --- a/src/ui/uploadwidget.c +++ b/src/ui/uploadwidget.c @@ -255,7 +255,7 @@ void init_UploadWidget(iUploadWidget *d) { setFlags_Widget(as_Widget(d->token), expand_WidgetFlag, iTrue); setFocus_Widget(as_Widget(d->input)); } - setFont_InputWidget(d->input, FONT_ID(monospace_FontId, regular_FontStyle, uiNormal_FontSize)); + setFont_InputWidget(d->input, FONT_ID(monospace_FontId, regular_FontStyle, uiSmall_FontSize)); setUseReturnKeyBehavior_InputWidget(d->input, iFalse); /* traditional text editor */ setLineLimits_InputWidget(d->input, 7, 20); setHint_InputWidget(d->input, "${hint.upload.text}"); -- cgit v1.2.3