Files
gio/font/opentype/opentype.go
T
Chris Waldon 47d25c1394 go.*,font/opentype,text: switch to latest go-text/typesetting api
This commit upgrades our go-text version to the latest one which internalizes
harfbuzz and supports text truncators. This allows us to drop our dependency
upon Benoit's textlayout package.

Signed-off-by: Chris Waldon <christopher.waldon.dev@gmail.com>
2023-03-28 09:25:09 -06:00

31 lines
604 B
Go

// SPDX-License-Identifier: Unlicense OR MIT
// Package opentype implements text layout and shaping for OpenType
// files.
package opentype
import (
"bytes"
"fmt"
"github.com/go-text/typesetting/font"
)
// Face is a shapeable representation of a font.
type Face struct {
face font.Face
}
// Parse constructs a Face from source bytes.
func Parse(src []byte) (Face, error) {
face, err := font.ParseTTF(bytes.NewReader(src))
if err != nil {
return Face{}, fmt.Errorf("failed parsing truetype font: %w", err)
}
return Face{face: face}, nil
}
func (f Face) Face() font.Face {
return f.face
}