59 {
60 if (!fontmgr_understands_ft_named_instance_bits()) {
61 return;
62 }
63
64 FcConfig* config = build_fontconfig_with_fontfile("/fonts/NotoSansCJK-VF-subset.otf.ttc");
66
67 static constexpr const char* family_names[]{"Noto Sans CJK JP",
68 "Noto Sans CJK HK",
69 "Noto Sans CJK SC",
70 "Noto Sans CJK TC",
71 "Noto Sans CJK KR"};
72 static constexpr const struct Test {
73 int weight;
74 bool highBitsExpectation;
76 {100, false},
77 {300, true },
78 {350, true },
79 {400, true },
80 {500, true },
81 {700, true },
82 {900, true },
83 };
84
85 for (auto&& font_name : family_names) {
86 for (
auto&& [weight, highBitsExpectation] :
tests) {
88
92 const bool r = fciDirect->matchFamilyName(
93 font_name, fontStyle, &resultIdentity, &resultFamily, &resultStyle);
94
98 (resultIdentity.
fTTCIndex >> 16 > 0) == highBitsExpectation,
99 "Expected to have the ttcIndex' upper 16 bits refer to a named instance.");
100
101
102
103
106
107 if (!typeface) {
108 ERRORF(
reporter,
"Could not instantiate typeface, FcVersion: %d", FcGetVersion());
109 return;
110 }
111
113 typeface->getFamilyName(&family_from_typeface);
114
116 family_from_typeface ==
SkString(font_name),
117 "Matched font's family name should match the request.");
118
119 SkFontStyle intrinsic_style = typeface->fontStyle();
121 intrinsic_style.
weight() == weight,
122 "Matched font's weight should match request.");
123 if (intrinsic_style.
weight() != weight) {
125 "Matched font had weight: %d, expected %d, family: %s",
127 weight,
128 family_from_typeface.
c_str());
129 }
130
131 int numAxes = typeface->getVariationDesignPosition(nullptr, 0);
132 std::vector<SkFontArguments::VariationPosition::Coordinate> coords;
133 coords.resize(numAxes);
134 typeface->getVariationDesignPosition(coords.data(), numAxes);
135
137 coords.size() == 1,
138 "The font must only have one axis, the weight axis.");
139
142 "The weight axis must be present and configured.");
143
145 static_cast<int>(coords[0].
value) == weight,
146 "The weight axis must match the weight from the request.");
147 }
148 }
149
150}
static constexpr SkFourByteTag SkSetFourByteTag(char a, char b, char c, char d)
#define REPORTER_ASSERT(r, cond,...)
const char * c_str() const