Issue 618 in svgweb: Font-size based upon percentage in text element

7 views
Skip to first unread message

svg...@googlecode.com

unread,
May 24, 2011, 11:17:06 PM5/24/11
to svg-w...@googlegroups.com
Status: New
Owner: ----
Labels: Type-Defect Priority-Low

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..

svg...@googlecode.com

unread,
May 25, 2011, 12:25:28 AM5/25/11
to svg-w...@googlegroups.com

Comment #1 on issue 618 by AbrahamD...@gmail.com: Font-size based upon

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());
}

svg...@googlecode.com

unread,
May 25, 2011, 12:43:35 AM5/25/11
to svg-w...@googlegroups.com

Comment #2 on issue 618 by AbrahamD...@gmail.com: Font-size based upon

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;

svg...@googlecode.com

unread,
May 25, 2011, 12:49:36 AM5/25/11
to svg-w...@googlegroups.com

Comment #3 on issue 618 by AbrahamD...@gmail.com: Font-size based upon

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.

svg...@googlecode.com

unread,
Oct 30, 2012, 12:33:32 PM10/30/12
to svg-w...@googlegroups.com

Comment #4 on issue 618 by fibinse....@gmail.com: Font-size based upon
Would be helpful to have this, if you want the text to be centered within a
plot. Say, a box plot.

Reply all
Reply to author
Forward
0 new messages