Search code examples
x11freetypesubpixel

How to subpixel render glyphs with XRender extension


I found this great example of text rendering using XRender extension. But the font is loaded from Freetype in grayscale format, is there a way to ustilize XRender to draw subpixel (LCD) antialiased glyphs? If yes, how?


Solution

  • Glyphs can be in any format you see in QueryPictFormats response (but all glyphs in glyphset share same format). Basically you render subpixel antialiased glyphs with freetype, upload it to rgba32 glyphset and rest is the same as when you use a8 (alpha only, see https://github.com/ereslibre/x11/blob/master/xrender/rendertext.c#L46-L47)