librsvg source for verification 2026-05-22

This commit is contained in:
2026-05-22 16:45:08 +08:00
commit 75af7ac721
2138 changed files with 161177 additions and 0 deletions

20
rsvg/tests/fixtures/text/bounds-ref.svg vendored Normal file
View File

@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="utf-8"?>
<svg xmlns="http://www.w3.org/2000/svg" width="600" height="600">
<rect x="0" y="0" width="100%" height="100%" fill="white"/>
<!-- The transform is to move the squares a bit down, so they match the Ahem font's glyph extents -->
<g transform="translate(0, 10)">
<rect x="50" y="50" width="50" height="50" fill="lime"/>
<rect x="100" y="50" width="50" height="50" fill="blue"/>
<rect x="200" y="50" width="50" height="50" fill="lime"/>
<rect x="200" y="100" width="50" height="50" fill="blue"/>
<rect x="300" y="50" width="50" height="50" fill="lime"/>
<rect x="300" y="100" width="50" height="50" fill="blue"/>
<rect x="400" y="50" width="50" height="50" fill="lime"/>
<rect x="450" y="50" width="50" height="50" fill="blue"/>
</g>
</svg>

After

Width:  |  Height:  |  Size: 822 B

48
rsvg/tests/fixtures/text/bounds.svg vendored Normal file
View File

@@ -0,0 +1,48 @@
<?xml version="1.0" encoding="utf-8"?>
<svg xmlns="http://www.w3.org/2000/svg" width="600" height="600">
<defs>
<linearGradient id="horizontal" gradientUnits="objectBoundingBox" x1="0" y1="0" x2="1" y2="0">
<stop stop-color="lime" offset="0.0"/>
<stop stop-color="lime" offset="0.5"/>
<stop stop-color="blue" offset="0.5"/>
<stop stop-color="blue" offset="1.0"/>
</linearGradient>
<linearGradient id="vertical" gradientUnits="objectBoundingBox" x1="0" y1="0" x2="0" y2="1">
<stop stop-color="lime" offset="0.0"/>
<stop stop-color="lime" offset="0.5"/>
<stop stop-color="blue" offset="0.5"/>
<stop stop-color="blue" offset="1.0"/>
</linearGradient>
</defs>
<rect x="0" y="0" width="100%" height="100%" fill="white"/>
<style type="text/css">
text {
font: 50px Ahem;
}
</style>
<!-- Test that the bounding box of <text> is correct by creating groups of two squares,
one green and one blue. The gradients use objectBoundingBox, so they fill both
squares at the same time.
The first test is horizontal, to test the horizontal bounds.
The second test is vertical, to test the vertical bounds.
-->
<text id="a" x="50" y="100" fill="url(#horizontal)" stroke-width="2">XX</text>
<text id="b" x="0" y="-10" fill="url(#horizontal)" transform="translate(200, 60) rotate(90)">XX</text>
<text id="c" fill="url(#vertical)">
<tspan x="300" y="100">X</tspan>
<tspan x="300" y="150">X</tspan>
</text>
<text id="d" fill="url(#vertical)" transform="translate(490, 110) rotate(-90)">
<tspan x="0" y="-50">X</tspan>
<tspan x="0" y="0">X</tspan>
</text>
</svg>

After

Width:  |  Height:  |  Size: 1.7 KiB

View File

@@ -0,0 +1,4 @@
<svg viewBox="0 0 200 200" xmlns="http://www.w3.org/2000/svg">
<rect width="100%" height="100%" fill="white"/>
<rect x="60" y="40" width="80" height="120" fill="black"/>
</svg>

After

Width:  |  Height:  |  Size: 181 B

View File

