Re: Adjusting width of rendered string

On Thu, 2003-08-21 at 17:43, Lars Clausen wrote:
> Hi!
> In Dia, we need to render our strings with the same width at different zoom
> levels.  This doesn't automatically happen because fonts don't scale
> linearly.  So far, we've been tweaking the size by scaling a little bit to
> at least make the string fit, but a) it's slow, b) it's ugly, c) it's slow,
> d) it doesn't always work, and e) it's ugly and slow.
> I was hoping there would be an easy way to adjust the spacing between
> letters to account for this (yes, I know letterspacing is evil, but it
> should be small enough amounts to not be noticable).
> I looked through the Pango docs, but didn't find any way to do this short
> of doing my own run, which I'd rather avoid.  Is there any way to tell
> Pango 'add this much total space to the line with letterspacing'?  Can
> anybody show me examples of doing this either way?

No, not currently. You can get the glyph strings, for the PangoLayout,
copy them, adjust the spacing and render, but it's hard to get all
the necessary information to do a good job of this, however - you need
to know:

 - Linear metrics for the layout - so you know where things would
   go without resolution dependent metrics
 - Some of the same information you need when justifying - where
   is the whitespace, which characters are attached to each other,

I've been playing around with this problem recently, and you can see
draft of a writeup of it at

Various hacks of Pango internals were used when producing the figures;
I haven't quite figured out what the final interfaces should look like.


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