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

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

Issue 2581083003: Initial OpenType Font Variations Support (Closed)
Patch Set: Fix makeUnique syntax 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..d09bc6d4b41bde339012a6d5055f6007d399d167 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())};
+ }
+ sk_sp<SkFontMgr> fm(SkFontMgr::RefDefault());
+ // 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