32 while (iterA.experimentalNext(&runAInfo)) {
35 SkASSERT(iterB.experimentalNext(&runBInfo));
36 for (
int i = 0;
i < runAInfo.
count; ++
i) {
43 pathA.
dump(&streamA,
false);
44 pathB.
dump(&streamB,
false);
47 if (dataA->
size() != dataB->
size() ||
48 memcmp(dataA->
data(), dataB->
data(), dataA->
size() - 1)) {
53 SkDebugf(
"Different path in font %s for glyph index: %d glyph id: %d, data sizes "
57 std::string fontationsPath(
reinterpret_cast<const char*
>(dataA->
bytes()),
59 std::string freetypePath(
reinterpret_cast<const char*
>(dataB->
bytes()),
61 SkDebugf(
"Path A (Fontations): \n%s\n", fontationsPath.c_str());
62 SkDebugf(
"Path B (FreeType): \n%s\n", freetypePath.c_str());
70class FontationsFtComparison {
72 FontationsFtComparison(std::string fontMatch, std::string langMatch)
73 : fTestDataIterator(fontMatch, langMatch) {}
77 size_t numTestsExecuted = 0;
78 while (fTestDataIterator.next(&
testSet)) {
88 SkFont fontationsFont(fontationsTypeface);
89 SkFont freetypeFont(freetypeTypeface);
94 font.setSubpixel(
true);
98 configureFont(fontationsFont);
99 configureFont(freetypeFont);
101 for (
const auto& sampleLang :
testSet.langSamples) {
103 makeTextBlobWithFontAndText(fontationsFont, sampleLang.sampleLong);
105 makeTextBlobWithFontAndText(freetypeFont, sampleLang.sampleLong);
108 textBlobsAllPathsEqual(
109 fontationsTextBlob, freetypeTextBlob,
testSet.fontName),
110 "paths not equal for %s",
116 numTestsExecuted > 0,
117 "Error: FontationsFtComparison did not run any tests, missing third-party "
118 "googlefonts_testdata resource? See bin/fetch-fonts-testdata.");
127 font.getTypeface()->getFamilyName(&fam);
130 SkScalar shapeWidth =
font.getTypeface()->getUnitsPerEm() * testPhrase.
size() * 1.10f;
132 testPhrase.
c_str(), testPhrase.
size(),
font,
true, shapeWidth, &textBlobBuilder);
133 return textBlobBuilder.makeBlob();
142 FontationsFtComparison(
"Noto Sans",
143 "en_Latn|es_Latn|pt_Latn|id_Latn|ru_Cyrl|fr_Latn|tr_Latn|vi_Latn|de_"
144 "Latn|it_Latn|pl_Latn|nl_Latn|uk_Cyrl|gl_Latn|ro_Latn|cs_Latn|hu_Latn|"
145 "el_Grek|se_Latn|da_Latn|bg_Latn|sk_Latn|fi_Latn|bs_Latn|ca_Latn|no_"
146 "Latn|sr_Latn|sr_Cyrl|lt_Latn|hr_Latn|sl_Latn|uz_Latn|uz_Cyrl|lv_Latn|"
147 "et_Latn|az_Latn|az_Cyrl|la_Latn|tg_Latn|tg_Cyrl|sw_Latn|mn_Cyrl|kk_"
148 "Latn|kk_Cyrl|sq_Latn|af_Latn|ha_Latn|ky_Cyrl")
153 FontationsFtComparison(
"Noto Sans Devanagari",
"hi_Deva|mr_Deva").assertAllPathsEqual(
reporter);
157 FontationsFtComparison(
"Noto Sans Arabic",
"ar_Arab|uz_Arab|kk_Arab|ky_Arab")
162 FontationsFtComparison(
"Noto Sans Bengali",
"bn_Beng").assertAllPathsEqual(
reporter);
166 FontationsFtComparison(
"Noto Sans JP",
"ja_Jpan").assertAllPathsEqual(
reporter);
170 FontationsFtComparison(
"Noto Sans Thai",
"th_Thai").assertAllPathsEqual(
reporter);
174 FontationsFtComparison(
"Noto Sans SC",
"zh_Hans").assertAllPathsEqual(
reporter);
178 FontationsFtComparison(
"Noto Sans TC",
"zh_Hant").assertAllPathsEqual(
reporter);
182 FontationsFtComparison(
"Noto Sans KR",
"ko_Kore").assertAllPathsEqual(
reporter);
186 FontationsFtComparison(
"Noto Sans Tamil",
"ta_Taml").assertAllPathsEqual(
reporter);
190 FontationsFtComparison(
"Noto Sans Newa",
"new_Newa").assertAllPathsEqual(
reporter);
194 FontationsFtComparison(
"Noto Sans Kannada",
"kn_Knda").assertAllPathsEqual(
reporter);
198 FontationsFtComparison(
"Noto Sans Tagalog",
"fil_Tglg").assertAllPathsEqual(
reporter);
202 FontationsFtComparison(
"Noto Sans Telugu",
"te_Telu").assertAllPathsEqual(
reporter);
206 FontationsFtComparison(
"Noto Sans Gujarati",
"gu_Gujr").assertAllPathsEqual(
reporter);
210 FontationsFtComparison(
"Noto Sans Georgian",
"ka_Geor").assertAllPathsEqual(
reporter);
214 FontationsFtComparison(
"Noto Sans Malayalam",
"ml_Mlym").assertAllPathsEqual(
reporter);
218 FontationsFtComparison(
"Noto Sans Khmer",
"km_Khmr").assertAllPathsEqual(
reporter);
222 FontationsFtComparison(
"Noto Sans Sinhala",
"si_Sinh").assertAllPathsEqual(
reporter);
226 FontationsFtComparison(
"Noto Sans Myanmar",
"my_Mymr").assertAllPathsEqual(
reporter);
230 FontationsFtComparison(
"Noto Sans Javanese",
"jv_Java").assertAllPathsEqual(
reporter);
234 FontationsFtComparison(
"Noto Sans Mongolian",
"mn_Mong").assertAllPathsEqual(
reporter);
238 FontationsFtComparison(
"Noto Sans Armenian",
"hy_Armn").assertAllPathsEqual(
reporter);
242 FontationsFtComparison(
"Noto Sans Elbasan",
"sq_Elba").assertAllPathsEqual(
reporter);
246 FontationsFtComparison(
"Noto Sans Vithkuqi",
"sq_Vith").assertAllPathsEqual(
reporter);
250 FontationsFtComparison(
"Noto Sans Gurmukhi",
"pa_Guru").assertAllPathsEqual(
reporter);
DEF_TEST(Fontations_NotoSans, reporter)
static const ConicPts testSet[]
#define SkASSERT_RELEASE(cond)
void SK_SPI SkDebugf(const char format[],...) SK_PRINTF_LIKE(1
@ kNone
glyph outlines unchanged
SK_API sk_sp< SkTypeface > SkTypeface_Make_Fontations(std::unique_ptr< SkStreamAsset > fontData, const SkFontArguments &args)
#define REPORTER_ASSERT(r, cond,...)
const uint8_t * bytes() const
const void * data() const
sk_sp< SkData > detachAsData()
bool getPath(SkGlyphID glyphID, SkPath *path) const
@ kSubpixelAntiAlias
glyph positioned in pixel using transparency
void dump(SkWStream *stream, bool dumpAsHex) const
static std::unique_ptr< SkShaper > Make(sk_sp< SkFontMgr > fallback=nullptr)
static std::unique_ptr< SkStreamAsset > MakeFromFile(const char path[])
const char * c_str() const
static sk_sp< SkTypeface > MakeFromStream(std::unique_ptr< SkStreamAsset >, const SkFontArguments &)
int getUnitsPerEm() const
font
Font Metadata and Metrics.