This is a POC for grapheme shaping. That is, we shape individual grapheme clusters, but not whole text runs. This means we do get support for e.g. emoji ZWJ sequences, but we do not get support for e.g. ligatures.
Unicode grapheme cluster segmentation is done with libutf8proc, and text shaping is done with fcft_grapheme_rasterize() (available in fcft-2.3.0 and later).
This renders several classes of Unicode sequences correctly, but not all. The biggest problem is finding out the display width of the grapheme; glibc's wcswidth() is just the sum of wcwidth() for each character, which is wrong in many cases.
(削除) For now, I've implemented a dumb Reverted to using glibc's my_wcswidth() that never returns anything larger than 2. (削除ここまで)wcswidth() for now, as that causes the least breakage with client applications.
(削除) Another problem is graphemes that result in multiple glyphs that are supposed to be rendered after each other, e.g. 👩👩👧👶; these are currently rendered on top of each other, just like This is somewhat working now.g̈. (削除ここまで)
utf8proc is an optional dependency. Whether to compile foot with support for grapheme cluster segmentation or not is controlled with the -Dgrapheme-clustering=disabled|enabled|auto meson command line option.
There is also a run-time option, tweak.grapheme-shaping (disabled by default) that enables/disables grapheme shaping. When disabled, old-style zero-width combining is done (i.e. zero-width codepoints are appended to the last cell) instead of cluster segmentation, and the rendering engine will not use fcft_grapheme_rasterize().
Thus, you can get partial shaping support without utf8proc; you can still enable tweak.grapheme-shaping and foot will use fcft_grapheme_rasterize() on all cells with more than a single base character. However, since foot cannot do grapheme cluster segmentation without utf8proc, we are limited to the most basic sequences. In practice, combining marks (which foot's renderer handles even without grapheme shaping).
In other words, to be able to render emoji sequences, you need both a foot build with utf8proc support, and an fcft build with HarfBuzz support, and enable tweak.grapheme-shaping.
TODO
(削除) Display width - useWe usewcswidth()or implement our own? (削除ここまで)wcswidth().- Multi-glyph positioning - odd values from harfbuzz, and seems to depend on font
- Weird vertical glyph positioning data from HarfBuzz - fcft currently ignores these.
(削除) Maximum grapheme cluster length? Or allocate dynamically? (削除ここまで)Keep allocating dynamically.(削除) Text/emoji presentation selection. (削除ここまで)This is done in fcft.- Add compile time option to enable/disable grapheme shaping (
-Dgrapheme-clustering) - Add runtime configuration option to enable/disable grapheme shaping (
tweak.grapheme-shaping). - Make utf8proc an optional dependency (required if
-Dgrapheme-clustering=enabled). - Detect when fcft is harfbuzz capable.
- Restore old combining marks handling, to be used both then utf8proc is not available/have been disabled, or when grapheme shaping has been disabled in the configuration.
(削除) Decide which OTF tags to enable. (削除ここまで)Taken from fontconfig.- Run benchmarks to verify foot hasn't gotten slower (when grapheme shaping is disabled).
- Variant selectors.