diff options
Diffstat (limited to 'vendor/text.c')
| -rw-r--r-- | vendor/text.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/vendor/text.c b/vendor/text.c index 8b2a54e..a453067 100644 --- a/vendor/text.c +++ b/vendor/text.c @@ -277,7 +277,11 @@ bool sk_text_draw_scaled(SDL_Renderer *renderer, int face, float x, float y, flo const int size = font_size(raster, dpi); /* How much larger than rasterized it is drawn: 1 when it is drawn as it is. */ const float k = scale / raster; - const Uint32 color = ((Uint32)r << 16) | ((Uint32)g << 8) | b; + /* ASCII uses a reusable coverage mask; animated ink never rerasterizes it. + Keep the existing painted path for Unicode, including color emoji. */ + bool mask = true; + for (size_t i = 0; i < len; ++i) if ((unsigned char)utf8[i] >= 128) { mask = false; break; } + const Uint32 color = mask ? 0xffffff : ((Uint32)r << 16) | ((Uint32)g << 8) | b; const uint64_t hash = hash_text(utf8, len); Text *entry = NULL; for (size_t i = 0; i < CACHE_ENTRIES; ++i) { @@ -309,7 +313,7 @@ bool sk_text_draw_scaled(SDL_Renderer *renderer, int face, float x, float y, flo entry->used = c->frame; /* Cairo pixels are premultiplied; modulate RGB and alpha together. Color glyphs retain their intrinsic paint, while ordinary text uses its ink. */ - SDL_SetTextureColorMod(entry->texture, a, a, a); + SDL_SetTextureColorMod(entry->texture, mask ? r * a / 255 : a, mask ? g * a / 255 : a, mask ? b * a / 255 : a); SDL_SetTextureAlphaMod(entry->texture, a); SDL_FRect dest = {.x=(roundf(x*dpi)+entry->left)/dpi,.y=(roundf(y*dpi)+entry->top)/dpi, .w=entry->width/dpi,.h=entry->height/dpi}; |
