summaryrefslogtreecommitdiff
path: root/src/ui/text.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/ui/text.c')
-rw-r--r--src/ui/text.c32
1 files changed, 19 insertions, 13 deletions
diff --git a/src/ui/text.c b/src/ui/text.c
index 8ed04bb4..6f87a6d0 100644
--- a/src/ui/text.c
+++ b/src/ui/text.c
@@ -46,6 +46,8 @@ iDeclareType(Font)
46iDeclareType(Glyph) 46iDeclareType(Glyph)
47iDeclareTypeConstructionArgs(Glyph, iChar ch) 47iDeclareTypeConstructionArgs(Glyph, iChar ch)
48 48
49static const float contentScale_Text_ = 1.3f;
50
49int gap_Text; /* cf. gap_UI in metrics.h */ 51int gap_Text; /* cf. gap_UI in metrics.h */
50int enableHalfPixelGlyphs_Text = iTrue; /* debug setting */ 52int enableHalfPixelGlyphs_Text = iTrue; /* debug setting */
51int enableKerning_Text = iTrue; /* looking up kern pairs is slow */ 53int enableKerning_Text = iTrue; /* looking up kern pairs is slow */
@@ -139,6 +141,7 @@ static iText text_;
139 141
140static void initFonts_Text_(iText *d) { 142static void initFonts_Text_(iText *d) {
141 const float textSize = fontSize_UI * d->contentFontSize; 143 const float textSize = fontSize_UI * d->contentFontSize;
144 const float monoSize = fontSize_UI * d->contentFontSize / contentScale_Text_ * 0.866f;
142 const struct { 145 const struct {
143 const iBlock *ttf; 146 const iBlock *ttf;
144 int size; 147 int size;
@@ -147,16 +150,16 @@ static void initFonts_Text_(iText *d) {
147 { &fontSourceSansProRegular_Embedded, fontSize_UI, defaultSymbols_FontId }, 150 { &fontSourceSansProRegular_Embedded, fontSize_UI, defaultSymbols_FontId },
148 { &fontSourceSansProRegular_Embedded, fontSize_UI * 1.125f, defaultMediumSymbols_FontId }, 151 { &fontSourceSansProRegular_Embedded, fontSize_UI * 1.125f, defaultMediumSymbols_FontId },
149 { &fontFiraMonoRegular_Embedded, fontSize_UI * 0.866f, defaultSymbols_FontId }, 152 { &fontFiraMonoRegular_Embedded, fontSize_UI * 0.866f, defaultSymbols_FontId },
150 { &fontFiraSansRegular_Embedded, textSize, symbols_FontId }, 153 { &fontNunitoRegular_Embedded, textSize, symbols_FontId },
151 { &fontFiraMonoRegular_Embedded, textSize * 0.866f, smallSymbols_FontId }, 154 { &fontFiraMonoRegular_Embedded, monoSize, smallSymbols_FontId },
152 { &fontFiraMonoRegular_Embedded, textSize * 0.666f, smallSymbols_FontId }, 155 { &fontFiraMonoRegular_Embedded, monoSize * 0.750f, smallSymbols_FontId },
153 { &fontFiraSansRegular_Embedded, textSize * 1.333f, mediumSymbols_FontId }, 156 { &fontNunitoRegular_Embedded, textSize * 1.333f, mediumSymbols_FontId },
154 { &fontFiraSansItalic_Embedded, textSize, symbols_FontId }, 157 { &fontNunitoLightItalic_Embedded, textSize, symbols_FontId },
155 { &fontFiraSansBold_Embedded, textSize, symbols_FontId }, 158 { &fontNunitoBold_Embedded, textSize, symbols_FontId },
156 { &fontFiraSansBold_Embedded, textSize * 1.333f, mediumSymbols_FontId }, 159 { &fontNunitoBold_Embedded, textSize * 1.333f, mediumSymbols_FontId },
157 { &fontFiraSansBold_Embedded, textSize * 1.666f, largeSymbols_FontId }, 160 { &fontNunitoBold_Embedded, textSize * 1.666f, largeSymbols_FontId },
158 { &fontFiraSansBold_Embedded, textSize * 2.000f, hugeSymbols_FontId }, 161 { &fontNunitoBold_Embedded, textSize * 2.000f, hugeSymbols_FontId },
159 { &fontFiraSansLight_Embedded, textSize * 1.666f, largeSymbols_FontId }, 162 { &fontNunitoExtraLight_Embedded, textSize * 1.666f, largeSymbols_FontId },
160 { &fontSymbola_Embedded, fontSize_UI, defaultSymbols_FontId }, 163 { &fontSymbola_Embedded, fontSize_UI, defaultSymbols_FontId },
161 { &fontSymbola_Embedded, fontSize_UI * 1.125f, defaultMediumSymbols_FontId }, 164 { &fontSymbola_Embedded, fontSize_UI * 1.125f, defaultMediumSymbols_FontId },
162 { &fontSymbola_Embedded, textSize, symbols_FontId }, 165 { &fontSymbola_Embedded, textSize, symbols_FontId },
@@ -219,7 +222,7 @@ static void deinitCache_Text_(iText *d) {
219 222
220void init_Text(SDL_Renderer *render) { 223void init_Text(SDL_Renderer *render) {
221 iText *d = &text_; 224 iText *d = &text_;
222 d->contentFontSize = 1.0f; 225 d->contentFontSize = contentScale_Text_;
223 d->ansiEscape = new_RegExp("\\[([0-9;]+)m", 0); 226 d->ansiEscape = new_RegExp("\\[([0-9;]+)m", 0);
224 d->render = render; 227 d->render = render;
225 /* A grayscale palette for rasterized glyphs. */ { 228 /* A grayscale palette for rasterized glyphs. */ {
@@ -244,6 +247,7 @@ void deinit_Text(void) {
244} 247}
245 248
246void setContentFontSize_Text(float fontSizeFactor) { 249void setContentFontSize_Text(float fontSizeFactor) {
250 fontSizeFactor *= contentScale_Text_;
247 iAssert(fontSizeFactor > 0); 251 iAssert(fontSizeFactor > 0);
248 if (iAbs(text_.contentFontSize - fontSizeFactor) > 0.001f) { 252 if (iAbs(text_.contentFontSize - fontSizeFactor) > 0.001f) {
249 text_.contentFontSize = fontSizeFactor; 253 text_.contentFontSize = fontSizeFactor;
@@ -522,12 +526,14 @@ static iRect run_Font_(iFont *d, enum iRunMode mode, iRangecc text, size_t maxLe
522 /* TODO: No need to decode the next char twice; check this on the next iteration. */ 526 /* TODO: No need to decode the next char twice; check this on the next iteration. */
523 const char *peek = chPos; 527 const char *peek = chPos;
524 const iChar next = nextChar_(&peek, text.end); 528 const iChar next = nextChar_(&peek, text.end);
529#if 0
525 if (ch == '/' && next == '/') { 530 if (ch == '/' && next == '/') {
526 /* Manual kerning for double-slash. */ 531 /* Manual kerning for double-slash. */
527 xpos -= glyph->rect[hoff].size.x * 0.5f; 532 xpos -= glyph->rect[hoff].size.x * 0.5f;
528 } 533 } else
534#endif
529#if defined (LAGRANGE_ENABLE_KERNING) 535#if defined (LAGRANGE_ENABLE_KERNING)
530 else if (enableKerning_Text && !d->manualKernOnly && next) { 536 if (enableKerning_Text && !d->manualKernOnly && next) {
531 xpos += d->scale * stbtt_GetCodepointKernAdvance(&d->font, ch, next); 537 xpos += d->scale * stbtt_GetCodepointKernAdvance(&d->font, ch, next);
532 } 538 }
533#endif 539#endif