Search code examples
jasper-reportsexport-to-pdf

PDF created using JRXML template does not render Service Mark Symbol ℠ in the static text field


I have a jrxml template to create PDF. It has a static text field with symbols like TradeMark, Copyright and ServiceMark. The TradeMark and Copyright symbols are rendered properly in the PDF but not ServiceMark. I use Jasper v6.16.0 and Times New Roman font.


Solution

  • The Times New Roman font doesn't seem to include a glyph for the service mark character. Therefore you'll need to use a different font to render the symbol in PDF.

    You can either use a different font for the whole text (for instance the DejaVu Sans font included in the JasperReports fonts jar does have a glyph for the service mark symbol), or create a font set so that the text uses Times New Roman for letters/digits/etc and only uses DejaVu Sans (or another font) for characters that Times New Roman doesn't support.

    Such a font set would look something like this in the font extension:

    <fontFamilies>
        <fontFamily name="Times New Roman">
            <normal>...path.../Times New Roman.ttf</normal>
            <pdfEncoding>Identity-H</pdfEncoding>
            <pdfEmbedded>true</pdfEmbedded>
        </fontFamily>
        
        <fontSet name="Times New Roman Font Set">
            <family familyName="Times New Roman"/>
            <family familyName="DejaVu Sans">
                <excludedScript>LATIN</excludedScript>
            </family>
        </fontSet>  
    </fontFamilies>