New issue
Advanced search Search tips

Issue 670246 link

Starred by 3 users

Issue metadata

Status: Fixed
Owner:
Closed: Dec 2017
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: Mac
Pri: 3
Type: Bug

Blocking:
issue 792874



Sign in to add a comment

[Mac] Allow instantiation of system fonts with variation parameters

Project Member Reported by drott@chromium.org, Dec 1 2016

Issue description

Currently we can only instantiate a variation fonts from a decoded web font buffer, even though some system fonts on macOS support variation axes, compare

https://jsfiddle.net/k6pkvj66/1/
https://jsfiddle.net/0v1wkpmz/

Our current approach on Mac font matching is to implement our own font matching, then use SkCreateTypefaceFromCTFont to create an SkTypeface.

Ben, do you recommend using SkFontMgr's createFromStream and doing something like
m_typeface->openStream(nullptr)->duplicate() on the existing system font SkTypeface object created from SkCreateTypefaceFromCTFont? Or will there be a separate API for instantiation of a system font with variation axis parameters in Skia?

 

Comment 1 by drott@chromium.org, Dec 1 2016

I've got a proof of concept working using the approach sketched above.

We eventually need a way to create system fonts with FontParameters for multiple reasons, but this is generally a good one. In particular, SkTypeface::openStream is much more expensive on the Mac (and somewhat less accurate), mostly due to the limited API. For the time being it should work out fine to just call SkFontMgr::createFromStream though. If you run into oddities on Mac let me know, the code in Skia is quite... interesting due to working around various bugs.
Project Member

Comment 3 by bugdroid1@chromium.org, Dec 22 2016

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/d5cec19a655dbb722f75bfccdaa44f69c0827e64

commit d5cec19a655dbb722f75bfccdaa44f69c0827e64
Author: drott <drott@chromium.org>
Date: Thu Dec 22 18:32:45 2016

Initial OpenType Font Variations Support

Adding support for instantiating OpenType Font Variations from web fonts
through font-variation-settings on Linux and Mac. Linux currenly
requires a system FreeType at version 2.6.5 or newer and at least macOS
10.11, but support is still experimental.

With this CL, in addition to web fonts Mac supports instantiating system
font variations.

Some known issues, see meta bug  crbug.com/669453 :
* Correct mark positioning requires new HarfBuzz API to pass axis
  parameters from Skia to HarfBuzz
* Incorrect advance width scaling on Linux when hinting is enabled (as
  it is by default), discussed and almost solved in
  https://bugs.chromium.org/p/skia/issues/detail?id=5917

TEST=fast/text/variable-fonts/variable-box-font.html,
fast/text/variable-fonts/variable-mac-system-font.html,
http/tests/webfont/variable-box-font-arraybuffer.html
FontSettingsTest.cpp
BUG= 669459 ,  670246 

