gsr
09/13/2024, 5:38 PMgsr
09/13/2024, 8:32 PM<!--- download a ttf file --->
<cfset filePath = ExpandPath("assets/fonts/NotoSansGurmukhi-Regular")>
<cfhttp url="<https://notofonts.github.io/gurmukhi/fonts/NotoSerifGurmukhi/full/ttf/NotoSerifGurmukhi-Regular.ttf?raw=true>"
getasbinary="true" file="#filePath#"/>
<!--- add the font to java.awt.GraphicsEnvironment --->
<cfset oFont = createObject('java', 'java.awt.Font') />
<cfset stream = createObject('java', 'java.io.FileInputStream').init(filePath) />
<cfset sFont = oFont.createFont(oFont.TRUETYPE_FONT, stream) />
<cfset createObject('java', 'java.awt.GraphicsEnvironment').getLocalGraphicsEnvironment().registerFont(sFont) />
<cfset application.__fontAdded = 1 />
<!--- create an image and write text to it --->
<cfset text = "This IS a custom Font Test with imageDrawText()" />
<cfset myImg = imageNew("", 800, 50) />
<cfset imageSetAntialiasing(myImg, true) />
<cfset imageDrawText(myImg, text, 10, 35, {
size="40.0"
, font="NotoSerifGurmukhi-Regular"// <<<------ this is what it was all about!
}) />
<cfimage action="write" source="#myImg#" destination="#expandPath('./test1.png')#" quality="1" overwrite="true" />
<!--- output test1 --->
<img src="test1.png" />
<hr/>
<!--- create a captcha file --->
<cfimage action="captcha" text="Captcha test" width="600" height="150" fonts="NotoSerifGurmukhi-Regular" fontSize="50"
destination="test2.png" overwrite="true" />
<!--- output test2 --->
<img src="test2.png" />Tomy Saman
09/15/2024, 11:23 PMtext = "This IS a custom Font Test with imageDrawText()"), do you expect cfimage does the magic to translate that English text to India Punjabi writing??gsr
09/16/2024, 12:46 PMgsr
09/16/2024, 12:48 PMTomy Saman
09/16/2024, 11:24 PMTomy Saman
09/16/2024, 11:24 PM<cfset text = "This IS a custom Font Test with imageDrawText()" /> and <cfimage action="captcha" text="Captcha test" ...> does not support UTF?gsr
09/16/2024, 11:26 PMgsr
09/16/2024, 11:26 PMgsr
09/16/2024, 11:26 PMgsr
09/16/2024, 11:26 PMTomy Saman
09/16/2024, 11:27 PMTomy Saman
09/16/2024, 11:34 PMgsr
09/16/2024, 11:34 PMgsr
09/16/2024, 11:41 PMgsr
09/16/2024, 11:43 PMTomy Saman
09/16/2024, 11:58 PM<!--- download a ttf file --->
<cfset filePath = ExpandPath("./NotoSansGurmukhi-Regular")>
<cfhttp url="<https://notofonts.github.io/gurmukhi/fonts/NotoSerifGurmukhi/full/ttf/NotoSerifGurmukhi-Regular.ttf?raw=true>"
getasbinary="true" file="#filePath#"/>
<!--- add the font to java.awt.GraphicsEnvironment --->
<cfset oFont = createObject('java', 'java.awt.Font') />
<cfset stream = createObject('java', 'java.io.FileInputStream').init(filePath) />
<cfset sFont = oFont.createFont(oFont.TRUETYPE_FONT, stream) />
<cfset createObject('java', 'java.awt.GraphicsEnvironment').getLocalGraphicsEnvironment().registerFont(sFont) />
<cfset application.__fontAdded = 1 />
<!--- create an image and write text to it --->
<cfset text = "test1.png ਸਰਮਨ" />
<cfset myImg = imageNew("", 800, 50) />
<cfset imageSetAntialiasing(myImg, true) />
<cfset imageDrawText(myImg, text, 10, 35, {
size="40.0"
, font="NotoSerifGurmukhi-Regular"
}) />
<cfimage action="write" source="#myImg#" destination="#expandPath('./test1.png')#" quality="1" overwrite="true" />
<!--- output test1 --->
<img src="test1.png" />
<hr/>
<!--- create a captcha file --->
<cfimage action="captcha" text="test2.png ਸਰਮਨ" width="600" height="150" fonts="NotoSerifGurmukhi-Regular" fontSize="50"
destination="#expandPath('./test2.png')#" overwrite="true" />
<!--- output test2 --->
<img src="test2.png" />Tomy Saman
09/16/2024, 11:59 PMgsr
09/16/2024, 11:59 PMTomy Saman
09/16/2024, 11:59 PMgsr
09/17/2024, 12:00 AMTomy Saman
09/17/2024, 12:01 AMgsr
09/17/2024, 12:02 AMgsr
09/17/2024, 12:02 AMgsr
09/17/2024, 12:02 AMTomy Saman
09/17/2024, 12:25 AMਸਰਮਨ and then see if can see it correctly in your browser?gsr
09/17/2024, 12:25 AMgsr
09/17/2024, 12:25 AMgsr
09/17/2024, 12:26 AMgsr
09/17/2024, 12:27 AMTomy Saman
09/17/2024, 12:31 AMgsr
09/17/2024, 1:00 AMgsr
09/17/2024, 1:16 AMgsr
09/17/2024, 1:16 AMgsr
09/18/2024, 12:36 PMgsr
09/18/2024, 12:36 PMTomy Saman
09/20/2024, 12:37 AMgsr
09/20/2024, 1:22 AM