蜡染库升级后,Apache FOP XSLT 的 svg-text 渲染质量发生了变化
我们最近从 FOP 2.1 迁移到 FOP 2.6,并见证了 PNG 输出质量的变化。 在我们的应用程序中,fop 与抗锯齿关闭一起使用,而在 fop2.1 (+batik 1.8) 中,文本输出在没有抗锯齿的情况下呈现得很好。
但在我们升级到 FOP 2.6 后,PNG 输出是使用抗锯齿生成的,而不考虑 fop.xconf 设置或文本渲染设置。
我通过设置不同的文本渲染值尝试了各种选项,但无法再获得相同的质量。我尝试了不同版本的 Batik lib,似乎从 v1.9 开始就可以看到这种变化。 似乎 batik 忽略了 fop.xconf 中的抗锯齿关闭配置。
fop.xconf
<?xml version="1.0"?>
<fop version="1.0">
<complex-scripts disabled="false"/>
<renderers>
<renderer mime="image/png">
<color-mode>rgb</color-mode>
<transparent-page-background>false</transparent-page-background>
<background-color>white</background-color>
<anti-aliasing>false</anti-aliasing>
<rendering>false</rendering>
<fonts>
</fonts>
</renderer>
</renderers>
</fop>
示例 XSL
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.1" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format" exclude-result-prefixes="fo">
<xsl:output method="xml" version="1.0" omit-xml-declaration="no" indent="yes"/>
<xsl:param name="versionParam" select="'1.0'"/>
<xsl:template match="articles[@page=1]">
<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
<fo:layout-master-set>
<fo:simple-page-master master-name="simpleA4" page-height="168px" page-width="384px">
<fo:region-body /> <!-- background-color="#FFFF00" -->
</fo:simple-page-master>
</fo:layout-master-set>
<fo:page-sequence master-reference="simpleA4">
<fo:flow flow-name="xsl-region-body">
<!-- Temporarily Unavailable -->
<fo:block-container position="absolute" overflow="visible">
<fo:block>
<fo:instream-foreign-object xmlns:svg="http://www.w3.org/2000/svg">
<svg xmlns="http://www.w3.org/2000/svg" height="100" width="240" viewport="10 10 290 200">
<text x="150" y="20" fill="black" text-anchor="start" font-size="22pt" text-rendering="optimizeLegibility">STWOA</text>
</svg>
</fo:instream-foreign-object>
</fo:block>
</fo:block-container>
</fo:flow>
</fo:page-sequence>
</fo:root>
</xsl:template>
</xsl:stylesheet>
任何帮助或提示将不胜感激!
We recently migrated from FOP 2.1 to FOP 2.6 and witnessed a change in PNG output quality.
In our application fop is used with antialiasing OFF and in fop2.1 ( +batik 1.8) the text output is rendered nicely with no antialiasing .
But after we upgraded to FOP 2.6, PNG output is generated with antialiasing, without considering the fop.xconf setting or the text-rendering settings.
I tried various options by setting different text-rendering values but not able to get the same quality any more. I tried different versions of Batik lib and it seems that this change is seen from v1.9 onwards.
Seems like batik is ignoring anti-aliasing OFF configuration from the fop.xconf .
fop.xconf
<?xml version="1.0"?>
<fop version="1.0">
<complex-scripts disabled="false"/>
<renderers>
<renderer mime="image/png">
<color-mode>rgb</color-mode>
<transparent-page-background>false</transparent-page-background>
<background-color>white</background-color>
<anti-aliasing>false</anti-aliasing>
<rendering>false</rendering>
<fonts>
</fonts>
</renderer>
</renderers>
</fop>
Sample XSL
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.1" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format" exclude-result-prefixes="fo">
<xsl:output method="xml" version="1.0" omit-xml-declaration="no" indent="yes"/>
<xsl:param name="versionParam" select="'1.0'"/>
<xsl:template match="articles[@page=1]">
<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
<fo:layout-master-set>
<fo:simple-page-master master-name="simpleA4" page-height="168px" page-width="384px">
<fo:region-body /> <!-- background-color="#FFFF00" -->
</fo:simple-page-master>
</fo:layout-master-set>
<fo:page-sequence master-reference="simpleA4">
<fo:flow flow-name="xsl-region-body">
<!-- Temporarily Unavailable -->
<fo:block-container position="absolute" overflow="visible">
<fo:block>
<fo:instream-foreign-object xmlns:svg="http://www.w3.org/2000/svg">
<svg xmlns="http://www.w3.org/2000/svg" height="100" width="240" viewport="10 10 290 200">
<text x="150" y="20" fill="black" text-anchor="start" font-size="22pt" text-rendering="optimizeLegibility">STWOA</text>
</svg>
</fo:instream-foreign-object>
</fo:block>
</fo:block-container>
</fo:flow>
</fo:page-sequence>
</fo:root>
</xsl:template>
</xsl:stylesheet>
Any help or hints would be highly appreciated !
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论