mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-06 01:45:36 +00:00
deps,text,widget,font/opentype: [API] add harfbuzz-powered text shaper
This commit introduces a new text shaping infrastructure powered by Benoit Kugler's Go source-port of harfbuzz. This shaper can properly display complex scripts and RTL text. This commit changes the signature of the text.Shaper function, which is a breaking API change. The new functionality is available via opentype.ParseHarfbuzz, which configures a text.Shaper leveraging the new backend. References: https://todo.sr.ht/~eliasnaur/gio/146 Signed-off-by: Chris Waldon <christopher.waldon.dev@gmail.com>
This commit is contained in:
+2
-2
@@ -58,7 +58,7 @@ func clipLine(lines []text.Line, alignment text.Alignment, width int, clip image
|
||||
|
||||
func subLayout(line text.Line, startCol, endCol int) text.Layout {
|
||||
adv := line.Layout.Advances
|
||||
if startCol == len(adv) {
|
||||
if startCol == line.Layout.Runes.Count {
|
||||
return text.Layout{}
|
||||
}
|
||||
adv = adv[startCol:endCol]
|
||||
@@ -90,7 +90,7 @@ func (p1 screenPos) Less(p2 screenPos) bool {
|
||||
func (l Label) Layout(gtx layout.Context, s text.Shaper, font text.Font, size unit.Value, txt string) layout.Dimensions {
|
||||
cs := gtx.Constraints
|
||||
textSize := fixed.I(gtx.Px(size))
|
||||
lines := s.LayoutString(font, textSize, cs.Max.X, txt)
|
||||
lines := s.LayoutString(font, textSize, cs.Max.X, gtx.Locale, txt)
|
||||
if max := l.MaxLines; max > 0 && len(lines) > max {
|
||||
lines = lines[:max]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user