【问题标题】:Embedded ttf font in itext program not getting loaded in a Linux machineitext 程序中的嵌入式 ttf 字体未在 Linux 机器中加载
【发布时间】:2014-10-01 20:19:57
【问题描述】:

在我的程序中,我使用这样的东西 -

String arielunicodePath = config_Folder_Path+File.separatorChar
        +"resources"+File.separatorChar + "ARIALUNI.ttf";
arielunicodebase =  BaseFont.createFont(arielunicodePath, BaseFont.WINANSI,  BaseFont.EMBEDDED);

我已将 ARIALUNI.ttf 文件放在项目中的正确位置。

它在我的 Windows 机器上运行良好。但是当我将它部署到我们的 Linux 服务器时,上面的字体创建命令失败并出现以下错误 -

java.io.IOException: /x/programs/reporttransformationmsgd/config/resources/ARIALUNI.ttf not found as file or resource.

我确认该文件在程序正在寻找的确切位置上可用。

我在这里错过了什么?

【问题讨论】:

  • 我确认该文件在程序正在寻找的确切位置上可用。 - 您是否还检查了大小写相等? Linux 文件系统通常区分大小写,在我的 Windows 上,我找到了 ARIALUNI.TTF,而不是 ARIALUNI.ttf...
  • 是的,这正是问题所在。不错的收获:)
  • 很高兴为您提供帮助。我将评论作为答案。

标签: linux pdf fonts pdf-generation itext


【解决方案1】:

在 Windows 上开发和在 Linux 上部署时,有时会忘记 Linux 通常会以区分大小写的方式处理文件名,而 Windows 则不会。

在手头的情况下,程序寻找的文件名是ARIALUNI.ttf,而字体文件实际上(就像在 Windows 字体文件夹中一样)被命名为 ARIALUNI.TTF

在 Windows 上测试小写扩展意味着没有问题,而在 Linux 上它会导致 not found as file or resource IOException.

【讨论】:

    猜你喜欢
    • 2012-11-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-10-12
    • 1970-01-01
    • 2011-07-02
    • 2013-05-27
    • 1970-01-01
    相关资源
    最近更新 更多