Bug 100446 - local(Helvetica) in src descriptor prevent fallback
Summary: local(Helvetica) in src descriptor prevent fallback
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Text (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Kenichi Ishibashi
URL:
Keywords:
Depends on: 100498
Blocks:
  Show dependency treegraph
 
Reported: 2012-10-25 19:50 PDT by Kenichi Ishibashi
Modified: 2012-10-30 17:45 PDT (History)
5 users (show)

See Also:


Attachments
test case (337 bytes, text/html)
2012-10-25 19:50 PDT, Kenichi Ishibashi
no flags Details
Patch (1.86 KB, patch)
2012-10-25 22:30 PDT, Kenichi Ishibashi
no flags Details | Formatted Diff | Diff
Patch for landing (2.47 KB, patch)
2012-10-25 23:23 PDT, Kenichi Ishibashi
no flags Details | Formatted Diff | Diff
Patch for landing (6.12 KB, patch)
2012-10-30 16:49 PDT, Kenichi Ishibashi
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Kenichi Ishibashi 2012-10-25 19:50:56 PDT
Created attachment 170791 [details]
test case

Test case attached.

WebKit doesn't fallback src descriptor of @font-face when the src descriptor contain "local(Helvetica)" even if a machine doesn't have Helvetica font. Instead, WebKit uses Arial font to render text.

The following code causes the issue (in FontCache.cpp):

static const AtomicString& alternateFamilyName(const AtomicString& familyName)
{
    ...
    // Alias Arial and Helvetica
    DEFINE_STATIC_LOCAL(AtomicString, arial, ("Arial"));
    DEFINE_STATIC_LOCAL(AtomicString, helvetica, ("Helvetica"));
    if (equalIgnoringCase(familyName, arial))
        return helvetica;
    if (equalIgnoringCase(familyName, helvetica))
        return arial;
    ...
}

Helvetica is replaced with Arial when Helvetica isn't on the machine. Since most machines have Arial, the text will be rendered with Arial. This behavior prevents page authors to use their Helvetica fonts as webfonts.
Comment 1 Kenichi Ishibashi 2012-10-25 19:52:08 PDT
I'm not sure why these replacements exists. We can fix the issue by just removing these replacements.

Mitz, what do you think?
Comment 2 mitz 2012-10-25 21:22:49 PDT
(In reply to comment #1)
> I'm not sure why these replacements exists. We can fix the issue by just removing these replacements.
> 
> Mitz, what do you think?

I think the aliases exist for better compatibility with some websites, and that this bug can be fixed by changing CSSFontFaceSource::getFontData() to pass true as the checkingAlternateName parameter of getCachedFontData().
Comment 3 Kenichi Ishibashi 2012-10-25 22:30:37 PDT
Created attachment 170815 [details]
Patch
Comment 4 Kenichi Ishibashi 2012-10-25 22:32:06 PDT
(In reply to comment #2)
> I think the aliases exist for better compatibility with some websites, and that this bug can be fixed by changing CSSFontFaceSource::getFontData() to pass true as the checkingAlternateName parameter of getCachedFontData().

Thanks for the suggestion. It works. Posted a patch.
Comment 5 mitz 2012-10-25 22:42:04 PDT
Comment on attachment 170815 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=170815&action=review

> Source/WebCore/ChangeLog:19
> +

Somewhere in this change log there should be a description of the problem and how it was solved. Something along these lines, perhaps:
FontCache::getCachedFontData() has a mechanism that aliases a few pairs of font family names, so that if the family name specified in the font-family property is not available on the system, but the its alias is available, it will be used instead. This is appropriate for the font-family property, but not for font family names specified in the local() function of the src descriptor in a @font-face rule.

> Source/WebCore/css/CSSFontFaceSource.cpp:109
> +        return fontCache()->getCachedFontData(fontDescription, m_string, true);

You can even add a comment before this line explaining why we’re passing true.
Comment 6 Kenichi Ishibashi 2012-10-25 23:23:03 PDT
Created attachment 170825 [details]
Patch for landing
Comment 7 Kenichi Ishibashi 2012-10-25 23:23:34 PDT
Comment on attachment 170815 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=170815&action=review

Thank you for review.

>> Source/WebCore/ChangeLog:19
>> +
> 
> Somewhere in this change log there should be a description of the problem and how it was solved. Something along these lines, perhaps:
> FontCache::getCachedFontData() has a mechanism that aliases a few pairs of font family names, so that if the family name specified in the font-family property is not available on the system, but the its alias is available, it will be used instead. This is appropriate for the font-family property, but not for font family names specified in the local() function of the src descriptor in a @font-face rule.

Done.

>> Source/WebCore/css/CSSFontFaceSource.cpp:109
>> +        return fontCache()->getCachedFontData(fontDescription, m_string, true);
> 
> You can even add a comment before this line explaining why we’re passing true.

Done.
Comment 8 WebKit Review Bot 2012-10-26 02:09:23 PDT
Comment on attachment 170825 [details]
Patch for landing

Clearing flags on attachment: 170825

Committed r132589: <http://trac.webkit.org/changeset/132589>
Comment 9 WebKit Review Bot 2012-10-26 02:09:27 PDT
All reviewed patches have been landed.  Closing bug.
Comment 10 WebKit Review Bot 2012-10-26 04:30:16 PDT
Re-opened since this is blocked by bug 100498
Comment 11 Kenichi Ishibashi 2012-10-30 16:49:03 PDT
Created attachment 171549 [details]
Patch for landing
Comment 12 WebKit Review Bot 2012-10-30 17:45:37 PDT
Comment on attachment 171549 [details]
Patch for landing

Clearing flags on attachment: 171549

Committed r132969: <http://trac.webkit.org/changeset/132969>
Comment 13 WebKit Review Bot 2012-10-30 17:45:41 PDT
All reviewed patches have been landed.  Closing bug.