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