Re: Problems with window position, virtual desktops and fonts
- From: John Cupitt <john cupitt ng-london org uk>
- To: Jan-Marek Glogowski <glogow stud fbi fh-darmstadt de>
- Cc: gtk-list gnome org
- Subject: Re: Problems with window position, virtual desktops and fonts
- Date: Mon, 02 Jul 2001 14:03:21 +0100
Jan-Marek Glogowski wrote:
> > > 3. Quick way to find the best font to fill an area
> >
> > 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 :-)
>
> I think pango just works with gtk 1.3.x - am I right?
Hi Jan, yes, you're right. I was thinking pango would make the job more
complicated, since you wouldn't be able to measure all of the glyphs in
advance and just add them up to find the size of a string.
> I thought of a new way to load the fonts.
> My program is already multi threaded. So I will start a thread, which will
> load all the possible fonts. Normally the user wouldn't often change the
> font. So I keep them loaded and size lookup would be quick.
> That's the theory but how much mem takes a loaded font (if it's really a
> bitmap)?
I think this would take a lot of time and memory :-( Although your
application is threaded, not all X servers are. You may find the server
locks while it renders all of the fonts to bitmaps for you.
I would try to hide this by loading the fonts only the first time you
need to make a query, keeping a cache of font metrics, and unloading
again after I had found all the sizes.
I think ideally you want a way to get the font metrics without having to
render the whole font ... but I don't know to do this :-( you'd need to
ask again on gtk-list.
> BTW - what does HTH stand for?
Hope That Helps :)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]