Bug 92724 - CSSFontSelector::getFontData() doesn't check font-weight
Summary: CSSFontSelector::getFontData() doesn't check font-weight
Status: RESOLVED WONTFIX
Alias: None
Product: WebKit
Classification: Unclassified
Component: CSS (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Kenichi Ishibashi
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-07-31 00:38 PDT by Kenichi Ishibashi
Modified: 2012-08-06 19:42 PDT (History)
7 users (show)

See Also:


Attachments
Patch (6.55 KB, patch)
2012-07-31 01:29 PDT, Kenichi Ishibashi
no flags Details | Formatted Diff | Diff
Archive of layout-test-results from gce-cr-linux-07 (688.95 KB, application/zip)
2012-07-31 02:21 PDT, WebKit Review Bot
no flags Details
Patch (6.67 KB, patch)
2012-07-31 18:35 PDT, Kenichi Ishibashi
mitz: review-
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-07-31 00:38:41 PDT
CSSFontSelector::getFontData() checks font-variants and font-style, but doesn't check font-weight. This results WebKit download unnecessary webfonts.

You can try the behavior at http://jsbin.com/ehiwam/9/quiet
Results of major browsers are:
- Chrome/Safari: downloads two fonts (both bold faces)
- Firefox: downloads single font
- Opera: downloads all four
- IE: downloads all four

The current draft spec(http://dev.w3.org/csswg/css3-fonts/#font-prop-desc) says:

"For a font family defined with several @font-face rules, user agents can either download all faces in the family or use these descriptors to selectively download font faces that match actual styles used in document."

The current behavior doesn't violate the spec, but I think it would be better to follow FireFox.
Comment 1 Kenichi Ishibashi 2012-07-31 01:29:51 PDT
Created attachment 155464 [details]
Patch
Comment 2 WebKit Review Bot 2012-07-31 02:21:26 PDT
Comment on attachment 155464 [details]
Patch

Attachment 155464 [details] did not pass chromium-ews (chromium-xvfb):
Output: http://queues.webkit.org/results/13391619

New failing tests:
fast/css/font-face-multiple-faces.html
Comment 3 WebKit Review Bot 2012-07-31 02:21:31 PDT
Created attachment 155471 [details]
Archive of layout-test-results from gce-cr-linux-07

The attached test failures were seen while running run-webkit-tests on the chromium-ews.
Bot: gce-cr-linux-07  Port: <class 'webkitpy.common.config.ports.ChromiumXVFBPort'>  Platform: Linux-2.6.39-gcg-201203291735-x86_64-with-Ubuntu-10.04-lucid
Comment 4 Kenichi Ishibashi 2012-07-31 02:39:40 PDT
(In reply to comment #2)
> (From update of attachment 155464 [details])
> Attachment 155464 [details] did not pass chromium-ews (chromium-xvfb):
> Output: http://queues.webkit.org/results/13391619
> 
> New failing tests:
> fast/css/font-face-multiple-faces.html

Expected failure. I checked the test on my machine and it should be rebaselined.
Comment 5 mitz 2012-07-31 08:15:33 PDT
Comment on attachment 155464 [details]
Patch

I think this can omit some Unicode ranges of a normal-weight font when asking for a bold font and there are no bold faces covering those ranges.
Comment 6 Kenichi Ishibashi 2012-07-31 18:35:04 PDT
Created attachment 155700 [details]
Patch
Comment 7 Kenichi Ishibashi 2012-07-31 18:38:06 PDT
(In reply to comment #5)
> (From update of attachment 155464 [details])
> I think this can omit some Unicode ranges of a normal-weight font when asking for a bold font and there are no bold faces covering those ranges.

You are right. I updated the patch so that the change only applies when asking a normal weight font. I think this matches checks of font-style and font-variant.
Comment 8 mitz 2012-08-06 11:47:15 PDT
Comment on attachment 155700 [details]
Patch

This is still wrong. For example, it breaks this test case:

<style>
    @font-face {
        font-family: custom;
        src: url(file:///Library/Fonts/Herculanum.ttf);
        font-weight: 500;
        unicode-range: U+0060-0061;
    }
    @font-face {
        font-family: custom;
        src: url(file:///Library/Fonts/Zapfino.ttf);
        font-weight: 300;
    }
</style>
<div style="font-family: custom;">ab</div>
Comment 9 Kenichi Ishibashi 2012-08-06 17:44:02 PDT
(In reply to comment #8)
> (From update of attachment 155700 [details])
> This is still wrong. For example, it breaks this test case:
> 
> <style>
>     @font-face {
>         font-family: custom;
>         src: url(file:///Library/Fonts/Herculanum.ttf);
>         font-weight: 500;
>         unicode-range: U+0060-0061;
>     }
>     @font-face {
>         font-family: custom;
>         src: url(file:///Library/Fonts/Zapfino.ttf);
>         font-weight: 300;
>     }
> </style>
> <div style="font-family: custom;">ab</div>

s/ab/c/ ? Anyway it looks like I need to modify  a lot of portions of CSSSegmentedFontFace and others and I don't think it's worth to do. Thank you for review.