Bug 31804 - Safari/Chromium for Windows fails to load many CJK WebFonts and some Latin WebFonts
Summary: Safari/Chromium for Windows fails to load many CJK WebFonts and some Latin We...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebCore Misc. (show other bugs)
Version: 528+ (Nightly build)
Hardware: PC Windows XP
: P2 Normal
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-11-23 06:33 PST by Yusuke Sato
Modified: 2009-12-02 11:18 PST (History)
7 users (show)

See Also:


Attachments
allow_multiple_faces_v1 (1.29 KB, patch)
2009-11-23 06:41 PST, Yusuke Sato
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Yusuke Sato 2009-11-23 06:33:27 PST
Safari for Windows fails to load OpenType web fonts (@font-face) that have 2 or more faces.
Chromium for Windows also fails to load TrueType and OpenType web fonts that have 2 or more faces.

This is because the renameAndActivateFont() function in WebCore/platform/graphics/opentype/OpenTypeUtilities.cpp, which is used by Safari for Windows and Chromium for Windows, explicitly refuses such fonts. However, since most of CJK ttf/otf fonts and some of Latin ttf/otf fonts have more than 2 faces (e.g., one is for horizontal writing and the other is for vertical writing), the restriction seems to be too strict. For example, HIRAGINO (ヒラギノ) font, which is the default Japanese OpenType font for Mac OS X, has 2 faces.

I'll attach a one-line patch that allows WebKit to load such fonts. Just for reference, Safari for Mac seems not to have the restriction. I tried to load the HIRAGINO font to Safari for Mac via @font-face (on my local machine, of course), and it succeeded. A comment in WebCore/platform/graphics/mac/FontCustomPlatformData.cpp says that when a font has more than 2 faces, the first one is used for rendering, and I believe this behavior is good enough for most cases.
Comment 1 Yusuke Sato 2009-11-23 06:41:43 PST
Created attachment 43711 [details]
allow_multiple_faces_v1
Comment 2 Eric Seidel (no email) 2009-11-25 21:18:49 PST
mitz wrote the code, hyatt reviewed it.  The change looks fine to me, but perhaps mitz had a reason for making this != 1 instead of < 1.

I would suggest we let mitz comment before this is landed.
Comment 3 Yusuke Sato 2009-11-30 07:15:50 PST
Slightly modified the summary so that it states the actual circumstance of the issue. An example of load failure of a Latin webfont is: http://code.google.com/p/chromium/issues/detail?id=28567

mitz, can you please take a look at the patch?
Comment 4 Adam Barth 2009-11-30 12:35:25 PST
style-queue successfully ran check-webkit-style on attachment 43711 [details] without any errors
Comment 5 mitz 2009-12-01 10:00:20 PST
I am trying to understand how this is supposed to work. On my Mac OS X v10.6 system, there are multiple font files whose name begins with ヒラギノ. Does one of them contain multiple faces? Which one?
Comment 6 Yusuke Sato 2009-12-01 17:39:18 PST
(In reply to comment #5)
> I am trying to understand how this is supposed to work. On my Mac OS X v10.6
> system, there are multiple font files whose name begins with ヒラギノ. Does one of
> them contain multiple faces? Which one?

Please try "ヒラギノ角ゴ ProN W6", for example.

$ ls -l /System/Library/Fonts/ヒラギノ角ゴ\ ProN\ W6.otf
-rw-r--r--  1 root  wheel  7515064 May 31  2008 /System/Library/Fonts/ヒラギノ角ゴ ProN W6.otf
Comment 7 mitz 2009-12-02 08:54:38 PST
(In reply to comment #3)
> An example of load failure of a Latin webfont is:
> http://code.google.com/p/chromium/issues/detail?id=28567

The URL in that bug, <http://www.alistapart.com/d/cssatten/stef.html>, is rendered correctly in Safari on Windows with TOT WebKit. I confirmed that even if I skip the TTLoadEmbeddedFont() call in createFontCustomPlatformData() and take the renameAndActivateFont() branch, all fonts on that page load correctly.
Comment 8 mitz 2009-12-02 09:20:26 PST
(In reply to comment #6)

> Please try "ヒラギノ角ゴ ProN W6", for example.

I could reproduce the problem with that font, i.e. numFonts was 2.
Comment 9 Eric Seidel (no email) 2009-12-02 09:28:45 PST
Comment on attachment 43711 [details]
allow_multiple_faces_v1

Marking cq+ since Yusuke isn't a committer yet.
Comment 10 WebKit Commit Bot 2009-12-02 11:17:54 PST
Comment on attachment 43711 [details]
allow_multiple_faces_v1

Clearing flags on attachment: 43711

Committed r51605: <http://trac.webkit.org/changeset/51605>
Comment 11 WebKit Commit Bot 2009-12-02 11:18:02 PST
All reviewed patches have been landed.  Closing bug.