Re: problem with portability of text extents



On 02/14/2011 02:54 PM, Bogdan Butnaru wrote:
> On Mon, Feb 14, 2011 at 20:41, John Ellson
> <ellson research att com> wrote:
>> Thanks for your suggestion.
> You’re welcome!
>
>> The whitespace above the text was still unreasonably large in
>> both cases (for normal alphanumerics).
>>
>> So the bug isn't in variation in the font engine implementations.
>> The bug is in the definition of logical_rect.y. Pango doesn't
>> let me specify a font-file, it only lets me specify a
>> font-family, and I still question if the font designer's
>> arbitrary y=0 reference is suitable for layout purposes.
>>
>> While playing with this, I found a font in which the ink_rect
>> exceeds the boundaries of the logical_rect in the x direction.
>> http://www.1001freefonts.com/font/BaroqueScript.zip If this is
>> allowed, then it should also be allowed to define the
>> logical_rect.y to be the maximum ascent of some selection of
>> "normal" characters, while allowing other characters, such as
>> math integrals, to exceed it.
>
> I think I understand your needs, but it’s hard to define “normal”
> in general. (Consider that Pango needs to deal not only with Latin
> “alphanumerics”, but all kinds of scripts.)
>
> Can’t you just work-around this by simply telling Pango to draw
> whatever you consider “normal” (for example, a string containing
> the characters A–Z, a–z and 0–9, perhaps with a couple of accented
> capitals if you expect to need it) in a hidden buffer, with the
> font you need the measurements of, and then take the ink_rect and
> use that? If I understand correctly, you need a per-font measure to
> use for general layout, not measurement of a particular string,
> right?
>
> (This method would allow any user to define what they consider
> “normal”; someone developing for Arabic will probably use a string
> with Arabic letters, and a Chinese user might use a few “standard”
> ideographs, etc. I’d guess that’s why the method isn’t provided by
> Pango itself.)
>
> — Bogdan Butnaru
>

Well, yes, but, doesn't pango already contain code to determine the
bounding box of a language-specific string? The English one being;
    "The quick brown fox ..."
(See: pango/glyphstring.c)

Would it be out-of-line for pango to also accumulate maximum ascent of
this string and offer that in logical_rect.y ?
(Having logical_rect.y always contain 0 doesn't carry any useful
information. It doesn't need to restate the font-designer's 0 reference.)

Basically, yes, I'm looking for a per-font-family measure to use for
general layout.   I'm expecting that a test of any font matching the
family description would produce a similar result (for well known
families like "Times").  So a value from the local font that matches
the family should be sufficient for reasonably uniform layouts across
platforms.


John Ellson


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