[sugar] X fonts, and Cairo fonts

Jim Gettys jg
Fri Mar 16 19:44:31 EDT 2007


In the very short term, you can quickly get AA fonts by the use of the
Xft library.  It's api is similar to antique core fonts dinosaurs like
you and me remember.  I have a vague memory that Keith Packard Xft'ized
TK at one point, but don't know that that ever got upstream (some
maintainers were less enlightened than other ones).

However, in the longer term, text layout better get done by Pango: you
really don't want to reinvent text layout for fun languages like Arabic,
Thai, the Indic languages, etc.

                                - Jim



On Wed, 2007-03-14 at 00:19 -0700, Don Hopkins wrote:
> Dan Williams wrote:
> >
> > Don't use "standard old X library functions".  Freetype is your friend.
> > Or Pango + Cairo, which use freetype underneath.
> >   
> Unfortunately I'm trying to get along with a crufty 1992 version of 
> TCL/Tk for now, and upgrading or rewriting the text display routines 
> might take a lot of work.
> Is there a font library with an X11-api-like interface, or a an example 
> of how to drop something like FreeType into an old X11 program? (This is 
> mainly for get-it-out-the-door-asap purposes, not a long term solution, 
> so it doesn't have to be perfect, just more readable than the ugly 
> microscopic "fixed" font!)
> > Technically you shouldn't have to scale your point sizes, right?  ie 1
> > pt is defined as 1/72 of an inch IIRC, which is completely resolution
> > independent.  1/72 of an inch is the same on a 96dpi display as it is on
> > a 200dpi display because the font renderer should compensate for the
> > increased resolution but keep the visual size the same.
> >   
> The problem or misunderstanding I'm having with Python/Cairo/Pango is 
> that it scales the fonts as it should according to the DPI, but the 
> graphics coordinates I'm drawing in by default seem to be pixels instead 
> of points (or that may be what I'm hallucinating). The bitmaps and 
> shapes and line drawing come out much smaller on the olpc screen than on 
> the big laptop screen (apparently being draw at 1:1 pixel resolution), 
> while the text is about the same physical size on the each screen 
> (apparently drawn in physical points, according to the screen's dpi).
> 
> > This is complicated somewhat because we're running in Xephyr in the
> > sugar-jhbuild environment, which I think throws some DPI calculations
> > off.  I'm not entirely sure what the solution is here.
> >
> > But as far as I know, if you tell Pango to render a 12pt font on the XO,
> > it should come out the same physical size (ie, 1/6th of an inch) as on
> > your laptop, because that's what points are supposed to do.
> >
> > Dan
> >   
> I've been lazily testing python code by just connecting to my regular 
> X11 server instead of Xephyr. Maybe that's my problem. What advantages 
> are there using Xephyr? Is it required to run the Sugar window manager 
> and activity stuff? Is Xephyr configured to 200 dpi, to show how 
> graphics will come out on the olpc screen? For developing 
> Python/Cairo/Pango components that don't require the Sugar window 
> manager, would it be ok not to use Xephyr, and just configure X's main 
> screen to think it's 200dpi? Or is it important to test stuff running 
> inside of Xephyr?
> 
>     -Don
> 
> _______________________________________________
> Sugar mailing list
> Sugar at laptop.org
> http://mailman.laptop.org/mailman/listinfo/sugar
-- 
Jim Gettys
One Laptop Per Child




More information about the Sugar-devel mailing list