Один из непростых квестов, с которыми мне пришлось столкнуться в последнее время - добавление китайских шрифтов для создания документов с помощью библиотеки jasperreports.
Решил так:
1. Скачал китайский true type шрифт ARIALUNI.TTF вот отсюда: https://community.jaspersoft.com/sites/default/files/files/Report24775-eastAsian.zip
2. Добавил в каталог resources проекта файл шрифтов, а также следующие файлы:
Место размещения файлов должно быть следующим:
3. Проверил доступность шрифтов для библиотеки jasperreports:
Решил так:
1. Скачал китайский true type шрифт ARIALUNI.TTF вот отсюда: https://community.jaspersoft.com/sites/default/files/files/Report24775-eastAsian.zip
2. Добавил в каталог resources проекта файл шрифтов, а также следующие файлы:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<fontFamilies> | |
<fontFamily name="ARIALUNI"> | |
<normal><![CDATA[fonts/ARIALUNI/ARIALUNI.TTF]]></normal> | |
<pdfEncoding><![CDATA[Identity-H]]></pdfEncoding> | |
<exportFonts/> | |
</fontFamily> | |
</fontFamilies> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
net.sf.jasperreports.extension.registry.factory.fonts=net.sf.jasperreports.engine.fonts.SimpleFontExtensionsRegistryFactory | |
net.sf.jasperreports.extension.simple.font.families.ireportfamily1565796714618=fonts/fontsfamily1565796714618.xml |
Место размещения файлов должно быть следующим:
3. Проверил доступность шрифтов для библиотеки jasperreports:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import net.sf.jasperreports.extensions.ExtensionsEnvironment; | |
import net.sf.jasperreports.engine.fonts.FontFamily; | |
public class Application { | |
public static void main(String args[]) { | |
List<FontFamily> families = ExtensionsEnvironment.getExtensionsRegistry().getExtensions(FontFamily.class); | |
System.out.println("Available fonts: " + families); | |
} | |
} |