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>
In preparation for using Shaper with an io.Reader, rework the API to not refer
to strings. In particular, introduce Glyph for holding the rune in addition to
the advance. For fast traversing of the underlying text, add Len to Line with
the UTF8 length.
Layout is a useless wrapper around []Line; remove it while we're
here.
Signed-off-by: Elias Naur <mail@eliasnaur.com>
MacroOp is about to lose the ability to run a different operation list
than the one it was recorded on. Text shape caches rely on that property,
and must use the new CallOp operation added for purpose.
Signed-off-by: Elias Naur <mail@eliasnaur.com>
Before this change, the default font was the one registered with an empty
Typeface.
We're about to use the correct names for fonts, so change Shaper to
fallback to the first registered typeface instead.
Signed-off-by: Elias Naur <mail@eliasnaur.com>
There is now a single shaping implementation, Shaper, for all fonts, replacing
Family that only covered a single typeface.
A typeface is identified by a name, where the empty string denotes the
default typeface.
Font is introduced to specify a particular font from the typeface, style,
weight and size.
Face is changed to an interface for a particular layout and shaping method.
The text/shape package is renamed to text/opentype and contains a Face
implementation based on golang.org/x/image/font/sfnt.
Signed-off-by: Elias Naur <mail@eliasnaur.com>