Width has the greatest priority. If the value of pattern.width is 5 (normal) or less, narrower width values are checked first, then wider values. If the value of pattern.width is greater than 5 (normal), wider values are checked first, followed by narrower values.
Italic/Oblique has the next highest priority. If italic requested and there is some italic font, use it. If oblique requested and there is some oblique font, use it. If italic requested and there is some oblique font, use it. If oblique requested and there is some italic font, use it.
Exact match. If pattern.weight < 400, weights below pattern.weight are checked in descending order followed by weights above pattern.weight in ascending order until a match is found. If pattern.weight > 500, weights above pattern.weight are checked in ascending order followed by weights below pattern.weight in descending order until a match is found. If pattern.weight is 400, 500 is checked first and then the rule for pattern.weight < 400 is used. If pattern.weight is 500, 400 is checked first and then the rule for pattern.weight < 400 is used.
184 {
186 if (0 == count) {
187 return nullptr;
188 }
189
190 struct Score {
191 int score;
192 int index;
193 Score&
operator +=(
int rhs) { this->score += rhs;
return *
this; }
194 Score&
operator <<=(
int rhs) { this->score <<= rhs;
return *
this; }
195 bool operator <(
const Score& that) {
return this->score < that.score; }
196 };
197
198 Score maxScore = { 0, 0 };
202 Score currentScore = { 0,
i };
203
204
205
208 currentScore += 10 - pattern.
width() + current.
width();
209 } else {
210 currentScore += 10 - current.
width();
211 }
212 } else {
214 currentScore += 10 + pattern.
width() - current.
width();
215 } else {
216 currentScore += current.
width();
217 }
218 }
219 currentScore <<= 8;
220
221
222
226 "SkFontStyle::Slant values not as required.");
228 0 <= current.
slant() && current.
slant() <= 2);
229 static const int score[3][3] = {
230
231 { 3 , 1 , 2 },
232 { 1 , 3 , 2 },
233 { 1 , 2 , 3 },
234
235 };
236 currentScore += score[pattern.
slant()][current.
slant()];
237 currentScore <<= 8;
238
239
240
241
242
243
245 currentScore += 1000;
246
247 }
else if (pattern.
weight() < 400) {
249 currentScore += 1000 - pattern.
weight() + current.
weight();
250 } else {
251 currentScore += 1000 - current.
weight();
252 }
253
254 }
else if (pattern.
weight() <= 500) {
256 currentScore += 1000 + pattern.
weight() - current.
weight();
258 currentScore += 500 + current.
weight();
259 } else {
260 currentScore += 1000 - current.
weight();
261 }
262
263 }
else if (pattern.
weight() > 500) {
265 currentScore += 1000 + pattern.
weight() - current.
weight();
266 } else {
267 currentScore += current.
weight();
268 }
269 }
270
271 if (maxScore < currentScore) {
272 maxScore = currentScore;
273 }
274 }
275
277}
virtual sk_sp< SkTypeface > createTypeface(int index)=0
virtual void getStyle(int index, SkFontStyle *, SkString *style)=0
constexpr bool operator<(const EnumType &lhs, const Mask< EnumType > &rhs)
SINT Vec< N, T > & operator+=(Vec< N, T > &x, const Vec< N, T > &y)
SINT Vec< N, T > & operator<<=(Vec< N, T > &x, int bits)