CJK support

A quieter space for design discussion of long-term projects
robn
Posts: 302
Joined: Mon Jul 01, 2013 1:11 am
Location: Melbourne, Australia

Re: CJK support

Post by robn »

Big progress today:

Image

This is UIHeadingFont with three TrueType fonts under the hood, assigned by Unicode range. The font config files are now JSON. Example:

Code: Select all

{
   "name" : "UIHeadingFont",
   "faces" : [
      {
         "fontFile" : "Orbiteer-Bold.ttf",
         "pixelWidth" : 20,
         "pixelHeight" : 20
      },
      {
         "fontFile" : "DejaVuSans.ttf",
         "pixelWidth" : 18,
         "pixelHeight" : 18,
         "ranges" : [
            [ "0x0400", "0x04FF" ],
            [ "0x0500", "0x0527" ],
            [ "0x2DE0", "0x2DFF" ],
            [ "0xA640", "0xA697" ],
            [ "0xA69F", "0xA69F" ]
         ]
      },
      {
         "fontFile" : "wqy-microhei.ttc",
         "pixelWidth" : 20,
         "pixelHeight" : 20,
         "ranges" : [
            [ "0x4E00",  "0x9FFF"  ],
            [ "0x3400",  "0x4DFF"  ],
            [ "0x20000", "0x2A6DF" ],
            [ "0xF900",  "0xFAFF"  ],
            [ "0x2F800", "0x2FA1F" ]
         ]
      }
   ]
}
Obviously there's some limitations. Metrics are only taken from the first face (though I could try to merge them from all faces but its still imprecise), and there's no kerning between mixed faces. But if we choose fonts that complement each other well it should be barely noticable.

I'll get this cleaned up soon and probably merged in a day or two, then we'll have support for pretty much all the text we'll ever need!
robn
Posts: 302
Joined: Mon Jul 01, 2013 1:11 am
Location: Melbourne, Australia

Re: CJK support

Post by robn »

robn
Posts: 302
Joined: Mon Jul 01, 2013 1:11 am
Location: Melbourne, Australia

Re: CJK support

Post by robn »

Merged, and also added WQY Micro Hei as mentioned. So here's what's on master with the Chinese Mandarin translation enabled:

Image

Image

Image

Image

Image
Post Reply