• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

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

New Here ,
May 30, 2024 May 30, 2024

Copy link to clipboard

Copied

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.

Views

343

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

New Here , Jun 14, 2024 Jun 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;}

Votes

Translate

Translate
Community Expert ,
Jun 07, 2024 Jun 07, 2024

Copy link to clipboard

Copied

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jun 13, 2024 Jun 13, 2024

Copy link to clipboard

Copied

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jun 14, 2024 Jun 14, 2024

Copy link to clipboard

Copied

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;}

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 15, 2024 Jun 15, 2024

Copy link to clipboard

Copied

LATEST

@kalyan_SS , Thanks for sharing that.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation