xgb-render: go back to RGBA because of alignment

Size 9 just happened to have the buffer 16 bytes wide.
This commit is contained in:
Přemysl Eric Janouch 2018-08-23 04:46:21 +02:00
parent 23586eae01
commit 41e04fdc9f
Signed by: p
GPG Key ID: A0420B94F92B9493
1 changed files with 9 additions and 6 deletions

View File

@ -226,7 +226,7 @@ func main() {
// LCD subpixel rendering isn't supported. :(
opts := &truetype.Options{
Size: 9,
Size: 10,
DPI: 96, // TODO: Take this from the screen or monitor.
Hinting: font.HintingFull,
}
@ -234,10 +234,12 @@ func main() {
bounds := f.Bounds(fixed.Int26_6(opts.Size * float64(opts.DPI) *
(64.0 / 72.0)))
var alphaFormat render.Pictformat
var rgbFormat render.Pictformat
for _, pf := range pformats.Formats {
if pf.Depth == 8 && pf.Direct.AlphaMask == 0xff {
alphaFormat = pf.Id
// Hopefully. Might want to check byte order.
if pf.Depth == 32 && pf.Direct.AlphaMask != 0 {
rgbFormat = pf.Id
break
}
}
@ -248,11 +250,12 @@ func main() {
// NOTE: A depth of 24 will not work, the server always rejects it.
// Composite alpha doesn't make sense since golang/freetype can't use it.
_ = render.CreateGlyphSet(X, gsid, alphaFormat)
// We use RGBA here just so that lines are padded to 32 bits.
_ = render.CreateGlyphSet(X, gsid, rgbFormat)
// NOTE: We could do gamma post-correction in higher precision if we
// implemented our own clone of the image.Image implementation.
nrgb := image.NewGray(image.Rect(
nrgb := image.NewRGBA(image.Rect(
+bounds.Min.X.Floor(),
-bounds.Min.Y.Floor(),
+bounds.Max.X.Ceil(),