Debian Codegraph @

test_non_regression/fail/na/script/text-dom-05-f.svg

raw
1 <svg version="1.1" baseProfile="full" id="svg-root"
2 width="100%" height="100%" viewBox="0 0 480 360"
3 xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
4 <!--======================================================================-->
5 <!--= SVG 1.1 2nd Edition Test Case =-->
6 <!--======================================================================-->
7 <!--= Copyright 2009 World Wide Web Consortium, (Massachusetts =-->
8 <!--= Institute of Technology, European Research Consortium for =-->
9 <!--= Informatics and Mathematics (ERCIM), Keio University). =-->
10 <!--= All Rights Reserved. =-->
11 <!--= See http://www.w3.org/Consortium/Legal/. =-->
12 <!--======================================================================-->
13 <d:SVGTestCase xmlns:d="http://www.w3.org/2000/02/svg/testsuite/description/"
14 template-version="1.3" reviewer="CL" author="CM" status="reviewed"
15 version="$Revision: 1.6 $" testname="$RCSfile: text-dom-05-f.svg,v $">
16 <d:testDescription xmlns="http://www.w3.org/1999/xhtml" href="http://www.w3.org/TR/SVG11/text.html#InterfaceSVGTextContentElement">
17 <p>
18 This tests that methods on the SVGTextContentElement interface
19 that take an index to a character or a number of characters
20 actually interpret these as indexes to or numbers of UTF-16 code
21 units. To test this, a character from outside the Basic Multilingual Plane
22 (U+10000; LINEAR B SYLLABLE B008) is used in a text string.
23 This character is stored in UTF-16 as a surrogate pair.
24 </p>
25 <p>
26 The test consists of 5 sub-tests, which test the methods
27 methods on the SVGTextContentElement interface. The result
28 of each sub-test is shown as a small rectangle: black
29 indicates that the sub-test did not run, red indicates that
30 the sub-test failed and green indicates that the sub-test
31 succeeded.
32 </p>
33 </d:testDescription>
34 <d:operatorScript xmlns="http://www.w3.org/1999/xhtml">
35 <p>
36 Run the test. No interaction required.
37 </p>
38 <p>
39 The test relies on support for WebFonts - either SVG Fonts, or WOFF, or OpenType.
40 </p>
41 </d:operatorScript>
42 <d:passCriteria xmlns="http://www.w3.org/1999/xhtml">
43 <p>
44 The test is passed if all 5 rectangles are green.
45 </p>
46 </d:passCriteria>
47 </d:SVGTestCase>
48 <title id="test-title">$RCSfile: text-dom-05-f.svg,v $</title>
49 <defs>
50 <font-face font-family="SVGFreeSansASCII" unicode-range="U+0-7F">
51 <font-face-src>
52 <font-face-uri xlink:href="../resources/SVGFreeSans.svg#ascii"/>
53 </font-face-src>
54 </font-face>
55 </defs>
56 <g id="test-body-content" font-family="SVGFreeSansASCII,sans-serif" font-size="18">
57 <text x='10' y='30' font-size='13'>Test that SVGTextContentElement methods work on UTF-16 code units</text>
58 <text x='10' y='60' font-size='11'>Methods that rely on layout</text>
59 <font-face font-family='SPlaneOne'>
60 <font-face-src>
61 <font-face-uri xlink:href="../resources/Plane1/PlaneOne.svg#SPlaneOne"/>
62 </font-face-src>
63 </font-face>
64 <style type="text/css">
65 @font-face {
66 font-family: PlaneOne;
67 src: url(woffs/PlaneOne.woff) format("woff");
68 }
69 </style>
70
71 <text id='t' x='50' y='50' visibility='hidden' font-family='PlaneOne, SPlaneOne' font-size='10' rotate='10 20 30'>a&#x10000;b</text>
72
73 <rect id='r3' x='10' y='120' width='30' height='30'/>
74 <text x='50' y='140'>getStartPositionOfChar</text>
75
76 <rect id='r4' x='10' y='160' width='30' height='30'/>
77 <text x='50' y='180'>getEndPositionOfChar</text>
78
79 <rect id='r5' x='10' y='200' width='30' height='30'/>
80 <text x='50' y='220'>getExtentOfChar</text>
81
82 <rect id='r6' x='10' y='240' width='30' height='30'/>
83 <text x='50' y='260'>getRotationOfChar</text>
84
85 <rect id='r7' x='10' y='280' width='30' height='30'/>
86 <text x='50' y='300'>getCharNumAtPosition</text>
87
88 <script><![CDATA[
89 function $(x) { return document.getElementById(x) }
90 function eq(a, b) {
91 if (a.length != b.length) return false;
92 for (var i = 0; i < a.length; i++) if (a[i] != b[i]) return false;
93 return true;
94 }
95 function p(x, y) {
96 var p = document.documentElement.createSVGPoint();
97 p.x = x;
98 p.y = y;
99 return p;
100 }
101
102 var t = $('t');
103 var x, b;
104
105 b = false;
106 try {
107 x = [
108 t.getStartPositionOfChar(0).x,
109 t.getStartPositionOfChar(1).x,
110 t.getStartPositionOfChar(2).x,
111 t.getStartPositionOfChar(3).x
112 ];
113 b = eq(x, [50, 51, 51, 53]);
114 } catch (e) {
115 }
116 $('r3').setAttribute('fill', b ? 'green' : 'red');
117
118 b = false;
119 try {
120 x = [
121 t.getEndPositionOfChar(0).x,
122 t.getEndPositionOfChar(1).x,
123 t.getEndPositionOfChar(2).x,
124 t.getEndPositionOfChar(3).x
125 ];
126 b = x[0] < x[1] && x[1] == x[2] && x[2] < x[3];
127 } catch (e) {
128 }
129 $('r4').setAttribute('fill', b ? 'green' : 'red');
130
131 b = false;
132 try {
133 x = [
134 t.getExtentOfChar(0).width,
135 t.getExtentOfChar(1).width,
136 t.getExtentOfChar(2).width,
137 t.getExtentOfChar(3).width
138 ];
139 b = eq(x, [1, 2, 2, 4]);
140 } catch (e) {
141 }
142 $('r5').setAttribute('fill', b ? 'green' : 'red');
143
144 b = false;
145 try {
146 x = [
147 t.getRotationOfChar(0),
148 t.getRotationOfChar(1),
149 t.getRotationOfChar(2),
150 t.getRotationOfChar(3)
151 ];
152 b = eq(x, [10, 20, 20, 30]);
153 } catch (e) {
154 }
155 $('r6').setAttribute('fill', b ? 'green' : 'red');
156
157 b = false;
158 try {
159 x = [
160 t.getCharNumAtPosition(p(50.5, 49)),
161 t.getCharNumAtPosition(p(51.5, 49)), // within first half of the glyph represented by the two surrogates
162 t.getCharNumAtPosition(p(52.5, 49)), // within second half of the glyph represented by the two surrogates
163 t.getCharNumAtPosition(p(53.5, 49))
164 ];
165 b = eq(x, [0, 1, 2, 3]);
166 } catch (e) {
167 }
168 $('r7').setAttribute('fill', b ? 'green' : 'red');
169 ]]></script>
170 </g>
171 <g font-family="SVGFreeSansASCII,sans-serif" font-size="32">
172 <text id="revision" x="10" y="340" stroke="none" fill="black">$Revision: 1.6 $</text>
173 </g>
174 <rect id="test-frame" x="1" y="1" width="478" height="358" fill="none" stroke="#000"/>
175 <!-- comment out this watermark once the test is approved -->
176 <g id="draft-watermark">
177 <rect x="1" y="1" width="478" height="20" fill="red" stroke="black" stroke-width="1"/>
178 <text font-family="SVGFreeSansASCII,sans-serif" font-weight="bold" font-size="20" x="240"
179 text-anchor="middle" y="18" stroke-width="0.5" stroke="black" fill="white">DRAFT</text>
180 </g>
181 </svg>