getsubstringlength-emoji-ligatures.html (1011B)
1 <!DOCTYPE html> 2 <title>SVGTextContentElement.getSubStringLength on Emoji with ligatures</title> 3 <script src="/resources/testharness.js"></script> 4 <script src="/resources/testharnessreport.js"></script> 5 <svg> 6 <g font-size="50" text-rendering="geometricPrecision"> 7 <text y="50">๐ฆ</text> 8 <text y="100">๐จโ๐ฉโ๐งโ๐ฆ</text> 9 <text y="50" x="100">๐จโ</text> 10 <text y="100" x="100">๐ฉ๐ฝโ๐พ</text> 11 <text y="50" x="150">๐จโ๐ฆ</text> 12 <text y="100" x="150">๐ฑ๐ฝโโ๏ธ</text> 13 <text y="50" x="200">๐ ๐ฝ</text> 14 </g> 15 </svg> 16 <script> 17 test(function() { 18 for (const element of Array.from(document.getElementsByTagName('text'))) { 19 const subStringLength = element.getSubStringLength(0, element.getNumberOfChars()); 20 const bboxWidth = element.getBBox().width; 21 // Expect the value computed by getSubStringLength() to roughly 22 // match the value computed for the bbox. 23 assert_approx_equals(subStringLength, bboxWidth, 1); 24 } 25 }); 26 </script>