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 )
const FontSelectPattern* const pReqFont = &rFSD;
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
mfFontRotation = pReqFont->mnOrientation * (M_PI / 1800.0);
......@@ -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
// TODO: is it worth it to cache the CTFontRef in SetFont() and reuse it here?
CTFontRef aCTFontRef = (CTFontRef)CFDictionaryGetValue( mpStyleDict, kCTFontAttributeName );
const double fPixelSize = (mfFontScale * fDPIY);
rMetric.mnAscent = lrint( CTFontGetAscent( aCTFontRef ) * fPixelSize);
rMetric.mnDescent = lrint( CTFontGetDescent( aCTFontRef ) * fPixelSize);
rMetric.mnIntLeading = lrint( CTFontGetLeading( aCTFontRef ) * fPixelSize);
......@@ -153,10 +144,10 @@ bool CTTextStyle::GetGlyphBoundRect( sal_GlyphId nGlyphId, Rectangle& rRect ) co
const CTFontOrientation aFontOrientation = kCTFontDefaultOrientation; // TODO: horz/vert
const CGRect aCGRect = CTFontGetBoundingRectsForGlyphs( aCTFontRef, aFontOrientation, &nCGGlyph, NULL, 1 );
rRect.Left() = lrint( mfFontScale * aCGRect.origin.x );
rRect.Top() = lrint( mfFontScale * aCGRect.origin.y );
rRect.Right() = lrint( mfFontScale * (aCGRect.origin.x + aCGRect.size.width) );
rRect.Bottom() = lrint( mfFontScale * (aCGRect.origin.y + aCGRect.size.height) );
rRect.Left() = lrint( aCGRect.origin.x );
rRect.Top() = lrint( aCGRect.origin.y );
rRect.Right() = lrint( aCGRect.origin.x + aCGRect.size.width );
rRect.Bottom() = lrint( aCGRect.origin.y + aCGRect.size.height );
return true;
}
......@@ -219,13 +210,6 @@ bool CTTextStyle::GetGlyphOutline( sal_GlyphId nGlyphId, basegfx::B2DPolyPolygon
MyCGPathApplierFunc( (void*)&aGgoData, &aClosingElement );
#endif
// apply the font scale
if( mfFontScale != 1.0 ) {
basegfx::B2DHomMatrix aScale;
aScale.scale( +mfFontScale, +mfFontScale );
rResult.transform( aScale );
}
return true;
}
......
......@@ -59,11 +59,6 @@ private:
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
// mutable members since these details are all lazy initialized
mutable double mfCachedWidth; // cached value of resulting typographical width
......@@ -80,7 +75,6 @@ CTLayout::CTLayout( const CTTextStyle* pTextStyle )
, mpAttrString( NULL )
, mpCTLine( NULL )
, mnCharCount( 0 )
, mfFontScale( pTextStyle->mfFontScale )
, mfCachedWidth( -1 )
, mnBaseAdv( 0 )
{
......@@ -149,7 +143,7 @@ void CTLayout::AdjustLayout( ImplLayoutArgs& rArgs )
// in RTL-layouts trailing spaces are leftmost
// TODO: use BiDi-algorithm to thoroughly check this assumption
if( rArgs.mnFlags & SAL_LAYOUT_BIDI_RTL)
mnBaseAdv = rint( CTLineGetTrailingWhitespaceWidth( mpCTLine ) * mfFontScale );
mnBaseAdv = rint( CTLineGetTrailingWhitespaceWidth( mpCTLine ) );
// return early if there is nothing to do
if( nPixelWidth <= 0 )
......@@ -160,7 +154,7 @@ void CTLayout::AdjustLayout( ImplLayoutArgs& rArgs )
if( (nOrigWidth >= nPixelWidth-1) && (nOrigWidth <= nPixelWidth+1) )
return;
CTLineRef pNewCTLine = CTLineCreateJustifiedLine( mpCTLine, 1.0, nPixelWidth / mfFontScale );
CTLineRef pNewCTLine = CTLineCreateJustifiedLine( mpCTLine, 1.0, nPixelWidth );
if( !pNewCTLine ) { // CTLineCreateJustifiedLine can and does fail
// handle failure by keeping the unjustified layout
// TODO: a better solution such as
......@@ -189,12 +183,12 @@ void CTLayout::DrawText( SalGraphics& rGraphics ) const
// so apply a temporary transformation that it flips back
// also compensate if the font was size limited
CGContextSaveGState( rAquaGraphics.mrContext );
CGContextScaleCTM( rAquaGraphics.mrContext, +mfFontScale, -mfFontScale );
CGContextScaleCTM( rAquaGraphics.mrContext, 1.0, -1.0 );
CGContextSetShouldAntialias( rAquaGraphics.mrContext, !rAquaGraphics.mbNonAntialiasedText );
// Draw the text
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 )
{
......@@ -321,7 +315,7 @@ int CTLayout::GetNextGlyphs( int nLen, sal_GlyphId* pGlyphIDs, Point& rPos, int&
*(pFallbackFonts++) = pFallbackFont;
if( !nCount++ ) {
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
......@@ -342,7 +336,7 @@ long CTLayout::GetTextWidth() const
mfCachedWidth = CTLineGetTypographicBounds( mpCTLine, NULL, NULL, NULL);
}
const long nScaledWidth = lrint( mfFontScale * mfCachedWidth );
const long nScaledWidth = lrint( mfCachedWidth );
return nScaledWidth;
}
......@@ -392,7 +386,7 @@ int CTLayout::GetTextBreak( long nMaxWidth, long /*nCharExtra*/, int nFactor ) c
return STRING_LEN;
CTTypesetterRef aCTTypeSetter = CTTypesetterCreateWithAttributedString( mpAttrString );
const double fCTMaxWidth = (double)nMaxWidth / (nFactor * mfFontScale);
const double fCTMaxWidth = (double)nMaxWidth / nFactor;
CFIndex nIndex = CTTypesetterSuggestClusterBreak( aCTTypeSetter, 0, fCTMaxWidth );
if( nIndex >= mnCharCount )
return STRING_LEN;
......@@ -420,11 +414,11 @@ void CTLayout::GetCaretPositions( int nMaxIndex, sal_Int32* pCaretXArray ) const
(void)fPos2; // TODO: split cursor at line direction change
// update previous trailing position
if( n > 0 )
pCaretXArray[ 2*n-1 ] = lrint( fPos1 * mfFontScale );
pCaretXArray[ 2*n-1 ] = lrint( fPos1 );
// update current leading position
if( 2*n >= nMaxIndex )
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
const Point aPos = GetDrawPosition( Point(mnBaseAdv, 0) );
// CoreText top-bottom are vertically flipped from a VCL aspect
rVCLRect.Left() = aPos.X() + mfFontScale * aMacRect.origin.x;
rVCLRect.Right() = aPos.X() + mfFontScale * (aMacRect.origin.x + aMacRect.size.width);
rVCLRect.Bottom() = aPos.Y() - mfFontScale * aMacRect.origin.y;
rVCLRect.Top() = aPos.Y() - mfFontScale * (aMacRect.origin.y + aMacRect.size.height);
rVCLRect.Left() = aPos.X() + aMacRect.origin.x;
rVCLRect.Right() = aPos.X() + aMacRect.origin.x + aMacRect.size.width;
rVCLRect.Bottom() = aPos.Y() - aMacRect.origin.y;
rVCLRect.Top() = aPos.Y() - aMacRect.origin.y + aMacRect.size.height;
return true;
}
......
......@@ -67,7 +67,6 @@ SystemFontList::~SystemFontList( void )
ImplMacTextStyle::ImplMacTextStyle( const FontSelectPattern& rReqFont )
: mpFontData( (ImplMacFontData*)rReqFont.mpFontData )
, mfFontScale( 1.0 )
, mfFontStretch( 1.0 )
, mfFontRotation( 0.0 )
{}
......
......@@ -108,8 +108,6 @@ public:
//###protected:
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
float mfFontStretch;
/// 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