[Webkit-unassigned] [Bug 113439] New: DOM floating point support for text size (especially in SVG)
bugzilla-daemon at webkit.org
bugzilla-daemon at webkit.org
Wed Mar 27 14:00:01 PDT 2013
https://bugs.webkit.org/show_bug.cgi?id=113439
Summary: DOM floating point support for text size (especially
in SVG)
Product: WebKit
Version: 525.x (Safari 3.2)
Platform: All
OS/Version: Mac OS X 10.8
Status: UNCONFIRMED
Severity: Normal
Priority: P2
Component: SVG
AssignedTo: webkit-unassigned at lists.webkit.org
ReportedBy: alanou at google.com
CC: zimmermann at kde.org, pdr at google.com
Summary
I am trying to force text in SVG to have an exact position and size across browsers and systems. The <text> tag produces very inconsistent results (which I would like to see fixed, but seems like a more difficult problem). As a work around, I am attempting to scale the text using a desired width and the width of the text as reported by the DOM.
I have used the following DOM methods in an attempt to get the text width:
- SVGTextContentElement.getComputedTextLength()
http://www.w3.org/TR/SVG/text.html#InterfaceSVGTextContentElement
- SVGLocatable.getBBox().width
http://www.w3.org/TR/SVG/types.html#InterfaceSVGLocatable
http://www.w3.org/TR/SVG/types.html#InterfaceSVGRect
- Element.getBoundingClientRect().width
http://www.w3.org/TR/cssom-view/#the-getclientrects-and-getboundingclientrect-methods
http://www.w3.org/TR/cssom-view/#clientrect
Each of these DOM members are defined to return floating point values by the w3c. Chome, Firefox, and IE each return floating point values for some of these DOM members. Opera and Safari both return rounded-off integers for all of them. The result is the scaling factor I generate to size the text perfectly is off by a small amount and the text jitters as the zoom level is changed.
As a workaround, I can use a very, very large font or viewport to reduce the impact of the loss of precision due to round-off. However, I'm not crazy about that solution.
getComputedTextLength is the most important one to fix for me since it is the only one of the three that Chrome returns floating point for.
I've attached an HTML sample file that can be used for testing.
Steps to Reproduce:
1. Open the attached file.
2. In the text input labeled "Font Size", enter different font sizes and press enter.
Expected Results:
The text should always be the same width as the red box.
Actual Results:
The text size changes to be slightly larger and smaller than the red box.
Regression:
No
Notes:
Try setting the font size to something large like "2200". The text is nearly the same size as the box, but goes outside of it by a small amount. Changing the font size to "2300" changes the size of the text a little bit. It is an improvement over the change from "22" to "23", but still isn't perfect.
--
Configure bugmail: https://bugs.webkit.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.
More information about the webkit-unassigned
mailing list