diff options
author | Mike Klein <mtklein@chromium.org> | 2017-11-09 13:45:10 -0500 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2017-11-10 15:30:57 +0000 |
commit | cb6940bf42e39271afe0fb3c2bfdd9e28d12f504 (patch) | |
tree | 9d600f8679a5694c3b4ff71166d67cf09a37d433 /tests | |
parent | 35970ec0c861f7b5ee7cca2789b7dc5954cb6bb4 (diff) |
DM FontMgr updates
- return nullptr for the various makeFromFoo() that we can't support,
and tweak a few unit tests to bail out early when they do
- create FontStyleSet and SkTypefaces once
- abort early from FontHostStream if we can't openStream()
- implement SkTestTypeface::onCreateFamilyNameIterator()
with SkOTUtils::LocalizedStrings_SingleName() so FontNames passes
- pin out-of-range glyph IDs to zero in SkTestTypeface
Change-Id: Iac53265e331fc1c5c507513af3ab299063e6610a
Reviewed-on: https://skia-review.googlesource.com/69501
Reviewed-by: Ben Wagner <bungeman@google.com>
Commit-Queue: Mike Klein <mtklein@chromium.org>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/FontHostStreamTest.cpp | 6 | ||||
-rw-r--r-- | tests/TypefaceTest.cpp | 10 |
2 files changed, 15 insertions, 1 deletions
diff --git a/tests/FontHostStreamTest.cpp b/tests/FontHostStreamTest.cpp index c3bc878da8..e97ea0dcc2 100644 --- a/tests/FontHostStreamTest.cpp +++ b/tests/FontHostStreamTest.cpp @@ -88,6 +88,12 @@ DEF_TEST(FontHostStream, reporter) { : SkTypeface::MakeDefault()); int ttcIndex; std::unique_ptr<SkStreamAsset> fontData(typeface->openStream(&ttcIndex)); + if (!fontData) { + // We're using a SkTypeface that can't give us a stream. + // This happens with portable or system fonts. End the test now. + return; + } + sk_sp<SkTypeface> streamTypeface(SkTypeface::MakeFromStream(fontData.release())); SkFontDescriptor desc; diff --git a/tests/TypefaceTest.cpp b/tests/TypefaceTest.cpp index 6175d36157..c8e96c5a7c 100644 --- a/tests/TypefaceTest.cpp +++ b/tests/TypefaceTest.cpp @@ -50,7 +50,10 @@ static void TypefaceStyle_test(skiatest::Reporter* reporter, os2Table->usWidthClass.value = static_cast<WidthType>(SkEndian_SwapBE16(width)); sk_sp<SkTypeface> newTypeface(SkTypeface::MakeFromStream(new SkMemoryStream(sk_ref_sp(data)))); - SkASSERT_RELEASE(newTypeface); + if (!newTypeface) { + // Not all SkFontMgr can MakeFromStream(). + return; + } SkFontStyle newStyle = newTypeface->fontStyle(); @@ -111,6 +114,11 @@ DEF_TEST(TypefaceAxes, reporter) { // TODO: if axes are set and the back-end doesn't support them, should we create the typeface? sk_sp<SkTypeface> typeface = fm->makeFromStream(std::move(distortable), params); + if (!typeface) { + // Not all SkFontMgr can makeFromStream(). + return; + } + int count = typeface->getVariationDesignPosition(nullptr, 0); if (count == -1) { return; |