diff options
author | Přemysl Janouch <p@janouch.name> | 2018-08-23 04:46:21 +0200 |
---|---|---|
committer | Přemysl Janouch <p@janouch.name> | 2018-09-02 18:25:36 +0200 |
commit | 41e04fdc9f04f19f2284ccf2da7b9f910c8569d2 (patch) | |
tree | 1901948198da06292a9758bc98cf0b8e34a35f3c | |
parent | 23586eae01b5ff3b187bd3786fe5c55f87f8c001 (diff) | |
download | haven-41e04fdc9f04f19f2284ccf2da7b9f910c8569d2.tar.gz haven-41e04fdc9f04f19f2284ccf2da7b9f910c8569d2.tar.xz haven-41e04fdc9f04f19f2284ccf2da7b9f910c8569d2.zip |
xgb-render: go back to RGBA because of alignment
Size 9 just happened to have the buffer 16 bytes wide.
-rw-r--r-- | prototypes/xgb-xrender.go | 15 |
1 files changed, 9 insertions, 6 deletions
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(), |