Chromium Code Reviews| Index: gm/fontmgr.cpp |
| diff --git a/gm/fontmgr.cpp b/gm/fontmgr.cpp |
| index d9a0aa5f4ba02ee5498b594e5b29d7ad049a4a5a..62b26f2007ee5426cfc7226881947ebfe04e11b7 100644 |
| --- a/gm/fontmgr.cpp |
| +++ b/gm/fontmgr.cpp |
| @@ -24,6 +24,27 @@ static SkScalar drawString(SkCanvas* canvas, const SkString& text, SkScalar x, |
| return x + paint.measureText(text.c_str(), text.size()); |
| } |
| +static SkScalar drawCharacter(SkCanvas* canvas, uint32_t character, SkScalar x, |
| + SkScalar y, SkPaint& paint, SkFontMgr* fm, |
| + const char* fontName, const char* bpc47, |
| + const SkFontStyle& fontStyle) { |
| + // find typeface containing the requested character and draw it |
| + SkString ch; |
| + ch.appendUnichar(character); |
| + SkTypeface* typeface = fm->matchFamilyStyleCharacter(fontName, fontStyle, bpc47, character); |
| + SkSafeUnref(paint.setTypeface(typeface)); |
| + x = drawString(canvas, ch, x, y, paint) + 20; |
|
tomhudson
2014/08/21 20:24:41
Assuming character width << 20?
|
| + |
| + // repeat the process, but this time use the family name of the typeface |
| + // from the first pass. This emulates the behavior in Blink where it |
| + // it expects to get the same glyph when following this pattern. |
| + SkString familyName; |
| + typeface->getFamilyName(&familyName); |
|
bungeman-skia
2014/08/26 21:15:44
'typeface' can be NULL here if 'matchFamilyStyleCh
|
| + SkTypeface* typefaceCopy = fm->legacyCreateTypeface(familyName.c_str(), SkTypeface::kNormal); |
|
bungeman-skia
2014/08/26 21:55:35
Instead of 'SkTypeface::kNormal', you might want t
|
| + SkSafeUnref(paint.setTypeface(typefaceCopy)); |
| + return drawString(canvas, ch, x, y, paint) + 20; |
| +} |
| + |
| class FontMgrGM : public skiagm::GM { |
| public: |
| FontMgrGM(SkFontMgr* fontMgr = NULL) { |
| @@ -44,7 +65,7 @@ protected: |
| } |
| virtual SkISize onISize() { |
| - return SkISize::Make(640, 1024); |
| + return SkISize::Make(1536, 768); |
| } |
| virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE { |
| @@ -75,6 +96,12 @@ protected: |
| SkSafeUnref(paint.setTypeface(set->createTypeface(j))); |
| x = drawString(canvas, sname, x, y, paint) + 20; |
| + |
| + // check to see that we get different glyphs in japanese and chinese |
| + x = drawCharacter(canvas, 0x5203, x, y, paint, fm, fName.c_str(), "zh", fs); |
| + x = drawCharacter(canvas, 0x5203, x, y, paint, fm, fName.c_str(), "ja", fs); |
| + // check that emoji characters are found |
| + x = drawCharacter(canvas, 0x1f601, x, y, paint, fm, fName.c_str(), NULL, fs); |
| } |
| y += 24; |
| } |