| 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 13 matching lines...) Expand all Loading... |
| 24 return x + paint.measureText(text.c_str(), text.size()); | 24 return x + paint.measureText(text.c_str(), text.size()); |
| 25 } | 25 } |
| 26 | 26 |
| 27 static SkScalar drawCharacter(SkCanvas* canvas, uint32_t character, SkScalar x, | 27 static SkScalar drawCharacter(SkCanvas* canvas, uint32_t character, SkScalar x, |
| 28 SkScalar y, SkPaint& paint, SkFontMgr* fm, | 28 SkScalar y, SkPaint& paint, SkFontMgr* fm, |
| 29 const char* fontName, const char* bpc47, | 29 const char* fontName, const char* bpc47, |
| 30 const SkFontStyle& fontStyle) { | 30 const SkFontStyle& fontStyle) { |
| 31 // find typeface containing the requested character and draw it | 31 // find typeface containing the requested character and draw it |
| 32 SkString ch; | 32 SkString ch; |
| 33 ch.appendUnichar(character); | 33 ch.appendUnichar(character); |
| 34 SkTypeface* typeface = fm->matchFamilyStyleCharacter(fontName, fontStyle, bp
c47, character); | 34 SkTypeface* typeface = fm->matchFamilyStyleCharacter(fontName, fontStyle, &b
pc47, 1, character); |
| 35 SkSafeUnref(paint.setTypeface(typeface)); | 35 SkSafeUnref(paint.setTypeface(typeface)); |
| 36 x = drawString(canvas, ch, x, y, paint) + 20; | 36 x = drawString(canvas, ch, x, y, paint) + 20; |
| 37 | 37 |
| 38 if (NULL == typeface) { | 38 if (NULL == typeface) { |
| 39 return x; | 39 return x; |
| 40 } | 40 } |
| 41 | 41 |
| 42 // repeat the process, but this time use the family name of the typeface | 42 // repeat the process, but this time use the family name of the typeface |
| 43 // from the first pass. This emulates the behavior in Blink where it | 43 // from the first pass. This emulates the behavior in Blink where it |
| 44 // it expects to get the same glyph when following this pattern. | 44 // it expects to get the same glyph when following this pattern. |
| (...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 221 }; | 221 }; |
| 222 | 222 |
| 223 ////////////////////////////////////////////////////////////////////////////// | 223 ////////////////////////////////////////////////////////////////////////////// |
| 224 | 224 |
| 225 DEF_GM( return SkNEW(FontMgrGM); ) | 225 DEF_GM( return SkNEW(FontMgrGM); ) |
| 226 DEF_GM( return SkNEW(FontMgrMatchGM); ) | 226 DEF_GM( return SkNEW(FontMgrMatchGM); ) |
| 227 | 227 |
| 228 #ifdef SK_BUILD_FOR_WIN | 228 #ifdef SK_BUILD_FOR_WIN |
| 229 DEF_GM( return SkNEW_ARGS(FontMgrGM, (SkFontMgr_New_DirectWrite())); ) | 229 DEF_GM( return SkNEW_ARGS(FontMgrGM, (SkFontMgr_New_DirectWrite())); ) |
| 230 #endif | 230 #endif |
| OLD | NEW |