You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-dev@xmlgraphics.apache.org by sp...@chezphil.org on 2001/11/05 16:27:04 UTC
viewBox: distorted text?
Hi FOP people,
A recent message indicated that viewBox on SVG should now work, so
I've taken out the kludgey work-around that I previously used to cope
with not having this. And yes it does - nearly - work. But it looks
to me as if there's some sort of strange rounding going on in the
coordinates. I don't get this when I render the same SVG source to
bitmaps using Batik's rasteriser, or when I run FOP with -awt, so I
reckon the problem is in the PDF code.
There's an example below. This shows the same SVG fragment four
times. It contains a single svg:text item. The first time, this is
unmodified and comes out distorted: it looks like some coordinates
have been slightly displaced or rounded. [If it's not distorted for
you, please let me know!]
Assuming that this was something getting rounded to an integer when it
shouldn't be I scaled the viewbox by 10 and put a
transform="scale(10)" around the contents. This is the second
example, and it looks fine. Scaling by 100 in the third example also
works. But when I scale by 1000, in the fourth example, the image is
reduced to a single point! Unfortunately there isn't a single scale
factor that works for all of my SVG source files.
Any ideas what's up? I'm using FOP 0.20.2, using the Sun JRE version
1.3.1, and I get similar results on Solaris and Windows. The shapes
of the distorted characters differ on the different platforms,
presumably because the fonts are different.
Here's the code:
<?xml version="1.0" encoding="UTF-8"?>
<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
<fo:layout-master-set>
<fo:simple-page-master margin-right="25mm" margin-left="25mm"
margin-bottom="20mm" margin-top="15mm"
page-height="297mm" page-width="210mm"
master-name="a4">
<fo:region-before extent="10mm"/>
<fo:region-after extent="10mm"/>
<fo:region-body margin-bottom="15mm" margin-top="15mm"/>
</fo:simple-page-master>
</fo:layout-master-set>
<fo:page-sequence master-name="a4">
<fo:flow flow-name="xsl-region-body">
<fo:block>
<fo:instream-foreign-object>
<svg:svg xmlns:svg="http://www.w3.org/2000/svg"
fill="none" width="5cm" height="1cm"
viewBox="0 0 5.0 1.0"
preserveAspectRatio="xMidYMid meet"
contentScriptType="text/ecmascript"
contentStyleType="text/css">
<svg:text fill="#000000" text-anchor="start" font-size="0.3"
x="0.1" y="0.2">x1: Hello World</svg:text>
</svg:svg>
</fo:instream-foreign-object>
</fo:block>
<fo:block>
<fo:instream-foreign-object>
<svg:svg xmlns:svg="http://www.w3.org/2000/svg"
fill="none" width="5cm" height="1cm"
viewBox="0 0 50.0 10.0"
preserveAspectRatio="xMidYMid meet"
contentScriptType="text/ecmascript"
contentStyleType="text/css">
<svg:g transform="scale(10.0)">
<svg:text fill="#000000" text-anchor="start" font-size="0.3"
x="0.1" y="0.2">x10: Hello World</svg:text>
</svg:g>
</svg:svg>
</fo:instream-foreign-object>
</fo:block>
<fo:block>
<fo:instream-foreign-object>
<svg:svg xmlns:svg="http://www.w3.org/2000/svg"
fill="none" width="5cm" height="1cm"
viewBox="0 0 500 100"
preserveAspectRatio="xMidYMid meet"
contentScriptType="text/ecmascript"
contentStyleType="text/css">
<svg:g transform="scale(100)">
<svg:text fill="#000000" text-anchor="start" font-size="0.3"
x="0.1" y="0.2">x100: Hello World</svg:text>
</svg:g>
</svg:svg>
</fo:instream-foreign-object>
</fo:block>
<fo:instream-foreign-object>
<svg:svg xmlns:svg="http://www.w3.org/2000/svg"
fill="none" width="5cm" height="1cm"
viewBox="0 0 5000 1000"
preserveAspectRatio="xMidYMid meet"
contentScriptType="text/ecmascript"
contentStyleType="text/css">
<svg:g transform="scale(1000)">
<svg:text fill="#000000" text-anchor="start" font-size="0.3"
x="0.1" y="0.2">x1000: Hello World</svg:text>
</svg:g>
</svg:svg>
</fo:instream-foreign-object>
</fo:flow>
</fo:page-sequence>
</fo:root>
Thanks for your attention.
--Phil.
---------------------------------------------------------------------
To unsubscribe, e-mail: fop-dev-unsubscribe@xml.apache.org
For additional commands, email: fop-dev-help@xml.apache.org