text: Refactoring

This commit is contained in:
Hajime Hoshi 2018-02-11 16:17:59 +09:00
parent 05671e784b
commit a5f9382878

View File

@ -59,9 +59,9 @@ func fontFaceToFace(f font.Face) face {
return value return value
} }
} }
fe := face{f} fa := face{f}
faces[f] = fe faces[f] = fa
return fe return fa
} }
var ( var (
@ -232,8 +232,8 @@ func (a *atlas) draw(glyph *glyph) {
a.tmpImage.Clear() a.tmpImage.Clear()
} }
func getGlyphFromCache(face font.Face, r rune, now int64) *glyph { func getGlyphFromCache(face face, r rune, now int64) *glyph {
ch := char{fontFaceToFace(face), r} ch := char{face, r}
a, ok := atlases[ch.atlasGroup()] a, ok := atlases[ch.atlasGroup()]
if ok { if ok {
g, ok := a.charToGlyph[ch] g, ok := a.charToGlyph[ch]
@ -301,7 +301,8 @@ func Draw(dst *ebiten.Image, text string, face font.Face, x, y int, clr color.Co
if prevC >= 0 { if prevC >= 0 {
fx += face.Kern(prevC, c) fx += face.Kern(prevC, c)
} }
if g := getGlyphFromCache(face, c, n); g != nil { fa := fontFaceToFace(face)
if g := getGlyphFromCache(fa, c, n); g != nil {
if !g.char.empty() { if !g.char.empty() {
g.draw(dst, fx, fixed.I(y), clr) g.draw(dst, fx, fixed.I(y), clr)
} }