summaryrefslogtreecommitdiff
path: root/src/ui/text_simple.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/ui/text_simple.c')
-rw-r--r--src/ui/text_simple.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/src/ui/text_simple.c b/src/ui/text_simple.c
index 8b1de64a..81fb94a5 100644
--- a/src/ui/text_simple.c
+++ b/src/ui/text_simple.c
@@ -61,6 +61,7 @@ static iRect runSimple_Font_(iFont *d, const iRunArgs *args) {
61 and other non-complex LTR scripts. Composed glyphs are not supported (must rely on text 61 and other non-complex LTR scripts. Composed glyphs are not supported (must rely on text
62 being in a pre-composed form). This algorithm is used if HarfBuzz is not available. */ 62 being in a pre-composed form). This algorithm is used if HarfBuzz is not available. */
63 const iInt2 orig = args->pos; 63 const iInt2 orig = args->pos;
64 iTextAttrib attrib = { .colorId = args->color };
64 iRect bounds = { orig, init_I2(0, d->height) }; 65 iRect bounds = { orig, init_I2(0, d->height) };
65 float xpos = orig.x; 66 float xpos = orig.x;
66 float xposMax = xpos; 67 float xposMax = xpos;
@@ -86,7 +87,7 @@ static iRect runSimple_Font_(iFont *d, const iRunArgs *args) {
86// } 87// }
87 const iBool checkHitPoint = wrap && !isEqual_I2(wrap->hitPoint, zero_I2()); 88 const iBool checkHitPoint = wrap && !isEqual_I2(wrap->hitPoint, zero_I2());
88 const iBool checkHitChar = wrap && wrap->hitChar; 89 const iBool checkHitChar = wrap && wrap->hitChar;
89 const iBool isMonospaced = d->isMonospaced && !(mode & alwaysVariableWidthFlag_RunMode); 90 const iBool isMonospaced = isMonospaced_Font(d) && !(mode & alwaysVariableWidthFlag_RunMode);
90 if (isMonospaced) { 91 if (isMonospaced) {
91 monoAdvance = glyph_Font_(d, 'M')->advance; 92 monoAdvance = glyph_Font_(d, 'M')->advance;
92 } 93 }
@@ -166,7 +167,7 @@ static iRect runSimple_Font_(iFont *d, const iRunArgs *args) {
166 /* TODO: Check out if `uc_wordbreak_property()` from libunistring can be used here. */ 167 /* TODO: Check out if `uc_wordbreak_property()` from libunistring can be used here. */
167 if (ch == '\n') { 168 if (ch == '\n') {
168 /* Notify about the wrap. */ 169 /* Notify about the wrap. */
169 if (!notify_WrapText_(wrap, chPos, 0, iMax(xpos, xposExtend) - orig.x, iFalse)) { 170 if (!notify_WrapText_(wrap, chPos, attrib, 0, iMax(xpos, xposExtend) - orig.x)) {
170 break; 171 break;
171 } 172 }
172 lastWordEnd = NULL; 173 lastWordEnd = NULL;
@@ -246,7 +247,7 @@ static iRect runSimple_Font_(iFont *d, const iRunArgs *args) {
246 wrapPos = iMin(wrapPos, args->text.end); 247 wrapPos = iMin(wrapPos, args->text.end);
247 advance = wrapAdvance; 248 advance = wrapAdvance;
248 } 249 }
249 if (!notify_WrapText_(wrap, wrapPos, 0, advance, iFalse)) { 250 if (!notify_WrapText_(wrap, wrapPos, attrib, 0, advance)) {
250 break; 251 break;
251 } 252 }
252 lastWordEnd = NULL; 253 lastWordEnd = NULL;
@@ -282,8 +283,7 @@ static iRect runSimple_Font_(iFont *d, const iRunArgs *args) {
282 } 283 }
283 /* Symbols and emojis are NOT monospaced, so must conform when the primary font 284 /* Symbols and emojis are NOT monospaced, so must conform when the primary font
284 is monospaced. Except with Japanese script, that's larger than the normal monospace. */ 285 is monospaced. Except with Japanese script, that's larger than the normal monospace. */
285 const iBool useMonoAdvance = 286 const iBool useMonoAdvance = monoAdvance > 0; // && !isJapanese_FontId(fontId_Text_(glyph->font));
286 monoAdvance > 0 && !isJapanese_FontId(fontId_Text_(glyph->font));
287 const float advance = (useMonoAdvance && glyph->advance > 0 ? monoAdvance : glyph->advance); 287 const float advance = (useMonoAdvance && glyph->advance > 0 ? monoAdvance : glyph->advance);
288 if (!isMeasuring_(mode) && ch != 0x20 /* don't bother rendering spaces */) { 288 if (!isMeasuring_(mode) && ch != 0x20 /* don't bother rendering spaces */) {
289 if (useMonoAdvance && dst.w > advance && glyph->font != d && !isEmoji) { 289 if (useMonoAdvance && dst.w > advance && glyph->font != d && !isEmoji) {
@@ -328,9 +328,9 @@ static iRect runSimple_Font_(iFont *d, const iRunArgs *args) {
328 if (enableKerning_Text && next) { 328 if (enableKerning_Text && next) {
329 const uint32_t nextGlyphIndex = glyphIndex_Font_(glyph->font, next); 329 const uint32_t nextGlyphIndex = glyphIndex_Font_(glyph->font, next);
330 int kern = stbtt_GetGlyphKernAdvance( 330 int kern = stbtt_GetGlyphKernAdvance(
331 &glyph->font->font, index_Glyph_(glyph), nextGlyphIndex); 331 &glyph->font->fontFile->stbInfo, index_Glyph_(glyph), nextGlyphIndex);
332 /* Nunito needs some kerning fixes. */ 332 /* Nunito needs some kerning fixes. */
333 if (glyph->font->family == nunito_TextFont) { 333 if (glyph->font->fontSpec->flags & fixNunitoKerning_FontSpecFlag) {
334 if (ch == 'W' && (next == 'i' || next == 'h')) { 334 if (ch == 'W' && (next == 'i' || next == 'h')) {
335 kern = -30; 335 kern = -30;
336 } 336 }
@@ -362,7 +362,7 @@ static iRect runSimple_Font_(iFont *d, const iRunArgs *args) {
362 break; 362 break;
363 } 363 }
364 } 364 }
365 notify_WrapText_(wrap, chPos, 0, xpos - orig.x, iFalse); 365 notify_WrapText_(wrap, chPos, attrib, 0, xpos - orig.x);
366 if (checkHitChar && wrap->hitChar == args->text.end) { 366 if (checkHitChar && wrap->hitChar == args->text.end) {
367 wrap->hitAdvance_out = sub_I2(init_I2(xpos, ypos), orig); 367 wrap->hitAdvance_out = sub_I2(init_I2(xpos, ypos), orig);
368 } 368 }