2013-04-11 18:31:25 +00:00
|
|
|
/*
|
|
|
|
* Copyright 2013 Google Inc.
|
|
|
|
*
|
|
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
|
|
* found in the LICENSE file.
|
|
|
|
*/
|
|
|
|
|
2017-05-04 18:23:55 +00:00
|
|
|
#include "SkAdvancedTypefaceMetrics.h"
|
2013-04-11 18:31:25 +00:00
|
|
|
#include "SkCommandLineFlags.h"
|
2017-05-04 18:23:55 +00:00
|
|
|
#include "SkFont.h"
|
2013-04-11 18:31:25 +00:00
|
|
|
#include "SkFontMgr.h"
|
2017-05-04 18:23:55 +00:00
|
|
|
#include "SkPaint.h"
|
2013-04-11 18:31:25 +00:00
|
|
|
#include "SkTypeface.h"
|
2014-01-24 20:56:26 +00:00
|
|
|
#include "Test.h"
|
2013-04-11 18:31:25 +00:00
|
|
|
|
2015-11-12 17:50:08 +00:00
|
|
|
#include <initializer_list>
|
|
|
|
#include <limits>
|
|
|
|
#include <vector>
|
|
|
|
|
2014-04-08 15:04:29 +00:00
|
|
|
static void test_font(skiatest::Reporter* reporter) {
|
2018-11-12 18:19:37 +00:00
|
|
|
SkFont font(nullptr, 24);
|
2014-04-09 03:04:11 +00:00
|
|
|
|
2018-10-22 18:24:07 +00:00
|
|
|
REPORTER_ASSERT(reporter, font.getTypeface());
|
|
|
|
REPORTER_ASSERT(reporter, 24 == font.getSize());
|
|
|
|
REPORTER_ASSERT(reporter, 1 == font.getScaleX());
|
|
|
|
REPORTER_ASSERT(reporter, 0 == font.getSkewX());
|
2014-04-08 15:04:29 +00:00
|
|
|
|
|
|
|
uint16_t glyphs[5];
|
|
|
|
sk_bzero(glyphs, sizeof(glyphs));
|
|
|
|
|
2018-11-02 16:08:31 +00:00
|
|
|
// Check that no glyphs are copied with insufficient storage.
|
|
|
|
int count = font.textToGlyphs("Hello", 5, kUTF8_SkTextEncoding, glyphs, 2);
|
2014-04-08 15:04:29 +00:00
|
|
|
REPORTER_ASSERT(reporter, 5 == count);
|
2018-11-02 16:08:31 +00:00
|
|
|
for (const auto glyph : glyphs) { REPORTER_ASSERT(reporter, glyph == 0); }
|
|
|
|
|
|
|
|
SkAssertResult(font.textToGlyphs("Hello", 5, kUTF8_SkTextEncoding, glyphs,
|
|
|
|
SK_ARRAY_COUNT(glyphs)) == count);
|
|
|
|
|
2014-04-08 15:04:29 +00:00
|
|
|
for (int i = 0; i < count; ++i) {
|
|
|
|
REPORTER_ASSERT(reporter, 0 != glyphs[i]);
|
|
|
|
}
|
|
|
|
REPORTER_ASSERT(reporter, glyphs[0] != glyphs[1]); // 'h' != 'e'
|
|
|
|
REPORTER_ASSERT(reporter, glyphs[2] == glyphs[3]); // 'l' == 'l'
|
2014-04-09 03:04:11 +00:00
|
|
|
|
2018-10-22 18:24:07 +00:00
|
|
|
const SkFont newFont(font.makeWithSize(36));
|
|
|
|
REPORTER_ASSERT(reporter, font.getTypeface() == newFont.getTypeface());
|
|
|
|
REPORTER_ASSERT(reporter, 36 == newFont.getSize()); // double check we haven't changed
|
|
|
|
REPORTER_ASSERT(reporter, 24 == font.getSize()); // double check we haven't changed
|
2014-04-08 15:04:29 +00:00
|
|
|
|
|
|
|
SkPaint paint;
|
|
|
|
paint.setTextSize(18);
|
2018-10-22 18:24:07 +00:00
|
|
|
font = SkFont::LEGACY_ExtractFromPaint(paint);
|
|
|
|
REPORTER_ASSERT(reporter, font.getSize() == paint.getTextSize());
|
2014-04-08 15:04:29 +00:00
|
|
|
}
|
|
|
|
|
2013-09-18 20:32:25 +00:00
|
|
|
/*
|
|
|
|
* If the font backend is going to "alias" some font names to other fonts
|
|
|
|
* (e.g. sans -> Arial) then we want to at least get the same typeface back
|
|
|
|
* if we request the alias name multiple times.
|
|
|
|
*/
|
2013-09-19 18:06:03 +00:00
|
|
|
static void test_alias_names(skiatest::Reporter* reporter) {
|
|
|
|
const char* inNames[] = {
|
|
|
|
"sans", "sans-serif", "serif", "monospace", "times", "helvetica"
|
|
|
|
};
|
2013-09-20 07:01:33 +00:00
|
|
|
|
2013-09-19 18:06:03 +00:00
|
|
|
for (size_t i = 0; i < SK_ARRAY_COUNT(inNames); ++i) {
|
2016-05-31 18:42:36 +00:00
|
|
|
sk_sp<SkTypeface> first(SkTypeface::MakeFromName(inNames[i], SkFontStyle()));
|
2015-08-27 14:41:13 +00:00
|
|
|
if (nullptr == first.get()) {
|
2013-09-19 18:06:03 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
for (int j = 0; j < 10; ++j) {
|
2016-05-31 18:42:36 +00:00
|
|
|
sk_sp<SkTypeface> face(SkTypeface::MakeFromName(inNames[i], SkFontStyle()));
|
2013-09-19 18:06:03 +00:00
|
|
|
#if 0
|
|
|
|
SkString name;
|
|
|
|
face->getFamilyName(&name);
|
|
|
|
printf("request %s, received %s, first id %x received %x\n",
|
|
|
|
inNames[i], name.c_str(), first->uniqueID(), face->uniqueID());
|
|
|
|
#endif
|
|
|
|
REPORTER_ASSERT(reporter, first->uniqueID() == face->uniqueID());
|
|
|
|
}
|
2013-09-18 20:32:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-04-11 18:31:25 +00:00
|
|
|
static void test_fontiter(skiatest::Reporter* reporter, bool verbose) {
|
2016-11-04 15:49:42 +00:00
|
|
|
sk_sp<SkFontMgr> fm(SkFontMgr::RefDefault());
|
2013-04-11 18:31:25 +00:00
|
|
|
int count = fm->countFamilies();
|
|
|
|
|
|
|
|
for (int i = 0; i < count; ++i) {
|
|
|
|
SkString fname;
|
|
|
|
fm->getFamilyName(i, &fname);
|
|
|
|
|
2016-11-04 15:49:42 +00:00
|
|
|
sk_sp<SkFontStyleSet> fnset(fm->matchFamily(fname.c_str()));
|
|
|
|
sk_sp<SkFontStyleSet> set(fm->createStyleSet(i));
|
2013-05-01 14:21:20 +00:00
|
|
|
REPORTER_ASSERT(reporter, fnset->count() == set->count());
|
2013-04-11 18:31:25 +00:00
|
|
|
|
|
|
|
if (verbose) {
|
|
|
|
SkDebugf("[%2d] %s\n", i, fname.c_str());
|
|
|
|
}
|
|
|
|
|
|
|
|
for (int j = 0; j < set->count(); ++j) {
|
|
|
|
SkString sname;
|
|
|
|
SkFontStyle fs;
|
|
|
|
set->getStyle(j, &fs, &sname);
|
2013-04-25 14:59:32 +00:00
|
|
|
// REPORTER_ASSERT(reporter, sname.size() > 0);
|
2013-04-11 18:31:25 +00:00
|
|
|
|
2016-11-04 15:49:42 +00:00
|
|
|
sk_sp<SkTypeface> face(set->createTypeface(j));
|
2013-04-19 14:28:54 +00:00
|
|
|
// REPORTER_ASSERT(reporter, face.get());
|
2013-04-11 18:31:25 +00:00
|
|
|
|
|
|
|
if (verbose) {
|
|
|
|
SkDebugf("\t[%d] %s [%3d %d %d]\n", j, sname.c_str(),
|
2016-04-27 17:21:04 +00:00
|
|
|
fs.weight(), fs.width(), fs.slant());
|
2013-04-11 18:31:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-05-01 17:02:42 +00:00
|
|
|
static void test_match(skiatest::Reporter* reporter) {
|
|
|
|
sk_sp<SkFontMgr> fm(SkFontMgr::RefDefault());
|
|
|
|
sk_sp<SkFontStyleSet> styleSet(fm->matchFamily(nullptr));
|
|
|
|
REPORTER_ASSERT(reporter, styleSet);
|
|
|
|
}
|
|
|
|
|
2015-11-12 17:50:08 +00:00
|
|
|
static void test_matchStyleCSS3(skiatest::Reporter* reporter) {
|
|
|
|
static const SkFontStyle invalidFontStyle(101, SkFontStyle::kNormal_Width, SkFontStyle::kUpright_Slant);
|
|
|
|
|
|
|
|
class TestTypeface : public SkTypeface {
|
|
|
|
public:
|
2016-07-13 12:16:58 +00:00
|
|
|
TestTypeface(const SkFontStyle& fontStyle) : SkTypeface(fontStyle, false){}
|
2015-11-12 17:50:08 +00:00
|
|
|
protected:
|
|
|
|
SkStreamAsset* onOpenStream(int* ttcIndex) const override { return nullptr; }
|
2018-06-25 15:37:25 +00:00
|
|
|
sk_sp<SkTypeface> onMakeClone(const SkFontArguments& args) const override {
|
|
|
|
return sk_ref_sp(this);
|
|
|
|
}
|
2016-04-12 13:47:05 +00:00
|
|
|
SkScalerContext* onCreateScalerContext(const SkScalerContextEffects&,
|
|
|
|
const SkDescriptor*) const override {
|
2015-11-12 17:50:08 +00:00
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
void onFilterRec(SkScalerContextRec*) const override { }
|
2017-05-04 18:23:55 +00:00
|
|
|
std::unique_ptr<SkAdvancedTypefaceMetrics> onGetAdvancedMetrics() const override {
|
|
|
|
return nullptr;
|
|
|
|
}
|
2015-11-12 17:50:08 +00:00
|
|
|
void onGetFontDescriptor(SkFontDescriptor*, bool*) const override { }
|
|
|
|
virtual int onCharsToGlyphs(const void* chars, Encoding encoding,
|
|
|
|
uint16_t glyphs[], int glyphCount) const override {
|
|
|
|
if (glyphs && glyphCount > 0) {
|
|
|
|
sk_bzero(glyphs, glyphCount * sizeof(glyphs[0]));
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
2016-09-27 13:34:10 +00:00
|
|
|
int onCountGlyphs() const override { return 0; }
|
|
|
|
int onGetUPEM() const override { return 0; }
|
2015-11-12 17:50:08 +00:00
|
|
|
class EmptyLocalizedStrings : public SkTypeface::LocalizedStrings {
|
|
|
|
public:
|
|
|
|
bool next(SkTypeface::LocalizedString*) override { return false; }
|
|
|
|
};
|
|
|
|
void onGetFamilyName(SkString* familyName) const override {
|
|
|
|
familyName->reset();
|
|
|
|
}
|
|
|
|
SkTypeface::LocalizedStrings* onCreateFamilyNameIterator() const override {
|
|
|
|
return new EmptyLocalizedStrings;
|
2016-09-27 13:34:10 +00:00
|
|
|
}
|
2017-02-24 16:15:26 +00:00
|
|
|
int onGetVariationDesignPosition(
|
|
|
|
SkFontArguments::VariationPosition::Coordinate coordinates[],
|
|
|
|
int coordinateCount) const override
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
2015-11-12 17:50:08 +00:00
|
|
|
int onGetTableTags(SkFontTableTag tags[]) const override { return 0; }
|
|
|
|
size_t onGetTableData(SkFontTableTag, size_t, size_t, void*) const override {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
class TestFontStyleSet : public SkFontStyleSet {
|
|
|
|
public:
|
|
|
|
TestFontStyleSet(std::initializer_list<SkFontStyle> styles) : fStyles(styles) {}
|
|
|
|
int count() override { return static_cast<int>(fStyles.size()); }
|
|
|
|
void getStyle(int index, SkFontStyle* style, SkString*) override {
|
|
|
|
if (style) {
|
|
|
|
*style = fStyles[index];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
SkTypeface* createTypeface(int index) override {
|
|
|
|
if (index < 0 || this->count() <= index) {
|
2016-07-13 12:16:58 +00:00
|
|
|
return new TestTypeface(invalidFontStyle);
|
2015-11-12 17:50:08 +00:00
|
|
|
}
|
2016-07-13 12:16:58 +00:00
|
|
|
return new TestTypeface(fStyles[index]);
|
2015-11-12 17:50:08 +00:00
|
|
|
}
|
|
|
|
SkTypeface* matchStyle(const SkFontStyle& pattern) override {
|
|
|
|
return this->matchStyleCSS3(pattern);
|
|
|
|
}
|
|
|
|
private:
|
|
|
|
std::vector<SkFontStyle> fStyles;
|
|
|
|
};
|
|
|
|
|
|
|
|
SkFontStyle condensed_normal_100(SkFontStyle::kThin_Weight, SkFontStyle::kCondensed_Width, SkFontStyle::kUpright_Slant);
|
|
|
|
SkFontStyle condensed_normal_900(SkFontStyle::kBlack_Weight, SkFontStyle::kCondensed_Width, SkFontStyle::kUpright_Slant);
|
|
|
|
SkFontStyle condensed_italic_100(SkFontStyle::kThin_Weight, SkFontStyle::kCondensed_Width, SkFontStyle::kItalic_Slant);
|
|
|
|
SkFontStyle condensed_italic_900(SkFontStyle::kBlack_Weight, SkFontStyle::kCondensed_Width, SkFontStyle::kItalic_Slant);
|
2016-04-27 17:21:04 +00:00
|
|
|
SkFontStyle condensed_obliqu_100(SkFontStyle::kThin_Weight, SkFontStyle::kCondensed_Width, SkFontStyle::kOblique_Slant);
|
|
|
|
SkFontStyle condensed_obliqu_900(SkFontStyle::kBlack_Weight, SkFontStyle::kCondensed_Width, SkFontStyle::kOblique_Slant);
|
2015-11-12 17:50:08 +00:00
|
|
|
SkFontStyle expanded_normal_100(SkFontStyle::kThin_Weight, SkFontStyle::kExpanded_Width, SkFontStyle::kUpright_Slant);
|
|
|
|
SkFontStyle expanded_normal_900(SkFontStyle::kBlack_Weight, SkFontStyle::kExpanded_Width, SkFontStyle::kUpright_Slant);
|
|
|
|
SkFontStyle expanded_italic_100(SkFontStyle::kThin_Weight, SkFontStyle::kExpanded_Width, SkFontStyle::kItalic_Slant);
|
|
|
|
SkFontStyle expanded_italic_900(SkFontStyle::kBlack_Weight, SkFontStyle::kExpanded_Width, SkFontStyle::kItalic_Slant);
|
2016-04-27 17:21:04 +00:00
|
|
|
SkFontStyle expanded_obliqu_100(SkFontStyle::kThin_Weight, SkFontStyle::kExpanded_Width, SkFontStyle::kOblique_Slant);
|
|
|
|
SkFontStyle expanded_obliqu_900(SkFontStyle::kBlack_Weight, SkFontStyle::kExpanded_Width, SkFontStyle::kOblique_Slant);
|
2015-11-12 17:50:08 +00:00
|
|
|
|
|
|
|
SkFontStyle normal_normal_100(SkFontStyle::kThin_Weight, SkFontStyle::kNormal_Width, SkFontStyle::kUpright_Slant);
|
|
|
|
SkFontStyle normal_normal_300(SkFontStyle::kLight_Weight, SkFontStyle::kNormal_Width, SkFontStyle::kUpright_Slant);
|
|
|
|
SkFontStyle normal_normal_400(SkFontStyle::kNormal_Weight, SkFontStyle::kNormal_Width, SkFontStyle::kUpright_Slant);
|
|
|
|
SkFontStyle normal_normal_500(SkFontStyle::kMedium_Weight, SkFontStyle::kNormal_Width, SkFontStyle::kUpright_Slant);
|
|
|
|
SkFontStyle normal_normal_600(SkFontStyle::kSemiBold_Weight, SkFontStyle::kNormal_Width, SkFontStyle::kUpright_Slant);
|
|
|
|
SkFontStyle normal_normal_900(SkFontStyle::kBlack_Weight, SkFontStyle::kNormal_Width, SkFontStyle::kUpright_Slant);
|
|
|
|
|
|
|
|
struct StyleSetTest {
|
|
|
|
TestFontStyleSet styleSet;
|
|
|
|
struct Case {
|
|
|
|
SkFontStyle pattern;
|
|
|
|
SkFontStyle expectedResult;
|
|
|
|
};
|
|
|
|
std::vector<Case> cases;
|
|
|
|
} tests[] = {
|
|
|
|
{
|
|
|
|
{ condensed_normal_100,condensed_normal_900,condensed_italic_100,condensed_italic_900,
|
|
|
|
expanded_normal_100, expanded_normal_900, expanded_italic_100, expanded_italic_900 },
|
|
|
|
{
|
|
|
|
{ condensed_normal_100, condensed_normal_100 },
|
|
|
|
{ condensed_normal_900, condensed_normal_900 },
|
|
|
|
{ condensed_italic_100, condensed_italic_100 },
|
|
|
|
{ condensed_italic_900, condensed_italic_900 },
|
|
|
|
{ expanded_normal_100, expanded_normal_100 },
|
|
|
|
{ expanded_normal_900, expanded_normal_900 },
|
|
|
|
{ expanded_italic_100, expanded_italic_100 },
|
|
|
|
{ expanded_italic_900, expanded_italic_900 },
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
{
|
|
|
|
{ condensed_normal_100,condensed_italic_100,expanded_normal_100,expanded_italic_100 },
|
|
|
|
{
|
|
|
|
{ condensed_normal_100, condensed_normal_100 },
|
|
|
|
{ condensed_normal_900, condensed_normal_100 },
|
|
|
|
{ condensed_italic_100, condensed_italic_100 },
|
|
|
|
{ condensed_italic_900, condensed_italic_100 },
|
|
|
|
{ expanded_normal_100, expanded_normal_100 },
|
|
|
|
{ expanded_normal_900, expanded_normal_100 },
|
|
|
|
{ expanded_italic_100, expanded_italic_100 },
|
|
|
|
{ expanded_italic_900, expanded_italic_100 },
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
{
|
|
|
|
{ condensed_normal_900,condensed_italic_900,expanded_normal_900,expanded_italic_900 },
|
|
|
|
{
|
|
|
|
{ condensed_normal_100, condensed_normal_900 },
|
|
|
|
{ condensed_normal_900, condensed_normal_900 },
|
|
|
|
{ condensed_italic_100, condensed_italic_900 },
|
|
|
|
{ condensed_italic_900, condensed_italic_900 },
|
|
|
|
{ expanded_normal_100, expanded_normal_900 },
|
|
|
|
{ expanded_normal_900, expanded_normal_900 },
|
|
|
|
{ expanded_italic_100, expanded_italic_900 },
|
|
|
|
{ expanded_italic_900, expanded_italic_900 },
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
{
|
|
|
|
{ condensed_normal_100,condensed_normal_900,expanded_normal_100,expanded_normal_900 },
|
|
|
|
{
|
|
|
|
{ condensed_normal_100, condensed_normal_100 },
|
|
|
|
{ condensed_normal_900, condensed_normal_900 },
|
|
|
|
{ condensed_italic_100, condensed_normal_100 },
|
|
|
|
{ condensed_italic_900, condensed_normal_900 },
|
|
|
|
{ expanded_normal_100, expanded_normal_100 },
|
|
|
|
{ expanded_normal_900, expanded_normal_900 },
|
|
|
|
{ expanded_italic_100, expanded_normal_100 },
|
|
|
|
{ expanded_italic_900, expanded_normal_900 },
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
{
|
|
|
|
{ condensed_normal_100,expanded_normal_100 },
|
|
|
|
{
|
|
|
|
{ condensed_normal_100, condensed_normal_100 },
|
|
|
|
{ condensed_normal_900, condensed_normal_100 },
|
|
|
|
{ condensed_italic_100, condensed_normal_100 },
|
|
|
|
{ condensed_italic_900, condensed_normal_100 },
|
|
|
|
{ expanded_normal_100, expanded_normal_100 },
|
|
|
|
{ expanded_normal_900, expanded_normal_100 },
|
|
|
|
{ expanded_italic_100, expanded_normal_100 },
|
|
|
|
{ expanded_italic_900, expanded_normal_100 },
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
{
|
|
|
|
{ condensed_normal_900,expanded_normal_900 },
|
|
|
|
{
|
|
|
|
{ condensed_normal_100, condensed_normal_900 },
|
|
|
|
{ condensed_normal_900, condensed_normal_900 },
|
|
|
|
{ condensed_italic_100, condensed_normal_900 },
|
|
|
|
{ condensed_italic_900, condensed_normal_900 },
|
|
|
|
{ expanded_normal_100, expanded_normal_900 },
|
|
|
|
{ expanded_normal_900, expanded_normal_900 },
|
|
|
|
{ expanded_italic_100, expanded_normal_900 },
|
|
|
|
{ expanded_italic_900, expanded_normal_900 },
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
{
|
|
|
|
{ condensed_italic_100,condensed_italic_900,expanded_italic_100,expanded_italic_900 },
|
|
|
|
{
|
|
|
|
{ condensed_normal_100, condensed_italic_100 },
|
|
|
|
{ condensed_normal_900, condensed_italic_900 },
|
|
|
|
{ condensed_italic_100, condensed_italic_100 },
|
|
|
|
{ condensed_italic_900, condensed_italic_900 },
|
|
|
|
{ expanded_normal_100, expanded_italic_100 },
|
|
|
|
{ expanded_normal_900, expanded_italic_900 },
|
|
|
|
{ expanded_italic_100, expanded_italic_100 },
|
|
|
|
{ expanded_italic_900, expanded_italic_900 },
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
{
|
|
|
|
{ condensed_italic_100,expanded_italic_100 },
|
|
|
|
{
|
|
|
|
{ condensed_normal_100, condensed_italic_100 },
|
|
|
|
{ condensed_normal_900, condensed_italic_100 },
|
|
|
|
{ condensed_italic_100, condensed_italic_100 },
|
|
|
|
{ condensed_italic_900, condensed_italic_100 },
|
|
|
|
{ expanded_normal_100, expanded_italic_100 },
|
|
|
|
{ expanded_normal_900, expanded_italic_100 },
|
|
|
|
{ expanded_italic_100, expanded_italic_100 },
|
|
|
|
{ expanded_italic_900, expanded_italic_100 },
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
{
|
|
|
|
{ condensed_italic_900,expanded_italic_900 },
|
|
|
|
{
|
|
|
|
{ condensed_normal_100, condensed_italic_900 },
|
|
|
|
{ condensed_normal_900, condensed_italic_900 },
|
|
|
|
{ condensed_italic_100, condensed_italic_900 },
|
|
|
|
{ condensed_italic_900, condensed_italic_900 },
|
|
|
|
{ expanded_normal_100, expanded_italic_900 },
|
|
|
|
{ expanded_normal_900, expanded_italic_900 },
|
|
|
|
{ expanded_italic_100, expanded_italic_900 },
|
|
|
|
{ expanded_italic_900, expanded_italic_900 },
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
{
|
|
|
|
{ condensed_normal_100,condensed_normal_900,condensed_italic_100,condensed_italic_900 },
|
|
|
|
{
|
|
|
|
{ condensed_normal_100, condensed_normal_100 },
|
|
|
|
{ condensed_normal_900, condensed_normal_900 },
|
|
|
|
{ condensed_italic_100, condensed_italic_100 },
|
|
|
|
{ condensed_italic_900, condensed_italic_900 },
|
|
|
|
{ expanded_normal_100, condensed_normal_100 },
|
|
|
|
{ expanded_normal_900, condensed_normal_900 },
|
|
|
|
{ expanded_italic_100, condensed_italic_100 },
|
|
|
|
{ expanded_italic_900, condensed_italic_900 },
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
{
|
|
|
|
{ condensed_normal_100,condensed_italic_100 },
|
|
|
|
{
|
|
|
|
{ condensed_normal_100, condensed_normal_100 },
|
|
|
|
{ condensed_normal_900, condensed_normal_100 },
|
|
|
|
{ condensed_italic_100, condensed_italic_100 },
|
|
|
|
{ condensed_italic_900, condensed_italic_100 },
|
|
|
|
{ expanded_normal_100, condensed_normal_100 },
|
|
|
|
{ expanded_normal_900, condensed_normal_100 },
|
|
|
|
{ expanded_italic_100, condensed_italic_100 },
|
|
|
|
{ expanded_italic_900, condensed_italic_100 },
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
{
|
|
|
|
{ condensed_normal_900,condensed_italic_900 },
|
|
|
|
{
|
|
|
|
{ condensed_normal_100, condensed_normal_900 },
|
|
|
|
{ condensed_normal_900, condensed_normal_900 },
|
|
|
|
{ condensed_italic_100, condensed_italic_900 },
|
|
|
|
{ condensed_italic_900, condensed_italic_900 },
|
|
|
|
{ expanded_normal_100, condensed_normal_900 },
|
|
|
|
{ expanded_normal_900, condensed_normal_900 },
|
|
|
|
{ expanded_italic_100, condensed_italic_900 },
|
|
|
|
{ expanded_italic_900, condensed_italic_900 },
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
{
|
|
|
|
{ condensed_normal_100,condensed_normal_900 },
|
|
|
|
{
|
|
|
|
{ condensed_normal_100, condensed_normal_100 },
|
|
|
|
{ condensed_normal_900, condensed_normal_900 },
|
|
|
|
{ condensed_italic_100, condensed_normal_100 },
|
|
|
|
{ condensed_italic_900, condensed_normal_900 },
|
|
|
|
{ expanded_normal_100, condensed_normal_100 },
|
|
|
|
{ expanded_normal_900, condensed_normal_900 },
|
|
|
|
{ expanded_italic_100, condensed_normal_100 },
|
|
|
|
{ expanded_italic_900, condensed_normal_900 },
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
{
|
|
|
|
{ condensed_normal_100 },
|
|
|
|
{
|
|
|
|
{ condensed_normal_100, condensed_normal_100 },
|
|
|
|
{ condensed_normal_900, condensed_normal_100 },
|
|
|
|
{ condensed_italic_100, condensed_normal_100 },
|
|
|
|
{ condensed_italic_900, condensed_normal_100 },
|
|
|
|
{ expanded_normal_100, condensed_normal_100 },
|
|
|
|
{ expanded_normal_900, condensed_normal_100 },
|
|
|
|
{ expanded_italic_100, condensed_normal_100 },
|
|
|
|
{ expanded_italic_900, condensed_normal_100 },
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
{
|
|
|
|
{ condensed_normal_900 },
|
|
|
|
{
|
|
|
|
{ condensed_normal_100, condensed_normal_900 },
|
|
|
|
{ condensed_normal_900, condensed_normal_900 },
|
|
|
|
{ condensed_italic_100, condensed_normal_900 },
|
|
|
|
{ condensed_italic_900, condensed_normal_900 },
|
|
|
|
{ expanded_normal_100, condensed_normal_900 },
|
|
|
|
{ expanded_normal_900, condensed_normal_900 },
|
|
|
|
{ expanded_italic_100, condensed_normal_900 },
|
|
|
|
{ expanded_italic_900, condensed_normal_900 },
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
{
|
|
|
|
{ condensed_italic_100,condensed_italic_900 },
|
|
|
|
{
|
|
|
|
{ condensed_normal_100, condensed_italic_100 },
|
|
|
|
{ condensed_normal_900, condensed_italic_900 },
|
|
|
|
{ condensed_italic_100, condensed_italic_100 },
|
|
|
|
{ condensed_italic_900, condensed_italic_900 },
|
|
|
|
{ expanded_normal_100, condensed_italic_100 },
|
|
|
|
{ expanded_normal_900, condensed_italic_900 },
|
|
|
|
{ expanded_italic_100, condensed_italic_100 },
|
|
|
|
{ expanded_italic_900, condensed_italic_900 },
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
{
|
|
|
|
{ condensed_italic_100 },
|
|
|
|
{
|
|
|
|
{ condensed_normal_100, condensed_italic_100 },
|
|
|
|
{ condensed_normal_900, condensed_italic_100 },
|
|
|
|
{ condensed_italic_100, condensed_italic_100 },
|
|
|
|
{ condensed_italic_900, condensed_italic_100 },
|
|
|
|
{ expanded_normal_100, condensed_italic_100 },
|
|
|
|
{ expanded_normal_900, condensed_italic_100 },
|
|
|
|
{ expanded_italic_100, condensed_italic_100 },
|
|
|
|
{ expanded_italic_900, condensed_italic_100 },
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
{
|
|
|
|
{ condensed_italic_900 },
|
|
|
|
{
|
|
|
|
{ condensed_normal_100, condensed_italic_900 },
|
|
|
|
{ condensed_normal_900, condensed_italic_900 },
|
|
|
|
{ condensed_italic_100, condensed_italic_900 },
|
|
|
|
{ condensed_italic_900, condensed_italic_900 },
|
|
|
|
{ expanded_normal_100, condensed_italic_900 },
|
|
|
|
{ expanded_normal_900, condensed_italic_900 },
|
|
|
|
{ expanded_italic_100, condensed_italic_900 },
|
|
|
|
{ expanded_italic_900, condensed_italic_900 },
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
{
|
2016-04-27 17:21:04 +00:00
|
|
|
{ expanded_normal_100,expanded_normal_900,
|
|
|
|
expanded_italic_100,expanded_italic_900 },
|
2015-11-12 17:50:08 +00:00
|
|
|
{
|
|
|
|
{ condensed_normal_100, expanded_normal_100 },
|
|
|
|
{ condensed_normal_900, expanded_normal_900 },
|
|
|
|
{ condensed_italic_100, expanded_italic_100 },
|
|
|
|
{ condensed_italic_900, expanded_italic_900 },
|
2016-04-27 17:21:04 +00:00
|
|
|
{ condensed_obliqu_100, expanded_italic_100 },
|
|
|
|
{ condensed_obliqu_900, expanded_italic_900 },
|
2015-11-12 17:50:08 +00:00
|
|
|
{ expanded_normal_100, expanded_normal_100 },
|
|
|
|
{ expanded_normal_900, expanded_normal_900 },
|
|
|
|
{ expanded_italic_100, expanded_italic_100 },
|
|
|
|
{ expanded_italic_900, expanded_italic_900 },
|
2016-04-27 17:21:04 +00:00
|
|
|
{ expanded_obliqu_100, expanded_italic_100 },
|
|
|
|
{ expanded_obliqu_900, expanded_italic_900 },
|
2015-11-12 17:50:08 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
{
|
|
|
|
{ expanded_normal_100,expanded_italic_100 },
|
|
|
|
{
|
|
|
|
{ condensed_normal_100, expanded_normal_100 },
|
|
|
|
{ condensed_normal_900, expanded_normal_100 },
|
|
|
|
{ condensed_italic_100, expanded_italic_100 },
|
|
|
|
{ condensed_italic_900, expanded_italic_100 },
|
|
|
|
{ expanded_normal_100, expanded_normal_100 },
|
|
|
|
{ expanded_normal_900, expanded_normal_100 },
|
|
|
|
{ expanded_italic_100, expanded_italic_100 },
|
|
|
|
{ expanded_italic_900, expanded_italic_100 },
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
{
|
|
|
|
{ expanded_normal_900,expanded_italic_900 },
|
|
|
|
{
|
|
|
|
{ condensed_normal_100, expanded_normal_900 },
|
|
|
|
{ condensed_normal_900, expanded_normal_900 },
|
|
|
|
{ condensed_italic_100, expanded_italic_900 },
|
|
|
|
{ condensed_italic_900, expanded_italic_900 },
|
|
|
|
{ expanded_normal_100, expanded_normal_900 },
|
|
|
|
{ expanded_normal_900, expanded_normal_900 },
|
|
|
|
{ expanded_italic_100, expanded_italic_900 },
|
|
|
|
{ expanded_italic_900, expanded_italic_900 },
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
{
|
|
|
|
{ expanded_normal_100,expanded_normal_900 },
|
|
|
|
{
|
|
|
|
{ condensed_normal_100, expanded_normal_100 },
|
|
|
|
{ condensed_normal_900, expanded_normal_900 },
|
|
|
|
{ condensed_italic_100, expanded_normal_100 },
|
|
|
|
{ condensed_italic_900, expanded_normal_900 },
|
|
|
|
{ expanded_normal_100, expanded_normal_100 },
|
|
|
|
{ expanded_normal_900, expanded_normal_900 },
|
|
|
|
{ expanded_italic_100, expanded_normal_100 },
|
|
|
|
{ expanded_italic_900, expanded_normal_900 },
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
{
|
|
|
|
{ expanded_normal_100 },
|
|
|
|
{
|
|
|
|
{ condensed_normal_100, expanded_normal_100 },
|
|
|
|
{ condensed_normal_900, expanded_normal_100 },
|
|
|
|
{ condensed_italic_100, expanded_normal_100 },
|
|
|
|
{ condensed_italic_900, expanded_normal_100 },
|
|
|
|
{ expanded_normal_100, expanded_normal_100 },
|
|
|
|
{ expanded_normal_900, expanded_normal_100 },
|
|
|
|
{ expanded_italic_100, expanded_normal_100 },
|
|
|
|
{ expanded_italic_900, expanded_normal_100 },
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
{
|
|
|
|
{ expanded_normal_900 },
|
|
|
|
{
|
|
|
|
{ condensed_normal_100, expanded_normal_900 },
|
|
|
|
{ condensed_normal_900, expanded_normal_900 },
|
|
|
|
{ condensed_italic_100, expanded_normal_900 },
|
|
|
|
{ condensed_italic_900, expanded_normal_900 },
|
|
|
|
{ expanded_normal_100, expanded_normal_900 },
|
|
|
|
{ expanded_normal_900, expanded_normal_900 },
|
|
|
|
{ expanded_italic_100, expanded_normal_900 },
|
|
|
|
{ expanded_italic_900, expanded_normal_900 },
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
{
|
|
|
|
{ expanded_italic_100,expanded_italic_900 },
|
|
|
|
{
|
|
|
|
{ condensed_normal_100, expanded_italic_100 },
|
|
|
|
{ condensed_normal_900, expanded_italic_900 },
|
|
|
|
{ condensed_italic_100, expanded_italic_100 },
|
|
|
|
{ condensed_italic_900, expanded_italic_900 },
|
|
|
|
{ expanded_normal_100, expanded_italic_100 },
|
|
|
|
{ expanded_normal_900, expanded_italic_900 },
|
|
|
|
{ expanded_italic_100, expanded_italic_100 },
|
|
|
|
{ expanded_italic_900, expanded_italic_900 },
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
{
|
|
|
|
{ expanded_italic_100 },
|
|
|
|
{
|
|
|
|
{ condensed_normal_100, expanded_italic_100 },
|
|
|
|
{ condensed_normal_900, expanded_italic_100 },
|
|
|
|
{ condensed_italic_100, expanded_italic_100 },
|
|
|
|
{ condensed_italic_900, expanded_italic_100 },
|
|
|
|
{ expanded_normal_100, expanded_italic_100 },
|
|
|
|
{ expanded_normal_900, expanded_italic_100 },
|
|
|
|
{ expanded_italic_100, expanded_italic_100 },
|
|
|
|
{ expanded_italic_900, expanded_italic_100 },
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
{
|
|
|
|
{ expanded_italic_900 },
|
|
|
|
{
|
|
|
|
{ condensed_normal_100, expanded_italic_900 },
|
|
|
|
{ condensed_normal_900, expanded_italic_900 },
|
|
|
|
{ condensed_italic_100, expanded_italic_900 },
|
|
|
|
{ condensed_italic_900, expanded_italic_900 },
|
|
|
|
{ expanded_normal_100, expanded_italic_900 },
|
|
|
|
{ expanded_normal_900, expanded_italic_900 },
|
|
|
|
{ expanded_italic_100, expanded_italic_900 },
|
|
|
|
{ expanded_italic_900, expanded_italic_900 },
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
{
|
|
|
|
{ normal_normal_100, normal_normal_900 },
|
|
|
|
{
|
|
|
|
{ normal_normal_300, normal_normal_100 },
|
|
|
|
{ normal_normal_400, normal_normal_100 },
|
|
|
|
{ normal_normal_500, normal_normal_100 },
|
|
|
|
{ normal_normal_600, normal_normal_900 },
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
{
|
|
|
|
{ normal_normal_100, normal_normal_400, normal_normal_900 },
|
|
|
|
{
|
|
|
|
{ normal_normal_300, normal_normal_100 },
|
|
|
|
{ normal_normal_400, normal_normal_400 },
|
|
|
|
{ normal_normal_500, normal_normal_400 },
|
|
|
|
{ normal_normal_600, normal_normal_900 },
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
{
|
|
|
|
{ normal_normal_100, normal_normal_500, normal_normal_900 },
|
|
|
|
{
|
|
|
|
{ normal_normal_300, normal_normal_100 },
|
|
|
|
{ normal_normal_400, normal_normal_500 },
|
|
|
|
{ normal_normal_500, normal_normal_500 },
|
|
|
|
{ normal_normal_600, normal_normal_900 },
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
{
|
|
|
|
{ },
|
|
|
|
{
|
|
|
|
{ normal_normal_300, invalidFontStyle },
|
|
|
|
{ normal_normal_400, invalidFontStyle },
|
|
|
|
{ normal_normal_500, invalidFontStyle },
|
|
|
|
{ normal_normal_600, invalidFontStyle },
|
|
|
|
},
|
|
|
|
},
|
2016-04-27 17:21:04 +00:00
|
|
|
{
|
|
|
|
{ expanded_normal_100,expanded_normal_900,
|
|
|
|
expanded_italic_100,expanded_italic_900,
|
|
|
|
expanded_obliqu_100,expanded_obliqu_900, },
|
|
|
|
{
|
|
|
|
{ condensed_normal_100, expanded_normal_100 },
|
|
|
|
{ condensed_normal_900, expanded_normal_900 },
|
|
|
|
{ condensed_italic_100, expanded_italic_100 },
|
|
|
|
{ condensed_italic_900, expanded_italic_900 },
|
|
|
|
{ condensed_obliqu_100, expanded_obliqu_100 },
|
|
|
|
{ condensed_obliqu_900, expanded_obliqu_900 },
|
|
|
|
{ expanded_normal_100, expanded_normal_100 },
|
|
|
|
{ expanded_normal_900, expanded_normal_900 },
|
|
|
|
{ expanded_italic_100, expanded_italic_100 },
|
|
|
|
{ expanded_italic_900, expanded_italic_900 },
|
|
|
|
{ expanded_obliqu_100, expanded_obliqu_100 },
|
|
|
|
{ expanded_obliqu_900, expanded_obliqu_900 },
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
{ expanded_normal_100,expanded_normal_900,
|
|
|
|
expanded_obliqu_100,expanded_obliqu_900, },
|
|
|
|
{
|
|
|
|
{ condensed_normal_100, expanded_normal_100 },
|
|
|
|
{ condensed_normal_900, expanded_normal_900 },
|
|
|
|
{ condensed_italic_100, expanded_obliqu_100 },
|
|
|
|
{ condensed_italic_900, expanded_obliqu_900 },
|
|
|
|
{ condensed_obliqu_100, expanded_obliqu_100 },
|
|
|
|
{ condensed_obliqu_900, expanded_obliqu_900 },
|
|
|
|
{ expanded_normal_100, expanded_normal_100 },
|
|
|
|
{ expanded_normal_900, expanded_normal_900 },
|
|
|
|
{ expanded_italic_100, expanded_obliqu_100 },
|
|
|
|
{ expanded_italic_900, expanded_obliqu_900 },
|
|
|
|
{ expanded_obliqu_100, expanded_obliqu_100 },
|
|
|
|
{ expanded_obliqu_900, expanded_obliqu_900 },
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
{ expanded_italic_100,expanded_italic_900,
|
|
|
|
expanded_obliqu_100,expanded_obliqu_900, },
|
|
|
|
{
|
|
|
|
{ condensed_normal_100, expanded_obliqu_100 },
|
|
|
|
{ condensed_normal_900, expanded_obliqu_900 },
|
|
|
|
{ condensed_italic_100, expanded_italic_100 },
|
|
|
|
{ condensed_italic_900, expanded_italic_900 },
|
|
|
|
{ condensed_obliqu_100, expanded_obliqu_100 },
|
|
|
|
{ condensed_obliqu_900, expanded_obliqu_900 },
|
|
|
|
{ expanded_normal_100, expanded_obliqu_100 },
|
|
|
|
{ expanded_normal_900, expanded_obliqu_900 },
|
|
|
|
{ expanded_italic_100, expanded_italic_100 },
|
|
|
|
{ expanded_italic_900, expanded_italic_900 },
|
|
|
|
{ expanded_obliqu_100, expanded_obliqu_100 },
|
|
|
|
{ expanded_obliqu_900, expanded_obliqu_900 },
|
|
|
|
},
|
|
|
|
},
|
2015-11-12 17:50:08 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
for (StyleSetTest& test : tests) {
|
2016-10-26 14:35:22 +00:00
|
|
|
for (const StyleSetTest::Case& testCase : test.cases) {
|
2016-11-04 15:49:42 +00:00
|
|
|
sk_sp<SkTypeface> typeface(test.styleSet.matchStyle(testCase.pattern));
|
2015-11-12 17:50:08 +00:00
|
|
|
if (typeface) {
|
|
|
|
REPORTER_ASSERT(reporter, typeface->fontStyle() == testCase.expectedResult);
|
|
|
|
} else {
|
|
|
|
REPORTER_ASSERT(reporter, invalidFontStyle == testCase.expectedResult);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-04-11 19:04:34 +00:00
|
|
|
DEFINE_bool(verboseFontMgr, false, "run verbose fontmgr tests.");
|
2013-04-11 18:31:25 +00:00
|
|
|
|
2013-12-12 21:11:12 +00:00
|
|
|
DEF_TEST(FontMgr, reporter) {
|
2017-05-01 17:02:42 +00:00
|
|
|
test_match(reporter);
|
2015-11-12 17:50:08 +00:00
|
|
|
test_matchStyleCSS3(reporter);
|
2013-04-11 18:31:25 +00:00
|
|
|
test_fontiter(reporter, FLAGS_verboseFontMgr);
|
2013-09-19 18:06:03 +00:00
|
|
|
test_alias_names(reporter);
|
2014-04-08 15:04:29 +00:00
|
|
|
test_font(reporter);
|
2013-04-11 18:31:25 +00:00
|
|
|
}
|