petchgamer / svgweb

Automatically exported from code.google.com/p/svgweb
Other
0 stars 0 forks source link

Font-size based upon percentage in text element #618

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
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..

Original issue reported on code.google.com by AbrahamD...@gmail.com on 25 May 2011 at 3:16

GoogleCodeExporter commented 8 years ago
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());
}

Original comment by AbrahamD...@gmail.com on 25 May 2011 at 4:24

GoogleCodeExporter commented 8 years ago
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;

Original comment by AbrahamD...@gmail.com on 25 May 2011 at 4:43

GoogleCodeExporter commented 8 years ago
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.

Original comment by AbrahamD...@gmail.com on 25 May 2011 at 4:49

GoogleCodeExporter commented 8 years ago
Would be helpful to have this, if you want the text to be centered within a 
plot. Say, a box plot.

Original comment by fibinse....@gmail.com on 30 Oct 2012 at 4:33