diff options
author | Jaakko Keränen <jaakko.keranen@iki.fi> | 2021-10-06 17:02:28 +0300 |
---|---|---|
committer | Jaakko Keränen <jaakko.keranen@iki.fi> | 2021-10-06 17:02:28 +0300 |
commit | ea8e703458f801075151b30d001d78ce3ba71ae2 (patch) | |
tree | 88bb5f83d829e7885b449032eca1405ba80e5814 | |
parent | 61a3dc017067be43472dadb7909094aa04d1fe9d (diff) |
Fixed a couple of font issues
Scaling of monospace and symbols; cache reset.
-rw-r--r-- | res/fonts/fontpack.ini | 5 | ||||
-rw-r--r-- | src/ui/text.c | 22 | ||||
-rw-r--r-- | 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" | |||
11 | [iosevka] | 11 | [iosevka] |
12 | name = "Iosevka Term Extended" | 12 | name = "Iosevka Term Extended" |
13 | monospace = true | 13 | monospace = true |
14 | scaling = 0.866 | ||
15 | regular = "IosevkaTerm-Extended.ttf" | 14 | regular = "IosevkaTerm-Extended.ttf" |
16 | 15 | ||
17 | [smolemoji] | 16 | [smolemoji] |
@@ -33,7 +32,7 @@ name = "Noto Sans Symbols 2" | |||
33 | auxiliary = true | 32 | auxiliary = true |
34 | priority = 20 | 33 | priority = 20 |
35 | scaling = 1.45 | 34 | scaling = 1.45 |
36 | voffset = 1.2 | 35 | voffset = 0.5 |
37 | regular = "NotoSansSymbols2-Regular.ttf" | 36 | regular = "NotoSansSymbols2-Regular.ttf" |
38 | 37 | ||
39 | [notosymbols] | 38 | [notosymbols] |
@@ -41,5 +40,5 @@ name = "Noto Sans Symbols" | |||
41 | auxiliary = true | 40 | auxiliary = true |
42 | priority = 10 | 41 | priority = 10 |
43 | scaling = 2.0 | 42 | scaling = 2.0 |
44 | voffset = 0.5 | 43 | voffset = 1.2 |
45 | regular = "NotoSansSymbols-Regular.ttf" | 44 | 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 { | |||
132 | uint32_t indexTable[128 - 32]; /* quick ASCII lookup */ | 132 | uint32_t indexTable[128 - 32]; /* quick ASCII lookup */ |
133 | }; | 133 | }; |
134 | 134 | ||
135 | static void clearGlyphs_Font_(iGlyphTable *d) { | 135 | static void clearGlyphs_GlyphTable_(iGlyphTable *d) { |
136 | iForEach(Hash, i, &d->glyphs) { | 136 | if (d) { |
137 | delete_Glyph((iGlyph *) i.value); | 137 | iForEach(Hash, i, &d->glyphs) { |
138 | delete_Glyph((iGlyph *) i.value); | ||
139 | } | ||
140 | clear_Hash(&d->glyphs); | ||
138 | } | 141 | } |
139 | clear_Hash(&d->glyphs); | ||
140 | } | 142 | } |
141 | 143 | ||
142 | static void init_GlyphTable(iGlyphTable *d) { | 144 | static void init_GlyphTable(iGlyphTable *d) { |
@@ -145,7 +147,7 @@ static void init_GlyphTable(iGlyphTable *d) { | |||
145 | } | 147 | } |
146 | 148 | ||
147 | static void deinit_GlyphTable(iGlyphTable *d) { | 149 | static void deinit_GlyphTable(iGlyphTable *d) { |
148 | clearGlyphs_Font_(d); | 150 | clearGlyphs_GlyphTable_(d); |
149 | deinit_Hash(&d->glyphs); | 151 | deinit_Hash(&d->glyphs); |
150 | } | 152 | } |
151 | 153 | ||
@@ -457,11 +459,6 @@ static void initFonts_Text_(iText *d) { | |||
457 | setupFontVariants_Text_(d, spec, fontId); | 459 | setupFontVariants_Text_(d, spec, fontId); |
458 | } | 460 | } |
459 | } | 461 | } |
460 | /* test */ { | ||
461 | const iFont *h = font_Text_(preformatted_FontId); // FONT_ID(documentBody_FontId, regular_FontStyle, contentRegular_FontSize)); | ||
462 | printf("{%s} %d sz:%d st:%d\n", cstr_String(&h->fontSpec->name), h->height, sizeId_Text_(h), | ||
463 | styleId_Text_(h)); | ||
464 | } | ||
465 | #if 0 | 462 | #if 0 |
466 | iForIndices(i, fontData) { | 463 | iForIndices(i, fontData) { |
467 | iFont *font = font_Text_(i); | 464 | iFont *font = font_Text_(i); |
@@ -608,7 +605,7 @@ void setContentFontSize_Text(iText *d, float fontSizeFactor) { | |||
608 | static void resetCache_Text_(iText *d) { | 605 | static void resetCache_Text_(iText *d) { |
609 | deinitCache_Text_(d); | 606 | deinitCache_Text_(d); |
610 | iForEach(Array, i, &d->fonts) { | 607 | iForEach(Array, i, &d->fonts) { |
611 | clearGlyphs_Font_(i.value); | 608 | clearGlyphs_GlyphTable_(((iFont *) i.value)->table); |
612 | } | 609 | } |
613 | initCache_Text_(d); | 610 | initCache_Text_(d); |
614 | } | 611 | } |
@@ -720,6 +717,9 @@ iLocalDef iFont *characterFont_Font_(iFont *d, iChar ch, uint32_t *glyphIndex) { | |||
720 | continue; /* already checked this one */ | 717 | continue; /* already checked this one */ |
721 | } | 718 | } |
722 | if ((*glyphIndex = glyphIndex_Font_(font, ch)) != 0) { | 719 | if ((*glyphIndex = glyphIndex_Font_(font, ch)) != 0) { |
720 | printf("using %s[%f] for %lc (%x) => %d\n", | ||
721 | cstr_String(&font->fontSpec->name), font->fontSpec->scaling, | ||
722 | (int) ch, ch, glyphIndex_Font_(font, ch)); | ||
723 | return font; | 723 | return font; |
724 | } | 724 | } |
725 | } | 725 | } |
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) { | |||
255 | setFlags_Widget(as_Widget(d->token), expand_WidgetFlag, iTrue); | 255 | setFlags_Widget(as_Widget(d->token), expand_WidgetFlag, iTrue); |
256 | setFocus_Widget(as_Widget(d->input)); | 256 | setFocus_Widget(as_Widget(d->input)); |
257 | } | 257 | } |
258 | setFont_InputWidget(d->input, FONT_ID(monospace_FontId, regular_FontStyle, uiNormal_FontSize)); | 258 | setFont_InputWidget(d->input, FONT_ID(monospace_FontId, regular_FontStyle, uiSmall_FontSize)); |
259 | setUseReturnKeyBehavior_InputWidget(d->input, iFalse); /* traditional text editor */ | 259 | setUseReturnKeyBehavior_InputWidget(d->input, iFalse); /* traditional text editor */ |
260 | setLineLimits_InputWidget(d->input, 7, 20); | 260 | setLineLimits_InputWidget(d->input, 7, 20); |
261 | setHint_InputWidget(d->input, "${hint.upload.text}"); | 261 | setHint_InputWidget(d->input, "${hint.upload.text}"); |