@@ -0,0 +1,27 @@
<svg viewBox="0 0 200 200" xmlns="http://www.w3.org/2000/svg">
<rect width="100%" height="100%" fill="white"/>
<g transform="matrix(2 0 0 3 100 136)">
<!-- Explanation of the transform above:
The bug is about text-anchor="middle" not working properly when there is a
transform with scaling.
So, we create a transform with horizontal scaling 2, and vertical scaling 3.
Then we translate by 100 pixels horizontally (200/2 of the viewBox width), and
136 pixels vertically, because of the following:
In the Ahem font, each glyph is a square - https://web-platform-tests.org/writing-tests/ahem.html
The ascent above the baseline is 0.8em, and the descent below the baseline
is 0.2em. So, at font-size=40 it means the top is 0.8*40 = 32 units above the baseline. Since
the vertical scaling factor is 3, we translate by 32*3=96 pixels in the Y axis, plus an additional
(200 - (40 * 3)) / 2 = 40 pixels, thus adding up to the 136 pixels in the transform above.
The vertical translation will center the glyph vertically in the available space.
The bug is about the glyph not being horizontally centered in the available space.
-->
<text x="0" y="0" fill="black" font-family="Ahem" font-size="40" text-anchor="middle">W</text>
</g>
</svg>

After

Width:  |  Height:  |  Size: 1.3 KiB

View File

@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<svg xmlns="http://www.w3.org/2000/svg"
width="600" height="72" viewBox="0 0 600 72">
<text x="100" y="50" text-anchor="start" font-size="20">00-24-AF-2A-55-FC :MAC כתובת</text>
</svg>

After

Width:  |  Height:  |  Size: 238 B

View File

@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<svg xmlns="http://www.w3.org/2000/svg"
width="600" height="72" viewBox="0 0 600 72"
direction="rtl" xml:lang="he">
<title direction="ltr" xml:lang="en">Right-to-left Text</title>
<desc direction="ltr" xml:lang="en">
An example for using the 'direction' and 'unicode-bidi' properties
in documents that predominantly use right-to-left languages.
</desc>
<text x="100" y="50" text-anchor="end" font-size="20"> כתובת MAC:&#x200F;
<tspan direction="ltr" unicode-bidi="embed">00-24-AF-2A-55-FC</tspan>
</text>
</svg>

After

Width:  |  Height:  |  Size: 592 B

View File

@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<svg xmlns="http://www.w3.org/2000/svg" width="600" height="100">
<rect x="0" y="0" width="100%" height="100%" fill="white"/>
<line x1="300" y1="0" x2="300" y2="100" stroke-width="2" stroke="blue"/>
<line x1="0" y1="50" x2="600" y2="50" stroke-width="2" stroke="blue"/>
<rect x="200" y="14" width="80" height="20" fill="black"/>
<rect x="240" y="34" width="40" height="20" fill="black"/>
</svg>

After

Width:  |  Height:  |  Size: 445 B

View File

@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<svg xmlns="http://www.w3.org/2000/svg" width="600" height="100">
<rect x="0" y="0" width="100%" height="100%" fill="white"/>
<line x1="300" y1="0" x2="300" y2="100" stroke-width="2" stroke="blue"/>
<line x1="0" y1="50" x2="600" y2="50" stroke-width="2" stroke="blue"/>
<text text-anchor="end" transform="translate(300, 50)"
font-family="Ahem" font-size="20"
dx="-20" dy="-20">ABCD<tspan dx="-40" dy="1em">AB</tspan></text>
</svg>

After

Width:  |  Height:  |  Size: 495 B

View File

@@ -0,0 +1,4 @@
<svg xmlns="http://www.w3.org/2000/svg" width="50" height="50">
<text style="font: 5px Ahem;" x="5" y="10">X</text>
<text style="font: 5px Ahem;" x="5" y="25">XX</text>
</svg>

After

Width:  |  Height:  |  Size: 177 B

View File

@@ -0,0 +1,5 @@
<svg xmlns="http://www.w3.org/2000/svg" width="50" height="50">
<text style="font: 5px Ahem;" x="5" y="10">X<a style="display:none">X</a><tspan style="display:none">X</tspan></text>
<text style="font: 5px Ahem;" x="5" y="25">X<tspan><a style="display:none">X</a><tspan style="display:none">X<tspan style="display:inline" x="40">X</tspan><tspan style="display:block" x="45">X</tspan></tspan>X</tspan></text>
<text style="font: 5px Ahem; display: none" x="5" y="40">XXXXXX</text>
</svg>

After

Width:  |  Height:  |  Size: 487 B

