mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2025-09-26 20:11:28 +08:00
text/v2: use RuneLen instead of DecodeRuneInString for performance
This commit is contained in:
@@ -171,7 +171,7 @@ func (g *GoXFace) appendGlyphsForLine(glyphs []Glyph, line string, indexOffset i
|
||||
|
||||
// Adjust the position to the integers.
|
||||
// The current glyph images assume that they are rendered on integer positions so far.
|
||||
_, size := utf8.DecodeRuneInString(line[i:])
|
||||
size := utf8.RuneLen(r)
|
||||
|
||||
// Append a glyph even if img is nil.
|
||||
// This is necessary to return index information for control characters.
|
||||
|
@@ -166,9 +166,9 @@ type textChunk struct {
|
||||
func (m *MultiFace) splitText(text string) iter.Seq[textChunk] {
|
||||
return func(yield func(textChunk) bool) {
|
||||
var chunk textChunk
|
||||
for ri, r := range text {
|
||||
for _, r := range text {
|
||||
fi := -1
|
||||
_, l := utf8.DecodeRuneInString(text[ri:])
|
||||
l := utf8.RuneLen(r)
|
||||
for i, f := range m.faces {
|
||||
if !f.hasGlyph(r) && i < len(m.faces)-1 {
|
||||
continue
|
||||
|
Reference in New Issue
Block a user