0

I have one application using JasperReports and Java SE. It has embedded some fonts to be used in the reports.

The application works like a charm on Windows 10 Spanish edition and even on linux (lubuntu) in Spanish too. However, when I try to execute it in a computer with Windows 10 zh (Traditional Chinese) it throws this exception:

net.sf.jasperreports.engine.util.JRFontNotFoundException: Font "Microsoft JhengHei" is not available to the JVM. See the Javadoc for more details.
at net.sf.jasperreports.engine.fonts.FontUtil.checkAwtFont(FontUtil.java:360)
at net.sf.jasperreports.engine.fill.SimpleTextLineWrapper.loadFont(SimpleTextLineWrapper.java:368)
at net.sf.jasperreports.engine.fill.SimpleTextLineWrapper.getGeneralFontInfo(SimpleTextLineWrapper.java:338)
at net.sf.jasperreports.engine.fill.SimpleTextLineWrapper.createFontInfo(SimpleTextLineWrapper.java:278)
at net.sf.jasperreports.engine.fill.SimpleTextLineWrapper.start(SimpleTextLineWrapper.java:240)
at net.sf.jasperreports.engine.fill.TextMeasurer.measure(TextMeasurer.java:536)
at net.sf.jasperreports.engine.fill.JRFillTextElement.chopTextElement(JRFillTextElement.java:672)
at net.sf.jasperreports.engine.fill.JRFillStaticText.prepare(JRFillStaticText.java:186)
at net.sf.jasperreports.engine.fill.JRFillElementContainer.prepareElements(JRFillElementContainer.java:352)
at net.sf.jasperreports.engine.fill.JRFillBand.fill(JRFillBand.java:421)
at net.sf.jasperreports.engine.fill.JRFillBand.fill(JRFillBand.java:396)
at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillTitle(JRVerticalFiller.java:317)
at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReportStart(JRVerticalFiller.java:251)
at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReport(JRVerticalFiller.java:119)
at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:558)
at net.sf.jasperreports.engine.fill.BaseReportFiller.fill(BaseReportFiller.java:414)
at net.sf.jasperreports.engine.fill.JRFiller.fill(JRFiller.java:122)
at net.sf.jasperreports.engine.JasperFillManager.fill(JasperFillManager.java:667)
at net.sf.jasperreports.engine.JasperFillManager.fillReport(JasperFillManager.java:983)
at sample.controller.ReportGenerator.fillInReport(ReportGenerator.java:213)
at sample.view.Main$5.run(Main.java:271)
at java.lang.Thread.run(Unknown Source)

I am completely lost, I have no clue about where I can start. If any of you has a suggestion I will try it out.

EDIT:

When using Jasperreports you need to attach the TTF to the project to be further used. I already made this step but when executing my application on Chinese Windows version cannot get the fonts I already included. For any reason, the locale matters.

Michael Knight
  • 648
  • 2
  • 10
  • 26
  • Possible duplicate of [JVM fonts and JasperReports](http://stackoverflow.com/questions/3811908/jvm-fonts-and-jasperreports) – Alex K Mar 23 '16 at 07:02
  • No, it is not duplicated. The link you mention is about another issue I also experienced before. When using Jasperreports you need to attach the TTF to the project to be further used. I already made this step but when executing my application on Chinese Windows version cannot get the fonts I already included. For any reason, the locale matters. – Michael Knight Mar 23 '16 at 08:30

1 Answers1

0

Solved. I just changed the locale for a well known one in the main class of the project.

Locale.setDefault(Locale.US);

And this will set the US locale for the whole application.

Michael Knight
  • 648
  • 2
  • 10
  • 26