mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-24 18:58:54 +01:00
text/v2: bug fix: glyph image sizes might not be enough
Hajime found that one glyph 'ら' was not rendered correctly in a vertical Japanese text in examples/texti18n. This was due to an incorrect calculation of the image sizes. This change fixes this issue by always adding +1 to the sizes no matter what the glyph size is or the position is. It is in theory possible to determine whether this addition is necessary, but this is pretty complicated and might cause other issues.
This commit is contained in:
parent
b9b365a576
commit
20c216b2b1
@ -85,12 +85,10 @@ func segmentsToImage(segs []api.Segment, subpixelOffset fixed.Point26_6, glyphBo
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
if glyphBounds.Min.X&((1<<6)-1) != 0 {
|
// Add always 1 to the size.
|
||||||
w++
|
// In theory, it is possible to determine whether +1 is necessary or not, but the calculation is pretty complicated.
|
||||||
}
|
w++
|
||||||
if glyphBounds.Min.Y&((1<<6)-1) != 0 {
|
h++
|
||||||
h++
|
|
||||||
}
|
|
||||||
|
|
||||||
biasX := fixed26_6ToFloat32(-glyphBounds.Min.X + subpixelOffset.X)
|
biasX := fixed26_6ToFloat32(-glyphBounds.Min.X + subpixelOffset.X)
|
||||||
biasY := fixed26_6ToFloat32(-glyphBounds.Min.Y + subpixelOffset.Y)
|
biasY := fixed26_6ToFloat32(-glyphBounds.Min.Y + subpixelOffset.Y)
|
||||||
|
@ -147,12 +147,11 @@ func (s *StdFace) glyphImageImpl(r rune, subpixelOffset fixed.Point26_6, glyphBo
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
if glyphBounds.Min.X&((1<<6)-1) != 0 {
|
// Add always 1 to the size.
|
||||||
w++
|
// In theory, it is possible to determine whether +1 is necessary or not, but the calculation is pretty complicated.
|
||||||
}
|
w++
|
||||||
if glyphBounds.Min.Y&((1<<6)-1) != 0 {
|
h++
|
||||||
h++
|
|
||||||
}
|
|
||||||
rgba := image.NewRGBA(image.Rect(0, 0, w, h))
|
rgba := image.NewRGBA(image.Rect(0, 0, w, h))
|
||||||
|
|
||||||
d := font.Drawer{
|
d := font.Drawer{
|
||||||
|
Loading…
Reference in New Issue
Block a user