Re: Pango, set height in pixels
- From: Dennis Bjorklund <db zigo dhs org>
- To: Havoc Pennington <hp redhat com>
- Cc: <gtk-list gnome org>
- Subject: Re: Pango, set height in pixels
- Date: Mon, 14 Jan 2002 10:09:39 +0100 (CET)
On 13 Jan 2002, Havoc Pennington wrote:
> > The doc of pango_font_description_set_size () says
> >
> > size : the size for the font description in pango units. (PANGO_SCALE
> > pango units equals one point)
>
> PANGO_SCALE pango units equals one "device unit" which for the screen
> is pixels and for printed output would probably be points. The docs
> there are broken, yeah. I'll fix them.
I'm not sure that is correct either. I talked a bit on #gtk+ and there
doesn't seem to be any connection to pixels at all. You can end up with
any size, usually close to what you want, but you never know.
I made a small test program and put up some screenshots of how the text
rendering looks when I set the size to 20*PANGO_SCALE.
http://www.zigo.dhs.org/~dennis/pango-test/
The reason I want to know approx. how high the text is in pixels is
because I draw a chess board and want the coordinates to match the square
size. And the square size changes when I resize the window, so the
coordinate will have to change size as well.
The solution I have so far is to have a loop where I set the size, render
and then do pango_layout_get_pixel_extents () until the height is not to
big. In my test program when I set the height to 20*PANGO_SCALE the
logical rect was 36 pixels high.
Also notice the big difference in logical rect when I run with
GDK_USE_XFT=1. But probably it has chosen another font in this case.
It seems the loop (or binary search) is the correct way to get what I
need.
--
/Dennis
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]