From 39ccf5d386ae07d4fdfaac6c6e89c325efb61255 Mon Sep 17 00:00:00 2001 From: Hal Canary Date: Thu, 31 May 2018 14:50:58 -0400 Subject: Fix compile when SK_XML undefined Change-Id: Ia23b07434939acbf544854b94c4b10810c20ae1a Reviewed-on: https://skia-review.googlesource.com/131221 Reviewed-by: Florin Malita Commit-Queue: Hal Canary --- tools/fonts/SkTestFontMgr.cpp | 24 +++++++++++++++++------- tools/fonts/SkTestSVGTypeface.cpp | 6 +++++- 2 files changed, 22 insertions(+), 8 deletions(-) (limited to 'tools/fonts') diff --git a/tools/fonts/SkTestFontMgr.cpp b/tools/fonts/SkTestFontMgr.cpp index 4513a2f8d1..d2aadaa62a 100644 --- a/tools/fonts/SkTestFontMgr.cpp +++ b/tools/fonts/SkTestFontMgr.cpp @@ -5,11 +5,16 @@ * found in the LICENSE file. */ +#include + #include "SkFontDescriptor.h" #include "SkTestFontMgr.h" #include "sk_tool_utils.h" #include "SkTestTypeface.h" + +#ifdef SK_XML #include "SkTestSVGTypeface.h" +#endif namespace { @@ -90,20 +95,23 @@ private: class FontMgr final : public SkFontMgr { public: FontMgr() { - fFamilies[0] = sk_make_sp(0); - fFamilies[1] = sk_make_sp(1); - fFamilies[2] = sk_make_sp(2); - fFamilies[3] = sk_make_sp(SkTestSVGTypeface::Default()); + fFamilies.push_back(sk_make_sp(0)); + fFamilies.push_back(sk_make_sp(1)); + fFamilies.push_back(sk_make_sp(2)); + #ifdef SK_XML + fFamilies.push_back(sk_make_sp(SkTestSVGTypeface::Default())); + #endif } - int onCountFamilies() const override { return SK_ARRAY_COUNT(fFamilies); } + int onCountFamilies() const override { return fFamilies.size(); } void onGetFamilyName(int index, SkString* familyName) const override { *familyName = kFamilyNames[index]; } SkFontStyleSet* onCreateStyleSet(int index) const override { - return SkRef(fFamilies[index].get()); + sk_sp ref = fFamilies[index]; + return ref.release(); } SkFontStyleSet* onMatchFamily(const char familyName[]) const override { @@ -111,7 +119,9 @@ public: if (strstr(familyName, "ans")) { return this->createStyleSet(0); } if (strstr(familyName, "erif")) { return this->createStyleSet(1); } if (strstr(familyName, "ono")) { return this->createStyleSet(2); } + #ifdef SK_XML if (strstr(familyName, "oji")) { return this->createStyleSet(3); } + #endif } return this->createStyleSet(0); } @@ -164,7 +174,7 @@ public: } private: - sk_sp fFamilies[4]; + std::vector> fFamilies; }; } diff --git a/tools/fonts/SkTestSVGTypeface.cpp b/tools/fonts/SkTestSVGTypeface.cpp index 199c3b5df6..0ab59cfb28 100644 --- a/tools/fonts/SkTestSVGTypeface.cpp +++ b/tools/fonts/SkTestSVGTypeface.cpp @@ -5,6 +5,10 @@ * found in the LICENSE file. */ +#include "SkTestSVGTypeface.h" + +#ifdef SK_XML + #include "Resources.h" #include "SkAdvancedTypefaceMetrics.h" #include "SkBitmap.h" @@ -35,7 +39,6 @@ #include "SkSize.h" #include "SkStream.h" #include "SkSurface.h" -#include "SkTestSVGTypeface.h" #include "SkTDArray.h" #include "SkTemplates.h" #include "SkUtils.h" @@ -1296,3 +1299,4 @@ void SkTestSVGTypeface::exportTtxColr(SkWStream* out) const { out->writeText("\n"); } +#endif // SK_XML -- cgit v1.2.3