Hi Toshiya,

I wanted to add a thought here.

For this email I am going to refer to "all of the code that the svg
rendering callback hooks point to" as the `rendering port'.

I think we can off-load all of the rendering and the `bitmap_left' and
`bitmap_top' extraction part to the rendering port. Two libraries so far
provide a `get_bbox' feature. SVG Native can provide one very soon too. Of
course, none of these take into account clipping. But note that "not
accounting clipping" only leads to a bigger bounding box than the actual
one AFAIK. A very simple and relatively efficient check can be done to
confirm whether the box is "tight" or not. Something like the following:

Imagine we just rendered a 1000 by 1000 pixel image that we think is
"tight" but we aren't sure, since we don't know whether there was clipping
or not. We can simply iterate the boundary of this bitmap and if at least
one pixel is `inked' we can be sure that the box is tight. Thus, we can
straightaway calculate `bitmap_left' and `bitmap_top' and be sure that they
are the right values. If that's not the case, we can then run a algorithm
to get a tighter bounding box.

Let me know what you think and please point out if I have made logical
mistakes here.
_______________________________________________
Freetype-devel mailing list
[email protected]
https://lists.nongnu.org/mailman/listinfo/freetype-devel

Reply via email to