Including Liberation .ttf fonts in a grails war?

帅比萌擦擦* 提交于 2019-12-01 11:47:45

问题


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.

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


回答1:


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>

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



来源:https://stackoverflow.com/questions/6711480/including-liberation-ttf-fonts-in-a-grails-war

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!