font-optical-sizing applies the wrong variation value
authormmaxfield@apple.com <mmaxfield@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 23 May 2019 04:18:43 +0000 (04:18 +0000)
committermmaxfield@apple.com <mmaxfield@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 23 May 2019 04:18:43 +0000 (04:18 +0000)
commit6eef388db9d96d5a03c7c3372a5e7b427c007848
treeabde29c0cff8f312214c5b3838a3db27d145ecfb
parentf9c938cbeb2b9c388634466ba7e2bced89ab71b5
font-optical-sizing applies the wrong variation value
https://bugs.webkit.org/show_bug.cgi?id=197528
<rdar://problem/50152854>

Reviewed by Antti Koivisto.

Source/WebCore:

The OpenType spec says in
https://docs.microsoft.com/en-us/typography/opentype/spec/dvaraxistag_opsz

"Scale interpretation: Values can be interpreted as text size, in points."

It turns out that it means "typographic point size" which is equal to CSS pixels, not
CSS points.

There are two parts of the font that are sensitive to optical sizing: variation values and
the trak table. We don't want to set the variation value directly because then the trak table
won't be affected. Instead, we can use kCTFontOpticalSizeAttribute to set both of them together.
We will only do this when the CSS says text-rendering:optimizeLegibility or when the font has
an opsz axis but no STAT table. Otherwise, we won't do anything special, which lets CoreText
handle the default behavior for us. This gives us the same default behavior as the rest of the
system.

Tests: fast/text/variations/optical-sizing-trak-2.html
       fast/text/variations/optical-sizing-trak.html
       fast/text/variations/optical-sizing-units-2.html
       fast/text/variations/optical-sizing-units.html

* platform/graphics/cocoa/FontCacheCoreText.cpp:
(WebCore::FontType::FontType):
(WebCore::preparePlatformFont):
(WebCore::fontWithFamily):
(WebCore::FontCache::systemFallbackForCharacters):
* platform/graphics/cocoa/FontCacheCoreText.h:
* platform/graphics/cocoa/FontFamilySpecificationCoreText.cpp:
(WebCore::FontFamilySpecificationCoreText::fontRanges const):
* platform/graphics/mac/FontCustomPlatformData.cpp:
(WebCore::FontCustomPlatformData::fontPlatformData):

Source/WTF:

* wtf/Platform.h:

LayoutTests:

* fast/text/variations/optical-sizing-trak-2-expected-mismatch.html: Added.
* fast/text/variations/optical-sizing-trak-2.html: Added.
* fast/text/variations/optical-sizing-trak-expected.html: Added.
* fast/text/variations/optical-sizing-trak.html: Added.
* fast/text/variations/optical-sizing-units-2-expected-mismatch.html: Added.
* fast/text/variations/optical-sizing-units-2.html: Added.
* fast/text/variations/optical-sizing-units-expected.html: Added.
* fast/text/variations/optical-sizing-units.html: Added.
* fast/text/variations/resources/Amstelvar/Amstelvar-Roman-VF104.ttf: Added.
This font havariations/s been approved by the lawyers to add for layout tests.
* fast/text/variations/resources/Amstelvar/COPYRIGHT.md: Added.
* fast/text/variations/resources/Amstelvar/OFL.txt: Added.
* platform/win/TestExpectations:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@245672 268f45cc-cd09-0410-ab3c-d52691b4dbfc
20 files changed:
LayoutTests/ChangeLog
LayoutTests/fast/text/variations/optical-sizing-trak-2-expected-mismatch.html [new file with mode: 0644]
LayoutTests/fast/text/variations/optical-sizing-trak-2.html [new file with mode: 0644]
LayoutTests/fast/text/variations/optical-sizing-trak-expected.html [new file with mode: 0644]
LayoutTests/fast/text/variations/optical-sizing-trak.html [new file with mode: 0644]
LayoutTests/fast/text/variations/optical-sizing-units-2-expected-mismatch.html [new file with mode: 0644]
LayoutTests/fast/text/variations/optical-sizing-units-2.html [new file with mode: 0644]
LayoutTests/fast/text/variations/optical-sizing-units-expected.html [new file with mode: 0644]
LayoutTests/fast/text/variations/optical-sizing-units.html [new file with mode: 0644]
LayoutTests/fast/text/variations/resources/Amstelvar/Amstelvar-Roman-VF104.ttf [new file with mode: 0644]
LayoutTests/fast/text/variations/resources/Amstelvar/COPYRIGHT.md [new file with mode: 0644]
LayoutTests/fast/text/variations/resources/Amstelvar/OFL.txt [new file with mode: 0644]
LayoutTests/platform/win/TestExpectations
Source/WTF/ChangeLog
Source/WTF/wtf/Platform.h
Source/WebCore/ChangeLog
Source/WebCore/platform/graphics/cocoa/FontCacheCoreText.cpp
Source/WebCore/platform/graphics/cocoa/FontCacheCoreText.h
Source/WebCore/platform/graphics/cocoa/FontFamilySpecificationCoreText.cpp
Source/WebCore/platform/graphics/mac/FontCustomPlatformData.cpp