diff --git a/text/v2/gotextseg.go b/text/v2/gotextseg.go index 32ec42326..f19edebf6 100644 --- a/text/v2/gotextseg.go +++ b/text/v2/gotextseg.go @@ -85,12 +85,10 @@ func segmentsToImage(segs []api.Segment, subpixelOffset fixed.Point26_6, glyphBo return nil } - if glyphBounds.Min.X&((1<<6)-1) != 0 { - w++ - } - if glyphBounds.Min.Y&((1<<6)-1) != 0 { - h++ - } + // 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++ + h++ biasX := fixed26_6ToFloat32(-glyphBounds.Min.X + subpixelOffset.X) biasY := fixed26_6ToFloat32(-glyphBounds.Min.Y + subpixelOffset.Y) diff --git a/text/v2/std.go b/text/v2/std.go index b7113812f..b687255b3 100644 --- a/text/v2/std.go +++ b/text/v2/std.go @@ -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 { - w++ - } - if glyphBounds.Min.Y&((1<<6)-1) != 0 { - h++ - } + // 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++ + h++ + rgba := image.NewRGBA(image.Rect(0, 0, w, h)) d := font.Drawer{