Use custom fonts when creating pdf using iReport
You should use the Font Extensions
mechanism.
After creating the font and exporting it as a jar file you should add generated jar file to the application classpath.
a) Creating new font in iReport (via Options -> Fonts -> "Install Font" Button)
b) Exporting the new font (or the existing one) as jar file in iReport (via Options -> Fonts -> "Export as extension" Button)
a) Creating new font in JasperReports Studio (via Window -> Preferences -> JasperStudio -> Fonts -> "Add" Button)
b) Configure your fonts
c) Create JAR with your fonts in it
You can find more information about using Font Extensions
here.
Adding a font to a jasper report
I know this is a bit late answere XD, but now you have an oficial simple guide on how you could do this steps by steps.
GUIDE
It tells you how to used it on a simple jasper report file, and then how to export and import it to be used on all reports.
When export a report to PDF change the font
You should use the Font Extensions mechanism.
Steps
Creating font in Jaspersoft Studio
You should create a new font with Window -> Preferences dialog:
With Font Family dialog you can set ttf file for your font:
Creating report's style
You should create a new style with help of context menu:
After that you can set font for this style:
And after that you can use this new style:
The sample
The jrxml file:
<?xml version="1.0" encoding="UTF-8"?>
<!-- Created with Jaspersoft Studio version last-->
<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="test_courier" language="groovy" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="2010b76c-0fe5-4a27-9c86-6846a6f9cc6a">
<property name="com.jaspersoft.studio.data.defaultdataadapter" value="Sample DB"/>
<style name="CustomFont" fontName="Courier New"/>
<queryString>
<![CDATA[select task from tasks]]>
</queryString>
<field name="TASK" class="java.lang.String"/>
<title>
<band height="79" splitType="Stretch">
<staticText>
<reportElement uuid="9205f787-f3b4-4b21-b2d9-19f52824e187" style="CustomFont" x="280" y="36" width="70" height="20"/>
<textElement/>
<text><![CDATA[Title]]></text>
</staticText>
</band>
</title>
<detail>
<band height="20" splitType="Stretch">
<textField>
<reportElement uuid="f23e8674-c45d-4dc7-92f3-93e5d0b41c16" style="CustomFont" x="0" y="0" width="70" height="20"/>
<textElement/>
<textFieldExpression><![CDATA[$F{TASK}]]></textFieldExpression>
</textField>
</band>
</detail>
</jasperReport>
The report's design in Studio:
And the result will be (pdf file generated by Jaspersoft Studion and opened in Adobe Reader):
Note:
You can find more info about Font Extensions here
Related Topics
Why Does Eclipse Complain About @Override on Interface Methods
Spark SQL How to Explode Without Losing Null Values
Execute .Jar File from a Java Program
How to Generate Cdata Block Using Jaxb
Reference Is Ambiguous with Generics
Preserving Parameter/Argument Names in Compiled Java Classes
Why Can't a Generic Type Parameter Have a Lower Bound in Java
Select an Option from the Right-Click Menu in Selenium Webdriver - Java
How to Convert String to Date Without Knowing the Format
How to Read the Manifest File for a Webapp Running in Apache Tomcat
Eclipse Error: "Failed to Connect to Remote Vm"