Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(733)

Unified Diff: third_party/WebKit/Source/platform/fonts/mac/FontPlatformDataMac.mm

Issue 2581083003: Initial OpenType Font Variations Support (Closed)
Patch Set: Fix hash collision tests, adjust test expectations Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/platform/fonts/mac/FontPlatformDataMac.mm
diff --git a/third_party/WebKit/Source/platform/fonts/mac/FontPlatformDataMac.mm b/third_party/WebKit/Source/platform/fonts/mac/FontPlatformDataMac.mm
index 27a754ddbf36f18ad235eea62e32adda3205eda3..14a49885a1c96300b23c3d2ffab2102f3352206a 100644
--- a/third_party/WebKit/Source/platform/fonts/mac/FontPlatformDataMac.mm
+++ b/third_party/WebKit/Source/platform/fonts/mac/FontPlatformDataMac.mm
@@ -25,6 +25,7 @@
#import "platform/LayoutTestSupport.h"
#import "platform/fonts/Font.h"
+#import "platform/fonts/opentype/FontSettings.h"
#import "platform/fonts/shaping/HarfBuzzFace.h"
#import "platform/graphics/skia/SkiaUtils.h"
#import "public/platform/Platform.h"
@@ -163,7 +164,8 @@ FontPlatformData::FontPlatformData(NSFont* nsFont,
float size,
bool syntheticBold,
bool syntheticItalic,
- FontOrientation orientation)
+ FontOrientation orientation,
+ FontVariationSettings* variationSettings)
: m_textSize(size),
m_syntheticBold(syntheticBold),
m_syntheticItalic(syntheticItalic),
@@ -178,6 +180,21 @@ FontPlatformData::FontPlatformData(NSFont* nsFont,
// and ~/Library Fonts, see crbug.com/72727 or crbug.com/108645.
m_typeface = loadFromBrowserProcess(nsFont, size);
}
+
+ if (variationSettings && variationSettings->size() < UINT16_MAX) {
+ SkFontMgr::FontParameters::Axis axes[variationSettings->size()];
+ for (size_t i = 0; i < variationSettings->size(); ++i) {
+ AtomicString featureTag = variationSettings->at(i).tag();
+ axes[i] = {atomicStringToFourByteTag(featureTag),
+ SkFloatToScalar(variationSettings->at(i).value())};
+ }
+ RefPtr<SkFontMgr> fm = adoptRef(SkFontMgr::RefDefault());
kojii 2016/12/21 14:53:12 Same (sk_sp)
drott 2016/12/21 15:22:00 Done.
+ // TODO crbug.com/670246: Refactor this to a future Skia API that acccepts
+ // axis parameters on system fonts directly.
+ m_typeface = sk_sp<SkTypeface>(fm->createFromStream(
+ m_typeface->openStream(nullptr)->duplicate(),
+ SkFontMgr::FontParameters().setAxes(axes, variationSettings->size())));
+ }
}
} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698