Jump to content
Changes to the Jaspersoft community edition download ×

michele.cucci

Recommended Posts

  • Replies 9
  • Created
  • Last Reply

Top Posters In This Topic

The font is probably not on the Server where you are running the report.  There is a section on handling fonts in the user documentation for Studio.  You may beed a font jar, which is loaded to the server.  Your report runs with the correct font in development because the font is likely on your laptop or desktop.

Link to comment
Share on other sites

  • 6 months later...
Hi guys, I'm having the same problem with font embed in PDF.

I have done all the steps to add a font in pdf.

 

(Source / Preferences / Fonts / Add) and added the jar generated in the application path. And nothing worked.

 

I defined the size font to 24, but when I've printed in pdf, the size font is 10.

Could someone help me with this, because the various tutorials of the internet has not worked.

 

Thank you.

 

Att


 

Astork

Link to comment
Share on other sites

  • 11 months later...

Sub-Report fonts not working - FIXED

I have a groovy/grails application from which I call my .jrxml files to render jasper reports.  Thse do not need to be compiled, but any reports having a sub-report MUST have the sub-report component compiled to a .jasper which is referenced from my applicatoin and called at runtime.

The font related issue I have been experiencing is that wherever I have called a pre-compiled sub-report, the fonts I use do not appear in either the right fontface, size or bold/italic - I simply lose control over the font altogether.  This has been with only the sub-report component of the whole report, the main report produces exactly as expected.

After searching the web, and the Japser comminity for 18 months, and trying the font import /export to .jar and import into my grails app, nothing worked.  I tried all of the suggested methods of adding each font as a .jar file, butn nothing seemed to work for me.

 

Finally, I upgraded the version of the jasper plugin I was using in my grails app, and instantly, the font issues vanished and the whole report was finally being rendered correctly, pre-compiled sub-reports and all!  The whole thing was finally playing ball.  That's after 18 months.

 

This fixed it!

Previosuly I had the following line in my BuildConfig.groovy file

compile ":jasper:1.8.0"

but when I changed it to the most recent version and re-compiled my project, all of the font face/size issues simply dissappeared.

 Here's my plugin line now.

compile "org.grails.plugins:jasper:1.11.0"

 

I sure hope this saves someone else from having to serach the web for 18 months.

 

Regards,

 

Icy

Link to comment
Share on other sites

EDIT to above post:  It seems as though my efforts (from the post above) were only a partial fix for the whole font issue.  It turns out that the true fix was to take the latest version of jasperreports-fonts-6.2.2.jar and unpack it (can be done by changing the .jar to .zip).

 

Once unpacked, I could edit the jasperreports_extension.properties to include new fontfaces I planned to add, following THIS example.  I also had to copy in the new font files and update the fonts.xml to include the new fonts and reference them, but that was a  simple copy and paste of a previous fontFamily and edit the fields.

 

Once saved, I could re-package the jar file with my own name (I used the java jar command jar -cfM myFonts.jar .)

 

With my new myFonts.jar in my grails lib directory, all fonts behaved as planned, including italic, bold and bold-italic.  Any fonts I reference in my jrxml which were not present, defaulted to a plain Helvetica.

 

Below is the resluting files.

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.dejavu=net/sf/jasperreports/fonts/fonts.xml
net.sf.jasperreports.extension.simple.font.families.arial=net/sf/jasperreports/fonts/fonts.xml
net.sf.jasperreports.extension.simple.font.families.timesnewroman=net/sf/jasperreports/fonts/fonts.xml

 

fonts.xml:

<?xml version="1.0" encoding="UTF-8"?>

