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

Unified Diff: src/ports/SkFontHost_mac.cpp

Issue 1873923002: Begin switch to SkFontStyle for legacy calls. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Dont update bzl file now. Created 4 years, 8 months 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
« no previous file with comments | « src/ports/SkFontHost_fontconfig.cpp ('k') | src/ports/SkFontHost_win.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/ports/SkFontHost_mac.cpp
diff --git a/src/ports/SkFontHost_mac.cpp b/src/ports/SkFontHost_mac.cpp
index 8d4a3f8cfcc0a1a39d3edd24bdcf34a1fd94fedf..70693ee1445d8774be70bd1a6421f63b03a00192 100644
--- a/src/ports/SkFontHost_mac.cpp
+++ b/src/ports/SkFontHost_mac.cpp
@@ -420,22 +420,6 @@ static SkFontStyle fontstyle_from_descriptor(CTFontDescriptorRef desc) {
: SkFontStyle::kUpright_Slant);
}
-static SkTypeface::Style computeStyleBits(CTFontRef font, bool* isFixedPitch) {
- unsigned style = SkTypeface::kNormal;
- CTFontSymbolicTraits traits = CTFontGetSymbolicTraits(font);
-
- if (traits & kCTFontBoldTrait) {
- style |= SkTypeface::kBold;
- }
- if (traits & kCTFontItalicTrait) {
- style |= SkTypeface::kItalic;
- }
- if (isFixedPitch) {
- *isFixedPitch = (traits & kCTFontMonoSpaceTrait) != 0;
- }
- return (SkTypeface::Style)style;
-}
-
#define WEIGHT_THRESHOLD ((SkFontStyle::kNormal_Weight + SkFontStyle::kBold_Weight)/2)
// kCTFontColorGlyphsTrait was added in the Mac 10.7 and iPhone 4.3 SDKs.
@@ -493,9 +477,12 @@ private:
/** Creates a typeface without searching the cache. Takes ownership of the CTFontRef. */
static SkTypeface* NewFromFontRef(CTFontRef fontRef, CFTypeRef resourceRef, bool isLocalStream) {
SkASSERT(fontRef);
- bool isFixedPitch;
- SkFontStyle style = SkFontStyle(computeStyleBits(fontRef, &isFixedPitch));
+ AutoCFRelease<CTFontDescriptorRef> desc(CTFontCopyFontDescriptor(fontRef));
+ SkFontStyle style = fontstyle_from_descriptor(desc);
+
+ CTFontSymbolicTraits traits = CTFontGetSymbolicTraits(fontRef);
+ bool isFixedPitch = SkToBool(traits & kCTFontMonoSpaceTrait);
return new SkTypeface_Mac(fontRef, resourceRef, style, isFixedPitch, isLocalStream);
}
@@ -2572,10 +2559,12 @@ protected:
return create_from_dataProvider(pr);
}
- virtual SkTypeface* onLegacyCreateTypeface(const char familyName[],
- unsigned styleBits) const override {
-
- SkFontStyle style = SkFontStyle((SkTypeface::Style)styleBits);
+#ifdef SK_VERY_LEGACY_CREATE_TYPEFACE
+ SkTypeface* onLegacyCreateTypeface(const char familyName[], unsigned styleBits) const override {
+ SkFontStyle style = SkFontStyle::FromOldStyle(styleBits);
+#else
+ SkTypeface* onLegacyCreateTypeface(const char familyName[], SkFontStyle style) const override {
+#endif
if (familyName) {
familyName = map_css_names(familyName);
}
« no previous file with comments | « src/ports/SkFontHost_fontconfig.cpp ('k') | src/ports/SkFontHost_win.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698