Revert "more robust outline flipping"

This reverts commit 1890926805.
This commit is contained in:
jrkb 2023-09-19 15:52:18 +02:00
parent ef4cdafb8d
commit 6f8b6633be

View file

@ -712,7 +712,6 @@ class Font {
if(charcode == '\r' || charcode == '\n'){ if(charcode == '\r' || charcode == '\n'){
continue; continue;
} }
// if does exist already
if(glyphs.count(glyphIdentity) != 0){ if(glyphs.count(glyphIdentity) != 0){
continue; continue;
} }
@ -931,10 +930,9 @@ class Font {
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;
} }
// outmost outline must be clock-wise
// then flip direction the deeper we go inside
for(int i = 0; i < n_contours; i++){ for(int i = 0; i < n_contours; i++){
int insideAnother = 0; if(directions[i] < 0){
bool flip = true;
for(int j = 0; j < n_contours; j++){ for(int j = 0; j < n_contours; j++){
if(i != j){ if(i != j){
bool inside = bbs[j].xMin <= bbs[i].xMin bool inside = bbs[j].xMin <= bbs[i].xMin
@ -942,15 +940,11 @@ class Font {
&& bbs[j].yMin <= bbs[i].yMin && bbs[j].yMin <= bbs[i].yMin
&& bbs[j].yMax >= bbs[i].yMax; && bbs[j].yMax >= bbs[i].yMax;
if(inside){ if(inside){
insideAnother++; flip = false;
break;
} }
} }
} }
bool flip = false;
if((insideAnother % 2 == 0 && directions[i] < 0)
|| (insideAnother % 2 == 1 && directions[i] > 0)){
flip = true;
}
if(flip){ if(flip){
for(BufferCurve & curve : curves[i]){ for(BufferCurve & curve : curves[i]){
float tmp_x = curve.x0; float tmp_x = curve.x0;
@ -962,7 +956,7 @@ class Font {
} }
std::reverse(curves[i].begin(), curves[i].end()); std::reverse(curves[i].begin(), curves[i].end());
} }
//} }
bufferCurves.insert(bufferCurves.end(), curves[i].begin(), curves[i].end()); bufferCurves.insert(bufferCurves.end(), curves[i].begin(), curves[i].end());
} }
}else{ }else{