Skip to content

Commit cadd0bc

Browse files
committed
Fix for font outlines. See below:
* Outlines were hinted, causing deformations to the actual clean outline. Outlines are now unhinted. * Quadratic curves were converted to cubic curves. This unnecessarily increases complexity of the outlines and introduces extra vertices. If triangulated, these extra vertices cause extra triangles, etc. There is no need to convert quadratic curves, as they are natively supported by the Path2d class.
1 parent 9348e13 commit cadd0bc

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

src/cinder/Font.cpp

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -653,7 +653,7 @@ Shape2d Font::getGlyphShape( Glyph glyphIndex ) const
653653
static const MAT2 matrix = { { 0, 1 }, { 0, 0 }, { 0, 0 }, { 0, -1 } };
654654
GLYPHMETRICS metrics;
655655
DWORD bytesGlyph = ::GetGlyphOutlineW( FontManager::instance()->getFontDc(), glyphIndex,
656-
GGO_NATIVE | GGO_GLYPH_INDEX, &metrics, 0, NULL, &matrix);
656+
GGO_NATIVE | GGO_GLYPH_INDEX | GGO_UNHINTED, &metrics, 0, NULL, &matrix);
657657

658658
if( bytesGlyph == GDI_ERROR )
659659
throw FontGlyphFailureExc();
@@ -665,7 +665,7 @@ Shape2d Font::getGlyphShape( Glyph glyphIndex ) const
665665
}
666666

667667
if( ::GetGlyphOutlineW( FontManager::instance()->getFontDc(), glyphIndex,
668-
GGO_NATIVE | GGO_GLYPH_INDEX, &metrics, bytesGlyph, buffer.get(), &matrix) == GDI_ERROR ) {
668+
GGO_NATIVE | GGO_GLYPH_INDEX | GGO_UNHINTED, &metrics, bytesGlyph, buffer.get(), &matrix) == GDI_ERROR ) {
669669
throw FontGlyphFailureExc();
670670
}
671671

@@ -689,19 +689,22 @@ Shape2d Font::getGlyphShape( Glyph glyphIndex ) const
689689
break;
690690
case TT_PRIM_QSPLINE:
691691
for( int i = 0; i < curve->cpfx - 1; i++ ) {
692-
vec2 p1 = resultShape.getCurrentPoint(), p2;
693-
vec2 c = msw::toVec2( points[i] ), c1, c2;
692+
vec2 c = msw::toVec2( points[i] );
693+
vec2 p2;
694694
if( i + 1 == curve->cpfx - 1 ) {
695695
p2 = msw::toVec2( points[i + 1] );
696696
}
697697
else {
698698
// records with more than one curve use interpolation for control points, per http://support.microsoft.com/kb/q87115/
699699
p2 = ( c + msw::toVec2( points[i + 1] ) ) / 2.0f;
700700
}
701-
702-
c1 = 2.0f * c / 3.0f + p1 / 3.0f;
703-
c2 = 2.0f * c / 3.0f + p2 / 3.0f;
704-
resultShape.curveTo( c1, c2, p2 );
701+
702+
//vec2 p1 = resultShape.getCurrentPoint();
703+
//vec2 c1 = 2.0f * c / 3.0f + p1 / 3.0f;
704+
//vec2 c2 = 2.0f * c / 3.0f + p2 / 3.0f;
705+
//resultShape.curveTo( c1, c2, p2 );
706+
707+
resultShape.quadTo( c, p2 );
705708
}
706709
break;
707710
case TT_PRIM_CSPLINE:

0 commit comments

Comments
 (0)