font/opentype: report valid bounds from layoutText for the empty string

Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
Elias Naur
2020-07-09 20:35:19 +02:00
parent 713770f808
commit 188bfa9a0b
2 changed files with 31 additions and 2 deletions
+3 -2
View File
@@ -176,9 +176,10 @@ func layoutText(sbuf *sfnt.Buffer, ppem fixed.Int26_6, maxWidth int, fonts []*op
}
var prev, word state
endLine := func() {
if prev.f != nil {
updateBounds(prev.f)
if prev.f == nil && len(fonts) > 0 {
prev.f = fonts[0]
}
updateBounds(prev.f)
nextLine.Layout = glyphs[:prev.idx:prev.idx]
nextLine.Len = prev.len
nextLine.Width = prev.x + prev.adv