From 41e04fdc9f04f19f2284ccf2da7b9f910c8569d2 Mon Sep 17 00:00:00 2001 From: Přemysl Janouch Date: Thu, 23 Aug 2018 04:46:21 +0200 Subject: xgb-render: go back to RGBA because of alignment Size 9 just happened to have the buffer 16 bytes wide. --- prototypes/xgb-xrender.go | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'prototypes') diff --git a/prototypes/xgb-xrender.go b/prototypes/xgb-xrender.go index ea20624..75bf62e 100644 --- a/prototypes/xgb-xrender.go +++ b/prototypes/xgb-xrender.go @@ -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(), -- cgit v1.2.3-70-g09d2