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

Side by Side Diff: src/core/SkTypeface.cpp

Issue 1818043002: SkTypeface::MakeFromName to take SkFontStyle. (Closed) Base URL: https://chromium.googlesource.com/skia.git@master
Patch Set: Created 4 years, 9 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright 2011 The Android Open Source Project 2 * Copyright 2011 The Android Open Source Project
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "SkAdvancedTypefaceMetrics.h" 8 #include "SkAdvancedTypefaceMetrics.h"
9 #include "SkEndian.h" 9 #include "SkEndian.h"
10 #include "SkFontDescriptor.h" 10 #include "SkFontDescriptor.h"
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 } 101 }
102 return face->uniqueID(); 102 return face->uniqueID();
103 } 103 }
104 104
105 bool SkTypeface::Equal(const SkTypeface* facea, const SkTypeface* faceb) { 105 bool SkTypeface::Equal(const SkTypeface* facea, const SkTypeface* faceb) {
106 return facea == faceb || SkTypeface::UniqueID(facea) == SkTypeface::UniqueID (faceb); 106 return facea == faceb || SkTypeface::UniqueID(facea) == SkTypeface::UniqueID (faceb);
107 } 107 }
108 108
109 /////////////////////////////////////////////////////////////////////////////// 109 ///////////////////////////////////////////////////////////////////////////////
110 110
111 SkTypeface* SkTypeface::CreateFromNameAndStyle(const char name[],
112 SkFontStyle fontStyle) {
113 if (nullptr == name) {
114 return RefDefault();
115 }
116 SkAutoTUnref<SkFontMgr> fm(SkFontMgr::RefDefault());
117 return fm->matchFamilyStyle(name, fontStyle);
118 }
119
111 SkTypeface* SkTypeface::CreateFromName(const char name[], Style style) { 120 SkTypeface* SkTypeface::CreateFromName(const char name[], Style style) {
112 if (gCreateTypefaceDelegate) { 121 if (gCreateTypefaceDelegate) {
113 SkTypeface* result = (*gCreateTypefaceDelegate)(name, style); 122 SkTypeface* result = (*gCreateTypefaceDelegate)(name, style);
114 if (result) { 123 if (result) {
115 return result; 124 return result;
116 } 125 }
117 } 126 }
118 if (nullptr == name) { 127 if (nullptr == name) {
119 return RefDefault(style); 128 return RefDefault(style);
120 } 129 }
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after
352 if (ctx.get()) { 361 if (ctx.get()) {
353 SkPaint::FontMetrics fm; 362 SkPaint::FontMetrics fm;
354 ctx->getFontMetrics(&fm); 363 ctx->getFontMetrics(&fm);
355 bounds->set(fm.fXMin * invTextSize, fm.fTop * invTextSize, 364 bounds->set(fm.fXMin * invTextSize, fm.fTop * invTextSize,
356 fm.fXMax * invTextSize, fm.fBottom * invTextSize); 365 fm.fXMax * invTextSize, fm.fBottom * invTextSize);
357 return true; 366 return true;
358 } 367 }
359 return false; 368 return false;
360 } 369 }
361 370
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698