text: simplify text layout and shaping API

First, replace LayoutOptions with an explicit maximum width parameter.  The
single-field option struct doesn't carry its weight, and I don't think we'll
see more global layout options in the future. Rather, I expect options to cover
spans of text or be part of a Font.

Second, replace the unit.Converter with an scaled text size. It's simpler and
allow the Editor and similar widgets to easily detect whether their cached
layouts are stale. Package text no longer depends on package unit, which is
now dealt with at the widget-level only.

Finally, remove the Size field from Font. It was a design mistake: a Font is
assumed to cover all sizes, as evidenced by the FontRegistry disregarding
Size when looking up fonts.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
Elias Naur
2020-02-03 23:19:28 +01:00
parent dcacca3442
commit 4c220f4554
12 changed files with 68 additions and 85 deletions
+3 -3
View File
@@ -30,9 +30,9 @@ type path struct {
}
type layoutKey struct {
ppem fixed.Int26_6
str string
opts LayoutOptions
ppem fixed.Int26_6
maxWidth int
str string
}
type pathKey struct {