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:
		@@ -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(),
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user