Skip to main content
Participant
May 30, 2024
Answered

Asian (Chinese language) fonts not working in AWS Linux 2023

  • May 30, 2024
  • 1 reply
  • 813 views

The following cfdocument is not displaying the fonts.

<cfoutput>

        <cfdocument format="pdf" fontembed="true">

            <style>

body{font-family: 'SimSun' 'Microsoft Yahei'; font-size: 35px; }

td,th, h1,h2,h3, p{font-family:'Microsoft Yahei', sans-serif,Helvetica, Arial;}

    </style>

        <cfoutput>

            <h1>PDF #chinese characters here#</h1> <!-- "PDF Example Title" in Chinese -->

          </cfoutput>

</cfdocument>

</cfoutput>

===========================

AWS Linux 2023 EC2 instance

CF2023 Trial

Tried:

Adding fonts via CF Administrator

Adding fonts to /usr/share/fonts

Adding fonts to /usr/share/fonts/default/TrueType

Used in-built web server as well as apache

 

All suggestions welcome!  Thank you.

    This topic has been closed for replies.
    Correct answer kalyan_SS

    Thanks everyone for the suggestions.  I got help from our CF AWS partner who pointed out the missing piece as shown in bold below:

    td,th, h1,h2,h3, p{font-family: 'SimSun', 'Microsoft Yahei', sans-serif,Helvetica, Arial;}

    1 reply

    BKBK
    Community Expert
    Community Expert
    June 7, 2024

    I don't know for sure what the cause of the problem is. But there are three things about your code that are questionable to me:

    1.  It is unclear what encoding is being used. The customary encoding to use is UTF-8.
    2.  Nested cfoutput can be troublesome. Avoid it.
    3.  The code currently has an HTML comment. Replace it with a CFML comment.

     

    Therefore, improve your code as follows, and see if it helps:

    <cfprocessingdirective pageencoding="utf-8">
    
    <cfset chineseCharactersToBeTested="待测试的汉字。">
    
    <cfdocument format="pdf" fontembed="true">
    
    	<style>
    		body{font-family: 'SimSun' 'Microsoft Yahei'; font-size: 35px; }
    		
    		td,th, h1,h2,h3, p{font-family:'Microsoft Yahei', sans-serif,Helvetica, Arial;}
    	</style>
    	
    	
    	<h1><cfoutput>PDF #chineseCharactersToBeTested#</cfoutput></h1> <!--- "PDF Example Title" in Chinese --->
    
    </cfdocument>
    

     I have attached the PDF that results from my test.

    CurtangWarrior
    Inspiring
    June 13, 2024

    Unfortunately the suggestions above didn't make a difference.  We have tried both with and without the explicit UTF-8 encoding and without any cfoutput at all (as it is really not necessary if the characters are just added into the html directly). Thank you for your suggestions.

    kalyan_SSAuthorCorrect answer
    Participant
    June 14, 2024

    Thanks everyone for the suggestions.  I got help from our CF AWS partner who pointed out the missing piece as shown in bold below:

    td,th, h1,h2,h3, p{font-family: 'SimSun', 'Microsoft Yahei', sans-serif,Helvetica, Arial;}