Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does java.awt.FontFormatException: bad table, tag=1196445523 indicating?

I have followed this link to add fonts to my jasper report project, but i get this exception when trying to build the report, what does this exception mean any way? i can't find any solution on how to solve it. note that i am trying to add Ubuntu-LI font

17:26:35-218 -  - raysis.rohani.rg.report.builder.ReportBuilder.show(120) - error in showing the jasper report (called from ReportBuilder)
net.sf.jasperreports.engine.JRRuntimeException: java.awt.FontFormatException: bad table, tag=1196445523
    at net.sf.jasperreports.engine.fonts.SimpleFontFace.<init>(SimpleFontFace.java:104)
    at net.sf.jasperreports.engine.fonts.SimpleFontFace.<init>(SimpleFontFace.java:128)
    at net.sf.jasperreports.engine.fonts.SimpleFontFace.getInstance(SimpleFontFace.java:67)
    at net.sf.jasperreports.engine.fonts.SimpleFontFamily.setNormal(SimpleFontFamily.java:99)
    at net.sf.jasperreports.engine.fonts.SimpleFontExtensionHelper.parseFontFamily(SimpleFontExtensionHelper.java:261)
    at net.sf.jasperreports.engine.fonts.SimpleFontExtensionHelper.parseFontFamilies(SimpleFontExtensionHelper.java:232)
    at net.sf.jasperreports.engine.fonts.SimpleFontExtensionHelper.loadFontFamilies(SimpleFontExtensionHelper.java:193)
    at net.sf.jasperreports.engine.fonts.SimpleFontExtensionHelper.loadFontFamilies(SimpleFontExtensionHelper.java:162)
    at net.sf.jasperreports.engine.fonts.FontExtensionsRegistry.getExtensions(FontExtensionsRegistry.java:56)
    at net.sf.jasperreports.extensions.DefaultExtensionsRegistry.getExtensions(DefaultExtensionsRegistry.java:110)
    at net.sf.jasperreports.engine.DefaultJasperReportsContext.getExtensions(DefaultJasperReportsContext.java:246)
    at net.sf.jasperreports.engine.fonts.FontUtil.getFontInfo(FontUtil.java:185)
    at net.sf.jasperreports.engine.fonts.FontUtil.getAwtFontFromBundles(FontUtil.java:245)
    at net.sf.dynamicreports.design.transformation.StyleResolver.getFont(StyleResolver.java:96)
    at net.sf.dynamicreports.design.transformation.StyleResolver.getFont(StyleResolver.java:71)
    at net.sf.dynamicreports.design.transformation.StyleResolver.getFontHeight(StyleResolver.java:52)
    at net.sf.dynamicreports.design.transformation.TemplateTransform.getTextFieldHeight(TemplateTransform.java:967)
    at net.sf.dynamicreports.design.transformation.ComponentTransform.textField(ComponentTransform.java:332)
    at net.sf.dynamicreports.design.transformation.ComponentTransform.component(ComponentTransform.java:152)
    at net.sf.dynamicreports.design.transformation.ComponentTransform.list(ComponentTransform.java:285)
    at net.sf.dynamicreports.design.transformation.BandTransform.band(BandTransform.java:184)
    at net.sf.dynamicreports.design.transformation.BandTransform.transform(BandTransform.java:74)
    at net.sf.dynamicreports.design.base.DRDesignReport.transform(DRDesignReport.java:135)
    at net.sf.dynamicreports.design.base.DRDesignReport.<init>(DRDesignReport.java:107)
    at net.sf.dynamicreports.design.base.DRDesignReport.<init>(DRDesignReport.java:99)
    at net.sf.dynamicreports.jasper.builder.JasperReportBuilder.toJasperReportDesign(JasperReportBuilder.java:261)
    at net.sf.dynamicreports.jasper.builder.JasperReportBuilder.getJasperParameters(JasperReportBuilder.java:288)
    at net.sf.dynamicreports.jasper.builder.JasperReportBuilder.toJasperPrint(JasperReportBuilder.java:299)
    at net.sf.dynamicreports.jasper.builder.JasperReportBuilder.show(JasperReportBuilder.java:328)
    at raysis.rohani.rg.report.JasperBuilder.show(JasperBuilder.java:121)
    at raysis.rohani.rg.report.builder.ReportBuilder.show(ReportBuilder.java:118)
    at raysis.rohani.rg.report.test.ReportMaker.main(ReportMaker.java:46)
Caused by: java.awt.FontFormatException: bad table, tag=1196445523
    at sun.font.TrueTypeFont.init(TrueTypeFont.java:547)
    at sun.font.TrueTypeFont.<init>(TrueTypeFont.java:191)
    at sun.font.SunFontManager.createFont2D(SunFontManager.java:2460)
    at java.awt.Font.<init>(Font.java:614)
    at java.awt.Font.createFont0(Font.java:968)
    at java.awt.Font.createFont(Font.java:876)
    at net.sf.jasperreports.engine.fonts.SimpleFontFace.<init>(SimpleFontFace.java:100)
    ... 31 more

any help will be highly apreciated

like image 959
MoienGK Avatar asked Dec 14 '13 14:12

MoienGK


2 Answers

In my case, I'm using Maven 3.3.3 to build my releases. The maven-resource-plugin was filtering the resources and applying UTF-8 in font files (.ttf).

So, I added this configuration and it solved the problem.

<build>
    <resources>
        <resource>
            <directory>${project.basedir}/src/main/resources</directory>
            <filtering>false</filtering>
            <includes>
                <include>**/jasperreports_extension.properties</include>
                <include>**/tecsofti-fonts.xml</include>
                <include>**/*.ttf</include>
            </includes>
        </resource>
    </resources>
</build>
like image 59
Leonardo Pessoa Avatar answered Oct 16 '22 02:10

Leonardo Pessoa


I managed to solve it by changing relative URL of font to absolute URL. But i don't know why relative URL causes that problem.

like image 34
MoienGK Avatar answered Oct 16 '22 04:10

MoienGK