aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--resources/fonts/fonts.xml32
-rw-r--r--tests/FontMgrAndroidParserTest.cpp18
-rw-r--r--tests/TypefaceTest.cpp6
3 files changed, 50 insertions, 6 deletions
diff --git a/resources/fonts/fonts.xml b/resources/fonts/fonts.xml
new file mode 100644
index 0000000000..a60d322359
--- /dev/null
+++ b/resources/fonts/fonts.xml
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="utf-8"?>
+<familyset version="21">
+ <!-- first font is default -->
+ <family name="sans-serif">
+ <font weight="100" style="normal"><axis tag="wght" stylevalue="0.5"/>Distortable.ttf</font>
+ <font weight="200" style="normal"><axis tag="wght" stylevalue="0.65"/>Distortable.ttf</font>
+ <font weight="300" style="normal"><axis tag="wght" stylevalue="0.85"/>Distortable.ttf</font>
+ <font weight="400" style="normal"><axis tag="wght" stylevalue="1.0"/>Distortable.ttf</font>
+ <font weight="500" style="normal"><axis tag="wght" stylevalue="1.2"/>Distortable.ttf</font>
+ <font weight="600" style="normal"><axis tag="wght" stylevalue="1.4"/>Distortable.ttf</font>
+ <font weight="700" style="normal"><axis tag="wght" stylevalue="1.6"/>Distortable.ttf</font>
+ <font weight="800" style="normal"><axis tag="wght" stylevalue="1.8"/>Distortable.ttf</font>
+ <font weight="900" style="normal"><axis tag="wght" stylevalue="2.0"/>Distortable.ttf</font>
+ </family>
+ <alias name="sans-serif-thin" to="sans-serif" weight="100" />
+ <alias name="sans-serif-light" to="sans-serif" weight="300" />
+ <alias name="sans-serif-black" to="sans-serif" weight="900" />
+ <alias name="arial" to="sans-serif" />
+ <alias name="helvetica" to="sans-serif" />
+ <alias name="tahoma" to="sans-serif" />
+ <alias name="verdana" to="sans-serif" />
+
+ <!-- fallback fonts -->
+ <family name="Em"><font weight="400" style="normal">Em.ttf</font></family>
+ <family name="HangingS"><font weight="400" style="normal">HangingS.ttf</font></family>
+ <family name="HintGasp"><font weight="400" style="normal">hintgasp.ttf</font></family>
+ <family name="RTeallyBigA"><font weight="400" style="normal">ReallyBigA.ttf</font></family>
+ <family name="Spider"><font weight="400" style="normal">SpiderSymbol.ttf</font></family>
+ <family name="TestTTC0"><font weight="400" style="normal" index="0">test.ttc</font></family>
+ <family name="TestTTC1"><font weight="400" style="normal" index="1">test.ttc</font></family>
+ <family name="Funkster"><font weight="400" style="normal">Funkster.ttf</font></family>
+</familyset>
diff --git a/tests/FontMgrAndroidParserTest.cpp b/tests/FontMgrAndroidParserTest.cpp
index b5346ef5b6..cd10d04dc6 100644
--- a/tests/FontMgrAndroidParserTest.cpp
+++ b/tests/FontMgrAndroidParserTest.cpp
@@ -8,7 +8,9 @@
#include "Resources.h"
#include "SkCommandLineFlags.h"
#include "SkFixed.h"
+#include "SkFontMgr_android.h"
#include "SkFontMgr_android_parser.h"
+#include "SkTypeface.h"
#include "Test.h"
#include <cmath>
@@ -220,3 +222,19 @@ DEF_TEST(FontMgrAndroidParser, reporter) {
SkDebugf("---- Resource files missing for FontConfigParser test\n");
}
}
+
+DEF_TEST(FontMgrAndroidLegacyMakeTypeface, reporter) {
+ SkString basePath = GetResourcePath("fonts/");
+ SkString fontsXml = GetResourcePath("fonts/fonts.xml");
+
+ SkFontMgr_Android_CustomFonts custom;
+ custom.fSystemFontUse = SkFontMgr_Android_CustomFonts::kOnlyCustom;
+ custom.fBasePath = basePath.c_str();
+ custom.fFontsXml = fontsXml.c_str();
+ custom.fFallbackFontsXml = nullptr;
+ custom.fIsolated = false;
+
+ sk_sp<SkFontMgr> fm(SkFontMgr_New_Android(&custom));
+ sk_sp<SkTypeface> t(fm->legacyMakeTypeface("non-existent-font", SkFontStyle()));
+ REPORTER_ASSERT(reporter, nullptr == t);
+}
diff --git a/tests/TypefaceTest.cpp b/tests/TypefaceTest.cpp
index 4ab8c5eec6..591b437ca5 100644
--- a/tests/TypefaceTest.cpp
+++ b/tests/TypefaceTest.cpp
@@ -184,12 +184,6 @@ DEF_TEST(Typeface, reporter) {
REPORTER_ASSERT(reporter, SkTypeface::Equal(nullptr, t2.get()));
REPORTER_ASSERT(reporter, SkTypeface::Equal(t1.get(), nullptr));
REPORTER_ASSERT(reporter, SkTypeface::Equal(t2.get(), nullptr));
-
- // Disabled temporarily. TODO(mtklein): test Android SkFontMgr directly?
-#if 0 && defined(SK_BUILD_FOR_ANDROID)
- sk_sp<SkTypeface> t3(SkTypeface::MakeFromName("non-existent-font", SkFontStyle()));
- REPORTER_ASSERT(reporter, nullptr == t3);
-#endif
}
namespace {