-
Hi, does tgfx offer an alternative to the SkParagraph API in Skia? For drawing text with font fallbacks, automatic line breaking etc. Or is this out of scope for tgfx? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
No, tgfx does not provide an alternative to the SkParagraph API in Skia. To begin with, both tgfx and Skia are low-level rendering engines designed primarily to offer methods for rendering pre-layouted text glyphs. What you're looking for is a text layout engine, which is a completely different domain. For reference, you can explore the relationship between Minikin and Skia. As far as I know, no major product uses SkParagraph, as it is merely a set of experimental APIs that lack the full capabilities of a standard text layout engine. If you need a fully functional text layout engine, Minikin is a good option, but it is quite complex in many ways. If you only need a simple function, such as drawing text with font fallbacks, you can use the HarfBuzz library to implement just the part you need. Alternatively, you can even skip HarfBuzz if you don't require support for ZWJ emojis. A simple implementation of font fallback can be found here: https://github.com/Tencent/tgfx/blob/main/src/layers/TextLayer.cpp#L279. Additionally, you can use the Layers module in tgfx directly to draw text with font fallback and line breaks. Given this, there isn’t much reason to implement the SkParagraph API. A full implementation would be overly complex, while a partial implementation would offer little advantage over creating a custom solution yourself. |
Beta Was this translation helpful? Give feedback.
No, tgfx does not provide an alternative to the SkParagraph API in Skia. To begin with, both tgfx and Skia are low-level rendering engines designed primarily to offer methods for rendering pre-layouted text glyphs. What you're looking for is a text layout engine, which is a completely different domain. For reference, you can explore the relationship between Minikin and Skia.
As far as I know, no major product uses SkParagraph, as it is merely a set of experimental APIs that lack the full capabilities of a standard text layout engine. If you need a fully functional text layout engine, Minikin is a good option, but it is quite complex in many ways. If you only need a simple function, such a…