Re: Pango: how to call the API?



Hi Noah,

Again:: thanks *greatly* for your time; apologies for my lack of
understanding in this field.

> This is a strange question. The fact that you want to "call pango from the
command line" makes me wonder what you're trying to do.

Sorry I'll try to explain quickly ..... my objective is to get a list of
fonts in Pango with their "average" character widths and load it into a
database as part of my web service, or to query pango "on the fly" even
better if fast :-)

I am doing some dynamic imaging on the web using SVG and librsvg (which uses
Pango to render text) that I am calling from the command line (with PHP).
Basically when a user changes between fonts I want to adjust the size
accordingly, and I thought as Pango has information on "relative font
sizing" I could take advantage of it.  Say for example a user has the text
"welcome", the font "arial" with text size "12".  If they want to change to
the font "arial black" then I would like to adjust the font size accordingly
down so that welcome fits in the same space (say to size "10" or whatever).
It doesn't have to be super exact, just fit okay ....

> If you want to get the width of every character in a font, the most
obvious way is to create a layout, set the font, set the text, measure the
layout extents, repeat 1114111 times. But you don't want to do that.

I'm not sure what the best approach is  (how did you get 1114111 btw? :-))::
I need to be fast or I need to get the information out in one go.  I can see
two options:
(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.
(2) Which is what I was thinking is get an average character width for each
required font and load it into a database.

I think (2) would be easier.....

> What are you trying to do?

Does this make sense?  Can I do this from the command line, or do I need to
write some code ?

Awesome, thank you soooooo much.

Kind Regards,

Z.

>
> Noah
>
>
> On Sat, Aug 30, 2003 at 23:41:54 -0700, Zitan Broth wrote:
> > Greetings Pangoneers,
> >
> > Sorry for the follow up question from below, but I want to call the
Pango
> > API and get the char width of a given font.
> >
> > How do I do this?  Can I call Pango from the command-line to get this
> > information out, cause that would be great ?  Or do I need to write some
C
> > code (scary) ?
> >
> > I have read through the site and the docs, so I guess I'm slow -- but
any
> > help anyone can offer is **hugely** appreciated.
> >
> > Thanks heaps,
> >
> > Z.
> >
> >
>
>





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