有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

java JasperReports默认字体

我有一个JasperReport模板(在服务器上生成),带有一个样式化的文本字段(RTF)。此字段的内容由用户生成,因此它可以包含客户端PC上安装的所有字体(称为字体X)。如果我现在在服务器上生成报告,则没有字体X,因此我希望将所有未知字体替换为字体Y

但是我得到的只是一个错误,没有找到字体。通常不需要关闭字体检查的功能(net.sf.jasperreports.awt.ignore.missing.font),因为我希望检查jrxml的字体

有没有办法设置默认字体(无需修改Jasper源代码)?(我已经在JRTyledText或JRTextUtil上找到了一些要点。)


共 (1) 个答案

  1. # 1 楼答案

    您可以尝试使用net.sf.jasperreports.default.font.name属性

    或者您可以使用default style

    <style name="Base" isDefault="true" ...>
    

    有关更多详细信息,您可以阅读此articleDefault Fonts and Inheritance部分

    更新:

    JasperReports Ultimate Guide的引用

    We strongly encourage people to use in their reports only fonts that are provided in font extensions. This is the only way to be sure that the fonts will be available to the application when the reports are executed at runtime. Using system fonts always brings the risk that the reports do not work properly when deployed on a machine that does not have those fonts installed.