Re: Adjusting width of rendered string

On 21 Aug 2003, Owen Taylor wrote:
> On Thu, 2003-08-21 at 17:43, Lars Clausen wrote:
>> 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,
> etc.
> 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.

That's a good description of what the problem entails.  I can certainly see
it being tricky, and it's a good point about monospace fonts (of which we
use quite a few) -- I always thought those would be easier to handle
because they're fixed width, but no.  

At the moment, we make a layout at one particular (arbitrary) resolution to
get a uniform length.  We then use that length, scaled to match the zoom
factor, to scale the font to ensure that it at least isn't any longer than
it should be.  I'm hoping to be able to adjust the algorithm to get the
longest rendering no longer than the scaled uniform length.  Am I right to
think that the length of a rendered string is at least monotonically
increasing with the font size?  Or can a slightly larger font size actually
cause a smaller rendered string?


Lars Clausen (| HÃ¥rdgrim of Numenor
"I do not agree with a word that you say, but I   |----------------------------
will defend to the death your right to say it."   | Where are we going, and
    --Evelyn Beatrice Hall paraphrasing Voltaire  | what's with the handbasket?

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