hack fix outlines
This commit is contained in:
parent
6f8b6633be
commit
4af4adb3e2
1 changed files with 55 additions and 27 deletions
|
@ -921,6 +921,9 @@ class Font {
|
||||||
std::vector <float> directions(n_contours, 0);
|
std::vector <float> directions(n_contours, 0);
|
||||||
std::vector <std::vector <BufferCurve> > curves(n_contours);
|
std::vector <std::vector <BufferCurve> > curves(n_contours);
|
||||||
std::vector <BBox> bbs(n_contours);
|
std::vector <BBox> bbs(n_contours);
|
||||||
|
int largestIndex = 0;
|
||||||
|
float largestArea = 0;
|
||||||
|
bool flipAll = false;
|
||||||
for(int i = 0; i < n_contours; i++){
|
for(int i = 0; i < n_contours; i++){
|
||||||
// Note: The end indices in face->glyph->outline.contours are inclusive.
|
// Note: The end indices in face->glyph->outline.contours are inclusive.
|
||||||
bbs[i].xMin = FLT_MAX;
|
bbs[i].xMin = FLT_MAX;
|
||||||
|
@ -929,7 +932,31 @@ class Font {
|
||||||
bbs[i].yMax = -FLT_MAX;
|
bbs[i].yMax = -FLT_MAX;
|
||||||
convertContour(curves[i], directions[i], bbs[i], &face->glyph->outline, start, face->glyph->outline.contours[i], emSize);
|
convertContour(curves[i], directions[i], bbs[i], &face->glyph->outline, start, face->glyph->outline.contours[i], emSize);
|
||||||
start = face->glyph->outline.contours[i] + 1;
|
start = face->glyph->outline.contours[i] + 1;
|
||||||
|
float area = abs(bbs[i].xMax - bbs[i].xMin) * abs(bbs[i].yMax - bbs[i].yMin);
|
||||||
|
if(area > largestArea){
|
||||||
|
largestArea = area;
|
||||||
|
largestIndex = i;
|
||||||
|
if(directions[i] < 0){
|
||||||
|
flipAll = true;
|
||||||
|
}else{
|
||||||
|
flipAll = false;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(flipAll){
|
||||||
|
for(int i = 0; i < n_contours; i++){
|
||||||
|
for(BufferCurve & curve : curves[i]){
|
||||||
|
float tmp_x = curve.x0;
|
||||||
|
float tmp_y = curve.y0;
|
||||||
|
curve.x0 = curve.x2;
|
||||||
|
curve.y0 = curve.y2;
|
||||||
|
curve.x2 = tmp_x;
|
||||||
|
curve.y2 = tmp_y;
|
||||||
|
}
|
||||||
|
std::reverse(curves[i].begin(), curves[i].end());
|
||||||
|
bufferCurves.insert(bufferCurves.end(), curves[i].begin(), curves[i].end());
|
||||||
|
}
|
||||||
|
}else{
|
||||||
for(int i = 0; i < n_contours; i++){
|
for(int i = 0; i < n_contours; i++){
|
||||||
if(directions[i] < 0){
|
if(directions[i] < 0){
|
||||||
bool flip = true;
|
bool flip = true;
|
||||||
|
@ -959,6 +986,7 @@ class Font {
|
||||||
}
|
}
|
||||||
bufferCurves.insert(bufferCurves.end(), curves[i].begin(), curves[i].end());
|
bufferCurves.insert(bufferCurves.end(), curves[i].begin(), curves[i].end());
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}else{
|
}else{
|
||||||
short start = 0;
|
short start = 0;
|
||||||
for(int i = 0; i < face->glyph->outline.n_contours; i++){
|
for(int i = 0; i < face->glyph->outline.n_contours; i++){
|
||||||
|
|
Loading…
Reference in a new issue