From 8c10323154d1b8fb53bb9392d5239fecf0eabc61 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Thu, 14 Apr 2016 17:46:27 +0100 Subject: [PATCH] From Vladimir Chebaev, fixed handling of outline orientiation --- src/osgPlugins/freetype/FreeTypeFont.cpp | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/src/osgPlugins/freetype/FreeTypeFont.cpp b/src/osgPlugins/freetype/FreeTypeFont.cpp index fe54d1b56..0dcebb6a9 100644 --- a/src/osgPlugins/freetype/FreeTypeFont.cpp +++ b/src/osgPlugins/freetype/FreeTypeFont.cpp @@ -36,7 +36,8 @@ struct Char3DInfo _maxX(-FLT_MAX), _minX(FLT_MAX), _minY(FLT_MAX), - _coord_scale(1.0/64.0) + _coord_scale(1.0/64.0), + _reverseFill(false) { _geometry->setVertexArray(_verts.get()); } @@ -49,6 +50,17 @@ struct Char3DInfo { if (_currentPrimitiveSet.valid() && _currentPrimitiveSet->size()>1) { + if (_reverseFill) + { + for ( int near = 0, far = _currentPrimitiveSet->size() - 1; + near < far; + near++, far--) + { + std::swap((*_currentPrimitiveSet)[near], + (*_currentPrimitiveSet)[far]); + } + } + _geometry->addPrimitiveSet( _currentPrimitiveSet.get() ); } _currentPrimitiveSet = 0; @@ -168,7 +180,7 @@ struct Char3DInfo double _minX; double _minY; double _coord_scale; - + bool _reverseFill; }; @@ -461,6 +473,9 @@ osgText::Glyph3D * FreeTypeFont::getGlyph3D(const osgText::FontResolution& fontR funcs.shift = 0; funcs.delta = 0; + FT_Orientation orientation = FT_Outline_Get_Orientation(&outline); + char3d._reverseFill = (orientation == FT_ORIENTATION_POSTSCRIPT); + // ** record description FT_Error _error = FT_Outline_Decompose(&outline, &funcs, &char3d); if (_error)