diff options
author | Jaakko Keränen <jaakko.keranen@iki.fi> | 2020-11-05 06:48:20 +0200 |
---|---|---|
committer | Jaakko Keränen <jaakko.keranen@iki.fi> | 2020-11-05 06:48:20 +0200 |
commit | 20a176e1d91514ff2e060c67e448d014ee9b8806 (patch) | |
tree | efd1021b3a1295256f54d2f1e098da7e4a2a5e01 /src | |
parent | 4afa201a99c9076a92a0d3089a826160e3b4cbdf (diff) |
Cleanup
Diffstat (limited to 'src')
-rw-r--r-- | src/ui/text.c | 12 |
1 files changed, 2 insertions, 10 deletions
diff --git a/src/ui/text.c b/src/ui/text.c index a72d9e4f..d4a6b61d 100644 --- a/src/ui/text.c +++ b/src/ui/text.c | |||
@@ -417,8 +417,7 @@ static SDL_Surface *rasterizeGlyph_Font_(const iFont *d, uint32_t glyphIndex, fl | |||
417 | int w, h; | 417 | int w, h; |
418 | uint8_t *bmp = stbtt_GetGlyphBitmapSubpixel( | 418 | uint8_t *bmp = stbtt_GetGlyphBitmapSubpixel( |
419 | &d->font, d->scale, d->scale, xShift, 0.0f, glyphIndex, &w, &h, 0, 0); | 419 | &d->font, d->scale, d->scale, xShift, 0.0f, glyphIndex, &w, &h, 0, 0); |
420 | /* Note: `bmp` must be freed afterwards. */ | 420 | collect_Garbage(bmp, freeBmp_); /* `bmp` must be freed afterwards. */ |
421 | collect_Garbage(bmp, freeBmp_); | ||
422 | SDL_Surface *surface8 = | 421 | SDL_Surface *surface8 = |
423 | SDL_CreateRGBSurfaceWithFormatFrom(bmp, w, h, 8, w, SDL_PIXELFORMAT_INDEX8); | 422 | SDL_CreateRGBSurfaceWithFormatFrom(bmp, w, h, 8, w, SDL_PIXELFORMAT_INDEX8); |
424 | SDL_SetSurfacePalette(surface8, text_.grayscale); | 423 | SDL_SetSurfacePalette(surface8, text_.grayscale); |
@@ -471,12 +470,6 @@ static void cache_Font_(iFont *d, iGlyph *glyph, int hoff) { | |||
471 | if (hoff == 0) { | 470 | if (hoff == 0) { |
472 | int adv; | 471 | int adv; |
473 | const uint32_t gIndex = glyph->glyphIndex; | 472 | const uint32_t gIndex = glyph->glyphIndex; |
474 | // float advScale = d->scale; | ||
475 | // if (isJapanese_FontId(d - text_.fonts)) { | ||
476 | /* Treat as monospace. */ | ||
477 | // gIndex = stbtt_FindGlyphIndex(&d->font, 0x5712); | ||
478 | // advScale *= 2.0f; | ||
479 | // } | ||
480 | stbtt_GetGlyphHMetrics(&d->font, gIndex, &adv, NULL); | 473 | stbtt_GetGlyphHMetrics(&d->font, gIndex, &adv, NULL); |
481 | glyph->advance = d->scale * adv; | 474 | glyph->advance = d->scale * adv; |
482 | } | 475 | } |
@@ -541,8 +534,8 @@ iLocalDef iFont *characterFont_Font_(iFont *d, iChar ch, uint32_t *glyphIndex) { | |||
541 | } | 534 | } |
542 | 535 | ||
543 | static const iGlyph *glyph_Font_(iFont *d, iChar ch) { | 536 | static const iGlyph *glyph_Font_(iFont *d, iChar ch) { |
544 | /* It may actually come from a different font. */ | ||
545 | uint32_t glyphIndex = 0; | 537 | uint32_t glyphIndex = 0; |
538 | /* The glyph may actually come from a different font; look up the right font. */ | ||
546 | iFont *font = characterFont_Font_(d, ch, &glyphIndex); | 539 | iFont *font = characterFont_Font_(d, ch, &glyphIndex); |
547 | const void *node = value_Hash(&font->glyphs, ch); | 540 | const void *node = value_Hash(&font->glyphs, ch); |
548 | if (node) { | 541 | if (node) { |
@@ -707,7 +700,6 @@ static iRect run_Font_(iFont *d, enum iRunMode mode, iRangecc text, size_t maxLe | |||
707 | if (!isMeasuring_(mode)) { | 700 | if (!isMeasuring_(mode)) { |
708 | if (useMonoAdvance && dst.w > advance) { | 701 | if (useMonoAdvance && dst.w > advance) { |
709 | dst.x -= (dst.w - advance) / 2; | 702 | dst.x -= (dst.w - advance) / 2; |
710 | |||
711 | } | 703 | } |
712 | SDL_RenderCopy(text_.render, text_.cache, (const SDL_Rect *) &glyph->rect[hoff], &dst); | 704 | SDL_RenderCopy(text_.render, text_.cache, (const SDL_Rect *) &glyph->rect[hoff], &dst); |
713 | } | 705 | } |