Re: Some questions about OT-SVG glyph metrics and bounding boxes

First of all, I apologize if I lack knowledge of things pretty obvious to
the font world. I am new here! :)


> For what purpose do you want the side-bearing, and the ink-box? [...]
>

 The behavior of FreeType (for traditional fonts) is that it renders a
glyph tightly* and gives two fields called `bitmap_left' and `bitmap_top'.
These two fields give information about where to place the glyph with
respect to the origin and the baseline. So, for example, in many fonts, a
comma (,) and an apostrophe (') might have the same pixel data after
rendering and the only difference will be in the values of `bitmap_top' and
`bitmap_left'. Naturally, I want the same behavior with SVG glyphs too.

Now I'll describe issues with these:
1. *Rendering a glyph (tightly or not): *SVG glyphs are not necessarily in
(+x & +y) quadrant of the SVG coordinate system. In fact, most of the time
they aren't. If you directly send the SVG document to a rendering library
like `librsvg' it will only render whatever is in the (+x & +y) quadrant.
Which in most cases, doesn't have anything. To ensure that you are at least
rendering the whole glyph (not some clipped part of it), you must use
something like a `cairo_translate' to shift the whole image to the (+x
& +y) quadrant. But, then the question is, how much to shift? You can
either make good guesses and hope that you get the whole glyph rendered
properly (and they won't be tightly rendered anyways) or you can use some
functions which SVG libraries usually provide that can give you a bounding
box (in SVG coordinates). With the knowledge of this bounding box, you can
render the whole glyph properly (and in many cases, tightly). There's
another way to get this bounding box which I describe in my first email. I
just wanna know which one is the correct one.

2. *`bitmap_left' and `bitmap_top': *I get these from the bounding box in
SVG coordinates. There is some scaling to be done of course, but the
necessary information is there. These values directly correspond to the
bearings (AFAIK) and that's the reason why I was asking about them.

My major question here is, what's the right way to get these bounding
boxes? Using the functions SVG rendering libraries provide? Or assuming
that the TTF/CFF outline bbox is the same as that for SVG glyph (the
approach I describe in the first email).

[*] Please have a look at my attachments in the first email to see what I
mean by the word `tight'. If there's a better term for that please let me
know.

Received on Wednesday, 31 July 2019 10:31:22 UTC