From da1ba2a143993c44be2561ce412d98e4ab12c6e1 Mon Sep 17 00:00:00 2001 From: Joshua Granick Date: Thu, 23 Oct 2014 13:19:32 -0700 Subject: [PATCH] Fix initial support for cubic bezier font outlines, need to come back and add support for multiple quadratic curves for better quality --- project/src/graphics/Font.cpp | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/project/src/graphics/Font.cpp b/project/src/graphics/Font.cpp index a8030a422..c8cf197c0 100644 --- a/project/src/graphics/Font.cpp +++ b/project/src/graphics/Font.cpp @@ -203,10 +203,24 @@ namespace { return 0; } + + int outline_cubic_to(FVecPtr ctl1, FVecPtr ctl2, FVecPtr to, void *user) { + + // Cubic curves are not supported, we need to approximate to a quadratic + // TODO: divide into multiple curves + + glyph *g = static_cast(user); - int outline_cubic_to(FVecPtr, FVecPtr , FVecPtr , void *user) { - // Cubic curves are not supported - return 1; + 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) { - 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; result = FT_Outline_Decompose (&face->glyph->outline, &ofn, g);