Bug 96348

Summary: Texts with monospace font are incorrectly chosen when lang=zh
Product: WebKit Reporter: Yu-Cheng Chuang <ducksteven>
Component: CSSAssignee: Nobody <webkit-unassigned>
Status: RESOLVED CONFIGURATION CHANGED    
Severity: Normal CC: ap, bfulgham, chenzx, hail2u, mitz
Priority: P3    
Version: 528+ (Nightly build)   
Hardware: Mac   
OS: OS X 10.8   
URL: http://jsfiddle.net/HjJcD/1/
Attachments:
Description Flags
Screenshot of Facebook FQL sample code, when logged in as a Chinese user none

Description Yu-Cheng Chuang 2012-09-10 20:01:07 PDT
Created attachment 163268 [details]
Screenshot of Facebook FQL sample code, when logged in as a Chinese user

Safari version: 6.0
OS X Version: 10.8.1

Summary:

When a <pre> or <code> has lang attribute set to zh, zh-tw or zh-cn, or is inside an element with such lang attribute, then the texts are not in monospace font.

Code to reproduce:

    <pre lang='zh-tw'>hello world</pre>

Expected result:

"hello world" should be in monospaced font.

Actual result:

"hello world" are in sans-serif font.

Test code:

http://jsfiddle.net/HjJcD/1/

Real-world example:

https://developers.facebook.com/docs/reference/fql/

When logged in a Facebook account with user language set to Chinese (Traditional), the code examples are not in monospace font, but in Heiti TC.

I think this is because Safari now chooses font by the lang attribute, and in Mac OS X, monospace font of zh, zh-tw and zh-cn are the same as sans-serif font, described in DefaultFontFallback.plist (under /System/Library/Frameworks/CoreText.framework/Versions/A/Resources)
Comment 1 Alexey Proskuryakov 2012-09-11 11:30:45 PDT
Firefox also has this issue. Not sure if Chinese (and other CJK) OS X fonts even have monospace Roman characters.
Comment 2 Chen Zhixiang 2013-08-01 21:38:11 PDT
Hi, this bug seems also affecting <samp> element's render behavor in WinCE port.

since <samp>'s default html.css setting is "font-family: monospace", its font-size should be displayed smaller, but not.
Comment 3 Chen Zhixiang 2013-08-01 23:05:53 PDT
settings->setDefaultFixedFontSize(10); 

My problem resolved.
Comment 4 Brent Fulgham 2022-07-13 11:04:37 PDT
These test cases appear to work properly in modern WebKit.