Extract Android FontMgr part of Typeface test.
Part of the Typeface test is Android specific and tests that the Android legacyMakeTypeface returns nullptr when called with a non-null family name and there is no match. A new FontMgrAndroidLegacyMakeTypeface test is introduced to test this and also properly test creating one with SkFontMgr_Android_CustomFonts. Change-Id: Iceb8b9b5490f5eeeaeac30a68daf2c4daac53c86 Reviewed-on: https://skia-review.googlesource.com/70660 Reviewed-by: Mike Klein <mtklein@chromium.org> Commit-Queue: Ben Wagner <bungeman@google.com>
This commit is contained in:
parent
f44754a42b
commit
f1729a7937
32
resources/fonts/fonts.xml
Normal file
32
resources/fonts/fonts.xml
Normal file
@ -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>
|
@ -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);
|
||||
}
|
||||
|
@ -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 {
|
||||
|
Loading…
Reference in New Issue
Block a user