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

Unified Diff: src/core/SkTypeface.cpp

Issue 1905253002: Implement matchFamilyStyle for SkFontMgr_fontconfig (Closed) Base URL: https://chromium.googlesource.com/skia.git@master
Patch Set: 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 | « include/core/SkTypeface.h ('k') | src/fonts/SkFontMgr_fontconfig.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkTypeface.cpp
diff --git a/src/core/SkTypeface.cpp b/src/core/SkTypeface.cpp
index 855ef909e8c4c17a53c60bb5b708086efbe94391..136dc2da7df52b301f4d233b31b9c080ae98c3df 100644
--- a/src/core/SkTypeface.cpp
+++ b/src/core/SkTypeface.cpp
@@ -96,10 +96,20 @@ SkTypeface* SkTypeface::GetDefaultTypeface(Style style) {
});
}
+SkTypeface* SkTypeface::GetDefaultTypeface(SkFontStyle style) {
+ SkAutoTUnref<SkFontMgr> fm(SkFontMgr::RefDefault());
+ SkTypeface* t = fm->matchFamilyStyle(nullptr, style);
+ return t ? t : SkEmptyTypeface::Create();
+}
+
SkTypeface* SkTypeface::RefDefault(Style style) {
return SkRef(GetDefaultTypeface(style));
}
+SkTypeface* SkTypeface::RefDefault(SkFontStyle style) {
+ return SkRef(GetDefaultTypeface(style));
+}
+
uint32_t SkTypeface::UniqueID(const SkTypeface* face) {
if (nullptr == face) {
face = GetDefaultTypeface();
@@ -127,6 +137,14 @@ SkTypeface* SkTypeface::CreateFromName(const char name[], Style style) {
return fm->legacyCreateTypeface(name, SkFontStyle::FromOldStyle(style));
}
+SkTypeface* SkTypeface::CreateFromName(const char name[], SkFontStyle style) {
+ if (nullptr == name) {
+ return RefDefault(style);
+ }
+ SkAutoTUnref<SkFontMgr> fm(SkFontMgr::RefDefault());
+ return fm->matchFamilyStyle(name, style);
+}
+
SkTypeface* SkTypeface::CreateFromTypeface(const SkTypeface* family, Style s) {
if (!family) {
return SkTypeface::RefDefault(s);
« no previous file with comments | « include/core/SkTypeface.h ('k') | src/fonts/SkFontMgr_fontconfig.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698