643{
644 QPointF cp = QPointF();
645
646
647 QPainterPath glyph;
648 glyph.setFillRule(Qt::WindingFill);
649 int i = 0;
650 for (int j = 0; j < glyphSlot->outline.n_contours; ++j) {
651 int last_point = glyphSlot->outline.contours[j];
652
653 QPointF start = QPointF(glyphSlot->outline.points[i].x, glyphSlot->outline.points[i].y);
654 if (!(glyphSlot->outline.tags[i] & 1)) {
655 if (!(glyphSlot->outline.tags[last_point] & 1)) {
656
657 start = (QPointF(glyphSlot->outline.points[last_point].x, glyphSlot->outline.points[last_point].y) + start) / 2.0;
658 } else {
659
660 start = QPointF(glyphSlot->outline.points[last_point].x, glyphSlot->outline.points[last_point].y);
661 }
662 --i;
663 }
664 start += cp;
665
666 glyph.moveTo(start);
667 std::array<QPointF, 4> curve;
668 curve[0] = start;
669 size_t n = 1;
670 while (i < last_point) {
671 ++i;
672 curve.at(n) = cp + QPointF(glyphSlot->outline.points[i].x, glyphSlot->outline.points[i].y);
673
674
675
676
677 ++n;
678 switch (glyphSlot->outline.tags[i] & 3) {
679 case 2:
680
681 if (n < 4)
682 continue;
683 curve[3] = (curve[3] + curve[2]) / 2;
684 --i;
685 break;
686 case 0:
687
688 if (n < 3)
689 continue;
690 curve[3] = (curve[1] + curve[2]) / 2;
691 curve[2] = (2 * curve[1] + curve[3]) / 3;
692 curve[1] = (2 * curve[1] + curve[0]) / 3;
693 --i;
694 break;
695 case 1:
696 case 3:
697 if (n == 2) {
698
699 glyph.lineTo(curve[1]);
700 curve[0] = curve[1];
701 n = 1;
702 continue;
703 } else if (n == 3) {
704 curve[3] = curve[2];
705 curve[2] = (2 * curve[1] + curve[3]) / 3;
706 curve[1] = (2 * curve[1] + curve[0]) / 3;
707 }
708 break;
709 }
710
711 glyph.cubicTo(curve[1], curve[2], curve[3]);
712 curve[0] = curve[3];
713 n = 1;
714 }
715 if (n == 1) {
716
717 glyph.closeSubpath();
718 } else {
719 curve[3] = start;
720 if (n == 2) {
721 curve[2] = (2 * curve[1] + curve[3]) / 3;
722 curve[1] = (2 * curve[1] + curve[0]) / 3;
723 }
724
725 glyph.cubicTo(curve[1], curve[2], curve[3]);
726 }
727 ++i;
728 }
729 return glyph;
730}