Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error add font thai #342

Open
mustakeam opened this issue May 24, 2024 · 7 comments
Open

Error add font thai #342

mustakeam opened this issue May 24, 2024 · 7 comments

Comments

@mustakeam
Copy link

How to fix
Fatal error: Uncaught PHPJasper\Exception\ErrorCommandExecutable: Exception in thread "main" net.sf.jasperreports.engine.util.JRFontNotFoundException: Font "THSarabunNew" is not available to the JVM. See the Javadoc for more details. at net.sf.jasperreports.engine.fonts.FontUtil.checkAwtFont(FontUtil.java:604) at net.sf.jasperreports.engine.fill.SimpleTextLineWrapper.loadFont(SimpleTextLineWrapper.java:384) at net.sf.jasperreports.engine.fill.SimpleTextLineWrapper.getGeneralFontInfo(SimpleTextLineWrapper.java:354) at net.sf.jasperreports.engine.fill.SimpleTextLineWrapper.createFontInfo(SimpleTextLineWrapper.java:294) at net.sf.jasperreports.engine.fill.SimpleTextLineWrapper.start(SimpleTextLineWrapper.java:256) at net.sf.jasperreports.engine.fill.TextMeasurer.measure(TextMeasurer.java:543) at net.sf.jasperreports.engine.fill.JRFillTextElement.chopTextElement(JRFillTextElement.java:665) at net.sf.jasperreports.engine.fill.JRFillStaticText.prepare(JRFillStaticText.java:179) at net.sf.jasperreports in C:\xampp\htdocs\phpjasper\src\PHPJasper.php on line 251
image
image

@polppol
Copy link

polppol commented Oct 7, 2024

I think you should include jar of Thai font as a report "resources"
for jasperstarter You can do it like "jasperstarter pr myreport.jasper -f view -r myresources.jar"
but not sure how to do it with PHPJasper
I still finding too,

ps. i saw this #344
but no one answer yet of how to add external resources with PHPJasper

@SWK-Yoyo
Copy link

I have the smae problem. I fix it by add .ttf font into Java\jreX.X.X_XXX\lib\fonts folder and add pdfFontName into .jrxml file and it work (but i don't know how it work)

@ThantsinKS
Copy link

did you solve this error?

@ThantsinKS
Copy link

I have the smae problem. I fix it by add .ttf font into Java\jreX.X.X_XXX\lib\fonts folder and add pdfFontName into .jrxml file and it work (but i don't know how it work)

could you explain one more again?

@SWK-Yoyo
Copy link

SWK-Yoyo commented Apr 8, 2025

My font in file .jrxml look like this
<font fontName="Angsana New" size="14" pdfFontName="./fonts/ANGSAU.TTF" pdfEncoding="Identity-H"/>

  1. I add font in Java folder C:\Program Files\Java\jreX.X.X_XXX\lib\fonts for fontName format block
  2. Add path font you want to use in pdfFontName
  3. Set pdfEncoding="Identity-H" for encode font

@ThantsinKS
Copy link

My font in file .jrxml look like this <font fontName="Angsana New" size="14" pdfFontName="./fonts/ANGSAU.TTF" pdfEncoding="Identity-H"/>

  1. I add font in Java folder C:\Program Files\Java\jreX.X.X_XXX\lib\fonts for fontName format block
  2. Add path font you want to use in pdfFontName
  3. Set pdfEncoding="Identity-H" for encode font

this is my .jrxml

<textElement verticalAlignment="Middle">
					<!-- <font fontName="Noto Sans JP" pdfFontName="storage/fonts/NotoSansJP-Regular.ttf" isPdfEmbedded="true"/> -->
					<font fontName="Noto Sans JP" pdfFontName="var/www/html/jasper/fonts/NotoSansJP-Regular.ttf" pdfEncoding="Identity-H" />
				</textElement>

and i add font in this path beacuase i am using docker

COPY fonts/* /jasper/fonts/

ENV CLASSPATH=$CLASSPATH:/jasper/fonts

and i have .ttf file

Image

Image
and this is my laravel code, what is wrong with mine could you please show me how should i do

@SWK-Yoyo
Copy link

SWK-Yoyo commented Apr 8, 2025

I don't know docker and this problem so much but can you try this for me pls

  1. remove fontName="Noto Sans JP" and run it
  2. If it work but format character not work can you direct set font in jre\lib\fonts

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants