This commit is contained in:
win 2016-07-10 12:22:11 +00:00 committed by GitHub
commit 78d1c812ad
1 changed files with 28 additions and 6 deletions

View File

@ -116,11 +116,13 @@ bool loadGlyph(Shape &output, FontHandle *font, int unicode, double *advance) {
Point2 controlPoint[2];
// For each point on the contour
bool closeContour = false;
for (int round = 0, index = first; round == 0; ++index) {
// Close contour
if (index > last) {
index = first;
round++;
closeContour = true;
}
Point2 point(font->face->glyph->outline.points[index].x/64., font->face->glyph->outline.points[index].y/64.);
@ -128,17 +130,37 @@ bool loadGlyph(Shape &output, FontHandle *font, int unicode, double *advance) {
switch (state) {
case NONE:
REQUIRE(pointType == PATH_POINT);
startPoint = point;
state = PATH_POINT;
break;
if (pointType == PATH_POINT) {
startPoint = point;
state = PATH_POINT;
}
else if (pointType == QUADRATIC_POINT)
{
//eg. Windows Tahoma unicode 197
startPoint = point;
controlPoint[0] = point;
state = QUADRATIC_POINT;
}
else {
//err?
return false;
}
break;
case PATH_POINT:
if (pointType == PATH_POINT) {
contour.addEdge(new LinearSegment(startPoint, point));
startPoint = point;
} else {
controlPoint[0] = point;
state = pointType;
if (closeContour) {
//close contour mode
contour.addEdge(new LinearSegment(startPoint, point));
startPoint = point;
closeContour = false;
}
else {
controlPoint[0] = point;
state = pointType;
}
}
break;
case QUADRATIC_POINT: