[sugar] X fonts, and Cairo fonts

Dan Williams dcbw at redhat.com
Wed Mar 14 00:23:53 EDT 2007


On Tue, 2007-03-13 at 21:13 -0700, Don Hopkins wrote:
> Two questions about fonts:
> 
> For an X application, which fonts are available? Which are recommended? 
> xlsfonts does not list a lot of them, and the ones listed have ugly 
> sounding names. (Does the latest build add more fonts? I'm downloading 
> it now.) Are there more fonts available to X applications that I can't 
> see with xlsfonts? Specifically the OLPC Human Interface Guidelines 
> recommends Bitstream Vera Sans, which I would like to use. What font 
> string can I pass to the standard old X library functions to get that 
> nice font, and what sizes are available?

Don't use "standard old X library functions".  Freetype is your friend.
Or Pango + Cairo, which use freetype underneath.

> Maybe I'm just hallucinating, but for a Cairo/Pango application (pie 
> menus), it seems that the size a font is rendered depends on the screen 
> resolution. On my laptop/vmware/fedora core/x11 development system, I 
> configured all the pie menu fonts so they looked nice on the 75dpi 
> screen. But then when I ran the same Python code on the actual OLPC's 
> 200 dpi screen, the fonts came out way too big compared to the graphics. 
> So I had to reduce the point size of the font by multiplying by a factor 
> of 75/200 or so. But that was clumsy because Cairo font specs are 
> strings that look like "zapf-dingbats 64", and the point size is not a 
> number that's easy to scale mathematically.

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.

> It's kinda weird that the text adjust the font size for the dpi, but the 
> rest of the graphics don't. Is this a Pango thing or a Cairo thing? 
> Should I be checking the dpi and factoring that into the scale of the 
> graphics I draw, but not the text? (That's pretty inconvenient... Not 
> the way PostScript works. I'd prefer that all drawing scales according 
> to the screen resolution, not just fonts.) Is there a way to fake out 
> the dots per inch so the development machine acts like it has a 200 dpi 
> screen? Maybe the X configuration file? Or is there a better approach 
> that would enable the program to work correctly on any dpi screen, 
> without bending over backwards?

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




More information about the Sugar mailing list