OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2013 Google Inc. | 2 * Copyright 2013 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 "gm.h" | 8 #include "gm.h" |
9 #include "SkCanvas.h" | 9 #include "SkCanvas.h" |
10 #include "SkFontMgr.h" | 10 #include "SkFontMgr.h" |
(...skipping 27 matching lines...) Expand all Loading... |
38 | 38 |
39 if (nullptr == typeface) { | 39 if (nullptr == typeface) { |
40 return x; | 40 return x; |
41 } | 41 } |
42 | 42 |
43 // repeat the process, but this time use the family name of the typeface | 43 // repeat the process, but this time use the family name of the typeface |
44 // from the first pass. This emulates the behavior in Blink where it | 44 // from the first pass. This emulates the behavior in Blink where it |
45 // it expects to get the same glyph when following this pattern. | 45 // it expects to get the same glyph when following this pattern. |
46 SkString familyName; | 46 SkString familyName; |
47 typeface->getFamilyName(&familyName); | 47 typeface->getFamilyName(&familyName); |
48 #ifdef SK_VERY_LEGACY_CREATE_TYPEFACE | |
49 SkTypeface* typefaceCopy = fm->legacyCreateTypeface(familyName.c_str(), type
face->style()); | |
50 #else | |
51 SkTypeface* typefaceCopy = fm->legacyCreateTypeface(familyName.c_str(), type
face->fontStyle()); | 48 SkTypeface* typefaceCopy = fm->legacyCreateTypeface(familyName.c_str(), type
face->fontStyle()); |
52 #endif | |
53 SkSafeUnref(paint.setTypeface(typefaceCopy)); | 49 SkSafeUnref(paint.setTypeface(typefaceCopy)); |
54 return drawString(canvas, ch, x, y, paint) + 20; | 50 return drawString(canvas, ch, x, y, paint) + 20; |
55 } | 51 } |
56 | 52 |
57 static const char* zh = "zh"; | 53 static const char* zh = "zh"; |
58 static const char* ja = "ja"; | 54 static const char* ja = "ja"; |
59 | 55 |
60 class FontMgrGM : public skiagm::GM { | 56 class FontMgrGM : public skiagm::GM { |
61 public: | 57 public: |
62 FontMgrGM(SkFontMgr* fontMgr = nullptr) { | 58 FontMgrGM(SkFontMgr* fontMgr = nullptr) { |
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
306 | 302 |
307 DEF_GM(return new FontMgrGM;) | 303 DEF_GM(return new FontMgrGM;) |
308 DEF_GM(return new FontMgrMatchGM;) | 304 DEF_GM(return new FontMgrMatchGM;) |
309 DEF_GM(return new FontMgrBoundsGM(1.0, 0);) | 305 DEF_GM(return new FontMgrBoundsGM(1.0, 0);) |
310 DEF_GM(return new FontMgrBoundsGM(0.75, 0);) | 306 DEF_GM(return new FontMgrBoundsGM(0.75, 0);) |
311 DEF_GM(return new FontMgrBoundsGM(1.0, -0.25);) | 307 DEF_GM(return new FontMgrBoundsGM(1.0, -0.25);) |
312 | 308 |
313 #ifdef SK_BUILD_FOR_WIN | 309 #ifdef SK_BUILD_FOR_WIN |
314 DEF_GM(return new FontMgrGM(SkFontMgr_New_DirectWrite());) | 310 DEF_GM(return new FontMgrGM(SkFontMgr_New_DirectWrite());) |
315 #endif | 311 #endif |
OLD | NEW |