diff --git a/layout.go b/layout.go index 6df7c82..d299c38 100644 --- a/layout.go +++ b/layout.go @@ -58,13 +58,16 @@ func DoWord (text []rune, face font.Face) (word WordLayout, remaining []rune) { // consume and process the rune remaining = remaining[1:] - _, advance, ok := face.GlyphBounds(char) - if !ok { continue } - word.Runes = append (word.Runes, RuneLayout { + advance, ok := face.GlyphAdvance(char) + if !ok { + advance = tofuAdvance(face) + } + runeLayout := RuneLayout { X: x, Width: advance, Rune: char, - }) + } + word.Runes = append(word.Runes, runeLayout) // advance if gettingSpace { @@ -209,3 +212,11 @@ func (line *LineLayout) justify () { x += spacePerWord + word.Width } } + +func tofuAdvance (face font.Face) fixed.Int26_6 { + if advance, ok := face.GlyphAdvance('M'); ok { + return advance + } else { + return 16 + } +}