mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2025-01-27 11:12:44 +01:00
parent
087f30b72d
commit
bb60818e8d
14
text/text.go
14
text/text.go
@ -261,6 +261,9 @@ func colorToColorM(clr color.Color) ebiten.ColorM {
|
|||||||
// Be careful that this doesn't represent left-upper corner position.
|
// Be careful that this doesn't represent left-upper corner position.
|
||||||
// clr is the color for text rendering.
|
// clr is the color for text rendering.
|
||||||
//
|
//
|
||||||
|
// The '\n' newline character puts the following text on the next line.
|
||||||
|
// Line height is based on Metrics().Height of the font.
|
||||||
|
//
|
||||||
// Glyphs used for rendering are cached in least-recently-used way.
|
// Glyphs used for rendering are cached in least-recently-used way.
|
||||||
// It is OK to call Draw with a same text and a same face at every frame in terms of performance.
|
// It is OK to call Draw with a same text and a same face at every frame in terms of performance.
|
||||||
//
|
//
|
||||||
@ -271,7 +274,7 @@ func colorToColorM(clr color.Color) ebiten.ColorM {
|
|||||||
func Draw(dst *ebiten.Image, text string, face font.Face, x, y int, clr color.Color) {
|
func Draw(dst *ebiten.Image, text string, face font.Face, x, y int, clr color.Color) {
|
||||||
textM.Lock()
|
textM.Lock()
|
||||||
|
|
||||||
fx := fixed.I(x)
|
fx, fy := fixed.I(x), fixed.I(y)
|
||||||
prevR := rune(-1)
|
prevR := rune(-1)
|
||||||
|
|
||||||
runes := []rune(text)
|
runes := []rune(text)
|
||||||
@ -282,7 +285,14 @@ func Draw(dst *ebiten.Image, text string, face font.Face, x, y int, clr color.Co
|
|||||||
if prevR >= 0 {
|
if prevR >= 0 {
|
||||||
fx += face.Kern(prevR, r)
|
fx += face.Kern(prevR, r)
|
||||||
}
|
}
|
||||||
drawGlyph(dst, face, r, glyphImgs[i], fx, fixed.I(y), colorm)
|
if r == '\n' {
|
||||||
|
fx = fixed.I(x)
|
||||||
|
fy += face.Metrics().Height
|
||||||
|
prevR = rune(-1)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
drawGlyph(dst, face, r, glyphImgs[i], fx, fy, colorm)
|
||||||
fx += glyphAdvance(face, r)
|
fx += glyphAdvance(face, r)
|
||||||
|
|
||||||
prevR = r
|
prevR = r
|
||||||
|
Loading…
Reference in New Issue
Block a user