0

i want my Jasper Report to support something like 5 or 6 languages dynamically.

i wish to use the google noto-sans font (www.google.com/get/noto) and google noto, have a single file for each language, (beside the main font file )

should i create a couple of font extensions and add them to my classpath ?

following my previous question How to get non-english support when exporting to PDF?

Community
  • 1
  • 1
Shay_t
  • 163
  • 1
  • 16
  • What is unclear is if you like different font for different exports using same jrxml (same report, with only one font defined)? – Petter Friberg Feb 25 '16 at 15:34
  • In jrxml you define 1 font name and relative to this you can only have 1 font extension (you could try to make a work around not letting pdf find your font and set a default dynamically), but to me it seems like that you need 1 font that supports all your languages or different reports with different fonts (different languages) and multiple fonts in font-extensions – Petter Friberg Feb 25 '16 at 15:44
  • so how can i solve the onto-sans, (they provide a single main file, and another font file for any other language ) – Shay_t Feb 25 '16 at 15:54
  • Use the single main file!, create the font-extension, set the correct fontName and your up and running... – Petter Friberg Feb 25 '16 at 15:58
  • i think that in itext (not so familiar with the api, just googling) its possible to have a font fallback, just imagining if its possible to define a chain of font. – Shay_t Feb 25 '16 at 16:01
  • You do not need to do anything in itext.... (the itext example you saw is just to test... debugging).. You can not provide the font-extension and set default font to use in jasper report (change dynamically the default font). – Petter Friberg Feb 25 '16 at 16:21
  • I have answered this question, tell me if you have some doubts. – Petter Friberg Feb 26 '16 at 22:00

2 Answers2

2

In the jasper report you have

<font fontName="google_noto"/>

Related to this font you can only have 1 font-extension with the family name google_noto (containing the font for normal, bold, italic etc).

You can't switch this font extension dynamically the solution would be:

  1. Use a font that contains all relative language.

  2. Create a different jrxml (reports) for the different language with different fontName and the create font-extension with all the different family names:

    //report in English
    <font fontName="google_noto_en"/>
    //report in Italian        
    <font fontName="google_noto_it"/>
    

A work around would be to indicate fake font, disable errors for missing font and switch the default font as you like before generating report.

net.sf.jasperreports.awt.ignore.missing.font="true"
net.sf.jasperreports.default.font.name="google_en"

This question is about setting properties JRProperties became deprecated, recommended way of replacing

However, I would strong recommend and choose: "1. Use a font that contains all relative language"

Community
  • 1
  • 1
Petter Friberg
  • 21,252
  • 9
  • 60
  • 109
  • i agree, to use the same font is a better approach, since i don't want to manage different copies of my report. – Shay_t Feb 28 '16 at 06:29
  • also i wish i could do that in a single report, but i guess for now ill have to use a single font – Shay_t Feb 28 '16 at 06:30
  • Can we use font sets to render pdf reports? It is working on Jasper Studio. But, when it is used in a java application, the fonts are not loading – hermit Aug 25 '21 at 13:28
0

there is a way to do this...

you can put multiple textbox fields and on individual textbox use single font name which you want to display. the benfit would be if some font is not rendered in google_noto, then that textbox will show nothing(blank) and if that font is rendered in google_noto1 then that textbox will display that text.

I hope it works fine (Y)

Nitin Gaur
  • 124
  • 6