| 1 |
<svg version="1.1" baseProfile="basic" 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.4" reviewer="SVGWG" author="Vincent Hardy" status="accepted" |
| 15 |
version="$Revision: 1.7 $" testname="$RCSfile: coords-units-03-b.svg,v $"> |
| 16 |
<d:testDescription xmlns="http://www.w3.org/1999/xhtml" href="http://www.w3.org/TR/SVG11/coords.html#Units"> |
| 17 |
<p> |
| 18 |
This test verifies both the initial viewport size and the support for the various |
| 19 |
unit specifiers. |
| 20 |
</p> |
| 21 |
<p> |
| 22 |
The units in SVG can be: user coordinate and CSS units: em, ex, px, pt, pc, cm, mm, |
| 23 |
in and percentages. The test does not check the absolute length accuracy as this |
| 24 |
can only be truly validated with a ruler. However, it validates that the different |
| 25 |
units are supported by drawing multiple elements who have the same length specified |
| 26 |
in different units. |
| 27 |
</p> |
| 28 |
<p> |
| 29 |
The viewport is the "finite rectangular region" where rendering occurs in SVG. |
| 30 |
Hence, nothing should be rendered outside the viewport (paragraph 7.1). Furthermore, |
| 31 |
when no positioning properties are set on the top svg element, the initial viewport |
| 32 |
size should have the value of the top svg element's "width" and "height" attributes. |
| 33 |
To check this behavior, the test does not define positioning properties on the top |
| 34 |
svg element but defines its "width" and "height" properties. Then it fills a red |
| 35 |
rectangle that is bigger than the viewport size. Then, a rectangle, the size of the |
| 36 |
viewport is drawn in white. If rendering is limited to the viewport area, none of the |
| 37 |
red should show. |
| 38 |
</p> |
| 39 |
<p> |
| 40 |
The line showing the "ex" units will not necessarily appear with the same length |
| 41 |
as shown in the reference image because the X-height of a font is not |
| 42 |
necessarily half of the font size (which is assumed in the reference image where |
| 43 |
1ex is considered to be .5em). |
| 44 |
</p> |
| 45 |
</d:testDescription> |
| 46 |
<d:operatorScript xmlns="http://www.w3.org/1999/xhtml"> |
| 47 |
<p> |
| 48 |
Run the test. No interaction required. |
| 49 |
</p> |
| 50 |
</d:operatorScript> |
| 51 |
<d:passCriteria xmlns="http://www.w3.org/1999/xhtml"> |
| 52 |
<p>The test passes if the top three lines (user units, px, em) are the same length, |
| 53 |
the fifth line (%) is the same length as the top three lines, and the bottom |
| 54 |
five lines (in, cm, mm, pt, pc) are the same length. The fourth line (ex) may have |
| 55 |
any non-zero length, since the X-height of the font will depend on the exact font |
| 56 |
chosen by the user agent (which may vary).</p> |
| 57 |
</d:passCriteria> |
| 58 |
</d:SVGTestCase> |
| 59 |
<title id="test-title">$RCSfile: coords-units-03-b.svg,v $</title> |
| 60 |
<defs> |
| 61 |
<font-face font-family="SVGFreeSansASCII" unicode-range="U+0-7F"> |
| 62 |
<font-face-src> |
| 63 |
<font-face-uri xlink:href="../resources/SVGFreeSans.svg#ascii"/> |
| 64 |
</font-face-src> |
| 65 |
</font-face> |
| 66 |
</defs> |
| 67 |
<g id="test-body-content" font-family="SVGFreeSansASCII,sans-serif" font-size="18"> |
| 68 |
<g id="viewport-initial-size-test"> |
| 69 |
<!-- ====================================================================== --> |
| 70 |
<!-- First fill a rectangle that is bigger than the defined viewport ====== --> |
| 71 |
<!-- ====================================================================== --> |
| 72 |
<rect x="0px" y="0px" width="2000px" height="2000px" fill="red"/> |
| 73 |
<!-- ====================================================================== --> |
| 74 |
<!-- This second rectangle should cover the previous one, so none of the == --> |
| 75 |
<!-- red should show if the initial viewport has the requested size == --> |
| 76 |
<!-- ====================================================================== --> |
| 77 |
<rect x="0px" y="0px" width="480px" height="360px" fill="white"/> |
| 78 |
</g> |
| 79 |
<!-- viewport-initial-size-test --> |
| 80 |
<!-- Title --> |
| 81 |
<text x="125" y="20" fill="black" font-size="12" font-family="Arial">Initial viewport and CSS units test</text> |
| 82 |
<g id="units-test" fill="black" font-size="10pt" transform="translate(0, 60)"> |
| 83 |
<!-- ====================================================================== --> |
| 84 |
<!-- Now, draw rectangles using the various unit specifiers --> |
| 85 |
<!-- ====================================================================== --> |
| 86 |
<!-- User Space --> |
| 87 |
<text x="20" y="18">200</text> |
| 88 |
<text x="230" y="20">User space units (no specifier)</text> |
| 89 |
<rect x="20" y="20" width="200" height="1"/> |
| 90 |
<!-- ================== --> |
| 91 |
<!-- Relative CSS Units --> |
| 92 |
<!-- ================== --> |
| 93 |
<!-- Pixels : Should correspond to User Space, because the initial user --> |
| 94 |
<!-- coordinate is such that one user space unit equals one pixel in --> |
| 95 |
<!-- viewport. --> |
| 96 |
<text x="20" y="38">200 px</text> |
| 97 |
<text x="230" y="40">Pixels (px)</text> |
| 98 |
<rect x="20" y="40" width="200px" height="1"/> |
| 99 |
<!-- Font size (em). Should be equal to 200pt because current font's --> |
| 100 |
<!-- point size is 10pt --> |
| 101 |
<text x="20" y="58">20 em = 200 px (font-size=10px)</text> |
| 102 |
<text x="230" y="60">Relative to font size (em)</text> |
| 103 |
<g font-size="10px"> |
| 104 |
<rect x="20" y="60" width="20em" height="1"/> |
| 105 |
</g> |
| 106 |
<!-- X-Height (ex). With a 10px font-size, x-height is about 5px, so --> |
| 107 |
<!-- ex units would be about 200px --> |
| 108 |
<text x="20" y="78">40 ex</text> |
| 109 |
<text x="230" y="80">Relative to font x-height (ex)</text> |
| 110 |
<g font-size="10px"> |
| 111 |
<rect x="20" y="80" width="40ex" height="1"/> |
| 112 |
</g> |
| 113 |
<!-- ========================= --> |
| 114 |
<!-- Percentage --> |
| 115 |
<!-- ========================= --> |
| 116 |
<!-- 1% = 4.8px because viewport is 480px --> |
| 117 |
<text x="20" y="98">41.67% = 200 px</text> |
| 118 |
<text x="230" y="100">Percentage (%)</text> |
| 119 |
<rect x="20" y="100" width="41.67%" height="1"/> |
| 120 |
<!-- ========================= --> |
| 121 |
<!-- Absolute Length CSS Units --> |
| 122 |
<!-- ========================= --> |
| 123 |
<!-- Inches (should be the same length as following (cm) rect) --> |
| 124 |
<text x="20" y="118">1 in</text> |
| 125 |
<text x="230" y="120">Inches (in)</text> |
| 126 |
<rect x="20" y="120" width="1in" height="1"/> |
| 127 |
<!-- Centimeters(should be the same length as previous (in) rect) --> |
| 128 |
<!-- 1in = 2.54cm --> |
| 129 |
<text x="20" y="138">2.54 cm = 1 in</text> |
| 130 |
<text x="230" y="140">Centimeters (cm)</text> |
| 131 |
<rect x="20" y="140" width="2.54cm" height="1"/> |
| 132 |
<!-- Millimeters (should be the same length as previous (cm) rect) --> |
| 133 |
<!-- 10mm = 1cm --> |
| 134 |
<text x="20" y="158">25.4 mm = 1 in</text> |
| 135 |
<text x="230" y="160">Millimeters (mm)</text> |
| 136 |
<rect x="20" y="160" width="25.4mm" height="1"/> |
| 137 |
<!-- Points (should be the same length as (in) rect --> |
| 138 |
<!-- 1pt = 1/72 in --> |
| 139 |
<text x="20" y="178">72pt = 1 in</text> |
| 140 |
<text x="230" y="180">Points (pt)</text> |
| 141 |
<rect x="20" y="180" width="72pt" height="1"/> |
| 142 |
<!-- Picas (should be the same length as previous (pt) rect) --> |
| 143 |
<!-- 1pc = 12pt --> |
| 144 |
<text x="20" y="198">6pc = 1 in</text> |
| 145 |
<text x="230" y="200">Picas (pc)</text> |
| 146 |
<rect x="20" y="200" width="6pc" height="1"/> |
| 147 |
</g> |
| 148 |
<!-- units-test --> |
| 149 |
</g> |
| 150 |
<g font-family="SVGFreeSansASCII,sans-serif" font-size="32"> |
| 151 |
<text id="revision" x="10" y="340" stroke="none" fill="black">$Revision: 1.7 $</text> |
| 152 |
</g> |
| 153 |
<rect id="test-frame" x="1" y="1" width="478" height="358" fill="none" stroke="#000000"/> |
| 154 |
<!-- comment out this watermark once the test is approved --> |
| 155 |
<!--<g id="draft-watermark"> |
| 156 |
<rect x="1" y="1" width="478" height="20" fill="red" stroke="black" stroke-width="1"/> |
| 157 |
<text font-family="SVGFreeSansASCII,sans-serif" font-weight="bold" font-size="20" x="240" |
| 158 |
text-anchor="middle" y="18" stroke-width="0.5" stroke="black" fill="white">DRAFT</text> |
| 159 |
</g>--> |
| 160 |
</svg> |