1

I have a spark list component that uses an itemrenderer. It's a list of avatar (images) and names of people. Latin and other languages are displayed correctly but for Thai, where it only shows square boxes. Please help!

Here's the code I use:

<?xml version="1.0" encoding="utf-8"?>
  <s:ItemRenderer xmlns:fx="http://ns.adobe.com/mxml/2009"
    xmlns:s="library://ns.adobe.com/flex/spark"
    xmlns:mx="library://ns.adobe.com/flex/mx"
    xmlns:bd="com.bdement.imagecache.*"
    autoDrawBackground="false" width="270" height="45">
    <fx:Script>
      <![CDATA[
      override public function set data(object:Object):void {
        userName.text = "อีฟ จันทโรทัย";
      }
      ]]>
    </fx:Script>
    <s:HGroup click="onFriendClickReceived(event)" verticalAlign="middle"
      color.normal="#000000" horizontalAlign="left" width="270" height="45">
      <s:Spacer width="10"/>
      <bd:CachedImage id="userImage" cacheId="F32x32" width="32" height="32"
      left="8" verticalCenter="0"/>
      <s:Label id="userName" width="188" maxDisplayedLines="1" fontLookup="auto"
      fontFamily="Arial Unicode MS, Arial" verticalCenter="0" />
    </s:HGroup>
  </s:ItemRenderer>
dda
  • 6,030
  • 2
  • 25
  • 34
Luca
  • 51
  • 3

1 Answers1

2

You have to define a fontFamily for your language. Get a font that has Thai support in it, then embed like this:

[Embed(source="font.ttf", mimeType="application/x-font", embedAsCFF="true", fontFamily="ThaiFontFamily")]
private var ThaiFont:Class;

Then in your creationComplete handler embed font like this:

Font.registerFont(ThaiFont);

After this you are free to use your fontFamily in CSS or directly on your label in MXML. Like this:

<s:Label id="userName" width="188" maxDisplayedLines="1" fontLookup="auto" fontFamily="ThaiFontFamily" verticalCenter="0" />
Gio
  • 1,954
  • 3
  • 22
  • 42
  • I don't know any other ways. It should work. Did you follow every step correctly? – Gio Jul 23 '12 at 15:07
  • Yep, I tried both ways CSS and directly MXML too, only think could be the font that I downloaded that is not working (Arial Unicode), do you have a font that is working for sure? – Luca Jul 24 '12 at 10:23
  • No, sorry I don't have any Thai fonts. But I used Sylfaen for Georgian when I faced the same problem. Try that one.. – Gio Jul 24 '12 at 13:03
  • @Gio thanks for this answer. This problem had raised it's ugly head on a project I am working on, but using a font called kinnari and embedding it in this manner works. **Luca**, if you are still facing the same issue, then the font I used can be found here. http://www.hawaii.edu/thai/thaifonts/ – Tim B James Mar 09 '15 at 10:44