diff options
Diffstat (limited to 'src/ui/text.c')
-rw-r--r-- | src/ui/text.c | 46 |
1 files changed, 43 insertions, 3 deletions
diff --git a/src/ui/text.c b/src/ui/text.c index 51865654..edbc6583 100644 --- a/src/ui/text.c +++ b/src/ui/text.c | |||
@@ -316,6 +316,7 @@ static void initFonts_Text_(iText *d) { | |||
316 | { &fontSourceSans3Regular_Embedded, uiSize * 1.125f, 1.0f, uiMedium_FontSize }, | 316 | { &fontSourceSans3Regular_Embedded, uiSize * 1.125f, 1.0f, uiMedium_FontSize }, |
317 | { &fontSourceSans3Regular_Embedded, uiSize * 1.333f, 1.0f, uiBig_FontSize }, | 317 | { &fontSourceSans3Regular_Embedded, uiSize * 1.333f, 1.0f, uiBig_FontSize }, |
318 | { &fontSourceSans3Regular_Embedded, uiSize * 1.666f, 1.0f, uiLarge_FontSize }, | 318 | { &fontSourceSans3Regular_Embedded, uiSize * 1.666f, 1.0f, uiLarge_FontSize }, |
319 | { &fontSourceSans3Semibold_Embedded, uiSize * 0.8f, 1.0f, uiNormal_FontSize }, | ||
319 | /* UI fonts: bold weight */ | 320 | /* UI fonts: bold weight */ |
320 | { &fontSourceSans3Bold_Embedded, uiSize, 1.0f, uiNormal_FontSize }, | 321 | { &fontSourceSans3Bold_Embedded, uiSize, 1.0f, uiNormal_FontSize }, |
321 | { &fontSourceSans3Bold_Embedded, uiSize * 1.125f, 1.0f, uiMedium_FontSize }, | 322 | { &fontSourceSans3Bold_Embedded, uiSize * 1.125f, 1.0f, uiMedium_FontSize }, |
@@ -399,7 +400,9 @@ static void initCache_Text_(iText *d) { | |||
399 | d->cacheRowAllocStep = iMax(2, textSize / 6); | 400 | d->cacheRowAllocStep = iMax(2, textSize / 6); |
400 | /* Allocate initial (empty) rows. These will be assigned actual locations in the cache | 401 | /* Allocate initial (empty) rows. These will be assigned actual locations in the cache |
401 | once at least one glyph is stored. */ | 402 | once at least one glyph is stored. */ |
402 | for (int h = d->cacheRowAllocStep; h <= 2 * textSize + d->cacheRowAllocStep; h += d->cacheRowAllocStep) { | 403 | for (int h = d->cacheRowAllocStep; |
404 | h <= 2.5 * textSize + d->cacheRowAllocStep; | ||
405 | h += d->cacheRowAllocStep) { | ||
403 | pushBack_Array(&d->cacheRows, &(iCacheRow){ .height = 0 }); | 406 | pushBack_Array(&d->cacheRows, &(iCacheRow){ .height = 0 }); |
404 | } | 407 | } |
405 | d->cacheBottom = 0; | 408 | d->cacheBottom = 0; |
@@ -1020,10 +1023,10 @@ static iRect run_Font_(iFont *d, const iRunArgs *args) { | |||
1020 | prevCh = 0; | 1023 | prevCh = 0; |
1021 | continue; | 1024 | continue; |
1022 | } | 1025 | } |
1023 | if (ch == '\r') { /* color change */ | 1026 | if (ch == '\v') { /* color change */ |
1024 | iChar esc = nextChar_(&chPos, args->text.end); | 1027 | iChar esc = nextChar_(&chPos, args->text.end); |
1025 | int colorNum = args->color; | 1028 | int colorNum = args->color; |
1026 | if (esc == '\r') { /* Extended range. */ | 1029 | if (esc == '\v') { /* Extended range. */ |
1027 | esc = nextChar_(&chPos, args->text.end) + asciiExtended_ColorEscape; | 1030 | esc = nextChar_(&chPos, args->text.end) + asciiExtended_ColorEscape; |
1028 | colorNum = esc - asciiBase_ColorEscape; | 1031 | colorNum = esc - asciiBase_ColorEscape; |
1029 | } | 1032 | } |
@@ -1335,6 +1338,18 @@ void drawRangeN_Text(int fontId, iInt2 pos, int color, iRangecc text, size_t max | |||
1335 | drawBoundedN_Text_(fontId, pos, 0, color, text, maxChars); | 1338 | drawBoundedN_Text_(fontId, pos, 0, color, text, maxChars); |
1336 | } | 1339 | } |
1337 | 1340 | ||
1341 | void drawOutline_Text(int fontId, iInt2 pos, int outlineColor, int fillColor, iRangecc text) { | ||
1342 | for (int off = 0; off < 4; ++off) { | ||
1343 | drawRange_Text(fontId, | ||
1344 | add_I2(pos, init_I2(off % 2 == 0 ? -1 : 1, off / 2 == 0 ? -1 : 1)), | ||
1345 | outlineColor, | ||
1346 | text); | ||
1347 | } | ||
1348 | if (fillColor != none_ColorId) { | ||
1349 | drawRange_Text(fontId, pos, fillColor, text); | ||
1350 | } | ||
1351 | } | ||
1352 | |||
1338 | iInt2 advanceWrapRange_Text(int fontId, int maxWidth, iRangecc text) { | 1353 | iInt2 advanceWrapRange_Text(int fontId, int maxWidth, iRangecc text) { |
1339 | iInt2 size = zero_I2(); | 1354 | iInt2 size = zero_I2(); |
1340 | const char *endp; | 1355 | const char *endp; |
@@ -1376,6 +1391,31 @@ void drawCentered_Text(int fontId, iRect rect, iBool alignVisual, int color, con | |||
1376 | deinit_Block(&chars); | 1391 | deinit_Block(&chars); |
1377 | } | 1392 | } |
1378 | 1393 | ||
1394 | void drawCenteredOutline_Text(int fontId, iRect rect, iBool alignVisual, int outlineColor, | ||
1395 | int fillColor, const char *format, ...) { | ||
1396 | iBlock chars; | ||
1397 | init_Block(&chars, 0); { | ||
1398 | va_list args; | ||
1399 | va_start(args, format); | ||
1400 | vprintf_Block(&chars, format, args); | ||
1401 | va_end(args); | ||
1402 | } | ||
1403 | if (outlineColor != none_ColorId) { | ||
1404 | for (int off = 0; off < 4; ++off) { | ||
1405 | drawCenteredRange_Text( | ||
1406 | fontId, | ||
1407 | moved_Rect(rect, init_I2(off % 2 == 0 ? -1 : 1, off / 2 == 0 ? -1 : 1)), | ||
1408 | alignVisual, | ||
1409 | outlineColor, | ||
1410 | range_Block(&chars)); | ||
1411 | } | ||
1412 | } | ||
1413 | if (fillColor != none_ColorId) { | ||
1414 | drawCenteredRange_Text(fontId, rect, alignVisual, fillColor, range_Block(&chars)); | ||
1415 | } | ||
1416 | deinit_Block(&chars); | ||
1417 | } | ||
1418 | |||
1379 | void drawCenteredRange_Text(int fontId, iRect rect, iBool alignVisual, int color, iRangecc text) { | 1419 | void drawCenteredRange_Text(int fontId, iRect rect, iBool alignVisual, int color, iRangecc text) { |
1380 | iRect textBounds = alignVisual ? visualBounds_Text(fontId, text) | 1420 | iRect textBounds = alignVisual ? visualBounds_Text(fontId, text) |
1381 | : (iRect){ zero_I2(), advanceRange_Text(fontId, text) }; | 1421 | : (iRect){ zero_I2(), advanceRange_Text(fontId, text) }; |