New issue 618 by AbrahamD...@gmail.com: Font-size based upon percentage in
text element
http://code.google.com/p/svgweb/issues/detail?id=618
What steps will reproduce the problem?
1. Create a text element with a percentage based font-size.
2. Load SVG File and Change viewbox, width, and height.
What is the expected output? What do you see instead?
Expect font to scale according to rules for <length>.
Instead, it appears that font size remains the same.
What version of the product are you using? On what operating system,
browser, and version of Flash? Lurker Above on Flash 10.2.152.32
Is it possible to scale fonts or am I just being dumb about it? Linework
scales perfectly, so I am confused. Perhaps it is not supported yet or
perhaps there is another way to do it?
code sample:
svgViewer.viewer.xml.@viewBox = "0 0 1200 400"
svgViewer.viewer.xml.@width = "1200"
svgViewer.viewer.xml.@height = "400"
sample svg:
<text x="82%" y="5%" style="font-size:7%">Customers</text>
Thanks for the excellent svgweb viewer by the way..
Added the following to the SVGText Node Line 304 in order to support %
based font for my little project. Would love to see this incorporated for
future updates. Thanks.
if (SVGUnits.getType(fontSize) == SVGUnits.PERCENT) {
fontSizeNum = SVGUnits.parseNumPct(fontSize, this.svgParent.getWidth());
}
Also added this to SVGUnits.getType to support detection of decimal
percentages
} else if (/^\s*[0-9](\.[0-9]{1,2})?+%\s*$/.test(unit)) {
return SVGUnits.PERCENT;
By the way, the font size routine I added above does not calculate the
length based on the screen diagonal the way is is supposed to. I left it
that way because all my text runs horizontal, but i doubt that is the
proper way to do it. I just wanted to keep my local hacks to a minimum.