3 <title>BiDi getCharNumAtPosition()
</title>
4 <script src=
"../../resources/testharness.js"></script>
5 <script src=
"../../resources/testharnessreport.js"></script>
6 <svg width=
"50px" height=
"60px" font-family=
"Arial" font-size=
"30px">
7 <text y=
"40" direction=
"ltr">Foo הפוך
</text>
8 <text text-anchor=
"end" y=
"70" direction=
"rtl">Foo הפוך
</text>
11 function getExtents(textElement
) {
13 for (var i
= 0; i
< 8; ++i
)
14 glyphBBoxes
.push(textElement
.getExtentOfChar(i
));
18 function getCharNums(textElement
, glyphBBoxes
) {
20 var point
= textElement
.ownerSVGElement
.createSVGPoint();
21 for (var i
= 0; i
< glyphBBoxes
.length
; ++i
) {
22 var bbox
= glyphBBoxes
[i
];
23 point
.x
= bbox
.x
+ bbox
.width
/ 2;
24 point
.y
= bbox
.y
+ bbox
.height
/ 2;
25 charNums
.push(textElement
.getCharNumAtPosition(point
));
30 var textElements
= document
.querySelectorAll("text");
31 for (var j
= 0; j
< textElements
.length
; ++j
) {
32 var textElement
= textElements
[j
];
34 assert_equals(textElement
.textContent
.length
, 10);
35 var glyphChars
= getCharNums(textElement
, getExtents(textElement
));
36 for (var i
= 0; i
< glyphChars
.length
; ++i
)
37 assert_equals(glyphChars
[i
], i
);
38 }, document
.title
+', direction='+textElement
.getAttribute("direction")+'.');