Re: Pango: how to call the API?



Hi Noah,

Thank you.

>></snip>
> If you have the exact text then you can lay it out in each
> font and compare the sizes. That is the most accurate and is
> certainly more efficient than measuring each character.

Right, and you mention below that you get the width of the entire character
string (eg "welcome"), so it is just two queries which is probably real fast
with Pango ....

> > (1) kind of taking your suggested approach, layout "welcome" in arial,
sum
> > the width of each character, layout "welcome" in arial black, sum the
total
> > width and divide to get the relativity.  But I'd have to do this on the
fly.
>
> When you get text extents, it's not divided into characters,
> it's for the whole text. THe algorithm you describe is ok otherwise.

Cool.

> > (2) Which is what I was thinking is get an average character width for
each
> > required font and load it into a database.
>
> This is fine too, but use the font metrics approximate_char_width, don't
measure each character.

Great, this might be the simplier solution to start with.  The simplier the
better for me right now I think ....

> You need to write code. You might be able to do it in
> straight php; there are php language bindings to gtk+ (don't
> know about pango specifically). Or you can write a simple
> program and call that from your php.

You'd be talking about::  http://gtk.php.net/ I'll do some research on this,
it probably would be easier this way since it has been a long time since I
did C :-)  However if I need to use C it looks like I'll need to do
something like this::
http://mail.gnome.org/archives/gtk-devel-list/2002-August/msg00034.html ...
I hope .... :-)

Again thanks a lot,

G.








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