From ee6a9919a362e16c1d84a870ce867d1ad7b8a141 Mon Sep 17 00:00:00 2001 From: mboc Date: Tue, 31 May 2016 11:42:36 -0700 Subject: SkTypeface::MakeFromName to take SkFontStyle. SkTypeface::MakeFromName currently takes SkTypeface::Style, which is quite limited. This starts the transition to this function taking SkFontStyle instead. GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1818043002 TBR=reed He said it sounded like a good idea. Review-Url: https://codereview.chromium.org/1818043002 --- bench/SkGlyphCacheBench.cpp | 9 ++++--- bench/TextBlobBench.cpp | 2 +- dm/DM.cpp | 4 +-- fuzz/FilterFuzz.cpp | 4 +-- gm/all_bitmap_configs.cpp | 2 +- gm/colortype.cpp | 3 ++- gm/colortypexfermode.cpp | 3 ++- gm/colorwheel.cpp | 3 ++- gm/dftext.cpp | 2 +- gm/downsamplebitmap.cpp | 10 ++++---- gm/filterbitmap.cpp | 10 ++++---- gm/fontcache.cpp | 6 +++-- gm/gammatext.cpp | 5 ++-- gm/textblob.cpp | 2 +- gm/textblobrandomfont.cpp | 4 +-- gm/texteffects.cpp | 4 +-- gm/typeface.cpp | 3 ++- gm/variedtext.cpp | 10 +++++--- gm/verttext2.cpp | 4 +-- include/core/SkTypeface.h | 16 +++++++++++- samplecode/ClockFaceView.cpp | 3 ++- samplecode/SampleAll.cpp | 3 ++- samplecode/SampleFilterFuzz.cpp | 4 +-- samplecode/SampleFontScalerTest.cpp | 5 ++-- samplecode/SampleSlides.cpp | 3 ++- samplecode/SampleXfermodesBlur.cpp | 4 +-- src/core/SkTypeface.cpp | 29 ++++++++++++++++----- src/fonts/SkTestScalerContext.h | 2 +- src/utils/SkLua.cpp | 2 +- src/utils/SkWhitelistTypefaces.cpp | 10 ++++---- tests/FontHostStreamTest.cpp | 2 +- tests/FontHostTest.cpp | 4 +-- tests/FontMgrTest.cpp | 4 +-- tests/FontObjTest.cpp | 2 +- tests/PDFPrimitivesTest.cpp | 2 +- tests/PictureTest.cpp | 3 ++- tests/TypefaceTest.cpp | 4 +-- tools/sk_tool_utils.cpp | 6 ++--- tools/sk_tool_utils.h | 6 ++--- tools/sk_tool_utils_font.cpp | 7 +++--- tools/test_font_index.cpp | 50 ++++++++++++++++++------------------- 41 files changed, 154 insertions(+), 107 deletions(-) diff --git a/bench/SkGlyphCacheBench.cpp b/bench/SkGlyphCacheBench.cpp index c5e40af746..4d43a611d4 100644 --- a/bench/SkGlyphCacheBench.cpp +++ b/bench/SkGlyphCacheBench.cpp @@ -56,7 +56,8 @@ protected: SkPaint paint; paint.setAntiAlias(true); paint.setSubpixelText(true); - paint.setTypeface(sk_tool_utils::create_portable_typeface("serif", SkTypeface::kItalic)); + paint.setTypeface(sk_tool_utils::create_portable_typeface( + "serif", SkFontStyle::FromOldStyle(SkTypeface::kItalic))); for (int work = 0; work < loops; work++) { do_font_stuff(&paint); @@ -88,8 +89,10 @@ protected: size_t oldCacheLimitSize = SkGraphics::GetFontCacheLimit(); SkGraphics::SetFontCacheLimit(fCacheSize); sk_sp typefaces[] = - {sk_tool_utils::create_portable_typeface("serif", SkTypeface::kItalic), - sk_tool_utils::create_portable_typeface("sans-serif", SkTypeface::kItalic)}; + {sk_tool_utils::create_portable_typeface("serif", + SkFontStyle::FromOldStyle(SkTypeface::kItalic)), + sk_tool_utils::create_portable_typeface("sans-serif", + SkFontStyle::FromOldStyle(SkTypeface::kItalic))}; for (int work = 0; work < loops; work++) { SkTaskGroup().batch(16, [&](int threadIndex) { diff --git a/bench/TextBlobBench.cpp b/bench/TextBlobBench.cpp index 37bf311119..7c9b303430 100644 --- a/bench/TextBlobBench.cpp +++ b/bench/TextBlobBench.cpp @@ -27,7 +27,7 @@ public: protected: void onDelayedSetup() override { - fTypeface = sk_tool_utils::create_portable_typeface("serif", SkTypeface::kNormal); + fTypeface = sk_tool_utils::create_portable_typeface("serif", SkFontStyle()); // make textblob SkPaint paint; paint.setTypeface(fTypeface); diff --git a/dm/DM.cpp b/dm/DM.cpp index b10de5e4fe..8ee2ea739f 100644 --- a/dm/DM.cpp +++ b/dm/DM.cpp @@ -1219,7 +1219,7 @@ SkThread* start_status_thread() { #define PORTABLE_FONT_PREFIX "Toy Liberation " -static sk_sp create_from_name(const char familyName[], SkTypeface::Style style) { +static sk_sp create_from_name(const char familyName[], SkFontStyle style) { if (familyName && strlen(familyName) > sizeof(PORTABLE_FONT_PREFIX) && !strncmp(familyName, PORTABLE_FONT_PREFIX, sizeof(PORTABLE_FONT_PREFIX) - 1)) { return sk_tool_utils::create_portable_typeface(familyName, style); @@ -1229,7 +1229,7 @@ static sk_sp create_from_name(const char familyName[], SkTypeface::S #undef PORTABLE_FONT_PREFIX -extern sk_sp (*gCreateTypefaceDelegate)(const char [], SkTypeface::Style ); +extern sk_sp (*gCreateTypefaceDelegate)(const char [], SkFontStyle ); extern bool gDefaultProfileIsSRGB; diff --git a/fuzz/FilterFuzz.cpp b/fuzz/FilterFuzz.cpp index bbc403c636..cf92eae4d5 100644 --- a/fuzz/FilterFuzz.cpp +++ b/fuzz/FilterFuzz.cpp @@ -195,8 +195,8 @@ static SkFilterQuality make_filter_quality() { return static_cast(R(kHigh_SkFilterQuality+1)); } -static SkTypeface::Style make_typeface_style() { - return static_cast(R(SkTypeface::kBoldItalic+1)); +static SkFontStyle make_typeface_style() { + return SkFontStyle::FromOldStyle(R(SkTypeface::kBoldItalic+1)); } static SkPath1DPathEffect::Style make_path_1d_path_effect_style() { diff --git a/gm/all_bitmap_configs.cpp b/gm/all_bitmap_configs.cpp index c533b6fcae..bc296fcbe4 100644 --- a/gm/all_bitmap_configs.cpp +++ b/gm/all_bitmap_configs.cpp @@ -75,7 +75,7 @@ static void color_wheel_native(SkCanvas* canvas) { const SkScalar D = 0.3f * SkIntToScalar(SCALE); const SkScalar X = SkDoubleToScalar(D * sqrt_3_over_2); const SkScalar Y = D * SK_ScalarHalf; - sk_tool_utils::set_portable_typeface(&p, nullptr, SkTypeface::kBold); + sk_tool_utils::set_portable_typeface(&p, nullptr, SkFontStyle::FromOldStyle(SkTypeface::kBold)); p.setTextSize(0.28125f * SCALE); draw_center_letter('K', &p, SK_ColorBLACK, Z, Z, canvas); draw_center_letter('R', &p, SK_ColorRED, Z, D, canvas); diff --git a/gm/colortype.cpp b/gm/colortype.cpp index 68dfeee535..516bb75b4a 100644 --- a/gm/colortype.cpp +++ b/gm/colortype.cpp @@ -27,7 +27,8 @@ protected: paint.setShader(SkGradientShader::MakeSweep(0, 0, colors, nullptr, SK_ARRAY_COUNT(colors), 0, &local)); - sk_sp orig(sk_tool_utils::create_portable_typeface("serif", SkTypeface::kBold)); + sk_sp orig(sk_tool_utils::create_portable_typeface( + "serif", SkFontStyle::FromOldStyle(SkTypeface::kBold))); if (nullptr == orig) { orig = SkTypeface::MakeDefault(); } diff --git a/gm/colortypexfermode.cpp b/gm/colortypexfermode.cpp index 058b92d223..554282fadf 100644 --- a/gm/colortypexfermode.cpp +++ b/gm/colortypexfermode.cpp @@ -34,7 +34,8 @@ protected: paint.setShader(SkGradientShader::MakeSweep(0, 0, colors, nullptr, SK_ARRAY_COUNT(colors), 0, &local)); - sk_sp orig(sk_tool_utils::create_portable_typeface("serif", SkTypeface::kBold)); + sk_sp orig(sk_tool_utils::create_portable_typeface("serif", + SkFontStyle::FromOldStyle(SkTypeface::kBold))); if (nullptr == orig) { orig = SkTypeface::MakeDefault(); } diff --git a/gm/colorwheel.cpp b/gm/colorwheel.cpp index 2ebf330d9a..a1ca021b16 100644 --- a/gm/colorwheel.cpp +++ b/gm/colorwheel.cpp @@ -40,7 +40,8 @@ DEF_SIMPLE_GM(colorwheel, canvas, 256, 256) { DEF_SIMPLE_GM(colorwheelnative, canvas, 128, 28) { SkPaint paint; - sk_tool_utils::set_portable_typeface(&paint, "sans-serif", SkTypeface::kBold); + sk_tool_utils::set_portable_typeface(&paint, "sans-serif", + SkFontStyle::FromOldStyle(SkTypeface::kBold)); paint.setTextSize(18.0f); canvas->clear(sk_tool_utils::color_to_565(SK_ColorLTGRAY)); diff --git a/gm/dftext.cpp b/gm/dftext.cpp index c7d9a8b1bf..05aef4c9d6 100644 --- a/gm/dftext.cpp +++ b/gm/dftext.cpp @@ -70,7 +70,7 @@ protected: paint.setAntiAlias(true); paint.setSubpixelText(true); - sk_tool_utils::set_portable_typeface(&paint, "serif", SkTypeface::kNormal); + sk_tool_utils::set_portable_typeface(&paint, "serif"); const char* text = "Hamburgefons"; const size_t textLen = strlen(text); diff --git a/gm/downsamplebitmap.cpp b/gm/downsamplebitmap.cpp index 598382484f..ce3eb69654 100644 --- a/gm/downsamplebitmap.cpp +++ b/gm/downsamplebitmap.cpp @@ -29,7 +29,7 @@ static void make_checker(SkBitmap* bm, int size, int numChecks) { } } -static void setTypeface(SkPaint* paint, const char name[], SkTypeface::Style style) { +static void setTypeface(SkPaint* paint, const char name[], SkFontStyle style) { sk_tool_utils::set_portable_typeface(paint, name, style); } @@ -125,13 +125,13 @@ class DownsampleBitmapTextGM: public DownsampleBitmapGM { paint.setSubpixelText(true); paint.setTextSize(fTextSize); - setTypeface(&paint, "serif", SkTypeface::kNormal); + setTypeface(&paint, "serif", SkFontStyle()); canvas.drawText("Hamburgefons", 12, fTextSize/2, 1.2f*fTextSize, paint); - setTypeface(&paint, "serif", SkTypeface::kBold); + setTypeface(&paint, "serif", SkFontStyle::FromOldStyle(SkTypeface::kBold)); canvas.drawText("Hamburgefons", 12, fTextSize/2, 2.4f*fTextSize, paint); - setTypeface(&paint, "serif", SkTypeface::kItalic); + setTypeface(&paint, "serif", SkFontStyle::FromOldStyle(SkTypeface::kItalic)); canvas.drawText("Hamburgefons", 12, fTextSize/2, 3.6f*fTextSize, paint); - setTypeface(&paint, "serif", SkTypeface::kBoldItalic); + setTypeface(&paint, "serif", SkFontStyle::FromOldStyle(SkTypeface::kBoldItalic)); canvas.drawText("Hamburgefons", 12, fTextSize/2, 4.8f*fTextSize, paint); } private: diff --git a/gm/filterbitmap.cpp b/gm/filterbitmap.cpp index 51a8064d80..ec20e6efbe 100644 --- a/gm/filterbitmap.cpp +++ b/gm/filterbitmap.cpp @@ -12,7 +12,7 @@ #include "SkStream.h" #include "SkTypeface.h" -static void setTypeface(SkPaint* paint, const char name[], SkTypeface::Style style) { +static void setTypeface(SkPaint* paint, const char name[], SkFontStyle style) { sk_tool_utils::set_portable_typeface(paint, name, style); } @@ -123,13 +123,13 @@ class FilterBitmapTextGM: public FilterBitmapGM { paint.setSubpixelText(true); paint.setTextSize(fTextSize); - setTypeface(&paint, "serif", SkTypeface::kNormal); + setTypeface(&paint, "serif", SkFontStyle()); canvas.drawText("Hamburgefons", 12, fTextSize/2, 1.2f*fTextSize, paint); - setTypeface(&paint, "serif", SkTypeface::kBold); + setTypeface(&paint, "serif", SkFontStyle::FromOldStyle(SkTypeface::kBold)); canvas.drawText("Hamburgefons", 12, fTextSize/2, 2.4f*fTextSize, paint); - setTypeface(&paint, "serif", SkTypeface::kItalic); + setTypeface(&paint, "serif", SkFontStyle::FromOldStyle(SkTypeface::kItalic)); canvas.drawText("Hamburgefons", 12, fTextSize/2, 3.6f*fTextSize, paint); - setTypeface(&paint, "serif", SkTypeface::kBoldItalic); + setTypeface(&paint, "serif", SkFontStyle::FromOldStyle(SkTypeface::kBoldItalic)); canvas.drawText("Hamburgefons", 12, fTextSize/2, 4.8f*fTextSize, paint); } private: diff --git a/gm/fontcache.cpp b/gm/fontcache.cpp index c4af489304..22b29f47ab 100644 --- a/gm/fontcache.cpp +++ b/gm/fontcache.cpp @@ -32,8 +32,10 @@ protected: } void onOnceBeforeDraw() override { - fTypefaces[0] = sk_tool_utils::create_portable_typeface("serif", SkTypeface::kItalic); - fTypefaces[1] = sk_tool_utils::create_portable_typeface("sans-serif", SkTypeface::kItalic); + fTypefaces[0] = sk_tool_utils::create_portable_typeface("serif", + SkFontStyle::FromOldStyle(SkTypeface::kItalic)); + fTypefaces[1] = sk_tool_utils::create_portable_typeface("sans-serif", + SkFontStyle::FromOldStyle(SkTypeface::kItalic)); } void onDraw(SkCanvas* canvas) override { diff --git a/gm/gammatext.cpp b/gm/gammatext.cpp index c7d4309f97..8fa5171844 100644 --- a/gm/gammatext.cpp +++ b/gm/gammatext.cpp @@ -19,7 +19,7 @@ static sk_sp make_heatGradient(const SkPoint pts[2]) { } static bool setFont(SkPaint* paint, const char name[]) { - paint->setTypeface(SkTypeface::MakeFromName(name, SkTypeface::kNormal)); + paint->setTypeface(SkTypeface::MakeFromName(name, SkFontStyle())); return SkToBool(paint->getTypeface()); } @@ -104,7 +104,8 @@ static sk_sp make_gradient(SkColor c) { } static void set_face(SkPaint* paint) { - paint->setTypeface(SkTypeface::MakeFromName("serif", SkTypeface::kItalic)); + paint->setTypeface(SkTypeface::MakeFromName("serif", + SkFontStyle::FromOldStyle(SkTypeface::kItalic))); } static void draw_pair(SkCanvas* canvas, SkPaint* paint, const sk_sp& shader) { diff --git a/gm/textblob.cpp b/gm/textblob.cpp index 525cfd292d..2ac7d27f07 100644 --- a/gm/textblob.cpp +++ b/gm/textblob.cpp @@ -72,7 +72,7 @@ public: protected: void onOnceBeforeDraw() override { - fTypeface = sk_tool_utils::create_portable_typeface("serif", SkTypeface::kNormal); + fTypeface = sk_tool_utils::create_portable_typeface("serif", SkFontStyle()); SkPaint p; p.setTypeface(fTypeface); size_t txtLen = strlen(fText); diff --git a/gm/textblobrandomfont.cpp b/gm/textblobrandomfont.cpp index 51dbfceab3..2a6fc8e832 100644 --- a/gm/textblobrandomfont.cpp +++ b/gm/textblobrandomfont.cpp @@ -39,8 +39,8 @@ protected: paint.setLCDRenderText(true); // Setup our random scaler context - sk_sp orig(sk_tool_utils::create_portable_typeface("sans-serif", - SkTypeface::kBold)); + sk_sp orig(sk_tool_utils::create_portable_typeface( + "sans-serif", SkFontStyle::FromOldStyle(SkTypeface::kBold))); if (nullptr == orig) { orig = SkTypeface::MakeDefault(); } diff --git a/gm/texteffects.cpp b/gm/texteffects.cpp index a398ae2e68..e199594004 100644 --- a/gm/texteffects.cpp +++ b/gm/texteffects.cpp @@ -268,7 +268,7 @@ DEF_SIMPLE_GM(fancyunderline, canvas, 900, 1350) { const char test[] = "aAjJgGyY_|{-(~[,]qQ}pP}zZ"; SkPoint textPt = { 10, 80 }; for (int font = 0; font < 3; ++font) { - sk_tool_utils::set_portable_typeface(&paint, fam[font], SkTypeface::kNormal); + sk_tool_utils::set_portable_typeface(&paint, fam[font]); for (SkScalar textSize = 100; textSize > 10; textSize -= 20) { paint.setTextSize(textSize); const SkScalar uWidth = textSize / 15; @@ -312,7 +312,7 @@ DEF_SIMPLE_GM(fancyposunderline, canvas, 900, 1350) { const char test[] = "aAjJgGyY_|{-(~[,]qQ}pP}zZ"; SkPoint textPt = { 10, 80 }; for (int font = 0; font < 3; ++font) { - sk_tool_utils::set_portable_typeface(&paint, fam[font], SkTypeface::kNormal); + sk_tool_utils::set_portable_typeface(&paint, fam[font]); for (SkScalar textSize = 100; textSize > 10; textSize -= 20) { paint.setTextSize(textSize); const SkScalar uWidth = textSize / 15; diff --git a/gm/typeface.cpp b/gm/typeface.cpp index e77d27747f..e4e0d24867 100644 --- a/gm/typeface.cpp +++ b/gm/typeface.cpp @@ -103,7 +103,8 @@ protected: void onOnceBeforeDraw() override { for (int i = 0; i < gFaceStylesCount; i++) { fFaces[i] = SkTypeface::MakeFromName( - sk_tool_utils::platform_font_name(gFaceStyles[i].fName), gFaceStyles[i].fStyle); + sk_tool_utils::platform_font_name( + gFaceStyles[i].fName), SkFontStyle::FromOldStyle(gFaceStyles[i].fStyle)); } } diff --git a/gm/variedtext.cpp b/gm/variedtext.cpp index e295cbc998..e33c40b743 100644 --- a/gm/variedtext.cpp +++ b/gm/variedtext.cpp @@ -52,10 +52,12 @@ protected: SkScalar h = SkIntToScalar(size.fHeight); static_assert(4 == SK_ARRAY_COUNT(fTypefaces), "typeface_cnt"); - fTypefaces[0] = sk_tool_utils::create_portable_typeface("sans-serif", SkTypeface::kNormal); - fTypefaces[1] = sk_tool_utils::create_portable_typeface("sans-serif", SkTypeface::kBold); - fTypefaces[2] = sk_tool_utils::create_portable_typeface("serif", SkTypeface::kNormal); - fTypefaces[3] = sk_tool_utils::create_portable_typeface("serif", SkTypeface::kBold); + fTypefaces[0] = sk_tool_utils::create_portable_typeface("sans-serif", SkFontStyle()); + fTypefaces[1] = sk_tool_utils::create_portable_typeface("sans-serif", + SkFontStyle::FromOldStyle(SkTypeface::kBold)); + fTypefaces[2] = sk_tool_utils::create_portable_typeface("serif", SkFontStyle()); + fTypefaces[3] = sk_tool_utils::create_portable_typeface("serif", + SkFontStyle::FromOldStyle(SkTypeface::kBold)); SkRandom random; for (int i = 0; i < kCnt; ++i) { diff --git a/gm/verttext2.cpp b/gm/verttext2.cpp index 79cbdbcc8b..9afedc6078 100644 --- a/gm/verttext2.cpp +++ b/gm/verttext2.cpp @@ -24,9 +24,9 @@ protected: const int pointSize = 24; textHeight = SkIntToScalar(pointSize); fProp = SkTypeface::MakeFromName(sk_tool_utils::platform_font_name("sans-serif"), - SkTypeface::kNormal); + SkFontStyle()); fMono = SkTypeface::MakeFromName(sk_tool_utils::platform_font_name("monospace"), - SkTypeface::kNormal); + SkFontStyle()); } SkString onShortName() override { diff --git a/include/core/SkTypeface.h b/include/core/SkTypeface.h index 3a47bd2bb3..f67ba37416 100644 --- a/include/core/SkTypeface.h +++ b/include/core/SkTypeface.h @@ -100,6 +100,19 @@ public: } #endif + /** Creates a new reference to the typeface that most closely matches the + requested familyName and fontStyle. This method allows extended font + face specifiers as in the SkFontStyle type. Will never return null. + + @param familyName May be NULL. The name of the font family. + @param fontStyle The style of the typeface. + @return reference to the closest-matching typeface. Call must call + unref() when they are done. + */ + static sk_sp MakeFromName(const char familyName[], + SkFontStyle fontStyle); + +#ifdef SK_SUPPORT_LEGACY_TYPEFACE_MAKE_FROM_NAME /** Return the typeface that most closely matches the requested familyName and style. Pass nullptr as the familyName to request the default font for the requested style. Will never return nullptr. @@ -109,9 +122,10 @@ public: @return the closest-matching typeface. */ static sk_sp MakeFromName(const char familyName[], Style style); +#endif #ifdef SK_SUPPORT_LEGACY_TYPEFACE_PTR static SkTypeface* CreateFromName(const char familyName[], Style style) { - return MakeFromName(familyName, style).release(); + return MakeFromName(familyName, SkFontStyle::FromOldStyle(style)).release(); } #endif diff --git a/samplecode/ClockFaceView.cpp b/samplecode/ClockFaceView.cpp index 7c6158ada3..ef0fec7577 100644 --- a/samplecode/ClockFaceView.cpp +++ b/samplecode/ClockFaceView.cpp @@ -221,7 +221,8 @@ protected: paint.setAntiAlias(true); paint.setTextSize(SkIntToScalar(240)); - paint.setTypeface(SkTypeface::MakeFromName("sans-serif", SkTypeface::kBold)); + paint.setTypeface(SkTypeface::MakeFromName("sans-serif", + SkFontStyle::FromOldStyle(SkTypeface::kBold))); SkString str("9"); diff --git a/samplecode/SampleAll.cpp b/samplecode/SampleAll.cpp index 738b34e3ae..29b5c66c74 100644 --- a/samplecode/SampleAll.cpp +++ b/samplecode/SampleAll.cpp @@ -527,7 +527,8 @@ protected: paint.setAntiAlias(true); paint.setTextSize(SkIntToScalar(48)); - paint.setTypeface(SkTypeface::MakeFromName("sans-serif", SkTypeface::kBold)); + paint.setTypeface(SkTypeface::MakeFromName("sans-serif", + SkFontStyle::FromOldStyle(SkTypeface::kBold))); SkString str("GOOGLE"); diff --git a/samplecode/SampleFilterFuzz.cpp b/samplecode/SampleFilterFuzz.cpp index 88372414ca..78bc67386f 100644 --- a/samplecode/SampleFilterFuzz.cpp +++ b/samplecode/SampleFilterFuzz.cpp @@ -198,8 +198,8 @@ static SkFilterQuality make_filter_quality() { return static_cast(R(kHigh_SkFilterQuality+1)); } -static SkTypeface::Style make_typeface_style() { - return static_cast(R(SkTypeface::kBoldItalic+1)); +static SkFontStyle make_typeface_style() { + return SkFontStyle::FromOldStyle(SkTypeface::kBoldItalic+1); } static SkPath1DPathEffect::Style make_path_1d_path_effect_style() { diff --git a/samplecode/SampleFontScalerTest.cpp b/samplecode/SampleFontScalerTest.cpp index 72371ed807..bd9309790e 100644 --- a/samplecode/SampleFontScalerTest.cpp +++ b/samplecode/SampleFontScalerTest.cpp @@ -41,7 +41,8 @@ class FontScalerTestView : public SampleView { public: FontScalerTestView() { for (int i = 0; i < gFaceCount; i++) { - fFaces[i] = SkTypeface::MakeFromName(gFaces[i].fName, gFaces[i].fStyle); + fFaces[i] = SkTypeface::MakeFromName( + gFaces[i].fName, SkFontStyle::FromOldStyle(gFaces[i].fStyle)); } // this->setBGColor(0xFFDDDDDD); } @@ -85,7 +86,7 @@ protected: // paint.setSubpixelText(true); paint.setAntiAlias(true); paint.setLCDRenderText(true); - paint.setTypeface(SkTypeface::MakeFromName("Times Roman", SkTypeface::kNormal)); + paint.setTypeface(SkTypeface::MakeFromName("Times Roman", SkFontStyle())); // const char* text = "abcdefghijklmnopqrstuvwxyz"; const char* text = "Hamburgefons ooo mmm"; diff --git a/samplecode/SampleSlides.cpp b/samplecode/SampleSlides.cpp index edc2dd77a2..5858d2674e 100644 --- a/samplecode/SampleSlides.cpp +++ b/samplecode/SampleSlides.cpp @@ -625,7 +625,8 @@ static void texteffect_slide(SkCanvas* canvas) { SkScalar x = 20; SkScalar y = 80; SkPaint paint; - paint.setTypeface(SkTypeface::MakeFromName("Georgia", SkTypeface::kItalic)); + paint.setTypeface(SkTypeface::MakeFromName("Georgia", + SkFontStyle::FromOldStyle(SkTypeface::kItalic))); paint.setTextSize(75); paint.setAntiAlias(true); paint.setColor(SK_ColorBLUE); diff --git a/samplecode/SampleXfermodesBlur.cpp b/samplecode/SampleXfermodesBlur.cpp index 8a69f000f8..ef25114cf0 100644 --- a/samplecode/SampleXfermodesBlur.cpp +++ b/samplecode/SampleXfermodesBlur.cpp @@ -28,7 +28,7 @@ #include "SkBlurMaskFilter.h" static void setNamedTypeface(SkPaint* paint, const char name[]) { - paint->setTypeface(SkTypeface::MakeFromName(name, SkTypeface::kNormal)); + paint->setTypeface(SkTypeface::MakeFromName(name, SkFontStyle())); } static uint16_t gBG[] = { 0xFFFF, 0xCCCF, 0xCCCF, 0xFFFF }; @@ -90,7 +90,7 @@ protected: SkPaint paint; paint.setAntiAlias(true); paint.setTextSize(50); - paint.setTypeface(SkTypeface::MakeFromName("Arial Unicode MS", SkTypeface::kNormal)); + paint.setTypeface(SkTypeface::MakeFromName("Arial Unicode MS", SkFontStyle())); char buffer[10]; size_t len = SkUTF8_FromUnichar(0x8500, buffer); canvas->drawText(buffer, len, 40, 40, paint); diff --git a/src/core/SkTypeface.cpp b/src/core/SkTypeface.cpp index ba9e765e99..a4e814a534 100644 --- a/src/core/SkTypeface.cpp +++ b/src/core/SkTypeface.cpp @@ -27,7 +27,8 @@ extern void WhitelistSerializeTypeface(const SkTypeface*, SkWStream* ); #define SK_TYPEFACE_DELEGATE nullptr #endif -sk_sp (*gCreateTypefaceDelegate)(const char [], SkTypeface::Style ) = nullptr; +sk_sp (*gCreateTypefaceDelegate)(const char[], SkFontStyle) = nullptr; + void (*gSerializeTypefaceDelegate)(const SkTypeface*, SkWStream* ) = SK_TYPEFACE_DELEGATE; sk_sp (*gDeserializeTypefaceDelegate)(SkStream* ) = nullptr; @@ -108,18 +109,32 @@ bool SkTypeface::Equal(const SkTypeface* facea, const SkTypeface* faceb) { /////////////////////////////////////////////////////////////////////////////// +#ifdef SK_SUPPORT_LEGACY_TYPEFACE_MAKE_FROM_NAME sk_sp SkTypeface::MakeFromName(const char name[], Style style) { + return MakeFromName(name, SkFontStyle::FromOldStyle(style)); +} +#endif + +sk_sp SkTypeface::MakeFromName(const char name[], + SkFontStyle fontStyle) { if (gCreateTypefaceDelegate) { - sk_sp result = (*gCreateTypefaceDelegate)(name, style); + sk_sp result = (*gCreateTypefaceDelegate)(name, fontStyle); if (result) { return result; } } - if (nullptr == name) { - return MakeDefault(style); + if (nullptr == name && (fontStyle.slant() == SkFontStyle::kItalic_Slant || + fontStyle.slant() == SkFontStyle::kUpright_Slant) && + (fontStyle.weight() == SkFontStyle::kBold_Weight || + fontStyle.weight() == SkFontStyle::kNormal_Weight)) { + return MakeDefault(static_cast( + (fontStyle.slant() == SkFontStyle::kItalic_Slant ? SkTypeface::kItalic : + SkTypeface::kNormal) | + (fontStyle.weight() == SkFontStyle::kBold_Weight ? SkTypeface::kBold : + SkTypeface::kNormal))); } SkAutoTUnref fm(SkFontMgr::RefDefault()); - return sk_sp(fm->legacyCreateTypeface(name, SkFontStyle::FromOldStyle(style))); + return sk_sp(fm->legacyCreateTypeface(name, fontStyle)); } sk_sp SkTypeface::MakeFromTypeface(SkTypeface* family, Style s) { @@ -185,7 +200,9 @@ sk_sp SkTypeface::MakeDeserialize(SkStream* stream) { return typeface; } } - return SkTypeface::MakeFromName(desc.getFamilyName(), desc.getStyle()); + + return SkTypeface::MakeFromName(desc.getFamilyName(), + SkFontStyle::FromOldStyle(desc.getStyle())); } /////////////////////////////////////////////////////////////////////////////// diff --git a/src/fonts/SkTestScalerContext.h b/src/fonts/SkTestScalerContext.h index 5e772601bb..a5fa1de90d 100644 --- a/src/fonts/SkTestScalerContext.h +++ b/src/fonts/SkTestScalerContext.h @@ -41,7 +41,7 @@ public: mutable unsigned char fDebugBits[16]; mutable SkUnichar fDebugOverage[8]; const char* fDebugName; - SkTypeface::Style fDebugStyle; + SkFontStyle fDebugStyle; const char* debugFontName() const { return fName; } #endif private: diff --git a/src/utils/SkLua.cpp b/src/utils/SkLua.cpp index 4409e477e5..98880d0154 100644 --- a/src/utils/SkLua.cpp +++ b/src/utils/SkLua.cpp @@ -2049,7 +2049,7 @@ static int lsk_newTypeface(lua_State* L) { } } - sk_sp face(SkTypeface::MakeFromName(name, (SkTypeface::Style)style)); + sk_sp face(SkTypeface::MakeFromName(name, SkFontStyle::FromOldStyle(style))); // SkDebugf("---- name <%s> style=%d, face=%p ref=%d\n", name, style, face, face->getRefCnt()); if (nullptr == face) { face = SkTypeface::MakeDefault(); diff --git a/src/utils/SkWhitelistTypefaces.cpp b/src/utils/SkWhitelistTypefaces.cpp index 3368178769..bc454bfe1d 100644 --- a/src/utils/SkWhitelistTypefaces.cpp +++ b/src/utils/SkWhitelistTypefaces.cpp @@ -28,7 +28,7 @@ static bool timesNewRomanSerializedNameOnly = false; #define SUBNAME_PREFIX "sk_" -static bool font_name_is_local(const char* fontName, SkTypeface::Style style) { +static bool font_name_is_local(const char* fontName, SkFontStyle style) { if (!strcmp(fontName, "DejaVu Sans")) { return true; } @@ -162,7 +162,7 @@ void WhitelistSerializeTypeface(const SkTypeface* tf, SkWStream* wstream) { return; } const char* fontName = whitelist[whitelistIndex].fFontName; - if (!font_name_is_local(fontName, tf->style())) { + if (!font_name_is_local(fontName, tf->fontStyle())) { #if WHITELIST_DEBUG SkDebugf("name not found locally \"%s\" style=%d\n", fontName, tf->style()); #endif @@ -200,13 +200,13 @@ sk_sp WhitelistDeserializeTypeface(SkStream* stream) { if (!strncmp(SUBNAME_PREFIX, familyName, sizeof(SUBNAME_PREFIX) - 1)) { familyName += sizeof(SUBNAME_PREFIX) - 1; } - return SkTypeface::MakeFromName(familyName, desc.getStyle()); + return SkTypeface::MakeFromName(familyName, SkFontStyle::FromOldStyle(desc.getStyle())); } bool CheckChecksums() { for (int i = 0; i < whitelistCount; ++i) { const char* fontName = whitelist[i].fFontName; - sk_sp tf(SkTypeface::MakeFromName(fontName, SkTypeface::kNormal)); + sk_sp tf(SkTypeface::MakeFromName(fontName, SkFontStyle())); uint32_t checksum = compute_checksum(tf.get()); if (whitelist[i].fChecksum != checksum) { return false; @@ -261,7 +261,7 @@ bool GenerateChecksums() { sk_fwrite(line.c_str(), line.size(), file); for (int i = 0; i < whitelistCount; ++i) { const char* fontName = whitelist[i].fFontName; - sk_sp tf(SkTypeface::MakeFromName(fontName, SkTypeface::kNormal)); + sk_sp tf(SkTypeface::MakeFromName(fontName, SkFontStyle())); uint32_t checksum = compute_checksum(tf.get()); line.printf(checksumEntry, fontName, checksum); sk_fwrite(line.c_str(), line.size(), file); diff --git a/tests/FontHostStreamTest.cpp b/tests/FontHostStreamTest.cpp index ec32d9f031..66908bcb72 100644 --- a/tests/FontHostStreamTest.cpp +++ b/tests/FontHostStreamTest.cpp @@ -69,7 +69,7 @@ DEF_TEST(FontHostStream, reporter) { paint.setColor(SK_ColorGRAY); paint.setTextSize(SkIntToScalar(30)); - paint.setTypeface(SkTypeface::MakeFromName("Georgia", SkTypeface::kNormal)); + paint.setTypeface(SkTypeface::MakeFromName("Georgia", SkFontStyle())); SkIRect origRect = SkIRect::MakeWH(64, 64); SkBitmap origBitmap; diff --git a/tests/FontHostTest.cpp b/tests/FontHostTest.cpp index ebcc4ab2ae..811b4b3926 100644 --- a/tests/FontHostTest.cpp +++ b/tests/FontHostTest.cpp @@ -223,7 +223,7 @@ static void test_tables(skiatest::Reporter* reporter) { }; for (size_t i = 0; i < SK_ARRAY_COUNT(gNames); ++i) { - sk_sp face(SkTypeface::MakeFromName(gNames[i], SkTypeface::kNormal)); + sk_sp face(SkTypeface::MakeFromName(gNames[i], SkFontStyle())); if (face) { #ifdef DUMP_TABLES SkDebugf("%s\n", gNames[i]); @@ -277,7 +277,7 @@ static void test_advances(skiatest::Reporter* reporter) { char txt[] = "long.text.with.lots.of.dots."; for (size_t i = 0; i < SK_ARRAY_COUNT(faces); i++) { - paint.setTypeface(SkTypeface::MakeFromName(faces[i], SkTypeface::kNormal)); + paint.setTypeface(SkTypeface::MakeFromName(faces[i], SkFontStyle())); for (size_t j = 0; j < SK_ARRAY_COUNT(settings); j++) { paint.setHinting(settings[j].hinting); diff --git a/tests/FontMgrTest.cpp b/tests/FontMgrTest.cpp index 414631c58f..dd280cd837 100644 --- a/tests/FontMgrTest.cpp +++ b/tests/FontMgrTest.cpp @@ -64,12 +64,12 @@ static void test_alias_names(skiatest::Reporter* reporter) { }; for (size_t i = 0; i < SK_ARRAY_COUNT(inNames); ++i) { - sk_sp first(SkTypeface::MakeFromName(inNames[i], SkTypeface::kNormal)); + sk_sp first(SkTypeface::MakeFromName(inNames[i], SkFontStyle())); if (nullptr == first.get()) { continue; } for (int j = 0; j < 10; ++j) { - sk_sp face(SkTypeface::MakeFromName(inNames[i], SkTypeface::kNormal)); + sk_sp face(SkTypeface::MakeFromName(inNames[i], SkFontStyle())); #if 0 SkString name; face->getFamilyName(&name); diff --git a/tests/FontObjTest.cpp b/tests/FontObjTest.cpp index 66c8bd500f..44f799ece1 100644 --- a/tests/FontObjTest.cpp +++ b/tests/FontObjTest.cpp @@ -78,7 +78,7 @@ static void test_cachedfont(skiatest::Reporter* reporter) { char txt[] = "long.text.with.lots.of.dots."; for (size_t i = 0; i < SK_ARRAY_COUNT(faces); i++) { - paint.setTypeface(SkTypeface::MakeFromName(faces[i], SkTypeface::kNormal)); + paint.setTypeface(SkTypeface::MakeFromName(faces[i], SkFontStyle())); for (size_t j = 0; j < SK_ARRAY_COUNT(settings); j++) { paint.setHinting(settings[j].hinting); diff --git a/tests/PDFPrimitivesTest.cpp b/tests/PDFPrimitivesTest.cpp index 07ddabc912..e438bfef78 100644 --- a/tests/PDFPrimitivesTest.cpp +++ b/tests/PDFPrimitivesTest.cpp @@ -436,7 +436,7 @@ DEF_TEST(PDFFontCanEmbedTypeface, reporter) { !SkPDFFont::CanEmbedTypeface(noEmbedTypeface.get(), &canon)); } sk_sp portableTypeface( - sk_tool_utils::create_portable_typeface(NULL, SkTypeface::kNormal)); + sk_tool_utils::create_portable_typeface(NULL, SkFontStyle())); REPORTER_ASSERT(reporter, SkPDFFont::CanEmbedTypeface(portableTypeface.get(), &canon)); } diff --git a/tests/PictureTest.cpp b/tests/PictureTest.cpp index 6dbc86b147..f109482311 100644 --- a/tests/PictureTest.cpp +++ b/tests/PictureTest.cpp @@ -1163,7 +1163,8 @@ static void test_typeface(skiatest::Reporter* reporter) { SkPictureRecorder recorder; SkCanvas* canvas = recorder.beginRecording(10, 10); SkPaint paint; - paint.setTypeface(SkTypeface::MakeFromName("Arial", SkTypeface::kItalic)); + paint.setTypeface(SkTypeface::MakeFromName("Arial", + SkFontStyle::FromOldStyle(SkTypeface::kItalic))); canvas->drawText("Q", 1, 0, 10, paint); sk_sp picture(recorder.finishRecordingAsPicture()); SkDynamicMemoryWStream stream; diff --git a/tests/TypefaceTest.cpp b/tests/TypefaceTest.cpp index 6a606d4e95..13196bca48 100644 --- a/tests/TypefaceTest.cpp +++ b/tests/TypefaceTest.cpp @@ -12,7 +12,7 @@ DEF_TEST(Typeface, reporter) { - sk_sp t1(SkTypeface::MakeFromName(nullptr, SkTypeface::kNormal)); + sk_sp t1(SkTypeface::MakeFromName(nullptr, SkFontStyle())); sk_sp t2(SkTypeface::MakeDefault(SkTypeface::kNormal)); REPORTER_ASSERT(reporter, SkTypeface::Equal(t1.get(), t2.get())); @@ -22,7 +22,7 @@ DEF_TEST(Typeface, reporter) { REPORTER_ASSERT(reporter, SkTypeface::Equal(t2.get(), 0)); #ifdef SK_BUILD_FOR_ANDROID - sk_sp t3(SkTypeface::MakeFromName("non-existent-font", SkTypeface::kNormal)); + sk_sp t3(SkTypeface::MakeFromName("non-existent-font", SkFontStyle())); REPORTER_ASSERT(reporter, nullptr == t3); #endif } diff --git a/tools/sk_tool_utils.cpp b/tools/sk_tool_utils.cpp index 7343ce4744..9278c84807 100644 --- a/tools/sk_tool_utils.cpp +++ b/tools/sk_tool_utils.cpp @@ -80,7 +80,7 @@ sk_sp emoji_typeface() { return MakeResourceAsTypeface("/fonts/Funkster.ttf"); } if (!strcmp(sk_tool_utils::platform_os_emoji(), "SBIX")) { - return SkTypeface::MakeFromName("Apple Color Emoji", SkTypeface::kNormal); + return SkTypeface::MakeFromName("Apple Color Emoji", SkFontStyle()); } return nullptr; } @@ -156,11 +156,11 @@ SkColor color_to_565(SkColor color) { return SkPixel16ToColor(color16); } -sk_sp create_portable_typeface(const char* name, SkTypeface::Style style) { +sk_sp create_portable_typeface(const char* name, SkFontStyle style) { return create_font(name, style); } -void set_portable_typeface(SkPaint* paint, const char* name, SkTypeface::Style style) { +void set_portable_typeface(SkPaint* paint, const char* name, SkFontStyle style) { paint->setTypeface(create_font(name, style)); } diff --git a/tools/sk_tool_utils.h b/tools/sk_tool_utils.h index a16c2a2f6e..c4d7c8a265 100644 --- a/tools/sk_tool_utils.h +++ b/tools/sk_tool_utils.h @@ -72,12 +72,12 @@ namespace sk_tool_utils { * Sets the paint to use a platform-independent text renderer */ void set_portable_typeface(SkPaint* paint, const char* name = nullptr, - SkTypeface::Style style = SkTypeface::kNormal); + SkFontStyle style = SkFontStyle()); /** * Returns a platform-independent text renderer. */ - sk_sp create_portable_typeface(const char* name, SkTypeface::Style style); + sk_sp create_portable_typeface(const char* name, SkFontStyle style); /** Call to clean up portable font references. */ void release_portable_typefaces(); @@ -89,7 +89,7 @@ namespace sk_tool_utils { void write_pixels(SkCanvas*, const SkBitmap&, int x, int y, SkColorType, SkAlphaType); // private to sk_tool_utils - sk_sp create_font(const char* name, SkTypeface::Style); + sk_sp create_font(const char* name, SkFontStyle); /** Returns a newly created CheckerboardShader. */ sk_sp create_checkerboard_shader(SkColor c1, SkColor c2, int size); diff --git a/tools/sk_tool_utils_font.cpp b/tools/sk_tool_utils_font.cpp index f73576dbf6..8f701c2f21 100644 --- a/tools/sk_tool_utils_font.cpp +++ b/tools/sk_tool_utils_font.cpp @@ -29,7 +29,7 @@ void release_portable_typefaces() { SK_DECLARE_STATIC_MUTEX(gTestFontMutex); -sk_sp create_font(const char* name, SkTypeface::Style style) { +sk_sp create_font(const char* name, SkFontStyle style) { SkTestFontData* fontData = nullptr; const SubFont* sub; if (name) { @@ -47,8 +47,7 @@ sk_sp create_font(const char* name, SkTypeface::Style style) { // If we called SkTypeface::CreateFromName() here we'd recurse infinitely, // so we reimplement its core logic here inline without the recursive aspect. SkAutoTUnref fm(SkFontMgr::RefDefault()); - return sk_sp(fm->legacyCreateTypeface(name, - SkFontStyle::FromOldStyle(style))); + return sk_sp(fm->legacyCreateTypeface(name, style)); } } else { sub = &gSubFonts[gDefaultFontIndex]; @@ -66,7 +65,7 @@ sk_sp create_font(const char* name, SkTypeface::Style style) { fontData->fFontCache = SkSafeRef(font); } } - return sk_make_sp(font, SkFontStyle::FromOldStyle(style)); + return sk_make_sp(font, style); } } diff --git a/tools/test_font_index.cpp b/tools/test_font_index.cpp index b9bc24c63f..b52c004ccb 100644 --- a/tools/test_font_index.cpp +++ b/tools/test_font_index.cpp @@ -62,36 +62,36 @@ const int gTestFontsCount = (int) SK_ARRAY_COUNT(gTestFonts); struct SubFont { const char* fName; - SkTypeface::Style fStyle; + SkFontStyle fStyle; SkTestFontData& fFont; const char* fFile; }; const SubFont gSubFonts[] = { - { "monospace", SkTypeface::kNormal, gTestFonts[0], "LiberationMono-Regular.ttf" }, - { "monospace", SkTypeface::kBold, gTestFonts[1], "LiberationMono-Bold.ttf" }, - { "monospace", SkTypeface::kItalic, gTestFonts[2], "LiberationMono-Italic.ttf" }, - { "monospace", SkTypeface::kBoldItalic, gTestFonts[3], "LiberationMono-BoldItalic.ttf" }, - { "sans-serif", SkTypeface::kNormal, gTestFonts[4], "LiberationSans-Regular.ttf" }, - { "sans-serif", SkTypeface::kBold, gTestFonts[5], "LiberationSans-Bold.ttf" }, - { "sans-serif", SkTypeface::kItalic, gTestFonts[6], "LiberationSans-Italic.ttf" }, - { "sans-serif", SkTypeface::kBoldItalic, gTestFonts[7], "LiberationSans-BoldItalic.ttf" }, - { "serif", SkTypeface::kNormal, gTestFonts[8], "LiberationSerif-Regular.ttf" }, - { "serif", SkTypeface::kBold, gTestFonts[9], "LiberationSerif-Bold.ttf" }, - { "serif", SkTypeface::kItalic, gTestFonts[10], "LiberationSerif-Italic.ttf" }, - { "serif", SkTypeface::kBoldItalic, gTestFonts[11], "LiberationSerif-BoldItalic.ttf" }, - { "Toy Liberation Mono", SkTypeface::kNormal, gTestFonts[0], "LiberationMono-Regular.ttf" }, - { "Toy Liberation Mono", SkTypeface::kBold, gTestFonts[1], "LiberationMono-Bold.ttf" }, - { "Toy Liberation Mono", SkTypeface::kItalic, gTestFonts[2], "LiberationMono-Italic.ttf" }, - { "Toy Liberation Mono", SkTypeface::kBoldItalic, gTestFonts[3], "LiberationMono-BoldItalic.ttf" }, - { "Toy Liberation Sans", SkTypeface::kNormal, gTestFonts[4], "LiberationSans-Regular.ttf" }, - { "Toy Liberation Sans", SkTypeface::kBold, gTestFonts[5], "LiberationSans-Bold.ttf" }, - { "Toy Liberation Sans", SkTypeface::kItalic, gTestFonts[6], "LiberationSans-Italic.ttf" }, - { "Toy Liberation Sans", SkTypeface::kBoldItalic, gTestFonts[7], "LiberationSans-BoldItalic.ttf" }, - { "Toy Liberation Serif", SkTypeface::kNormal, gTestFonts[8], "LiberationSerif-Regular.ttf" }, - { "Toy Liberation Serif", SkTypeface::kBold, gTestFonts[9], "LiberationSerif-Bold.ttf" }, - { "Toy Liberation Serif", SkTypeface::kItalic, gTestFonts[10], "LiberationSerif-Italic.ttf" }, - { "Toy Liberation Serif", SkTypeface::kBoldItalic, gTestFonts[11], "LiberationSerif-BoldItalic.ttf" }, + { "monospace", SkFontStyle(), gTestFonts[0], "LiberationMono-Regular.ttf" }, + { "monospace", SkFontStyle::FromOldStyle(SkTypeface::kBold), gTestFonts[1], "LiberationMono-Bold.ttf" }, + { "monospace", SkFontStyle::FromOldStyle(SkTypeface::kItalic), gTestFonts[2], "LiberationMono-Italic.ttf" }, + { "monospace", SkFontStyle::FromOldStyle(SkTypeface::kBoldItalic), gTestFonts[3], "LiberationMono-BoldItalic.ttf" }, + { "sans-serif", SkFontStyle(), gTestFonts[4], "LiberationSans-Regular.ttf" }, + { "sans-serif", SkFontStyle::FromOldStyle(SkTypeface::kBold), gTestFonts[5], "LiberationSans-Bold.ttf" }, + { "sans-serif", SkFontStyle::FromOldStyle(SkTypeface::kItalic), gTestFonts[6], "LiberationSans-Italic.ttf" }, + { "sans-serif", SkFontStyle::FromOldStyle(SkTypeface::kBoldItalic), gTestFonts[7], "LiberationSans-BoldItalic.ttf" }, + { "serif", SkFontStyle(), gTestFonts[8], "LiberationSerif-Regular.ttf" }, + { "serif", SkFontStyle::FromOldStyle(SkTypeface::kBold), gTestFonts[9], "LiberationSerif-Bold.ttf" }, + { "serif", SkFontStyle::FromOldStyle(SkTypeface::kItalic), gTestFonts[10], "LiberationSerif-Italic.ttf" }, + { "serif", SkFontStyle::FromOldStyle(SkTypeface::kBoldItalic), gTestFonts[11], "LiberationSerif-BoldItalic.ttf" }, + { "Toy Liberation Mono", SkFontStyle(), gTestFonts[0], "LiberationMono-Regular.ttf" }, + { "Toy Liberation Mono", SkFontStyle::FromOldStyle(SkTypeface::kBold), gTestFonts[1], "LiberationMono-Bold.ttf" }, + { "Toy Liberation Mono", SkFontStyle::FromOldStyle(SkTypeface::kItalic), gTestFonts[2], "LiberationMono-Italic.ttf" }, + { "Toy Liberation Mono", SkFontStyle::FromOldStyle(SkTypeface::kBoldItalic), gTestFonts[3], "LiberationMono-BoldItalic.ttf" }, + { "Toy Liberation Sans", SkFontStyle(), gTestFonts[4], "LiberationSans-Regular.ttf" }, + { "Toy Liberation Sans", SkFontStyle::FromOldStyle(SkTypeface::kBold), gTestFonts[5], "LiberationSans-Bold.ttf" }, + { "Toy Liberation Sans", SkFontStyle::FromOldStyle(SkTypeface::kItalic), gTestFonts[6], "LiberationSans-Italic.ttf" }, + { "Toy Liberation Sans", SkFontStyle::FromOldStyle(SkTypeface::kBoldItalic), gTestFonts[7], "LiberationSans-BoldItalic.ttf" }, + { "Toy Liberation Serif", SkFontStyle(), gTestFonts[8], "LiberationSerif-Regular.ttf" }, + { "Toy Liberation Serif", SkFontStyle::FromOldStyle(SkTypeface::kBold), gTestFonts[9], "LiberationSerif-Bold.ttf" }, + { "Toy Liberation Serif", SkFontStyle::FromOldStyle(SkTypeface::kItalic), gTestFonts[10], "LiberationSerif-Italic.ttf" }, + { "Toy Liberation Serif", SkFontStyle::FromOldStyle(SkTypeface::kBoldItalic), gTestFonts[11], "LiberationSerif-BoldItalic.ttf" }, }; const int gSubFontsCount = (int) SK_ARRAY_COUNT(gSubFonts); -- cgit v1.2.3