mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-11-10 04:57:26 +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
|
||||
}
|
||||
|
||||
if glyphBounds.Min.X&((1<<6)-1) != 0 {
|
||||
// Add always 1 to the size.
|
||||
// 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++
|
||||
}
|
||||
|
||||
biasX := fixed26_6ToFloat32(-glyphBounds.Min.X + subpixelOffset.X)
|
||||
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
|
||||
}
|
||||
|
||||
if glyphBounds.Min.X&((1<<6)-1) != 0 {
|
||||
// Add always 1 to the size.
|
||||
// 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++
|
||||
}
|
||||
|
||||
rgba := image.NewRGBA(image.Rect(0, 0, w, h))
|
||||
|
||||
d := font.Drawer{
|
||||
|
Loading…
Reference in New Issue
Block a user