Review-Url: https://codereview.chromium.org/2581083003
Cr-Commit-Position: refs/heads/master@{#440455}

[modify] https://crrev.com/d5cec19a655dbb722f75bfccdaa44f69c0827e64/third_party/WebKit/LayoutTests/NeverFixTests
[add] https://crrev.com/d5cec19a655dbb722f75bfccdaa44f69c0827e64/third_party/WebKit/LayoutTests/fast/text/variable-fonts/variable-box-font-expected.html
[add] https://crrev.com/d5cec19a655dbb722f75bfccdaa44f69c0827e64/third_party/WebKit/LayoutTests/fast/text/variable-fonts/variable-box-font.html
[add] https://crrev.com/d5cec19a655dbb722f75bfccdaa44f69c0827e64/third_party/WebKit/LayoutTests/fast/text/variable-fonts/variable-mac-system-font.html
[add] https://crrev.com/d5cec19a655dbb722f75bfccdaa44f69c0827e64/third_party/WebKit/LayoutTests/http/tests/resources/variabletest_box.ttf
[add] https://crrev.com/d5cec19a655dbb722f75bfccdaa44f69c0827e64/third_party/WebKit/LayoutTests/http/tests/webfont/variable-box-font-arraybuffer-expected.html
[add] https://crrev.com/d5cec19a655dbb722f75bfccdaa44f69c0827e64/third_party/WebKit/LayoutTests/http/tests/webfont/variable-box-font-arraybuffer.html
[modify] https://crrev.com/d5cec19a655dbb722f75bfccdaa44f69c0827e64/third_party/WebKit/Source/core/css/BinaryDataFontFaceSource.cpp
[modify] https://crrev.com/d5cec19a655dbb722f75bfccdaa44f69c0827e64/third_party/WebKit/Source/core/css/CSSFontFaceSourceTest.cpp
[modify] https://crrev.com/d5cec19a655dbb722f75bfccdaa44f69c0827e64/third_party/WebKit/Source/core/css/RemoteFontFaceSource.cpp
[modify] https://crrev.com/d5cec19a655dbb722f75bfccdaa44f69c0827e64/third_party/WebKit/Source/core/loader/resource/FontResource.cpp
[modify] https://crrev.com/d5cec19a655dbb722f75bfccdaa44f69c0827e64/third_party/WebKit/Source/core/loader/resource/FontResource.h
[modify] https://crrev.com/d5cec19a655dbb722f75bfccdaa44f69c0827e64/third_party/WebKit/Source/platform/BUILD.gn
[modify] https://crrev.com/d5cec19a655dbb722f75bfccdaa44f69c0827e64/third_party/WebKit/Source/platform/fonts/FontCacheKey.h
[modify] https://crrev.com/d5cec19a655dbb722f75bfccdaa44f69c0827e64/third_party/WebKit/Source/platform/fonts/FontCustomPlatformData.cpp
[modify] https://crrev.com/d5cec19a655dbb722f75bfccdaa44f69c0827e64/third_party/WebKit/Source/platform/fonts/FontCustomPlatformData.h
[modify] https://crrev.com/d5cec19a655dbb722f75bfccdaa44f69c0827e64/third_party/WebKit/Source/platform/fonts/FontDescription.cpp
[modify] https://crrev.com/d5cec19a655dbb722f75bfccdaa44f69c0827e64/third_party/WebKit/Source/platform/fonts/FontPlatformData.h
[modify] https://crrev.com/d5cec19a655dbb722f75bfccdaa44f69c0827e64/third_party/WebKit/Source/platform/fonts/WebFontDecoder.cpp
[modify] https://crrev.com/d5cec19a655dbb722f75bfccdaa44f69c0827e64/third_party/WebKit/Source/platform/fonts/linux/FontPlatformDataLinux.cpp
[modify] https://crrev.com/d5cec19a655dbb722f75bfccdaa44f69c0827e64/third_party/WebKit/Source/platform/fonts/mac/FontCacheMac.mm
[modify] https://crrev.com/d5cec19a655dbb722f75bfccdaa44f69c0827e64/third_party/WebKit/Source/platform/fonts/mac/FontPlatformDataMac.mm
[add] https://crrev.com/d5cec19a655dbb722f75bfccdaa44f69c0827e64/third_party/WebKit/Source/platform/fonts/opentype/FontSettings.cpp
[modify] https://crrev.com/d5cec19a655dbb722f75bfccdaa44f69c0827e64/third_party/WebKit/Source/platform/fonts/opentype/FontSettings.h
[add] https://crrev.com/d5cec19a655dbb722f75bfccdaa44f69c0827e64/third_party/WebKit/Source/platform/fonts/opentype/FontSettingsTest.cpp
[modify] https://crrev.com/d5cec19a655dbb722f75bfccdaa44f69c0827e64/third_party/WebKit/Source/platform/fonts/shaping/HarfBuzzFace.cpp

Comment 4 by e...@chromium.org, Dec 5 2017

Can this be closed now drott?

Comment 5 by drott@chromium.org, Dec 7 2017

No, we only do instantiation of web fonts with variable axis parameters, we do not support variable system fonts yet, except on Mac.

Comment 6 by drott@chromium.org, Dec 7 2017

Status: Fixed (was: Assigned)
Or wait, well, since this bug is about Mac, we can close it, but we need to create a new one for other platforms, I'll do that.

Comment 7 by drott@chromium.org, May 31 2018

Summary: [Mac] Allow instantiation of system fonts with variation parameters (was: Allow instantiation of system fonts with variation parameters)

Comment 8 by drott@chromium.org, May 31 2018

Blocking: -669453 792874

Sign in to add a comment