java是什么awt.FontFormatException:坏表,标记=1196445523表示?

ac1kyiln  于 2023-04-28  发布在  Java
关注(0)|答案(4)|浏览(166)

我已经按照this link添加字体到我的碧玉报告项目,但我得到这个异常时,试图建立报告,这个异常是什么意思呢?我找不到解决的办法。注意我正在尝试添加Ubuntu-LI字体

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

任何帮助都将受到高度赞赏

uqdfh47h

uqdfh47h1#

在我的情况下,我使用Maven 3。3.3建立我的版本maven-resource-plugin正在过滤资源并在字体文件中应用UTF-8。ttf)。
所以,我添加了这个配置,它解决了这个问题。

<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>
dvtswwa3

dvtswwa32#

我设法解决它通过改变字体的相对URL到绝对URL。但我不知道为什么相对URL会导致这个问题。

dbf7pr2w

dbf7pr2w3#

我替换/fonts/FONT。TTF到./fonts/FONT。TTF及其工作说明:替换字体。xml和resources\jasperreports_extension。性能

rslzwgfq

rslzwgfq4#

在我的情况下,字体文件已损坏。当我更换它的时候它工作了。

相关问题