aseprite / laf

A C++ library to create desktop applications
https://aseprite.github.io/laf/
MIT License
274 stars 58 forks source link

Add SpriteTextBlob to improve the rendering of SpriteSheetFont #87

Closed dacap closed 2 months ago

dacap commented 2 months ago

To render text with a SpriteSheetFont we now create a SpriteTextBlob. This blob can render non-existent code points using a default fallback native font (SkiaFont) and create a chain of runs for each TextBlob that use a different font.

In this way we don't change the whole appearance of the rendered text with an antialiased font when a missing code point appears. We just use the fallback font to render that specific code point/char (or sequence of chars in one run).

This problem was reported several times and we can find examples here: https://github.com/aseprite/aseprite/issues/2890#issuecomment-903139176

As a side note, all code/static functions that use a text shaper (HarfBuzz, skshaper module, etc.) is separated in its own file (i.e. translation unit) to make binary executable files smaller when the shaper is not needed (e.g. in English-only apps).