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

>
> Just to weigh in on one aspect of this. As Leonard said, the SVG table
> spec says:
>
> “Glyph advance widths or heights are the same for SVG glyphs as for
> TrueType/CFF glyphs, though there may be small differences in glyph ink
> bounding boxes.”
>
> The “small differences” will of course depend on the design of the font.
> For example, a face with a section of blue sky around it may be represented
> in CFF/TT as the face by itself, without the sky, and thus the glyph bbox
> may be quite different.
>
>
Yes, that's a good point. That also means I shouldn't rely on the TTF/CFF
outline bbox.


>  It sounds like you need the glyph bboxes in order to use the 3 libraries
> you mention. If the bboxes are needed just to get a sense of how much
> memory to allocate for the rasterizing, perhaps you can pad the CFF/TT bbox
> by some amount to make it a bit bigger? (Of course, the CFF bbox will need
> to be calculated first…)
>

Well that is one of the reasons, but not as important. The important part
is getting a proper rendering with these libraries. Yes, the CFF/TTF bbox
would need to be calculated first, and it's easier to do that.


> But I’m just guessing here. It seems like someone familiar with the
> libraries may need to weigh in. I’ll check with Dirk re. SVG Native.
>

Yes, please, let's reach out to him.
I request everyone to kindly have a look at (it'll take 5 mins to skim
through the README):
https://github.com/moazin/svg-native-viewer/tree/demo-viewbox/svgnative/example/testSkia
`SVG Native Viewer' is an SVG rendering library by Adobe. I have modified
the `testSkia' program and I use it to render `example 2' from the OT-SVG
specs.  The README will show you my attempts to render that glyph and by
seeing the images you will get a good idea of why I think the bounding
boxes are necessary for rendering the glyph properly. The images in the
README are PNGs with a lot of transparency. Please open them in new tabs or
something similar so that you can see the boundaries of the image (the
transparency is shown in white and the background is white too, thus by
default you probably won't see the image boundaries, however, it's
important that you do). Hopefully, this link illustrates my point. Let me
know if there are doubts.


> The only accurate glyph bbox for SVG (as for CFF) is that obtained *after*
> the rendering of the glyph.
>

Yes. There are methods of obtaining bbox before rendering (such as the
functions the libraries themselves provide), I just can't be sure that they
will always give accurate answers. This is something I should research on.


> And yes, please ignore anything animation-related, even though such fonts
> are valid OT-SVG (even if they are not recommended for portability since
> they go beyond the minimum recommended subset). Animation is not in scope
> for the minimum OT-SVG that I believe is the goal of your project.
>

Yes, since FreeType is a very low-level library we don't really care about
animation.

Received on Saturday, 3 August 2019 05:51:59 UTC