mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-07 18:35:34 +00:00
47d25c1394
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>
31 lines
604 B
Go
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
|
|
}
|