On 11/19/2013 12:44 PM, kototama kototama wrote:
Hello,
I'm calculating the bbox value of a group containing a rectangle to
adapt its dimension to the text it contained.
If the calculation is not dynamic, but done on Java before dumping the
SVG XML, the problem may be related to the real font used. There is no
guarantee that the UA displaying the SVG has the font, or the font has
exactly the same metric that the one you used to calculate the sizes
In an ideal world were everyone comply with the latest standard, you
have a few options:
1- Transform the text to shapes
The infallible solution
2- Make the font available to the browser using a browser supported font
format
Never tried this, but it could work for no complex western languages
where laying out text hasn't complex rules
2- Transform the font to a SVG Font
Not all UA/browsers have support for SVG Fonts (Firefox hasn't, not
sure about Chrome)
3- User SVG flow elements
Batik has some extensions for this, no standard, SVG 1.2 has proposal
for that but there isn't any 1.2 compliant browser, and Batik isn't 1.2
compliant either
The generated SVG looks like this:
<g xmlns="http://www.w3.org/2000/svg" class="rectangle-node" id="node3"
transform="translate(200, 225)">
<rect style=" fill: white; stroke: black; " width="100.0" height="40.0"/>
<text x="50" font-size="12px" y="20" style=" dominant-baseline: central;
" font-family="helvetica" text-anchor="middle">Stuff</text>
</g>
As you can see on the attached image this works well with Batik (on the
right of the image) but the same SVG displayed in Chrome (on the left)
is not correct. The text flows out of the rectangle.
Why does this calculation is not renderer independent given the font
size and font are specified?
What kind of solution can I implement to solve this problem?
---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscr...@xmlgraphics.apache.org
For additional commands, e-mail: batik-users-h...@xmlgraphics.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscr...@xmlgraphics.apache.org
For additional commands, e-mail: batik-users-h...@xmlgraphics.apache.org