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

Side by Side Diff: src/ports/SkFontMgr_android.cpp

Issue 1207893002: Clean up a few includes, introduce iwyu. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: SkTypes to export stddef. Created 5 years, 4 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
« no previous file with comments | « src/ports/SkFontHost_fontconfig.cpp ('k') | src/ports/SkFontMgr_android_parser.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2014 Google Inc. 2 * Copyright 2014 Google Inc.
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 "SkFixed.h"
8 #include "SkFontDescriptor.h" 9 #include "SkFontDescriptor.h"
9 #include "SkFontHost_FreeType_common.h" 10 #include "SkFontHost_FreeType_common.h"
10 #include "SkFontMgr.h" 11 #include "SkFontMgr.h"
11 #include "SkFontMgr_android.h" 12 #include "SkFontMgr_android.h"
12 #include "SkFontMgr_android_parser.h" 13 #include "SkFontMgr_android_parser.h"
13 #include "SkFontStyle.h" 14 #include "SkFontStyle.h"
15 #include "SkRefCnt.h"
16 #include "SkString.h"
14 #include "SkStream.h" 17 #include "SkStream.h"
18 #include "SkTArray.h"
15 #include "SkTDArray.h" 19 #include "SkTDArray.h"
16 #include "SkTSearch.h" 20 #include "SkTSearch.h"
21 #include "SkTemplates.h"
17 #include "SkTypeface.h" 22 #include "SkTypeface.h"
18 #include "SkTypefaceCache.h" 23 #include "SkTypefaceCache.h"
19 24
20 #include <limits> 25 #include <limits>
21 26
27 class SkData;
28
22 class SkTypeface_Android : public SkTypeface_FreeType { 29 class SkTypeface_Android : public SkTypeface_FreeType {
23 public: 30 public:
24 SkTypeface_Android(const SkFontStyle& style, 31 SkTypeface_Android(const SkFontStyle& style,
25 bool isFixedPitch, 32 bool isFixedPitch,
26 const SkString& familyName) 33 const SkString& familyName)
27 : INHERITED(style, SkTypefaceCache::NewFontID(), isFixedPitch) 34 : INHERITED(style, SkTypefaceCache::NewFontID(), isFixedPitch)
28 , fFamilyName(familyName) 35 , fFamilyName(familyName)
29 { } 36 { }
30 37
31 protected: 38 protected:
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after
268 } 275 }
269 return SkRef(closest); 276 return SkRef(closest);
270 } 277 }
271 278
272 private: 279 private:
273 SkFontStyle style(int index) { 280 SkFontStyle style(int index) {
274 return fStyles[index]->fontStyle(); 281 return fStyles[index]->fontStyle();
275 } 282 }
276 static int match_score(const SkFontStyle& pattern, const SkFontStyle& candid ate) { 283 static int match_score(const SkFontStyle& pattern, const SkFontStyle& candid ate) {
277 int score = 0; 284 int score = 0;
278 score += abs((pattern.width() - candidate.width()) * 100); 285 score += SkTAbs((pattern.width() - candidate.width()) * 100);
279 score += abs((pattern.isItalic() == candidate.isItalic()) ? 0 : 1000); 286 score += SkTAbs((pattern.isItalic() == candidate.isItalic()) ? 0 : 1000) ;
280 score += abs(pattern.weight() - candidate.weight()); 287 score += SkTAbs(pattern.weight() - candidate.weight());
281 return score; 288 return score;
282 } 289 }
283 290
284 SkTArray<SkAutoTUnref<SkTypeface_AndroidSystem>, true> fStyles; 291 SkTArray<SkAutoTUnref<SkTypeface_AndroidSystem>, true> fStyles;
285 292
286 friend struct NameToFamily; 293 friend struct NameToFamily;
287 friend class SkFontMgr_Android; 294 friend class SkFontMgr_Android;
288 295
289 typedef SkFontStyleSet INHERITED; 296 typedef SkFontStyleSet INHERITED;
290 }; 297 };
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
393 SkAutoTUnref<SkTypeface_AndroidSystem> face(family->matchStyle(style )); 400 SkAutoTUnref<SkTypeface_AndroidSystem> face(family->matchStyle(style ));
394 401
395 if (!langTag.isEmpty() && !face->fLang.getTag().startsWith(langTag.c _str())) { 402 if (!langTag.isEmpty() && !face->fLang.getTag().startsWith(langTag.c _str())) {
396 continue; 403 continue;
397 } 404 }
398 405
399 if (SkToBool(face->fVariantStyle & kElegant_FontVariant) != elegant) { 406 if (SkToBool(face->fVariantStyle & kElegant_FontVariant) != elegant) {
400 continue; 407 continue;
401 } 408 }
402 409
403 SkPaint paint; 410 if (face->charsToGlyphs(&character, SkTypeface::kUTF32_Encoding, NUL L, 0)) {
404 paint.setTypeface(face);
405 paint.setTextEncoding(SkPaint::kUTF32_TextEncoding);
406
407 uint16_t glyphID;
408 paint.textToGlyphs(&character, sizeof(character), &glyphID);
409 if (glyphID != 0) {
410 return face.detach(); 411 return face.detach();
411 } 412 }
412 } 413 }
413 return NULL; 414 return NULL;
414 } 415 }
415 416
416 virtual SkTypeface* onMatchFamilyStyleCharacter(const char familyName[], 417 virtual SkTypeface* onMatchFamilyStyleCharacter(const char familyName[],
417 const SkFontStyle& style, 418 const SkFontStyle& style,
418 const char* bcp47[], 419 const char* bcp47[],
419 int bcp47Count, 420 int bcp47Count,
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
579 SkASSERT(custom->fSystemFontUse < SK_ARRAY_COUNT(gSystemFontUseStrings)) ; 580 SkASSERT(custom->fSystemFontUse < SK_ARRAY_COUNT(gSystemFontUseStrings)) ;
580 SkDEBUGF(("SystemFontUse: %s BasePath: %s Fonts: %s FallbackFonts: %s\n" , 581 SkDEBUGF(("SystemFontUse: %s BasePath: %s Fonts: %s FallbackFonts: %s\n" ,
581 gSystemFontUseStrings[custom->fSystemFontUse], 582 gSystemFontUseStrings[custom->fSystemFontUse],
582 custom->fBasePath, 583 custom->fBasePath,
583 custom->fFontsXml, 584 custom->fFontsXml,
584 custom->fFallbackFontsXml)); 585 custom->fFallbackFontsXml));
585 } 586 }
586 587
587 return SkNEW_ARGS(SkFontMgr_Android, (custom)); 588 return SkNEW_ARGS(SkFontMgr_Android, (custom));
588 } 589 }
OLDNEW
« no previous file with comments | « src/ports/SkFontHost_fontconfig.cpp ('k') | src/ports/SkFontMgr_android_parser.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698