View File

@@ -0,0 +1,11 @@
<svg xmlns="http://www.w3.org/2000/svg" width="500" height="500">
<style>
text {
font: 50px Sans;
fill: black;
}
</style>
<text x="50" y="100">Hello world!</text>
<text transform="translate(50, 200) rotate(45)">Hello again!</text>
</svg>

After

Width:  |  Height:  |  Size: 267 B

View File

@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<svg xmlns="http://www.w3.org/2000/svg" width="600" height="300">
<rect x="0" y="0" width="100%" height="100%" fill="white"/>
<line x1="50%" y1="0" x2="50%" y2="100%" stroke-width="2" stroke="blue"/>
<line x1="0" y1="100" x2="100%" y2="100" stroke-width="2" stroke="blue"/>
<rect x="280" y="64" width="20" height="20" fill="black"/>
<rect x="260" y="84" width="40" height="20" fill="black"/>
</svg>

After

Width:  |  Height:  |  Size: 449 B

View File

@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<svg xmlns="http://www.w3.org/2000/svg" width="600" height="300">
<rect x="0" y="0" width="100%" height="100%" fill="white"/>
<line x1="50%" y1="0" x2="50%" y2="100%" stroke-width="2" stroke="blue"/>
<line x1="0" y1="100" x2="100%" y2="100" stroke-width="2" stroke="blue"/>
<!-- If the dx on the second span is larger than the width of the first span... -->
<text x="50%" y="100" font-family="Ahem" font-size="20" text-anchor="end"><tspan dy="-1em">A</tspan><tspan dx="-40" dy="1em">BC</tspan></text>
</svg>

After

Width:  |  Height:  |  Size: 558 B

View File

@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<svg xmlns="http://www.w3.org/2000/svg" width="600" height="600">
<rect x="0" y="0" width="100%" height="100%" fill="white"/>
<text x="100" y="100" font-family="Ahem" font-size="20">ÉAppAÉÉAp</text>
</svg>

After

Width:  |  Height:  |  Size: 253 B

View File

@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<svg xmlns="http://www.w3.org/2000/svg" width="600" height="600">
<rect x="0" y="0" width="100%" height="100%" fill="white"/>
<text x="100" y="100" font-family="Ahem" font-size="20">ÉAp<tspan direction="rtl" unicode-bidi="bidi-override">ÉAp</tspan>ÉAp</text>
</svg>

After

Width:  |  Height:  |  Size: 313 B

View File

@@ -0,0 +1,5 @@
<svg xmlns="http://www.w3.org/2000/svg" width="50" height="50">
<text style="font: 5px Ahem;" x="5" y="10">X</text>
<text style="font: 5px Ahem;" x="5" y="25">X</text>
<text style="font: 5px Ahem;" x="20" y="25">X</text>
</svg>

After

Width:  |  Height:  |  Size: 230 B

View File

@@ -0,0 +1,4 @@
<svg xmlns="http://www.w3.org/2000/svg" width="50" height="50">
<text style="font: 5px Ahem;" x="5" y="10">X<tspan x="10" style="visibility:hidden">X</tspan><tspan style="visibility:hidden"><tspan x="15">X</tspan></tspan></text>
<text style="font: 5px Ahem;" x="5" y="25">X<tspan><tspan x="10" y="25" style="visibility:hidden">X</tspan><tspan x="15" style="visibility:hidden">X</tspan><tspan x="20">X</tspan></tspan></text>
</svg>

After

Width:  |  Height:  |  Size: 432 B

View File

@@ -0,0 +1,5 @@
<svg xmlns="http://www.w3.org/2000/svg" width="50" height="50">
<text style="font: 5px Ahem;" x="5" y="10">X<a style="visibility:hidden">X</a><tspan style="visibility:hidden">X</tspan></text>
<text style="font: 5px Ahem;" x="5" y="25">X<tspan><a style="visibility:hidden">X</a><tspan style="visibility:hidden">X</tspan>X</tspan></text>
<text style="font: 5px Ahem; visibility: hidden" x="5" y="40">XXXXXX</text>
</svg>

After

Width:  |  Height:  |  Size: 421 B