OLD | NEW |
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 "SkFontConfigParser_android.h" | 8 #include "SkFontConfigParser_android.h" |
9 #include "SkFontDescriptor.h" | 9 #include "SkFontDescriptor.h" |
10 #include "SkFontHost_FreeType_common.h" | 10 #include "SkFontHost_FreeType_common.h" |
(...skipping 16 matching lines...) Expand all Loading... |
27 #ifndef SK_DEBUG_FONTS | 27 #ifndef SK_DEBUG_FONTS |
28 #define SK_DEBUG_FONTS 0 | 28 #define SK_DEBUG_FONTS 0 |
29 #endif | 29 #endif |
30 | 30 |
31 #if SK_DEBUG_FONTS | 31 #if SK_DEBUG_FONTS |
32 # define DEBUG_FONT(args) SkDebugf args | 32 # define DEBUG_FONT(args) SkDebugf args |
33 #else | 33 #else |
34 # define DEBUG_FONT(args) | 34 # define DEBUG_FONT(args) |
35 #endif | 35 #endif |
36 | 36 |
| 37 // For test only. |
| 38 static const char* gTestMainConfigFile = NULL; |
| 39 static const char* gTestFallbackConfigFile = NULL; |
| 40 static const char* gTestFontFilePrefix = NULL; |
| 41 |
37 class SkTypeface_Android : public SkTypeface_FreeType { | 42 class SkTypeface_Android : public SkTypeface_FreeType { |
38 public: | 43 public: |
39 SkTypeface_Android(int index, | 44 SkTypeface_Android(int index, |
40 Style style, | 45 Style style, |
41 bool isFixedPitch, | 46 bool isFixedPitch, |
42 const SkString familyName) | 47 const SkString familyName) |
43 : INHERITED(style, SkTypefaceCache::NewFontID(), isFixedPitch) | 48 : INHERITED(style, SkTypefaceCache::NewFontID(), isFixedPitch) |
44 , fIndex(index) | 49 , fIndex(index) |
45 , fFamilyName(familyName) { } | 50 , fFamilyName(familyName) { } |
46 | 51 |
(...skipping 457 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
504 const char* mainConfigFile; | 509 const char* mainConfigFile; |
505 const char* fallbackConfigFile; | 510 const char* fallbackConfigFile; |
506 const char* basePath; | 511 const char* basePath; |
507 SkGetTestFontConfiguration(&mainConfigFile, &fallbackConfigFile, &basePath); | 512 SkGetTestFontConfiguration(&mainConfigFile, &fallbackConfigFile, &basePath); |
508 if (mainConfigFile) { | 513 if (mainConfigFile) { |
509 return SkNEW_ARGS(SkFontMgr_Android, (mainConfigFile, fallbackConfigFile
, basePath)); | 514 return SkNEW_ARGS(SkFontMgr_Android, (mainConfigFile, fallbackConfigFile
, basePath)); |
510 } | 515 } |
511 | 516 |
512 return SkNEW(SkFontMgr_Android); | 517 return SkNEW(SkFontMgr_Android); |
513 } | 518 } |
| 519 |
| 520 void SkUseTestFontConfigFile(const char* mainconf, const char* fallbackconf, |
| 521 const char* fontsdir) { |
| 522 gTestMainConfigFile = mainconf; |
| 523 gTestFallbackConfigFile = fallbackconf; |
| 524 gTestFontFilePrefix = fontsdir; |
| 525 SkASSERT(gTestMainConfigFile); |
| 526 SkASSERT(gTestFallbackConfigFile); |
| 527 SkASSERT(gTestFontFilePrefix); |
| 528 SkDEBUGF(("Use Test Config File Main %s, Fallback %s, Font Dir %s", |
| 529 gTestMainConfigFile, gTestFallbackConfigFile, gTestFontFilePrefix)
); |
| 530 } |
| 531 |
| 532 void SkGetTestFontConfiguration(const char** mainconf, const char** fallbackconf
, |
| 533 const char** fontsdir) { |
| 534 *mainconf = gTestMainConfigFile; |
| 535 *fallbackconf = gTestFallbackConfigFile; |
| 536 *fontsdir = gTestFontFilePrefix; |
| 537 } |
OLD | NEW |