mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2025-01-26 18:52:44 +01:00
text: Refactoring
This commit is contained in:
parent
05671e784b
commit
a5f9382878
13
text/text.go
13
text/text.go
@ -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)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user