<fontFamilies>

    <fontFamily name="Times New Roman">
        <normal>net/sf/jasperreports/fonts/timesnewroman/times.ttf</normal>
        <bold>net/sf/jasperreports/fonts/timesnewroman/timesbd.ttf</bold>
        <italic>net/sf/jasperreports/fonts/timesnewroman/timesi.ttf</italic>
        <boldItalic>net/sf/jasperreports/fonts/timesnewroman/timesbi.ttf</boldItalic>
        <pdfEncoding>Identity-H</pdfEncoding>
        <pdfEmbedded>true</pdfEmbedded>
        <exportFonts>
            <export key="net.sf.jasperreports.html">'Times New Roman', Arial, Helvetica, sans-serif</export>
            <export key="net.sf.jasperreports.xhtml">'Times New Roman', Arial, Helvetica, sans-serif</export>
        </exportFonts>
        <!--
        <locales>
            <locale>en_US</locale>
            <locale>de_DE</locale>
        </locales>
        -->
    </fontFamily>

    <fontFamily name="Arial">
        <normal>net/sf/jasperreports/fonts/arial/arial.ttf</normal>
        <bold>net/sf/jasperreports/fonts/arial/arialbd.ttf</bold>
        <italic>net/sf/jasperreports/fonts/arial/ariali.ttf</italic>
        <boldItalic>net/sf/jasperreports/fonts/arial/arialbi.ttf</boldItalic>
        <pdfEncoding>Identity-H</pdfEncoding>
        <pdfEmbedded>true</pdfEmbedded>
        <exportFonts>
            <export key="net.sf.jasperreports.html">'Arial', Arial, Helvetica, sans-serif</export>
            <export key="net.sf.jasperreports.xhtml">'Arial', Arial, Helvetica, sans-serif</export>
        </exportFonts>
        <!--
        <locales>
            <locale>en_US</locale>
            <locale>de_DE</locale>
        </locales>
        -->
    </fontFamily>
    
    <fontFamily name="DejaVu Sans">
        <normal>net/sf/jasperreports/fonts/dejavu/DejaVuSans.ttf</normal>
        <bold>net/sf/jasperreports/fonts/dejavu/DejaVuSans-Bold.ttf</bold>
        <italic>net/sf/jasperreports/fonts/dejavu/DejaVuSans-Oblique.ttf</italic>
        <boldItalic>net/sf/jasperreports/fonts/dejavu/DejaVuSans-BoldOblique.ttf</boldItalic>
        <pdfEncoding>Identity-H</pdfEncoding>
        <pdfEmbedded>true</pdfEmbedded>
        <exportFonts>
            <export key="net.sf.jasperreports.html">'DejaVu Sans', Arial, Helvetica, sans-serif</export>
            <export key="net.sf.jasperreports.xhtml">'DejaVu Sans', Arial, Helvetica, sans-serif</export>
        </exportFonts>
        <!--
        <locales>
            <locale>en_US</locale>
            <locale>de_DE</locale>
        </locales>
        -->
    </fontFamily>

    <fontFamily name="DejaVu Serif">
        <normal>net/sf/jasperreports/fonts/dejavu/DejaVuSerif.ttf</normal>
        <bold>net/sf/jasperreports/fonts/dejavu/DejaVuSerif-Bold.ttf</bold>
        <italic>net/sf/jasperreports/fonts/dejavu/DejaVuSerif-Italic.ttf</italic>
        <boldItalic>net/sf/jasperreports/fonts/dejavu/DejaVuSerif-BoldItalic.ttf</boldItalic>
        <pdfEncoding>Identity-H</pdfEncoding>
        <pdfEmbedded>true</pdfEmbedded>
        <exportFonts>
            <export key="net.sf.jasperreports.html">'DejaVu Serif', 'Times New Roman', Times, serif</export>
            <export key="net.sf.jasperreports.xhtml">'DejaVu Serif', 'Times New Roman', Times, serif</export>
        </exportFonts>
    </fontFamily>

    <fontFamily name="DejaVu Sans Mono">
        <normal>net/sf/jasperreports/fonts/dejavu/DejaVuSansMono.ttf</normal>
        <bold>net/sf/jasperreports/fonts/dejavu/DejaVuSansMono-Bold.ttf</bold>
        <italic>net/sf/jasperreports/fonts/dejavu/DejaVuSansMono-Oblique.ttf</italic>
        <boldItalic>net/sf/jasperreports/fonts/dejavu/DejaVuSansMono-BoldOblique.ttf</boldItalic>
        <pdfEncoding>Identity-H</pdfEncoding>
        <pdfEmbedded>true</pdfEmbedded>
        <exportFonts>
            <export key="net.sf.jasperreports.html">'DejaVu Sans Mono', 'Courier New', Courier, monospace</export>
            <export key="net.sf.jasperreports.xhtml">'DejaVu Sans Mono', 'Courier New', Courier, monospace</export>
        </exportFonts>
    </fontFamily>

    <!--
        Mapping Java logical fonts, for the sake of HTML export only.
    -->
    
    <fontFamily name="SansSerif">
        <exportFonts>
            <export key="net.sf.jasperreports.html">'DejaVu Sans', Arial, Helvetica, sans-serif</export>
            <export key="net.sf.jasperreports.xhtml">'DejaVu Sans', Arial, Helvetica, sans-serif</export>
        </exportFonts>
    </fontFamily>
    <fontFamily name="Serif">
        <exportFonts>
            <export key="net.sf.jasperreports.html">'DejaVu Serif', 'Times New Roman', Times, serif</export>
            <export key="net.sf.jasperreports.xhtml">'DejaVu Serif', 'Times New Roman', Times, serif</export>
        </exportFonts>
    </fontFamily>
    <fontFamily name="Monospaced">
        <exportFonts>
            <export key="net.sf.jasperreports.html">'DejaVu Sans Mono', 'Courier New', Courier, monospace</export>
            <export key="net.sf.jasperreports.xhtml">'DejaVu Sans Mono', 'Courier New', Courier, monospace</export>
        </exportFonts>
    </fontFamily>

</fontFamilies>

 

Maybe THIS post will save someone a heap of trouble.

 

Kind reagards,

Icy

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...