Fix initial support for cubic bezier font outlines, need to come back and add support for multiple quadratic curves for better quality

This commit is contained in:
Joshua Granick
2014-10-23 13:19:32 -07:00
parent a2533f111b
commit da1ba2a143

View File

@@ -204,9 +204,23 @@ namespace {
return 0; return 0;
} }
int outline_cubic_to(FVecPtr, FVecPtr , FVecPtr , void *user) { int outline_cubic_to(FVecPtr ctl1, FVecPtr ctl2, FVecPtr to, void *user) {
// Cubic curves are not supported
return 1; // Cubic curves are not supported, we need to approximate to a quadratic
// TODO: divide into multiple curves
glyph *g = static_cast<glyph*>(user);
g->pts.push_back(PT_CURVE);
g->pts.push_back((ctl1->x + ctl2->x) / 2 - g->x);
g->pts.push_back((ctl1->y + ctl2->y) / 2 - g->y);
g->pts.push_back(to->x - (ctl1->x + ctl2->x) / 2);
g->pts.push_back(to->y - (ctl1->y + ctl2->y) / 2);
g->x = to->x;
g->y = to->y;
return 0;
} }
@@ -368,7 +382,7 @@ namespace lime {
while (glyph_index != 0) { while (glyph_index != 0) {
if (FT_Load_Glyph (face, glyph_index, FT_LOAD_FORCE_AUTOHINT | FT_LOAD_DEFAULT) == 0) { if (FT_Load_Glyph (face, glyph_index, FT_LOAD_NO_BITMAP | FT_LOAD_FORCE_AUTOHINT | FT_LOAD_DEFAULT) == 0) {
glyph *g = new glyph; glyph *g = new glyph;
result = FT_Outline_Decompose (&face->glyph->outline, &ofn, g); result = FT_Outline_Decompose (&face->glyph->outline, &ofn, g);