mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-01 07:35:40 +00:00
font/opentype: treat invalid characters less specially
Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
@@ -79,18 +79,14 @@ func layoutText(buf *sfnt.Buffer, ppem fixed.Int26_6, str string, f *opentype, o
|
|||||||
}
|
}
|
||||||
for prev.idx < len(str) {
|
for prev.idx < len(str) {
|
||||||
c, s := utf8.DecodeRuneInString(str[prev.idx:])
|
c, s := utf8.DecodeRuneInString(str[prev.idx:])
|
||||||
a, ok := f.GlyphAdvance(buf, ppem, c)
|
a, valid := f.GlyphAdvance(buf, ppem, c)
|
||||||
if !ok {
|
|
||||||
prev.idx += s
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
next := state{
|
next := state{
|
||||||
r: c,
|
r: c,
|
||||||
advs: prev.advs,
|
advs: prev.advs,
|
||||||
idx: prev.idx + s,
|
idx: prev.idx + s,
|
||||||
x: prev.x + prev.adv,
|
x: prev.x + prev.adv,
|
||||||
adv: a,
|
adv: a,
|
||||||
valid: true,
|
valid: valid,
|
||||||
}
|
}
|
||||||
if c == '\n' {
|
if c == '\n' {
|
||||||
// The newline is zero width; use the previous
|
// The newline is zero width; use the previous
|
||||||
|
|||||||
Reference in New Issue
Block a user