Kaydet (Commit) fd786139 authored tarafından Khaled Hosny's avatar Khaled Hosny

Remove the never set mfFontScale

Lets just assume Core Text does not need this and react if a real
problem with “huge” font sizes arise.

Change-Id: I4031e7ca34692eb041ab10154df0064ab5efb462
üst 08e7b88d
...@@ -67,14 +67,6 @@ CTTextStyle::CTTextStyle( const FontSelectPattern& rFSD ) ...@@ -67,14 +67,6 @@ CTTextStyle::CTTextStyle( const FontSelectPattern& rFSD )
const FontSelectPattern* const pReqFont = &rFSD; const FontSelectPattern* const pReqFont = &rFSD;
double fScaledFontHeight = pReqFont->mfExactHeight; double fScaledFontHeight = pReqFont->mfExactHeight;
#if 0 // TODO: does CoreText need font size limiting???
static const float fMaxFontHeight = 144.0; // TODO: is there a limit for CoreText?
if( fScaledFontHeight > fMaxFontHeight )
{
mfFontScale = fScaledFontHeight / fMaxFontHeight;
fScaledFontHeight = fMaxFontHeight;
}
#endif
// convert font rotation to radian // convert font rotation to radian
mfFontRotation = pReqFont->mnOrientation * (M_PI / 1800.0); mfFontRotation = pReqFont->mnOrientation * (M_PI / 1800.0);
...@@ -121,13 +113,12 @@ CTTextStyle::~CTTextStyle( void ) ...@@ -121,13 +113,12 @@ CTTextStyle::~CTTextStyle( void )
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
void CTTextStyle::GetFontMetric( float fDPIY, ImplFontMetricData& rMetric ) const void CTTextStyle::GetFontMetric( float fPixelSize, ImplFontMetricData& rMetric ) const
{ {
// get the matching CoreText font handle // get the matching CoreText font handle
// TODO: is it worth it to cache the CTFontRef in SetFont() and reuse it here? // TODO: is it worth it to cache the CTFontRef in SetFont() and reuse it here?
CTFontRef aCTFontRef = (CTFontRef)CFDictionaryGetValue( mpStyleDict, kCTFontAttributeName ); CTFontRef aCTFontRef = (CTFontRef)CFDictionaryGetValue( mpStyleDict, kCTFontAttributeName );
const double fPixelSize = (mfFontScale * fDPIY);
rMetric.mnAscent = lrint( CTFontGetAscent( aCTFontRef ) * fPixelSize); rMetric.mnAscent = lrint( CTFontGetAscent( aCTFontRef ) * fPixelSize);
rMetric.mnDescent = lrint( CTFontGetDescent( aCTFontRef ) * fPixelSize); rMetric.mnDescent = lrint( CTFontGetDescent( aCTFontRef ) * fPixelSize);
rMetric.mnIntLeading = lrint( CTFontGetLeading( aCTFontRef ) * fPixelSize); rMetric.mnIntLeading = lrint( CTFontGetLeading( aCTFontRef ) * fPixelSize);
...@@ -153,10 +144,10 @@ bool CTTextStyle::GetGlyphBoundRect( sal_GlyphId nGlyphId, Rectangle& rRect ) co ...@@ -153,10 +144,10 @@ bool CTTextStyle::GetGlyphBoundRect( sal_GlyphId nGlyphId, Rectangle& rRect ) co
const CTFontOrientation aFontOrientation = kCTFontDefaultOrientation; // TODO: horz/vert const CTFontOrientation aFontOrientation = kCTFontDefaultOrientation; // TODO: horz/vert
const CGRect aCGRect = CTFontGetBoundingRectsForGlyphs( aCTFontRef, aFontOrientation, &nCGGlyph, NULL, 1 ); const CGRect aCGRect = CTFontGetBoundingRectsForGlyphs( aCTFontRef, aFontOrientation, &nCGGlyph, NULL, 1 );
rRect.Left() = lrint( mfFontScale * aCGRect.origin.x ); rRect.Left() = lrint( aCGRect.origin.x );
rRect.Top() = lrint( mfFontScale * aCGRect.origin.y ); rRect.Top() = lrint( aCGRect.origin.y );
rRect.Right() = lrint( mfFontScale * (aCGRect.origin.x + aCGRect.size.width) ); rRect.Right() = lrint( aCGRect.origin.x + aCGRect.size.width );
rRect.Bottom() = lrint( mfFontScale * (aCGRect.origin.y + aCGRect.size.height) ); rRect.Bottom() = lrint( aCGRect.origin.y + aCGRect.size.height );
return true; return true;
} }
...@@ -219,13 +210,6 @@ bool CTTextStyle::GetGlyphOutline( sal_GlyphId nGlyphId, basegfx::B2DPolyPolygon ...@@ -219,13 +210,6 @@ bool CTTextStyle::GetGlyphOutline( sal_GlyphId nGlyphId, basegfx::B2DPolyPolygon
MyCGPathApplierFunc( (void*)&aGgoData, &aClosingElement ); MyCGPathApplierFunc( (void*)&aGgoData, &aClosingElement );
#endif #endif
// apply the font scale
if( mfFontScale != 1.0 ) {
basegfx::B2DHomMatrix aScale;
aScale.scale( +mfFontScale, +mfFontScale );
rResult.transform( aScale );
}
return true; return true;
} }
......
...@@ -59,11 +59,6 @@ private: ...@@ -59,11 +59,6 @@ private:
int mnCharCount; // ==mnEndCharPos-mnMinCharPos int mnCharCount; // ==mnEndCharPos-mnMinCharPos
// to prevent overflows
// font requests get size limited by downscaling huge fonts
// in these cases the font scale becomes something bigger than 1.0
float mfFontScale; // TODO: does CoreText have a font size limit?
// cached details about the resulting layout // cached details about the resulting layout
// mutable members since these details are all lazy initialized // mutable members since these details are all lazy initialized
mutable double mfCachedWidth; // cached value of resulting typographical width mutable double mfCachedWidth; // cached value of resulting typographical width
...@@ -80,7 +75,6 @@ CTLayout::CTLayout( const CTTextStyle* pTextStyle ) ...@@ -80,7 +75,6 @@ CTLayout::CTLayout( const CTTextStyle* pTextStyle )
, mpAttrString( NULL ) , mpAttrString( NULL )
, mpCTLine( NULL ) , mpCTLine( NULL )
, mnCharCount( 0 ) , mnCharCount( 0 )
, mfFontScale( pTextStyle->mfFontScale )
, mfCachedWidth( -1 ) , mfCachedWidth( -1 )
, mnBaseAdv( 0 ) , mnBaseAdv( 0 )
{ {
...@@ -149,7 +143,7 @@ void CTLayout::AdjustLayout( ImplLayoutArgs& rArgs ) ...@@ -149,7 +143,7 @@ void CTLayout::AdjustLayout( ImplLayoutArgs& rArgs )
// in RTL-layouts trailing spaces are leftmost // in RTL-layouts trailing spaces are leftmost
// TODO: use BiDi-algorithm to thoroughly check this assumption // TODO: use BiDi-algorithm to thoroughly check this assumption
if( rArgs.mnFlags & SAL_LAYOUT_BIDI_RTL) if( rArgs.mnFlags & SAL_LAYOUT_BIDI_RTL)
mnBaseAdv = rint( CTLineGetTrailingWhitespaceWidth( mpCTLine ) * mfFontScale ); mnBaseAdv = rint( CTLineGetTrailingWhitespaceWidth( mpCTLine ) );
// return early if there is nothing to do // return early if there is nothing to do
if( nPixelWidth <= 0 ) if( nPixelWidth <= 0 )
...@@ -160,7 +154,7 @@ void CTLayout::AdjustLayout( ImplLayoutArgs& rArgs ) ...@@ -160,7 +154,7 @@ void CTLayout::AdjustLayout( ImplLayoutArgs& rArgs )
if( (nOrigWidth >= nPixelWidth-1) && (nOrigWidth <= nPixelWidth+1) ) if( (nOrigWidth >= nPixelWidth-1) && (nOrigWidth <= nPixelWidth+1) )
return; return;
CTLineRef pNewCTLine = CTLineCreateJustifiedLine( mpCTLine, 1.0, nPixelWidth / mfFontScale ); CTLineRef pNewCTLine = CTLineCreateJustifiedLine( mpCTLine, 1.0, nPixelWidth );
if( !pNewCTLine ) { // CTLineCreateJustifiedLine can and does fail if( !pNewCTLine ) { // CTLineCreateJustifiedLine can and does fail
// handle failure by keeping the unjustified layout // handle failure by keeping the unjustified layout
// TODO: a better solution such as // TODO: a better solution such as
...@@ -189,12 +183,12 @@ void CTLayout::DrawText( SalGraphics& rGraphics ) const ...@@ -189,12 +183,12 @@ void CTLayout::DrawText( SalGraphics& rGraphics ) const
// so apply a temporary transformation that it flips back // so apply a temporary transformation that it flips back
// also compensate if the font was size limited // also compensate if the font was size limited
CGContextSaveGState( rAquaGraphics.mrContext ); CGContextSaveGState( rAquaGraphics.mrContext );
CGContextScaleCTM( rAquaGraphics.mrContext, +mfFontScale, -mfFontScale ); CGContextScaleCTM( rAquaGraphics.mrContext, 1.0, -1.0 );
CGContextSetShouldAntialias( rAquaGraphics.mrContext, !rAquaGraphics.mbNonAntialiasedText ); CGContextSetShouldAntialias( rAquaGraphics.mrContext, !rAquaGraphics.mbNonAntialiasedText );
// Draw the text // Draw the text
const Point aVclPos = GetDrawPosition( Point(mnBaseAdv,0) ); const Point aVclPos = GetDrawPosition( Point(mnBaseAdv,0) );
CGPoint aTextPos = { +aVclPos.X()/mfFontScale, -aVclPos.Y()/mfFontScale }; CGPoint aTextPos = { (CGFloat) +aVclPos.X(), (CGFloat) -aVclPos.Y() };
if( mpTextStyle->mfFontRotation != 0.0 ) if( mpTextStyle->mfFontRotation != 0.0 )
{ {
...@@ -321,7 +315,7 @@ int CTLayout::GetNextGlyphs( int nLen, sal_GlyphId* pGlyphIDs, Point& rPos, int& ...@@ -321,7 +315,7 @@ int CTLayout::GetNextGlyphs( int nLen, sal_GlyphId* pGlyphIDs, Point& rPos, int&
*(pFallbackFonts++) = pFallbackFont; *(pFallbackFonts++) = pFallbackFont;
if( !nCount++ ) { if( !nCount++ ) {
const CGPoint& rCurPos = pCGGlyphPos[ nSubIndex ]; const CGPoint& rCurPos = pCGGlyphPos[ nSubIndex ];
rPos = GetDrawPosition( Point( mfFontScale * rCurPos.x, mfFontScale * rCurPos.y) ); rPos = GetDrawPosition( Point( rCurPos.x, rCurPos.y) );
} }
} }
nSubIndex = 0; // prepare for the next glyph run nSubIndex = 0; // prepare for the next glyph run
...@@ -342,7 +336,7 @@ long CTLayout::GetTextWidth() const ...@@ -342,7 +336,7 @@ long CTLayout::GetTextWidth() const
mfCachedWidth = CTLineGetTypographicBounds( mpCTLine, NULL, NULL, NULL); mfCachedWidth = CTLineGetTypographicBounds( mpCTLine, NULL, NULL, NULL);
} }
const long nScaledWidth = lrint( mfFontScale * mfCachedWidth ); const long nScaledWidth = lrint( mfCachedWidth );
return nScaledWidth; return nScaledWidth;
} }
...@@ -392,7 +386,7 @@ int CTLayout::GetTextBreak( long nMaxWidth, long /*nCharExtra*/, int nFactor ) c ...@@ -392,7 +386,7 @@ int CTLayout::GetTextBreak( long nMaxWidth, long /*nCharExtra*/, int nFactor ) c
return STRING_LEN; return STRING_LEN;
CTTypesetterRef aCTTypeSetter = CTTypesetterCreateWithAttributedString( mpAttrString ); CTTypesetterRef aCTTypeSetter = CTTypesetterCreateWithAttributedString( mpAttrString );
const double fCTMaxWidth = (double)nMaxWidth / (nFactor * mfFontScale); const double fCTMaxWidth = (double)nMaxWidth / nFactor;
CFIndex nIndex = CTTypesetterSuggestClusterBreak( aCTTypeSetter, 0, fCTMaxWidth ); CFIndex nIndex = CTTypesetterSuggestClusterBreak( aCTTypeSetter, 0, fCTMaxWidth );
if( nIndex >= mnCharCount ) if( nIndex >= mnCharCount )
return STRING_LEN; return STRING_LEN;
...@@ -420,11 +414,11 @@ void CTLayout::GetCaretPositions( int nMaxIndex, sal_Int32* pCaretXArray ) const ...@@ -420,11 +414,11 @@ void CTLayout::GetCaretPositions( int nMaxIndex, sal_Int32* pCaretXArray ) const
(void)fPos2; // TODO: split cursor at line direction change (void)fPos2; // TODO: split cursor at line direction change
// update previous trailing position // update previous trailing position
if( n > 0 ) if( n > 0 )
pCaretXArray[ 2*n-1 ] = lrint( fPos1 * mfFontScale ); pCaretXArray[ 2*n-1 ] = lrint( fPos1 );
// update current leading position // update current leading position
if( 2*n >= nMaxIndex ) if( 2*n >= nMaxIndex )
break; break;
pCaretXArray[ 2*n+0 ] = lrint( fPos1 * mfFontScale ); pCaretXArray[ 2*n+0 ] = lrint( fPos1 );
} }
} }
...@@ -447,10 +441,10 @@ bool CTLayout::GetBoundRect( SalGraphics& rGraphics, Rectangle& rVCLRect ) const ...@@ -447,10 +441,10 @@ bool CTLayout::GetBoundRect( SalGraphics& rGraphics, Rectangle& rVCLRect ) const
const Point aPos = GetDrawPosition( Point(mnBaseAdv, 0) ); const Point aPos = GetDrawPosition( Point(mnBaseAdv, 0) );
// CoreText top-bottom are vertically flipped from a VCL aspect // CoreText top-bottom are vertically flipped from a VCL aspect
rVCLRect.Left() = aPos.X() + mfFontScale * aMacRect.origin.x; rVCLRect.Left() = aPos.X() + aMacRect.origin.x;
rVCLRect.Right() = aPos.X() + mfFontScale * (aMacRect.origin.x + aMacRect.size.width); rVCLRect.Right() = aPos.X() + aMacRect.origin.x + aMacRect.size.width;
rVCLRect.Bottom() = aPos.Y() - mfFontScale * aMacRect.origin.y; rVCLRect.Bottom() = aPos.Y() - aMacRect.origin.y;
rVCLRect.Top() = aPos.Y() - mfFontScale * (aMacRect.origin.y + aMacRect.size.height); rVCLRect.Top() = aPos.Y() - aMacRect.origin.y + aMacRect.size.height;
return true; return true;
} }
......
...@@ -67,7 +67,6 @@ SystemFontList::~SystemFontList( void ) ...@@ -67,7 +67,6 @@ SystemFontList::~SystemFontList( void )
ImplMacTextStyle::ImplMacTextStyle( const FontSelectPattern& rReqFont ) ImplMacTextStyle::ImplMacTextStyle( const FontSelectPattern& rReqFont )
: mpFontData( (ImplMacFontData*)rReqFont.mpFontData ) : mpFontData( (ImplMacFontData*)rReqFont.mpFontData )
, mfFontScale( 1.0 )
, mfFontStretch( 1.0 ) , mfFontStretch( 1.0 )
, mfFontRotation( 0.0 ) , mfFontRotation( 0.0 )
{} {}
......
...@@ -108,8 +108,6 @@ public: ...@@ -108,8 +108,6 @@ public:
//###protected: //###protected:
const ImplMacFontData* mpFontData; const ImplMacFontData* mpFontData;
/// workaround to prevent overflows for huge font sizes
float mfFontScale;
/// <1.0: font is squeezed, >1.0 font is stretched, else 1.0 /// <1.0: font is squeezed, >1.0 font is stretched, else 1.0
float mfFontStretch; float mfFontStretch;
/// text rotation in radian /// text rotation in radian
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment