在 grails 战争中包括 Liberation .ttf 字体? [英] Including Liberation .ttf fonts in a grails war?

查看:22
本文介绍了在 grails 战争中包括 Liberation .ttf 字体?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我如何用我的 grails war 打包 liberation 字体?这些字体可能在我部署到的服务器上不可用,而我的报告系统需要这些字体.

How do I package the liberation fonts with my grails war? The fonts may not be available on the servers I'm deploying to, and I need the fonts for my reporting system.

我如何在 war 中包含字体,以便它们位于类路径上并且可供 JVM 使用?

How do I include the fonts in the war such that they're on the classpath and available to the JVM?

推荐答案

如果您明确将它们用于 jasper-reports,那么您可以这样做.

If you're using them for jasper-reports explicitly, then you can just do this.

grails-app/conf/jasperreports_extension.properties

net.sf.jasperreports.extension.registry.factory.simple.font.families=net.sf.jasperreports.engine.fonts.SimpleFontExtensionsRegistryFactory
net.sf.jasperreports.extension.simple.font.families.liberationsans=jasper_fonts.xml

grails-app/conf/jasper_fonts.xml

<?xml version="1.0" encoding="UTF-8"?>
<fontFamilies>
    <fontFamily name="Liberation Sans">
        <normal>lib/fonts/liberation-fonts-ttf-1.07.0/LiberationSans-Regular.ttf</normal>
        <bold>lib/fonts/liberation-fonts-ttf-1.07.0/LiberationSans-Bold.ttf</bold>
        <italic>lib/fonts/liberation-fonts-ttf-1.07.0/LiberationSans-Italic.ttf</italic>
        <boldItalic>lib/fonts/liberation-fonts-ttf-1.07.0/LiberationSans-BoldItalic.ttf</boldItalic>
        <pdfEncoding>Identity-H</pdfEncoding>
        <pdfEmbedded>true</pdfEmbedded>
        <exportFonts>
            <export key="net.sf.jasperreports.html">'Liberation Sans', Arial, Helvetica, sans-serif</export>
            <export key="net.sf.jasperreports.xhtml">'Liberation Sans', Arial, Helvetica, sans-serif</export>
        </exportFonts>
    </fontFamily>
</fontFamilies>

根据您的 TTF 字体进行适当修改.确保记下 元素,这样您的 HTML 报告就不会中断.

Modify as appropriate for your TTF font. Make sure you note the <exportFonts> element, so your HTML reports don't break.

这篇关于在 grails 战争中包括 Liberation .ttf 字体?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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