大胆不能在Jaspersoft Studio中使用除sans serif之外的字体 [英] Bold not working in Jaspersoft Studio for fonts other than sans serif

查看:267
本文介绍了大胆不能在Jaspersoft Studio中使用除sans serif之外的字体的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Jaspersoft Studio中,我创建了一个报告,我希望以粗体显示标题。如果我使用sans serif字体,那么它正常工作。如果我使用其他字体,则在Jaspersoft Studio的预览中会显示粗体,但在Jasper服务器中运行报表时不显示。
请帮助。

In Jaspersoft Studio I have created a report where I want to display title in bold. If I use sans serif font then it is working correctly. If I use other fonts, bold is displayed in the preview of Jaspersoft Studio, but is not showing when the report is run in the Jasper server. Please help.

推荐答案

你需要创建一个jasper字体扩展jar并将它放入你的类路径中时间(编译jrxmls时)以及运行时(运行报告时)。以下是jar(例如 jasperreports-fonts-5.5.2.jar )的外观:

You need to create a jasper fonts extension jar and place it into your classpath both compile-time (while compiling the jrxmls) as well as run-time (while running reports). Here is how the jar (e.g. jasperreports-fonts-5.5.2.jar) should look:

jasperreports_extension.properties 应该包含很少的属性来初始化字体。 (我已经使用了基于弹簧的字体初始化。你可能需要在你的类路径中添加几个弹簧罐,如spring-core,spring-beans等,如果还没有的话。)

The jasperreports_extension.properties should contain few properties to initialize fonts. (I have used spring based fonts initialization. You might need to add couple of spring jars like spring-core, spring-beans etc. to your classpath if not already present.)

net.sf.jasperreports.extension.registry.factory.fonts=net.sf.jasperreports.extensions.SpringExtensionsRegistryFactory
net.sf.jasperreports.extension.fonts.spring.beans.resource=fonts/fonts_def.xml

现在 fonts.xml 定义要添加的字体。

Now the fonts.xml to defined what fonts you want to add.

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="http://www.springframework.org/schema/beans
           http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">

   <bean id="fontBean001" class="net.sf.jasperreports.engine.fonts.SimpleFontFamily">
       <property name="name" value="Tahoma"/>
       <property name="normal" value="fonts/Tahoma.ttf"/>
       <property name="bold" value="fonts/Tahoma_Bold.ttf"/>
       <property name="pdfEmbedded" value="true"/>
   </bean>

   <bean id="fontBean002" class="net.sf.jasperreports.engine.fonts.SimpleFontFamily">
        <property name="name" value="Arial"/>
        <property name="normal" value="fonts/Arial.ttf"/>
        <property name="bold" value="fonts/Arial_Bold.ttf"/>
        <property name="italic" value="fonts/Arial_Italic.ttf"/>
        <property name="boldItalic" value="fonts/Arial_Bold_Italic.ttf"/>
        <property name="pdfEmbedded" value="true"/>
    </bean>

</beans>

注意属性pdfEmbedded。最后为要添加到jar的字体添加.ttf文件。

Note the property "pdfEmbedded" is "true". Finally add the .ttf file for the fonts you want to add to jar.

这篇关于大胆不能在Jaspersoft Studio中使用除sans serif之外的字体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