| 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 20 matching lines...) Expand all Loading... |
| 31 return x + paint.measureText(text.c_str(), text.size()); | 31 return x + paint.measureText(text.c_str(), text.size()); |
| 32 } | 32 } |
| 33 | 33 |
| 34 static SkScalar drawCharacter(SkCanvas* canvas, uint32_t character, SkScalar x, | 34 static SkScalar drawCharacter(SkCanvas* canvas, uint32_t character, SkScalar x, |
| 35 SkScalar y, SkPaint& paint, SkFontMgr* fm, | 35 SkScalar y, SkPaint& paint, SkFontMgr* fm, |
| 36 const char* fontName, const char* bpc47, | 36 const char* fontName, const char* bpc47, |
| 37 const SkFontStyle& fontStyle) { | 37 const SkFontStyle& fontStyle) { |
| 38 // find typeface containing the requested character and draw it | 38 // find typeface containing the requested character and draw it |
| 39 SkString ch; | 39 SkString ch; |
| 40 ch.appendUnichar(character); | 40 ch.appendUnichar(character); |
| 41 #ifdef SK_FM_NEW_MATCH_FAMILY_STYLE_CHARACTER |
| 42 SkTypeface* typeface = fm->matchFamilyStyleCharacter(fontName, fontStyle, &b
pc47, 1, character); |
| 43 #else |
| 41 SkTypeface* typeface = fm->matchFamilyStyleCharacter(fontName, fontStyle, bp
c47, character); | 44 SkTypeface* typeface = fm->matchFamilyStyleCharacter(fontName, fontStyle, bp
c47, character); |
| 45 #endif |
| 42 SkSafeUnref(paint.setTypeface(typeface)); | 46 SkSafeUnref(paint.setTypeface(typeface)); |
| 43 x = drawString(canvas, ch, x, y, paint) + 20; | 47 x = drawString(canvas, ch, x, y, paint) + 20; |
| 44 | 48 |
| 45 if (NULL == typeface) { | 49 if (NULL == typeface) { |
| 46 return x; | 50 return x; |
| 47 } | 51 } |
| 48 | 52 |
| 49 // repeat the process, but this time use the family name of the typeface | 53 // repeat the process, but this time use the family name of the typeface |
| 50 // from the first pass. This emulates the behavior in Blink where it | 54 // from the first pass. This emulates the behavior in Blink where it |
| 51 // it expects to get the same glyph when following this pattern. | 55 // it expects to get the same glyph when following this pattern. |
| (...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 315 | 319 |
| 316 ////////////////////////////////////////////////////////////////////////////// | 320 ////////////////////////////////////////////////////////////////////////////// |
| 317 | 321 |
| 318 DEF_GM( return SkNEW(FontMgrGM); ) | 322 DEF_GM( return SkNEW(FontMgrGM); ) |
| 319 DEF_GM( return SkNEW(FontMgrBoundsGM); ) | 323 DEF_GM( return SkNEW(FontMgrBoundsGM); ) |
| 320 DEF_GM( return SkNEW(FontMgrMatchGM); ) | 324 DEF_GM( return SkNEW(FontMgrMatchGM); ) |
| 321 | 325 |
| 322 #ifdef SK_BUILD_FOR_WIN | 326 #ifdef SK_BUILD_FOR_WIN |
| 323 DEF_GM( return SkNEW_ARGS(FontMgrGM, (SkFontMgr_New_DirectWrite())); ) | 327 DEF_GM( return SkNEW_ARGS(FontMgrGM, (SkFontMgr_New_DirectWrite())); ) |
| 324 #endif | 328 #endif |
| OLD | NEW |