50 if (!data->unique()) {
52 data = dataCopy.
get();
57 SkTAfter<SkSFNTHeader::TableDirectoryEntry>(sfntHeader);
60 for (
int tableEntryIndex = 0; tableEntryIndex < numTables; ++tableEntryIndex) {
62 os2TableEntry = tableEntry + tableEntryIndex;
69 SkOTTableOS2_V0* os2Table = SkTAddOffset<SkOTTableOS2_V0>(sfntHeader, os2TableOffset);
89 newStyle.
weight() == weight ||
90 (weight <= 10 && newStyle.
weight() == 100 * weight) ||
91 (weight == 4 && newStyle.
weight() == 350) ||
92 (weight == 5 && newStyle.
weight() == 400) ||
93 (weight == 0 && newStyle.
weight() == 1) ||
94 (weight == 1000 && newStyle.
weight() == 999)
101 "newStyle.width(): %d width: %" PRIu16, newStyle.
width(),
width);
141 Variation::Coordinate varPos[2];
142 int numAxes = typeface->getVariationDesignPosition(varPos, std::size(varPos));
154 const Variation::Coordinate nonDefaultPosition[] = {
163#if defined(SK_BUILD_FOR_MAC) || defined(SK_BUILD_FOR_IOS)
172 SkFontStyle ndfs = nonDefaultTypeface->fontStyle();
245 auto test = [&](
SkTypeface* typeface,
const Variation& expected,
int alsoAcceptedAxisTagCount) {
251 if (actualCount == -1) {
255 actualCount == alsoAcceptedAxisTagCount);
260 std::unique_ptr<Variation::Coordinate[]> actual(
new Variation::Coordinate[actualCount]);
262 if (actualCount == -1) {
266 actualCount == alsoAcceptedAxisTagCount);
269 std::unique_ptr<bool[]> expectedUsed(
new bool[expected.coordinateCount]());
270 for (
int actualIdx = 0; actualIdx < actualCount; ++actualIdx) {
271 bool actualFound =
false;
272 for (
int expectedIdx = 0; expectedIdx < expected.coordinateCount; ++expectedIdx) {
273 if (expectedUsed[expectedIdx]) {
277 if (actual[actualIdx].axis != expected.coordinates[expectedIdx].axis) {
284 if (!(
SkTAbs(fixedRead - fixedOriginal) < 2)) {
290 expectedUsed[expectedIdx] =
true;
294 "Actual axis '%c%c%c%c' with value '%f' not expected",
295 (
char)((actual[actualIdx].axis >> 24) & 0xFF),
296 (
char)((actual[actualIdx].axis >> 16) & 0xFF),
297 (
char)((actual[actualIdx].axis >> 8) & 0xFF),
298 (
char)((actual[actualIdx].axis ) & 0xFF),
312 const Variation::Coordinate defaultPosition[] = {
317 test(typeface.
get(), Variation{&defaultPosition[0], 2}, -1);
330 const Variation::Coordinate position[] = {
338 test(typeface.
get(), Variation{&position[1], 2}, 1);
351 const Variation::Coordinate position[] = {
358 test(typeface.
get(), Variation{&position[1], 1}, -1);
363 test(clone.
get(), Variation{&position[1], 1}, -1);
429 auto test = [&](
SkTypeface* typeface,
const Axis* expected,
int expectedCount,
430 int alsoAcceptedAxisTagCount)
437 if (actualCount == -1) {
441 actualCount == alsoAcceptedAxisTagCount);
443 std::unique_ptr<Axis[]> actual(
new Axis[actualCount]);
445 if (actualCount == -1) {
449 actualCount == alsoAcceptedAxisTagCount);
452 std::unique_ptr<bool[]> expectedUsed(
new bool[expectedCount]());
453 for (
int actualIdx = 0; actualIdx < actualCount; ++actualIdx) {
454 bool actualFound =
false;
455 for (
int expectedIdx = 0; expectedIdx < expectedCount; ++expectedIdx) {
456 if (expectedUsed[expectedIdx]) {
460 if (actual[actualIdx].tag != expected[expectedIdx].tag) {
467 if (!(
SkTAbs(fixedActualMin - fixedExpectedMin) < 2)) {
473 if (!(
SkTAbs(fixedActualMax - fixedExpectedMax) < 2)) {
479 if (!(
SkTAbs(fixedActualDefault - fixedExpectedDefault) < 2)) {
485 if (actual[actualIdx].isHidden() &&
486 actual[actualIdx].isHidden() != expected[expectedIdx].isHidden())
493 expectedUsed[expectedIdx] =
true;
497 "Actual axis '%c%c%c%c' with min %f max %f default %f hidden %s not expected",
498 (
char)((actual[actualIdx].tag >> 24) & 0xFF),
499 (
char)((actual[actualIdx].tag >> 16) & 0xFF),
500 (
char)((actual[actualIdx].tag >> 8) & 0xFF),
501 (
char)((actual[actualIdx].tag ) & 0xFF),
502 actual[actualIdx].
min,
503 actual[actualIdx].def,
504 actual[actualIdx].
max,
505 actual[actualIdx].isHidden() ?
"true" :
"false");
518 constexpr Axis expected[] = {
523 test(typeface.
get(), &expected[0], std::size(expected), -1);
536 constexpr Axis expected[] = {
541 test(typeface.
get(), &expected[0], std::size(expected), 1);
551 constexpr Axis expected[] = {
555 test(typeface.
get(), &expected[0], std::size(expected), -1);
626 size_t const textLen = strlen(
text);
628 font.getTypeface()->getFamilyName(&familyName);
631 char const *
const textEnd =
text + textLen;
632 std::unique_ptr<SkUnichar[]> originalCodepoints(
new SkUnichar[codepointCount]);
633 for (
size_t i = 0; i < codepointCount; ++i) {
637 font.unicharsToGlyphs(originalCodepoints.get(), codepointCount,
glyphs.get());
639 ERRORF(
reporter,
"Unexpected typeface \"%s\". Expected full support for emoji_sample_text.",
644 std::unique_ptr<SkUnichar[]> newCodepoints(
new SkUnichar[codepointCount]);
647 for (
size_t i = 0; i < codepointCount; ++i) {
655 "name:%s i:%zu original:%d new:%d glyph:%d", familyName.
c_str(), i,
656 originalCodepoints[i], newCodepoints[i],
glyphs[i]);