Improving Linux Font Support

Chris Double chris.double at double.co.nz
Mon Sep 30 02:43:10 UTC 2013


As I've mentioned in a previous email to the list, I've been working on
Xft support for Linux as a way to get nicer rendered fonts. So far I
have the Xft primitives implemented so that you can render Xft fonts
using the API. I don't yet have it hooked up with the Self font system
to display in the outliners though. I'm not sure if I'll get time to
work on that over the next couple of weeks so I've made the current
progress available on github in case anyone wants to hack on it:

<http://github.com/doublec/self/tree/linux_fonts>

Clone with:

  $ git clone git://github.com/doublec/self
  $ cd self
  $ git checkout -b linux_fonts origin/linux_fonts

The steps I take to display a font using the primitives are:

1) Create this object, drag it to the desktop and open an evaluator on it:
     (| parent* = traits oddball.
        window <- desktop w anyWindowCanvas.
        draw <- nil.
        font <- nil.
        xftcolor <- nil.
        xrcolor <- nil.
     |)

2) In the evaluator of the above object, create a draw object:

    draw: window display
           xftDrawCreate: window platformWindow
           Visual: window display screen defaultVisualOfScreen
           Colormap: window display screen defaultColormapOfScreen       
     
3) Create the color objects:

    xftcolor: xlib xftColor new.
    xrcolor: xlib xRenderColor new.

4) Set the alpha of the xRenderColor:

    xrcolor alpha: 16rffff

5) Set the xftColor:
   
    window display
     xftColorAllocValue: window display screen defaultVisualOfScreen
     Colormap: window display screen defaultColormapOfScreen
     RenderColor: xrcolor
     XftColor: xftcolor
    
6) Load a font:

    font: window display 
            xftFontOpenNameOnScreen: window display screen number 
            Name: 'verdana-18'

7) Display a string using the given font:

    draw xftDrawString8: xftcolor
         Font: font X: 100 Y: 100
         String: 'Hello World!'   

I've added support to the cmake files to look for Xft and Freetype. It
works on my system but I'm not entirely sure it's accurate.

Any thoughts on how best to plug this into the Self font system?

Chris.
-- 
http://www.bluishcoder.co.nz



More information about the Self-interest mailing list