Chinese, and other International Text in WPF/E

Chinese, and other International Text in WPF/E

Rate This
  • Comments 3

For our friends in the international community, text rendering is possible by means of the Glyph tag.

So, for example this XAML:

  <Canvas x:Name="GlyphDisplayCanvas" Canvas.Left="0" Canvas.Top="0" >

 

    <Glyphs x:Name="GlyphDisplay" Fill="Black" FontUri="./simhei.ttf"  

 

          FontRenderingEmSize="48" UnicodeString="你好, 你好" />

 

</Canvas>

Will render Chinese text in WPF/E.

Please note a couple of things:

1: You have to use the FontUri to specify the font, and you must use a font that supports the characters.

2: Make sure that you are licensed to redistribute said font.

I am working on a Whitepaper for MSDN to show how this can be used in conjunction with ASP.NET controls for IME-based text input in far eastern languages.

If you read Chinese, check out my colleague, Hong Chao Wang's blog for more details...

http://blog.joycode.com/joy/archive/2007/04/06/100553.aspx

Comments
  • Hi! (Henric from Tokyo here)

    This is great and I assume this goes for Japanese as well?

    On a side note, back in march 2006 I was working on a (WPF) project that made heavy use of flow documents. The application had a complex grid layout with several FlowDocumentPageViewers displaying Japanese content. One thing I noticed while doing this was that WPF was considerably slower at rendering quantities of Japanese glyphs as compared to rendering roman letters. (Naturally due to the complexity of a single glyph.)

    Have you noticed any performance impact in WPF/e when rendering Chinese letters as opposed to roman?

  • Hi Henric!

    Yes, it also applies to Japanese and anything else that needs UniCode.

    I'll be honest -- I haven't done any benchmarking on it...

    Laurence

  • hi, Laurence,

    The two far east fonts that on winxp are pretty big. It's probably not a good idea to ask user to download a 10Mg font file.

    So I would like to use those fonts if they are already on user's system.

    How how can I specify the path?

    FontUri="c:\windows\fonts\simsun.ttc"

    works in most cases, but not all because user's  windows dir might be D:\win instead C:\windows.  And %SYSTEMROOT% environment variable doesn't work here.

    Any Idea?

    Thanks

    Wensheng

Page 1 of 1 (3 items)
Leave a Comment
  • Please add 8 and 5 and type the answer here:
  • Post