[sugar] X fonts, and Cairo fonts

Don Hopkins dhopkins at DonHopkins.com
Wed Mar 14 03:19:45 EDT 2007


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



More information about the Sugar mailing list