Re: Problems with window position, virtual desktops and fonts



Jan-Marek Glogowski wrote:
> 1. Positioning of windows

Hi Jan,

I use gdk_window_get_root_origin() and gtk_widget_set_uposition().

> 2. Show / Hide a window on the same virtual desktop

Good question, but I can't help :-(

> 3. Quick way to find the best font to fill an area

> First I check if there is a scaleable font from the same family
> (XListFonts(...))
> 
> Then I construct Xfont - strings with different sizes, load the fonts
> (gdk_font_load(...) and check the current string width
> (gdk_string_width(...)) as long as the font width is smaller then
> the area.width.
> 
> Is there any way to speed this up? Even on a PIII 733 it needs seconds for
> about 50 fonts.

I believe when you load a scaleable font, X prerenders all the glyphs in
the font to bitmaps, ready to send to the display ... this is pretty
slow (and used to lock the X server while it did it, though I think this
has been fixed).

Maybe you could keep a cache: every time you load a font, measure the
width of all the characters you will be using, and keep the information
around in a big hash. When you test a string, add up the widths of the
characters, and compare to your limit.

I think X does not do kerning in XDrawString(), so for latin charsets at
least you'll be OK. I guess you've not tried this with pango :-)

HTH, John




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]