[Webkit-unassigned] [Bug 17078] New: SVGTextElement.getComputedTextLength does not work as expected (Acid3 bug)

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Tue Jan 29 14:53:54 PST 2008


http://bugs.webkit.org/show_bug.cgi?id=17078

           Summary: SVGTextElement.getComputedTextLength does not work as
                    expected (Acid3 bug)
           Product: WebKit
           Version: 525+ (Nightly build)
          Platform: Macintosh
        OS/Version: Mac OS X 10.5
            Status: NEW
          Severity: Normal
          Priority: P2
         Component: SVG
        AssignedTo: webkit-unassigned at lists.webkit.org
        ReportedBy: eric at webkit.org
                CC: zimmermann at kde.org


SVGTextElement.getComputedTextLength does not work as expected (Acid3 bug)

Test 78: expected: 4776, got: 5550 - getComputedTextLength failed.

I bet we're not respecting kerning or some advanced text feature as specified
by the Acid3SVGFont in question.

    function () {
      // test 78: external SVG fonts, from Erik Dahlstrom
      //
      // SVGFonts are described here[3], and the relevant DOM methods
      // used in the test are defined here[4].
      //
      // Note that in order to be more predictable the svg should be
      // visible, so that clause "For non-rendering environments, the
      // user agent shall make reasonable assumptions about glyph
      // metrics." doesn't influence the results. We use 'opacity:0'
      // to hide the SVG, but arguably it's still a "rendering
      // environment".
      //
      // The font-size 4000 was chosen because that matches the
      // unitsPerEm value in the svgfont, which makes it easy to check
      // the glyph advances since they will then be exactly what was
      // specified in the svgfont.
      //
      // [3] http://www.w3.org/TR/SVG11/fonts.html
      // [4]
http://www.w3.org/TR/SVG11/text.html#InterfaceSVGTextContentElement

      var svgns = "http://www.w3.org/2000/svg";
      var xlinkns = "http://www.w3.org/1999/xlink";
      var svgdoc = kungFuDeathGrip.firstChild.contentDocument;
      assert(svgdoc, "contentDocument failed on <object> for svg document.");
      var svg = svgdoc.documentElement;
      var text = svgdoc.createElementNS(svgns, "text");
      text.setAttribute("y", "1em");
      text.setAttribute("font-size", "4000");
      text.setAttribute("font-family", "ACID3svgfont");
      var textContent = svgdoc.createTextNode("abc");
      text.appendChild(textContent);
      svg.appendChild(text);
      // The font-size 4000 was chosen because that matches the unitsPerEm
value in the svgfont, 
      // which makes it easy to check the glyph advances since they will then
be exactly what was specified in the svgfont.
      assert(text.getNumberOfChars, "SVGTextContentElement.getNumberOfChars()
not supported.");
      assertEquals(text.getNumberOfChars(), 3, "getNumberOfChars returned
incorrect string length.");
      assertEquals(text.getComputedTextLength(), 4711+42+23,
"getComputedTextLength failed.");
      assertEquals(text.getSubStringLength(0,1), 42, "getSubStringLength #1
failed.");
      assertEquals(text.getSubStringLength(0,2), 42+23, "getSubStringLength #2
failed.");
      assertEquals(text.getSubStringLength(1,1), 23, "getSubStringLength #3
failed.");
      assertEquals(text.getSubStringLength(1,0), 0, "getSubStringLength #4
failed.");
      var code = -1000;
      try {
        var sl = text.getSubStringLength(1,3);
      } catch(e) {
        code = e.code;
      }
      assertEquals(code, DOMException.INDEX_SIZE_ERR, "getSubStringLength #1
didn't throw exception.");
      code = -1000;
      try {
        var sl = text.getSubStringLength(0,3);
      } catch(e) {
        code = e.code;
      }
      assertEquals(code, DOMException.INDEX_SIZE_ERR, "getSubStringLength #2
didn't throw exception.");
      code = -1000;
      try {
        var sl = text.getSubStringLength(1,2);
      } catch(e) {
        code = e.code;
      }
      assertEquals(code, DOMException.INDEX_SIZE_ERR, "getSubStringLength #3
didn't throw exception.");
      code = -1000;
      try {
        var sl = text.getSubStringLength(-17,20);
      } catch(e) {
        code = e.code;
      }
      assertEquals(code, DOMException.INDEX_SIZE_ERR, "getSubStringLength #4
didn't throw exception.");
      code = -1000;
      try {
        var sl = text.getSubStringLength(1,2);
      } catch(e) {
        code = e.code;
      }
      assertEquals(code, DOMException.INDEX_SIZE_ERR, "getSubStringLength #5
didn't throw exception.");
      assertEquals(text.getStartPositionOfChar(0).x, 0,
"getStartPositionOfChar(0).x returned invalid value.");
      assertEquals(text.getStartPositionOfChar(1).x, 42,
"getStartPositionOfChar(1).x returned invalid value.");
      assertEquals(text.getStartPositionOfChar(2).x, 42+23,
"getStartPositionOfChar(2).x returned invalid value.");
      assertEquals(text.getStartPositionOfChar(0).y, 4000,
"getStartPositionOfChar(0).y returned invalid value.");
      code = -1000;
      try {
        var val = text.getStartPositionOfChar(-1);
      } catch(e) {
        code = e.code;
      }
      assertEquals(code, DOMException.INDEX_SIZE_ERR, "getStartPositionOfChar
#1 exception failed.");
      code = -1000;
      try {
        var val = text.getStartPositionOfChar(4);
      } catch(e) {
        code = e.code;
      }
      assertEquals(code, DOMException.INDEX_SIZE_ERR, "getStartPositionOfChar
#2 exception failed.");
      assertEquals(text.getEndPositionOfChar(0).x, 42,
"getEndPositionOfChar(0).x returned invalid value.");
      assertEquals(text.getEndPositionOfChar(1).x, 42+23,
"getEndPositionOfChar(1).x returned invalid value.");
      assertEquals(text.getEndPositionOfChar(2).x, 42+23+4711,
"getEndPositionOfChar(2).x returned invalid value.");
      code = -1000;
      try {
        var val = text.getEndPositionOfChar(-17);
      } catch(e) {
        code = e.code;
      }
      assertEquals(code, DOMException.INDEX_SIZE_ERR, "getEndPositionOfChar #1
exception failed.");
      code = -1000;
      try {
        var val = text.getEndPositionOfChar(4);
      } catch(e) {
        code = e.code;
      }
      assertEquals(code, DOMException.INDEX_SIZE_ERR, "getEndPositionOfChar #2
exception failed.");
      return 5;
    },


-- 
Configure bugmail: http://bugs.webkit.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.



More information about the webkit-unassigned mailing list