diff options
author | Vladimir Glazounov <vg@openoffice.org> | 2006-11-01 16:48:18 +0000 |
---|---|---|
committer | Vladimir Glazounov <vg@openoffice.org> | 2006-11-01 16:48:18 +0000 |
commit | 0366f3a47138ceb14a4fb8cf2f10394dc9902c08 (patch) | |
tree | 5d97c0fbde0b9e0486b5fbfb4e1fb842b1053fea /cppcanvas/source | |
parent | 2f1842160c329a4a3b69356f678a31917bdda74a (diff) |
INTEGRATION: CWS thbpp5 (1.13.4); FILE MERGED
2006/10/13 20:00:31 thb 1.13.4.1: #i68512# Fixed double-rotation of outline text glyphs
Diffstat (limited to 'cppcanvas/source')
-rw-r--r-- | cppcanvas/source/mtfrenderer/textaction.cxx | 246 |
1 files changed, 128 insertions, 118 deletions
diff --git a/cppcanvas/source/mtfrenderer/textaction.cxx b/cppcanvas/source/mtfrenderer/textaction.cxx index 5679084e120c..31c42122274f 100644 --- a/cppcanvas/source/mtfrenderer/textaction.cxx +++ b/cppcanvas/source/mtfrenderer/textaction.cxx @@ -4,9 +4,9 @@ * * $RCSfile: textaction.cxx,v $ * - * $Revision: 1.14 $ + * $Revision: 1.15 $ * - * last change: $Author: obo $ $Date: 2006-10-12 15:00:26 $ + * last change: $Author: vg $ $Date: 2006-11-01 17:48:18 $ * * The Contents of this file are made available subject to * the terms of GNU Lesser General Public License Version 2.1. @@ -1966,148 +1966,158 @@ namespace cppcanvas // PolyPolygon. That polygon is then converted to // device coordinate system. + // #i68512# Temporarily switch off font rotation + // (which is already contained in the render state + // transformation matrix - otherwise, glyph polygons + // will be rotated twice) + const ::Font aOrigFont( rVDev.GetFont() ); + ::Font aUnrotatedFont( aOrigFont ); + aUnrotatedFont.SetOrientation(0); + rVDev.SetFont( aUnrotatedFont ); + // TODO(F3): Don't understand parameter semantics of // GetTextOutlines() ::PolyPolygon aResultingVCLPolyPolygon; PolyPolyVector aVCLPolyPolyVector; - if( rVDev.GetTextOutlines( aVCLPolyPolyVector, rText, - static_cast<USHORT>(nStartPos), - static_cast<USHORT>(nStartPos), - static_cast<USHORT>(nLen), - TRUE, 0, pDXArray ) ) - { - ::std::vector< sal_Int32 > aPolygonGlyphMap; + const bool bHaveOutlines( rVDev.GetTextOutlines( aVCLPolyPolyVector, rText, + static_cast<USHORT>(nStartPos), + static_cast<USHORT>(nStartPos), + static_cast<USHORT>(nLen), + TRUE, 0, pDXArray ) ); + rVDev.SetFont(aOrigFont); - // first glyph starts at polygon index 0 - aPolygonGlyphMap.push_back( 0 ); + if( !bHaveOutlines ) + return ActionSharedPtr(); - // temporarily remove offsetting from mapmode - // (outline polygons must stay at origin, only - // need to be scaled) - const ::MapMode aOldMapMode( rVDev.GetMapMode() ); + ::std::vector< sal_Int32 > aPolygonGlyphMap; - ::MapMode aScaleOnlyMapMode( aOldMapMode ); - aScaleOnlyMapMode.SetOrigin( ::Point() ); - rVDev.SetMapMode( aScaleOnlyMapMode ); + // first glyph starts at polygon index 0 + aPolygonGlyphMap.push_back( 0 ); - PolyPolyVector::const_iterator aIter( aVCLPolyPolyVector.begin() ); - const PolyPolyVector::const_iterator aEnd( aVCLPolyPolyVector.end() ); - for( ; aIter!= aEnd; ++aIter ) - { - ::PolyPolygon aVCLPolyPolygon; + // temporarily remove offsetting from mapmode + // (outline polygons must stay at origin, only + // need to be scaled) + const ::MapMode aOldMapMode( rVDev.GetMapMode() ); + + ::MapMode aScaleOnlyMapMode( aOldMapMode ); + aScaleOnlyMapMode.SetOrigin( ::Point() ); + rVDev.SetMapMode( aScaleOnlyMapMode ); + + PolyPolyVector::const_iterator aIter( aVCLPolyPolyVector.begin() ); + const PolyPolyVector::const_iterator aEnd( aVCLPolyPolyVector.end() ); + for( ; aIter!= aEnd; ++aIter ) + { + ::PolyPolygon aVCLPolyPolygon; - aVCLPolyPolygon = rVDev.LogicToPixel( *aIter ); + aVCLPolyPolygon = rVDev.LogicToPixel( *aIter ); - // append result to collecting polypoly - for( USHORT i=0; i<aVCLPolyPolygon.Count(); ++i ) + // append result to collecting polypoly + for( USHORT i=0; i<aVCLPolyPolygon.Count(); ++i ) + { + // #i47795# Ensure closed polygons (since + // FreeType returns the glyph outlines + // open) + const ::Polygon& rPoly( aVCLPolyPolygon.GetObject( i ) ); + const USHORT nCount( rPoly.GetSize() ); + if( nCount<3 || + rPoly[0] == rPoly[nCount-1] ) + { + // polygon either degenerate, or + // already closed. + aResultingVCLPolyPolygon.Insert( rPoly ); + } + else { - // #i47795# Ensure closed polygons (since - // FreeType returns the glyph outlines - // open) - const ::Polygon& rPoly( aVCLPolyPolygon.GetObject( i ) ); - const USHORT nCount( rPoly.GetSize() ); - if( nCount<3 || - rPoly[0] == rPoly[nCount-1] ) + ::Polygon aPoly(nCount+1); + + // close polygon explicitely + if( rPoly.HasFlags() ) { - // polygon either degenerate, or - // already closed. - aResultingVCLPolyPolygon.Insert( rPoly ); + for( USHORT j=0; j<nCount; ++j ) + { + aPoly[j] = rPoly[j]; + aPoly.SetFlags(j, rPoly.GetFlags(j)); + } + + // duplicate first point + aPoly[nCount] = rPoly[0]; + aPoly.SetFlags(nCount, POLY_NORMAL); } else { - ::Polygon aPoly(nCount+1); - - // close polygon explicitely - if( rPoly.HasFlags() ) - { - for( USHORT j=0; j<nCount; ++j ) - { - aPoly[j] = rPoly[j]; - aPoly.SetFlags(j, rPoly.GetFlags(j)); - } - - // duplicate first point - aPoly[nCount] = rPoly[0]; - aPoly.SetFlags(nCount, POLY_NORMAL); - } - else + for( USHORT j=0; j<nCount; ++j ) { - for( USHORT j=0; j<nCount; ++j ) - { - aPoly[j] = rPoly[j]; - } - - // duplicate first point - aPoly[nCount] = rPoly[0]; + aPoly[j] = rPoly[j]; } - aResultingVCLPolyPolygon.Insert( aPoly ); + // duplicate first point + aPoly[nCount] = rPoly[0]; } - } - - // TODO(F3): Depending on the semantics of - // GetTextOutlines(), this here is wrong! - // calc next glyph index - aPolygonGlyphMap.push_back( aResultingVCLPolyPolygon.Count() ); + aResultingVCLPolyPolygon.Insert( aPoly ); + } } - rVDev.SetMapMode( aOldMapMode ); - - const uno::Sequence< double > aCharWidthSeq( - pDXArray ? - setupDXArray( pDXArray, nLen, rVDev ) : - setupDXArray( rText, - nStartPos, - nLen, - rVDev ) ); - const uno::Reference< rendering::XPolyPolygon2D > xTextPoly( - ::vcl::unotools::xPolyPolygonFromPolyPolygon( - rCanvas->getUNOCanvas()->getDevice(), - aResultingVCLPolyPolygon ) ); - - ::Point aEmptyPoint; - if( rParms.maTextTransformation.isValid() ) - { - return ActionSharedPtr( - new OutlineAction( - rStartPoint, - rReliefOffset, - rReliefColor, - rShadowOffset, - rShadowColor, - aResultingVCLPolyPolygon.GetBoundRect(), - xTextPoly, - aPolygonGlyphMap, - aCharWidthSeq, - rVDev, - rCanvas, - rState, - rParms.maTextTransformation.getValue() ) ); - } - else - { - return ActionSharedPtr( - new OutlineAction( - rStartPoint, - rReliefOffset, - rReliefColor, - rShadowOffset, - rShadowColor, - aResultingVCLPolyPolygon.GetBoundRect(), - xTextPoly, - aPolygonGlyphMap, - aCharWidthSeq, - rVDev, - rCanvas, - rState ) ); - } + // TODO(F3): Depending on the semantics of + // GetTextOutlines(), this here is wrong! + + // calc next glyph index + aPolygonGlyphMap.push_back( aResultingVCLPolyPolygon.Count() ); } - return ActionSharedPtr(); + rVDev.SetMapMode( aOldMapMode ); + + const uno::Sequence< double > aCharWidthSeq( + pDXArray ? + setupDXArray( pDXArray, nLen, rVDev ) : + setupDXArray( rText, + nStartPos, + nLen, + rVDev ) ); + const uno::Reference< rendering::XPolyPolygon2D > xTextPoly( + ::vcl::unotools::xPolyPolygonFromPolyPolygon( + rCanvas->getUNOCanvas()->getDevice(), + aResultingVCLPolyPolygon ) ); + + ::Point aEmptyPoint; + if( rParms.maTextTransformation.isValid() ) + { + return ActionSharedPtr( + new OutlineAction( + rStartPoint, + rReliefOffset, + rReliefColor, + rShadowOffset, + rShadowColor, + aResultingVCLPolyPolygon.GetBoundRect(), + xTextPoly, + aPolygonGlyphMap, + aCharWidthSeq, + rVDev, + rCanvas, + rState, + rParms.maTextTransformation.getValue() ) ); + } + else + { + return ActionSharedPtr( + new OutlineAction( + rStartPoint, + rReliefOffset, + rReliefColor, + rShadowOffset, + rShadowColor, + aResultingVCLPolyPolygon.GetBoundRect(), + xTextPoly, + aPolygonGlyphMap, + aCharWidthSeq, + rVDev, + rCanvas, + rState ) ); + } } - } + } // namespace // --------------------------------------------------------------------------------- |