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.
Created attachment 155464 [details] Patch
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
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
(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 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.
Created attachment 155700 [details] Patch
(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 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>
(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.