{"id":255,"date":"2010-06-01T08:30:39","date_gmt":"2010-06-01T08:30:39","guid":{"rendered":"http:\/\/dev.gregbueno.com\/wp\/sakufu\/2010\/06\/01\/google_chrome_w\/"},"modified":"2010-06-01T08:30:39","modified_gmt":"2010-06-01T08:30:39","slug":"google_chrome_w","status":"publish","type":"post","link":"https:\/\/gregbueno.com\/sakufu\/2010\/06\/01\/google_chrome_w\/","title":{"rendered":"Google Chrome won&#8217;t render Japanese text with a sans-serif CSS"},"content":{"rendered":"<p>Here&#8217;s some text in Japanese: \u3053\u306e\u30bb\u30f3\u30c6\u30f3\u30b9\u306f\u65e5\u672c\u8a9e\u3067\u66f8\u3044\u305f\u3002<\/p>\n<p>Nothing strange so far, right?<\/p>\n<p>Here&#8217;s the same sentence in a <code>&lt;span\/&gt;<\/code> tag with a <code>style<\/code> attribute specifying Helvetica, Verdana and Arial fonts: <span style=\"font-family: 'Helvetica', 'Verdana', 'Arial', sans-serif\">\u3053\u306e\u30bb\u30f3\u30c6\u30f3\u30b9\u306f\u65e5\u672c\u8a9e\u3067\u66f8\u3044\u305f\u3002<\/span><\/p>\n<p>If you&#8217;re using Google Chrome, you may not even see the sentence at all. It will, however, render when you view the source code.<\/p>\n<p>Curious to know why some parts of my sites render Japanese text and others do not, I started inspecting elements with Japanese text in Chrome, enabling and disabling rules. When I disabled <tt>font-family<\/tt> rules specifying sans-serif fonts, the Japanese text re-appeared. Enabling the sans-serif rule made them disappear again.<\/p>\n<p><!--more--><\/p>\n<p>I&#8217;m running a Windows XP machine, and when I opened up the Character Map to see what extended characters Helvetica supports, I saw a sea of dots. Verdana and Arial supported extended Western characters but no Asian characters. (Arial Unicode MS does support Asian characters.)<\/p>\n<p>It looks like Chrome is pretty literal about how it renders fonts &#8212; if it encounters a character the font doesn&#8217;t support, it&#8217;s not going to render it. In fact, it won&#8217;t even bother trying to render an analogous sans-serif Japanese font.<\/p>\n<p>Here&#8217;s our same example sentence with a <code>style<\/code> attribute specifying a sans-serif <code>font-family<\/code>: <span style=\"font-family: sans-serif\">\u3053\u306e\u30bb\u30f3\u30c6\u30f3\u30b9\u3092\u66f8\u3044\u305f\u3002<\/span><\/p>\n<p>Firefox and Internet Explorer look like they substitute fonts to render sans-serif Japanese text, probably falling back on MS PGothic.<\/p>\n<p>If you want a mix of English and Japanese text to render with a sans-serif font in Google Chrome, it looks like you have to specify those sans-serif fonts in your CSS.<\/p>\n<p>Example: <span style=\"font-family: 'MS PGothic', 'Arial Unicode MS', 'Helvetica', 'Arial', sans-serif\">This sentence mixes \u65e5\u672c\u8a9e and \u82f1\u8a9e with Arial MS Unicode and MS PGothic specified in the <tt>font-family<\/tt>.<\/span><\/p>\n<p>Of course, this means your English text is also rendered in Arial Unicode MS or MS PGothic, which pales next Helvetica. And Mac users? Well, that&#8217;s an entire cross-platform can of worms I haven&#8217;t even tested.<\/p>\n<p><strong>UPDATE, 06\/01\/2010, 0917:<\/strong> Of course, this site uses UTF-8 for character encoding. If a site uses Shift-JIS or EUC-JP, these problems may not be an issue.<\/p>\n<p>Also, the examples may not adequately demonstrate the sans-serif issue, so here are more examples using <code>&lt;h1\/&gt;<\/code>.<\/p>\n<p>Sans-serif specified in <code>font-family<\/code>:<\/p>\n<h1 style=\"font-family: sans-serif\">\u65e5\u672c\u8a9e<\/h1>\n<p>Helvetica and sans-serif specified in <tt>font-family<\/tt>:<\/p>\n<h1 style=\"font-family: 'Helvetica', sans-serif\">\u65e5\u672c\u8a9e<\/h1>\n<p>MS PGothic specified in <tt>font-family<\/tt>:<\/p>\n<h1 style=\"font-family: 'MS PGothic'\">\u65e5\u672c\u8a9e<\/h1>\n<p>Arial Unicode MS specified in <tt>font-family<\/tt>:<\/p>\n<h1 style=\"font-family: 'Arial Unicode MS'\">\u65e5\u672c\u8a9e<\/h1>\n<p>Firefox falls back on MS PGothic in the Helvetica example. Internet Explorer falls back on a serif Japanese font. Chrome does not render it.<\/p>\n<p><strong>FOLLOW-UP:<\/strong> <a href=\"http:\/\/www.gregbueno.com\/index.php\/sakufu\/entry\/3780\/\">It&#8217;s actually WebKit&#8217;s fault<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Here&#8217;s some text in Japanese: \u3053\u306e\u30bb\u30f3\u30c6\u30f3\u30b9\u306f\u65e5\u672c\u8a9e\u3067\u66f8\u3044\u305f\u3002 Nothing strange so far, right? Here&#8217;s the same sentence in a &lt;span\/&gt; tag with a style attribute specifying Helvetica, Verdana and Arial fonts: \u3053\u306e\u30bb\u30f3\u30c6\u30f3\u30b9\u306f\u65e5\u672c\u8a9e\u3067\u66f8\u3044\u305f\u3002 If you&#8217;re using Google Chrome, you may not even see the sentence at all. It will, however, render when you view the source code. Curious [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[6],"tags":[],"class_list":["post-255","post","type-post","status-publish","format-standard","hentry","category-technophilia-professional"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p4Bkjq-47","_links":{"self":[{"href":"https:\/\/gregbueno.com\/sakufu\/wp-json\/wp\/v2\/posts\/255","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/gregbueno.com\/sakufu\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/gregbueno.com\/sakufu\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/gregbueno.com\/sakufu\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/gregbueno.com\/sakufu\/wp-json\/wp\/v2\/comments?post=255"}],"version-history":[{"count":0,"href":"https:\/\/gregbueno.com\/sakufu\/wp-json\/wp\/v2\/posts\/255\/revisions"}],"wp:attachment":[{"href":"https:\/\/gregbueno.com\/sakufu\/wp-json\/wp\/v2\/media?parent=255"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/gregbueno.com\/sakufu\/wp-json\/wp\/v2\/categories?post=255"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/gregbueno.com\/sakufu\/wp-json\/wp\/v2\/tags?post=255"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}