font/opentype: [API] replace old font type with harfbuzz

This commit replaces the previous opentype.Font with
an implementation that uses the new text shaper. In
order to keep the implementation simple, support for
opentype font collections was dropped. It should be
possible to re-add this support after some changes
to the text shaper's line wrapping algorithm.

To expand on the above, doing proper font fallback with
harfbuzz will require splitting the input text on font
glyph support boundaries, changing the input from a
simple shaping.Input to []shaping.Input with each input
matched against the font that supports its language.
The line wrapping then needs to be able to properly
consume that slice. Since the line wrapping algorithm is
really complex, I'm hoping to defer that modification
until this simple version is accepted.

References: https://todo.sr.ht/~eliasnaur/gio/146
Signed-off-by: Chris Waldon <christopher.waldon.dev@gmail.com>
This commit is contained in:
Chris Waldon
2022-03-16 16:01:38 -04:00
committed by Elias Naur
parent 42c99a5cb2
commit 01276238df
4 changed files with 20 additions and 393 deletions
+1 -1
View File
@@ -78,7 +78,7 @@ func CollectionHB() []text.FontFace {
}
func registerHB(fnt text.Font, ttf []byte) {
face, err := opentype.ParseHarfbuzz(ttf)
face, err := opentype.Parse(ttf)
if err != nil {
panic(fmt.Errorf("failed to parse font: %v", err))
}