180 {
182
184 public:
186 protected:
187 std::unique_ptr<SkStreamAsset>
onOpenStream(
int* ttcIndex)
const override {
return nullptr; }
190 }
193 {
196 }
199 return nullptr;
200 }
204 }
208 int onGetUPEM()
const override {
return 0; }
210 public:
212 };
215 }
218 return new EmptyLocalizedStrings;
219 }
223 int coordinateCount) const override
224 {
225 return 0;
226 }
228 int parameterCount) const override
229 {
230 return -1;
231 }
234 return 0;
235 }
236 };
237
239 public:
240 TestFontStyleSet(std::initializer_list<SkFontStyle> styles) : fStyles(styles) {}
241 int count()
override {
return static_cast<int>(fStyles.size()); }
243 if (style) {
244 *style = fStyles[index];
245 }
246 }
248 if (index < 0 || this->
count() <= index) {
250 }
252 }
255 }
256 private:
257 std::vector<SkFontStyle> fStyles;
258 };
259
272
279
280 struct StyleSetTest {
281 TestFontStyleSet styleSet;
282 struct Case {
285 };
286 std::vector<Case> cases;
288 {
289 { normal_normal_500, normal_normal_400 },
290 {
291 { normal_normal_400, normal_normal_400 },
292 { normal_normal_500, normal_normal_500 },
293 },
294 },
295
296 {
297 { normal_normal_500, normal_normal_300 },
298 {
299 { normal_normal_300, normal_normal_300 },
300 { normal_normal_400, normal_normal_500 },
301 { normal_normal_500, normal_normal_500 },
302 },
303 },
304
305 {
306 { condensed_normal_100,condensed_normal_900,condensed_italic_100,condensed_italic_900,
307 expanded_normal_100, expanded_normal_900, expanded_italic_100, expanded_italic_900 },
308 {
309 { condensed_normal_100, condensed_normal_100 },
310 { condensed_normal_900, condensed_normal_900 },
311 { condensed_italic_100, condensed_italic_100 },
312 { condensed_italic_900, condensed_italic_900 },
313 { expanded_normal_100, expanded_normal_100 },
314 { expanded_normal_900, expanded_normal_900 },
315 { expanded_italic_100, expanded_italic_100 },
316 { expanded_italic_900, expanded_italic_900 },
317 },
318 },
319
320 {
321 { condensed_normal_100,condensed_italic_100,expanded_normal_100,expanded_italic_100 },
322 {
323 { condensed_normal_100, condensed_normal_100 },
324 { condensed_normal_900, condensed_normal_100 },
325 { condensed_italic_100, condensed_italic_100 },
326 { condensed_italic_900, condensed_italic_100 },
327 { expanded_normal_100, expanded_normal_100 },
328 { expanded_normal_900, expanded_normal_100 },
329 { expanded_italic_100, expanded_italic_100 },
330 { expanded_italic_900, expanded_italic_100 },
331 },
332 },
333
334 {
335 { condensed_normal_900,condensed_italic_900,expanded_normal_900,expanded_italic_900 },
336 {
337 { condensed_normal_100, condensed_normal_900 },
338 { condensed_normal_900, condensed_normal_900 },
339 { condensed_italic_100, condensed_italic_900 },
340 { condensed_italic_900, condensed_italic_900 },
341 { expanded_normal_100, expanded_normal_900 },
342 { expanded_normal_900, expanded_normal_900 },
343 { expanded_italic_100, expanded_italic_900 },
344 { expanded_italic_900, expanded_italic_900 },
345 },
346 },
347
348 {
349 { condensed_normal_100,condensed_normal_900,expanded_normal_100,expanded_normal_900 },
350 {
351 { condensed_normal_100, condensed_normal_100 },
352 { condensed_normal_900, condensed_normal_900 },
353 { condensed_italic_100, condensed_normal_100 },
354 { condensed_italic_900, condensed_normal_900 },
355 { expanded_normal_100, expanded_normal_100 },
356 { expanded_normal_900, expanded_normal_900 },
357 { expanded_italic_100, expanded_normal_100 },
358 { expanded_italic_900, expanded_normal_900 },
359 },
360 },
361
362 {
363 { condensed_normal_100,expanded_normal_100 },
364 {
365 { condensed_normal_100, condensed_normal_100 },
366 { condensed_normal_900, condensed_normal_100 },
367 { condensed_italic_100, condensed_normal_100 },
368 { condensed_italic_900, condensed_normal_100 },
369 { expanded_normal_100, expanded_normal_100 },
370 { expanded_normal_900, expanded_normal_100 },
371 { expanded_italic_100, expanded_normal_100 },
372 { expanded_italic_900, expanded_normal_100 },
373 },
374 },
375
376 {
377 { condensed_normal_900,expanded_normal_900 },
378 {
379 { condensed_normal_100, condensed_normal_900 },
380 { condensed_normal_900, condensed_normal_900 },
381 { condensed_italic_100, condensed_normal_900 },
382 { condensed_italic_900, condensed_normal_900 },
383 { expanded_normal_100, expanded_normal_900 },
384 { expanded_normal_900, expanded_normal_900 },
385 { expanded_italic_100, expanded_normal_900 },
386 { expanded_italic_900, expanded_normal_900 },
387 },
388 },
389
390 {
391 { condensed_italic_100,condensed_italic_900,expanded_italic_100,expanded_italic_900 },
392 {
393 { condensed_normal_100, condensed_italic_100 },
394 { condensed_normal_900, condensed_italic_900 },
395 { condensed_italic_100, condensed_italic_100 },
396 { condensed_italic_900, condensed_italic_900 },
397 { expanded_normal_100, expanded_italic_100 },
398 { expanded_normal_900, expanded_italic_900 },
399 { expanded_italic_100, expanded_italic_100 },
400 { expanded_italic_900, expanded_italic_900 },
401 },
402 },
403
404 {
405 { condensed_italic_100,expanded_italic_100 },
406 {
407 { condensed_normal_100, condensed_italic_100 },
408 { condensed_normal_900, condensed_italic_100 },
409 { condensed_italic_100, condensed_italic_100 },
410 { condensed_italic_900, condensed_italic_100 },
411 { expanded_normal_100, expanded_italic_100 },
412 { expanded_normal_900, expanded_italic_100 },
413 { expanded_italic_100, expanded_italic_100 },
414 { expanded_italic_900, expanded_italic_100 },
415 },
416 },
417
418 {
419 { condensed_italic_900,expanded_italic_900 },
420 {
421 { condensed_normal_100, condensed_italic_900 },
422 { condensed_normal_900, condensed_italic_900 },
423 { condensed_italic_100, condensed_italic_900 },
424 { condensed_italic_900, condensed_italic_900 },
425 { expanded_normal_100, expanded_italic_900 },
426 { expanded_normal_900, expanded_italic_900 },
427 { expanded_italic_100, expanded_italic_900 },
428 { expanded_italic_900, expanded_italic_900 },
429 },
430 },
431
432 {
433 { condensed_normal_100,condensed_normal_900,condensed_italic_100,condensed_italic_900 },
434 {
435 { condensed_normal_100, condensed_normal_100 },
436 { condensed_normal_900, condensed_normal_900 },
437 { condensed_italic_100, condensed_italic_100 },
438 { condensed_italic_900, condensed_italic_900 },
439 { expanded_normal_100, condensed_normal_100 },
440 { expanded_normal_900, condensed_normal_900 },
441 { expanded_italic_100, condensed_italic_100 },
442 { expanded_italic_900, condensed_italic_900 },
443 },
444 },
445
446 {
447 { condensed_normal_100,condensed_italic_100 },
448 {
449 { condensed_normal_100, condensed_normal_100 },
450 { condensed_normal_900, condensed_normal_100 },
451 { condensed_italic_100, condensed_italic_100 },
452 { condensed_italic_900, condensed_italic_100 },
453 { expanded_normal_100, condensed_normal_100 },
454 { expanded_normal_900, condensed_normal_100 },
455 { expanded_italic_100, condensed_italic_100 },
456 { expanded_italic_900, condensed_italic_100 },
457 },
458 },
459
460 {
461 { condensed_normal_900,condensed_italic_900 },
462 {
463 { condensed_normal_100, condensed_normal_900 },
464 { condensed_normal_900, condensed_normal_900 },
465 { condensed_italic_100, condensed_italic_900 },
466 { condensed_italic_900, condensed_italic_900 },
467 { expanded_normal_100, condensed_normal_900 },
468 { expanded_normal_900, condensed_normal_900 },
469 { expanded_italic_100, condensed_italic_900 },
470 { expanded_italic_900, condensed_italic_900 },
471 },
472 },
473
474 {
475 { condensed_normal_100,condensed_normal_900 },
476 {
477 { condensed_normal_100, condensed_normal_100 },
478 { condensed_normal_900, condensed_normal_900 },
479 { condensed_italic_100, condensed_normal_100 },
480 { condensed_italic_900, condensed_normal_900 },
481 { expanded_normal_100, condensed_normal_100 },
482 { expanded_normal_900, condensed_normal_900 },
483 { expanded_italic_100, condensed_normal_100 },
484 { expanded_italic_900, condensed_normal_900 },
485 },
486 },
487
488 {
489 { condensed_normal_100 },
490 {
491 { condensed_normal_100, condensed_normal_100 },
492 { condensed_normal_900, condensed_normal_100 },
493 { condensed_italic_100, condensed_normal_100 },
494 { condensed_italic_900, condensed_normal_100 },
495 { expanded_normal_100, condensed_normal_100 },
496 { expanded_normal_900, condensed_normal_100 },
497 { expanded_italic_100, condensed_normal_100 },
498 { expanded_italic_900, condensed_normal_100 },
499 },
500 },
501
502 {
503 { condensed_normal_900 },
504 {
505 { condensed_normal_100, condensed_normal_900 },
506 { condensed_normal_900, condensed_normal_900 },
507 { condensed_italic_100, condensed_normal_900 },
508 { condensed_italic_900, condensed_normal_900 },
509 { expanded_normal_100, condensed_normal_900 },
510 { expanded_normal_900, condensed_normal_900 },
511 { expanded_italic_100, condensed_normal_900 },
512 { expanded_italic_900, condensed_normal_900 },
513 },
514 },
515
516 {
517 { condensed_italic_100,condensed_italic_900 },
518 {
519 { condensed_normal_100, condensed_italic_100 },
520 { condensed_normal_900, condensed_italic_900 },
521 { condensed_italic_100, condensed_italic_100 },
522 { condensed_italic_900, condensed_italic_900 },
523 { expanded_normal_100, condensed_italic_100 },
524 { expanded_normal_900, condensed_italic_900 },
525 { expanded_italic_100, condensed_italic_100 },
526 { expanded_italic_900, condensed_italic_900 },
527 },
528 },
529
530 {
531 { condensed_italic_100 },
532 {
533 { condensed_normal_100, condensed_italic_100 },
534 { condensed_normal_900, condensed_italic_100 },
535 { condensed_italic_100, condensed_italic_100 },
536 { condensed_italic_900, condensed_italic_100 },
537 { expanded_normal_100, condensed_italic_100 },
538 { expanded_normal_900, condensed_italic_100 },
539 { expanded_italic_100, condensed_italic_100 },
540 { expanded_italic_900, condensed_italic_100 },
541 },
542 },
543
544 {
545 { condensed_italic_900 },
546 {
547 { condensed_normal_100, condensed_italic_900 },
548 { condensed_normal_900, condensed_italic_900 },
549 { condensed_italic_100, condensed_italic_900 },
550 { condensed_italic_900, condensed_italic_900 },
551 { expanded_normal_100, condensed_italic_900 },
552 { expanded_normal_900, condensed_italic_900 },
553 { expanded_italic_100, condensed_italic_900 },
554 { expanded_italic_900, condensed_italic_900 },
555 },
556 },
557
558 {
559 { expanded_normal_100,expanded_normal_900,
560 expanded_italic_100,expanded_italic_900 },
561 {
562 { condensed_normal_100, expanded_normal_100 },
563 { condensed_normal_900, expanded_normal_900 },
564 { condensed_italic_100, expanded_italic_100 },
565 { condensed_italic_900, expanded_italic_900 },
566 { condensed_obliqu_100, expanded_italic_100 },
567 { condensed_obliqu_900, expanded_italic_900 },
568 { expanded_normal_100, expanded_normal_100 },
569 { expanded_normal_900, expanded_normal_900 },
570 { expanded_italic_100, expanded_italic_100 },
571 { expanded_italic_900, expanded_italic_900 },
572 { expanded_obliqu_100, expanded_italic_100 },
573 { expanded_obliqu_900, expanded_italic_900 },
574 },
575 },
576
577 {
578 { expanded_normal_100,expanded_italic_100 },
579 {
580 { condensed_normal_100, expanded_normal_100 },
581 { condensed_normal_900, expanded_normal_100 },
582 { condensed_italic_100, expanded_italic_100 },
583 { condensed_italic_900, expanded_italic_100 },
584 { expanded_normal_100, expanded_normal_100 },
585 { expanded_normal_900, expanded_normal_100 },
586 { expanded_italic_100, expanded_italic_100 },
587 { expanded_italic_900, expanded_italic_100 },
588 },
589 },
590
591 {
592 { expanded_normal_900,expanded_italic_900 },
593 {
594 { condensed_normal_100, expanded_normal_900 },
595 { condensed_normal_900, expanded_normal_900 },
596 { condensed_italic_100, expanded_italic_900 },
597 { condensed_italic_900, expanded_italic_900 },
598 { expanded_normal_100, expanded_normal_900 },
599 { expanded_normal_900, expanded_normal_900 },
600 { expanded_italic_100, expanded_italic_900 },
601 { expanded_italic_900, expanded_italic_900 },
602 },
603 },
604
605 {
606 { expanded_normal_100,expanded_normal_900 },
607 {
608 { condensed_normal_100, expanded_normal_100 },
609 { condensed_normal_900, expanded_normal_900 },
610 { condensed_italic_100, expanded_normal_100 },
611 { condensed_italic_900, expanded_normal_900 },
612 { expanded_normal_100, expanded_normal_100 },
613 { expanded_normal_900, expanded_normal_900 },
614 { expanded_italic_100, expanded_normal_100 },
615 { expanded_italic_900, expanded_normal_900 },
616 },
617 },
618
619 {
620 { expanded_normal_100 },
621 {
622 { condensed_normal_100, expanded_normal_100 },
623 { condensed_normal_900, expanded_normal_100 },
624 { condensed_italic_100, expanded_normal_100 },
625 { condensed_italic_900, expanded_normal_100 },
626 { expanded_normal_100, expanded_normal_100 },
627 { expanded_normal_900, expanded_normal_100 },
628 { expanded_italic_100, expanded_normal_100 },
629 { expanded_italic_900, expanded_normal_100 },
630 },
631 },
632
633 {
634 { expanded_normal_900 },
635 {
636 { condensed_normal_100, expanded_normal_900 },
637 { condensed_normal_900, expanded_normal_900 },
638 { condensed_italic_100, expanded_normal_900 },
639 { condensed_italic_900, expanded_normal_900 },
640 { expanded_normal_100, expanded_normal_900 },
641 { expanded_normal_900, expanded_normal_900 },
642 { expanded_italic_100, expanded_normal_900 },
643 { expanded_italic_900, expanded_normal_900 },
644 },
645 },
646
647 {
648 { expanded_italic_100,expanded_italic_900 },
649 {
650 { condensed_normal_100, expanded_italic_100 },
651 { condensed_normal_900, expanded_italic_900 },
652 { condensed_italic_100, expanded_italic_100 },
653 { condensed_italic_900, expanded_italic_900 },
654 { expanded_normal_100, expanded_italic_100 },
655 { expanded_normal_900, expanded_italic_900 },
656 { expanded_italic_100, expanded_italic_100 },
657 { expanded_italic_900, expanded_italic_900 },
658 },
659 },
660
661 {
662 { expanded_italic_100 },
663 {
664 { condensed_normal_100, expanded_italic_100 },
665 { condensed_normal_900, expanded_italic_100 },
666 { condensed_italic_100, expanded_italic_100 },
667 { condensed_italic_900, expanded_italic_100 },
668 { expanded_normal_100, expanded_italic_100 },
669 { expanded_normal_900, expanded_italic_100 },
670 { expanded_italic_100, expanded_italic_100 },
671 { expanded_italic_900, expanded_italic_100 },
672 },
673 },
674
675 {
676 { expanded_italic_900 },
677 {
678 { condensed_normal_100, expanded_italic_900 },
679 { condensed_normal_900, expanded_italic_900 },
680 { condensed_italic_100, expanded_italic_900 },
681 { condensed_italic_900, expanded_italic_900 },
682 { expanded_normal_100, expanded_italic_900 },
683 { expanded_normal_900, expanded_italic_900 },
684 { expanded_italic_100, expanded_italic_900 },
685 { expanded_italic_900, expanded_italic_900 },
686 },
687 },
688
689 {
690 { normal_normal_100, normal_normal_900 },
691 {
692 { normal_normal_300, normal_normal_100 },
693 { normal_normal_400, normal_normal_100 },
694 { normal_normal_500, normal_normal_100 },
695 { normal_normal_600, normal_normal_900 },
696 },
697 },
698
699 {
700 { normal_normal_100, normal_normal_400, normal_normal_900 },
701 {
702 { normal_normal_300, normal_normal_100 },
703 { normal_normal_400, normal_normal_400 },
704 { normal_normal_500, normal_normal_400 },
705 { normal_normal_600, normal_normal_900 },
706 },
707 },
708
709 {
710 { normal_normal_100, normal_normal_500, normal_normal_900 },
711 {
712 { normal_normal_300, normal_normal_100 },
713 { normal_normal_400, normal_normal_500 },
714 { normal_normal_500, normal_normal_500 },
715 { normal_normal_600, normal_normal_900 },
716 },
717 },
718
719 {
720 { },
721 {
722 { normal_normal_300, invalidFontStyle },
723 { normal_normal_400, invalidFontStyle },
724 { normal_normal_500, invalidFontStyle },
725 { normal_normal_600, invalidFontStyle },
726 },
727 },
728 {
729 { expanded_normal_100,expanded_normal_900,
730 expanded_italic_100,expanded_italic_900,
731 expanded_obliqu_100,expanded_obliqu_900, },
732 {
733 { condensed_normal_100, expanded_normal_100 },
734 { condensed_normal_900, expanded_normal_900 },
735 { condensed_italic_100, expanded_italic_100 },
736 { condensed_italic_900, expanded_italic_900 },
737 { condensed_obliqu_100, expanded_obliqu_100 },
738 { condensed_obliqu_900, expanded_obliqu_900 },
739 { expanded_normal_100, expanded_normal_100 },
740 { expanded_normal_900, expanded_normal_900 },
741 { expanded_italic_100, expanded_italic_100 },
742 { expanded_italic_900, expanded_italic_900 },
743 { expanded_obliqu_100, expanded_obliqu_100 },
744 { expanded_obliqu_900, expanded_obliqu_900 },
745 },
746 },
747 {
748 { expanded_normal_100,expanded_normal_900,
749 expanded_obliqu_100,expanded_obliqu_900, },
750 {
751 { condensed_normal_100, expanded_normal_100 },
752 { condensed_normal_900, expanded_normal_900 },
753 { condensed_italic_100, expanded_obliqu_100 },
754 { condensed_italic_900, expanded_obliqu_900 },
755 { condensed_obliqu_100, expanded_obliqu_100 },
756 { condensed_obliqu_900, expanded_obliqu_900 },
757 { expanded_normal_100, expanded_normal_100 },
758 { expanded_normal_900, expanded_normal_900 },
759 { expanded_italic_100, expanded_obliqu_100 },
760 { expanded_italic_900, expanded_obliqu_900 },
761 { expanded_obliqu_100, expanded_obliqu_100 },
762 { expanded_obliqu_900, expanded_obliqu_900 },
763 },
764 },
765 {
766 { expanded_italic_100,expanded_italic_900,
767 expanded_obliqu_100,expanded_obliqu_900, },
768 {
769 { condensed_normal_100, expanded_obliqu_100 },
770 { condensed_normal_900, expanded_obliqu_900 },
771 { condensed_italic_100, expanded_italic_100 },
772 { condensed_italic_900, expanded_italic_900 },
773 { condensed_obliqu_100, expanded_obliqu_100 },
774 { condensed_obliqu_900, expanded_obliqu_900 },
775 { expanded_normal_100, expanded_obliqu_100 },
776 { expanded_normal_900, expanded_obliqu_900 },
777 { expanded_italic_100, expanded_italic_100 },
778 { expanded_italic_900, expanded_italic_900 },
779 { expanded_obliqu_100, expanded_obliqu_100 },
780 { expanded_obliqu_900, expanded_obliqu_900 },
781 },
782 },
783 };
784
786 for (
const StyleSetTest::Case& testCase :
test.cases) {
788 if (typeface) {
790 } else {
792 }
793 }
794 }
795}
sk_bzero(glyphs, sizeof(glyphs))
static float next(float f)
sk_sp< T > sk_ref_sp(T *obj)
sk_sp< SkTypeface > matchStyleCSS3(const SkFontStyle &pattern)
virtual sk_sp< SkTypeface > createTypeface(int index)=0
virtual sk_sp< SkTypeface > matchStyle(const SkFontStyle &pattern)=0
virtual void getStyle(int index, SkFontStyle *, SkString *style)=0
static std::unique_ptr< SkScalerContext > MakeEmpty(sk_sp< SkTypeface > typeface, const SkScalerContextEffects &effects, const SkDescriptor *desc)
SkFontStyle fontStyle() const
void getGlyphToUnicodeMap(SkUnichar *glyphToUnicode) const override
bool onGlyphMaskNeedsCurrentColor() const override
void onCharsToGlyphs(const SkUnichar *chars, int count, SkGlyphID glyphs[]) const override
int onGetVariationDesignPosition(SkFontArguments::VariationPosition::Coordinate coordinates[], int coordinateCount) const override
SkTypeface::LocalizedStrings * onCreateFamilyNameIterator() const override
int onGetUPEM() const override
void getPostScriptGlyphNames(SkString *) const override
bool onGetPostScriptName(SkString *) const override
std::unique_ptr< SkAdvancedTypefaceMetrics > onGetAdvancedMetrics() const override
void onGetFamilyName(SkString *familyName) const override
int onGetVariationDesignParameters(SkFontParameters::Variation::Axis parameters[], int parameterCount) const override
int onGetTableTags(SkFontTableTag tags[]) const override
std::unique_ptr< SkStreamAsset > onOpenStream(int *ttcIndex) const override
size_t onGetTableData(SkFontTableTag tag, size_t offset, size_t length, void *data) const override
std::unique_ptr< SkScalerContext > onCreateScalerContext(const SkScalerContextEffects &, const SkDescriptor *desc) const override
void onFilterRec(SkScalerContextRec *rec) const override
sk_sp< SkTypeface > onMakeClone(const SkFontArguments &args) const override
int onCountGlyphs() const override
void onGetFontDescriptor(SkFontDescriptor *desc, bool *serialize) const override
G_BEGIN_DECLS G_MODULE_EXPORT FlValue * args