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

(AS3) Different fonts for each language in the text field

Explorer ,
Nov 13, 2023 Nov 13, 2023

I have a textfield with about 100000 characters.
Is there a way to display different fonts for each language in this field?
(For example) English=>"Arial", Hangul=>"Malkun Gothic"
If possible, please provide sample code.

246
Translate
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 ,
Nov 13, 2023 Nov 13, 2023

Hi.

 

You can create a new TextFormat instance, change the font property and apply this TextFormat instance to the target text field using the defaultTextFormat property.

 

Regards,

JC

Translate
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 ,
Nov 13, 2023 Nov 13, 2023

I think my question is wrong.
The text field contains a mixture of English and Korean.
In this case I am asking how to apply different fonts for each language.

Translate
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 ,
Nov 13, 2023 Nov 13, 2023

you can mix different fonts in the same textfield, but it would be easier and cleaner to use different textfields for different languages if both languages are to be displayed concurrently.

Translate
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 ,
Nov 14, 2023 Nov 14, 2023

I think applying multiple fonts to the same field is very complicated.
Thank you both for your advice.

Translate
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 ,
Nov 14, 2023 Nov 14, 2023

If that's the case, you need to use the htmlText property. Among other things, it makes possible to use more than one font face in the same text field.

 

Example:

 

yourTextField.htmlText = '<p><font face="Times New Roman">Lorem ipsum</font></p>\n<font face="Arial">Lorem ipsum</font></p>';

 

 

https://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/text/TextField.html#htmlTe...

image.pngexpand image

 

Regards,

JC

Translate
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 ,
Nov 14, 2023 Nov 14, 2023
LATEST

you can use as3 and non-html text via the setTextFormat method

Translate
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