ImageDrawText

Going from Coldfusion to Lucee (creating a text on image)
I just used that code from Lucee documention, and I get an Error

<cfscript>
				img=imageNew("",300,300,"RGB","##bf4f36");
				style={size="40",style="BOLD"};
				img.DrawText("I love lucee",55,120,style);
				cfimage(action="writeToBrowser",source=img);
			</cfscript>

The error is

Lucee 5.3.7.47 Error (java.lang.InternalError)
Message java.lang.reflect.InvocationTargetException
Stacktrace The Error Occurred in
/var/www/C020/site/index/captcha_generate.cfm: line 55

53: img=imageNew("",300,300,“RGB”,"##bf4f36");
54: style={size=“40”,style=“BOLD”};
55: img.DrawText(“I love lucee”,55,120,style);
56: cfimage(action=“writeToBrowser”,source=img);
57:
called from /var/www/C020/site/admin/lettre_admin.cfm: line 84

82:


83:
84:
85:
86:
Java Stacktrace lucee.runtime.exp.NativeException: java.lang.reflect.InvocationTargetException
at java.desktop/sun.font.FontManagerFactory$1.run(Unknown Source)
at java.base/java.security.AccessController.doPrivileged(Native Method)
at java.desktop/sun.font.FontManagerFactory.getInstance(Unknown Source)
at java.desktop/java.awt.Font.getFont2D(Unknown Source)
at java.desktop/java.awt.Font.defaultLineMetrics(Unknown Source)
at java.desktop/java.awt.Font.getLineMetrics(Unknown Source)

On
Linux debian 10
php 7.3
apache 2.4
Lucee 5.3.7.47

There is some related issue in Jira LDEV-2619,LDEV-2643

1 Like

I do not understand your question ?
Just try : http://demeter04.fr/index/test_text_image.cfm
This the exact code in Lucee documentation.
image.drawText() :: Lucee Documentation
I just copy/paste and try. And error.
Thanks for help.

Yes, I understood your question, in the Link.
I think, it is exactly the same issue.
What is the solution today ?

Thanks you.

read thru the jira tasks, the solution is provided there

The suggestion I found in jira, is
As suggested by @sbleon I’ve created/edited the file /opt/lucee/tomcat/bin/setenv.sh and added the following JVM system property to run Javas AWT in headless mode:

export JAVA_OPTS="-Djava.awt.headless=true"

Restarted Lucee and the issue went away.

I do not dare to open and modify that file,
Can I open with bloc-notes add this line after a ; (semi-column)
and save and replace that file ? (the restart Lucee)

Thanks for advise.

This has been solved with font installation on linux debian.
See thread : Bug with CFCHART - #4 by kabutotx
All functions needed the MS font had the same problem. Solved now.