Wednesday, August 22, 2012

Render English and Chinese with mono font

(This is an unresolved issue)

How to make a Chinese character exactly 2 English characters wide?

I've tried it in WPF application with Courier New and Segoe UI Mono, but both failed. And also tried SimSun as fallback font, failed again.

Here is the summary of my test.
Successful Examples
HTML with pre tag rendered by Chrome

Failed Examples
Visual Studio 2010
HTML without pre tag rendered by Chrome
HTML with and without pre tag rendered by IE

I tried Courier New and Segoe UI Mono with fallback font SimSun in my WPF app. The fallback font mechanism worked, because it can render STLiti which is 隶书, see below

One Chinese char is a little bit less than 2 English chars in width. when fallback font is SimSun, it's the same case
Figure 1

Visual Studio has the same issue
Figure 2

While Notepad++ is pretty successful
Figure 3

Different web browser has different behavior. With
<pre> tag would work well in Chrome while it can't give you Chinese char of 2 English chars width without
<pre>. And IE can't do it in both cases.

As you can see Chinese chars in Figure 3 is a little bit wider than Chinese chars in Figure 1. Is there a covered mechanism results narrow Chinese chars?

Post a Comment