在 SVG 中渲染 truetype 字体时出现问题

发布于 2024-08-16 03:07:45 字数 733 浏览 5 评论 0原文

我在通过 fop 将 svg 内的 truetype 字体渲染为 pdf 时遇到问题。

在最终的 pdf 中,字体是 Times New Roman,而不是我期望的 truetype 字体。

该文档的主要字体系列使用 Type 1 字体,并且还使用我生成的字体规格,并且这些字体规格显示正确。我认为 truetype 版本的字体过去只是为了图表而添加的。

奇怪的是,这在一个阶段起作用,但似乎已经停止工作,我现在无法让它恢复工作,因为我不明白它一开始是如何工作的。为了尝试让它恢复工作,我尝试了 Java 6、Java 5 和 FOP 0.95 和 0.93 以及最新的 FOP 主干的不同组合,但都没有成功。即使在 fop 生成中启用了完整跟踪,我也没有看到字体被 Times New Roman 替换的情况,但我认为这是因为 Batik 负责此渲染。

我已经运行了一些示例 Java 代码,并且 AWT 似乎可以正确地看到 TrueType 字体,我相信这就是 Batik 正在使用的字体。

我还尝试在 fop.xconf 文件中使用字体替换,但这似乎没有效果。在 fop.xconf 中,我只定义了 Type 1 字体和另一种 True Type 字体 Zapfdingbats,它们在 pdf 中得到了正确处理。我是否还应该在此处添加其他 truetype 字体,但检查我们的版本历史记录,它过去似乎并不存在。

我在这里缺少什么吗,因为我认为蜡染会采用 Windows ttf 字体并渲染它,但这似乎不起作用。任何帮助将不胜感激。 谢谢, 克罗克德

I'm having an issue with the rendering of a truetype font inside an svg being rendered to a pdf through fop.

In the final pdf the font comes out with Times New Roman instead of the truetype font I had expected.

The main font family of the document is using Type 1 fonts and are also using font metrics that I generated and these are appearing correctly. I think the truetype version of the font was added simply for the chart in the past.

The strange thing is that this was working at one stage and appears to have stopped working and I now cannot get it back working as I don't understand how it would have worked in the first place. To try and get it back working I have gone through different combinations of Java 6, Java 5 and FOP 0.95 and 0.93 and the latest FOP trunk all without success. Even with full trace enabled in the fop generation I see no mention of the font being substituted with Times New Roman but I assume this is because Batik takes responsibilty for this rendering.

I have run some sample Java code and the TrueType font seems to be correctly seen by AWT which I believe is what Batik is using.

I've also tried using font-substitions in the fop.xconf file but this didn't seem to have an effect. In the fop.xconf I have only defined the Type 1 fonts and one other True Type Font Zapfdingbats which are handled correctly in the pdf. Should I also add the other truetype font here but checking our version history it doesn't seem to have been there in the past.

Is there anything I'm missing here as I thought the batik would take the windows ttf font and render it but this doesn't seem to work. Any help would be greatly appreciated.
Thanks,
Crocked

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

痕至 2024-08-23 03:07:45

看看 FOP 用户邮件列表上的以下答案:

因此,要实现此功能,您应该执行以下操作:

  • 使用 FOP 0.95
  • 不要使用通过 TTFReader 生成的 XML 字体规格文件。这些都不再需要了。
  • 确保您要使用的字体已安装在操作系统中(以便 Batik 可以通过 AWT/Java2D 访问它们)并配置为 FOP(最简单的方法:http://xmlgraphics.apache.org/fop/0.95/fonts.html#basics)
  • 使用正确的字体系列名称SVG。该字体的 PostScript 名称将不起作用。

Take a look at the following answers made on the FOP users mailing list:

So, to make this work, you should do the following:

  • Use FOP 0.95
  • Don't work with XML font metrics files generated through TTFReader. These are no longer necessary.
  • Make sure the fonts you want to use are installed in your operating system (so Batik has access to them via AWT/Java2D) and configured for FOP (easiest way: , http://xmlgraphics.apache.org/fop/0.95/fonts.html#basics)
  • Use the right font family name of the font in SVG. The font's PostScript name won't work.
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文