[Libreoffice-commits] core.git: Branch 'libreoffice-4-1' - vcl/coretext
Khaled Hosny
khaledhosny at eglug.org
Thu Jun 6 02:27:03 PDT 2013
vcl/coretext/ctlayout.cxx | 27 +++------------------------
1 file changed, 3 insertions(+), 24 deletions(-)
New commits:
commit 2132e8e2145562499f31bfad5e3997cea4042b52
Author: Khaled Hosny <khaledhosny at eglug.org>
Date: Tue Jun 4 12:05:33 2013 +0200
Drop the trailing white space crack
Whatever this is, all it seems to do it to cause jitter when editing
text. The only place where this has any use is when editing RTL text
since Core Text seems to always place the trailing space on the right.
Change-Id: I35726775fb2a11761d264238fe702e58bbafd7fd
diff --git a/vcl/coretext/ctlayout.cxx b/vcl/coretext/ctlayout.cxx
index be9f0e3..e2b44c1 100644
--- a/vcl/coretext/ctlayout.cxx
+++ b/vcl/coretext/ctlayout.cxx
@@ -58,7 +58,6 @@ private:
CTLineRef mpCTLine;
int mnCharCount; // ==mnEndCharPos-mnMinCharPos
- int mnTrailingSpaces;
// to prevent overflows
// font requests get size limited by downscaling huge fonts
@@ -68,7 +67,6 @@ private:
// cached details about the resulting layout
// mutable members since these details are all lazy initialized
mutable double mfCachedWidth; // cached value of resulting typographical width
- mutable double mfTrailingSpaceWidth; // in Pixels
// x-offset relative to layout origin
// currently only used in RTL-layouts
@@ -82,10 +80,8 @@ CTLayout::CTLayout( const CTTextStyle* pTextStyle )
, mpAttrString( NULL )
, mpCTLine( NULL )
, mnCharCount( 0 )
-, mnTrailingSpaces( 0 )
, mfFontScale( pTextStyle->mfFontScale )
, mfCachedWidth( -1 )
-, mfTrailingSpaceWidth( 0 )
, mnBaseAdv( 0 )
{
CFRetain( mpTextStyle->GetStyleDict() );
@@ -126,11 +122,6 @@ bool CTLayout::LayoutText( ImplLayoutArgs& rArgs )
mpCTLine = CTLineCreateWithAttributedString( mpAttrString );
CFRelease( aCFText);
- // get info about trailing whitespace to prepare for text justification in AdjustLayout()
- mnTrailingSpaces = 0;
- for( int i = mnEndCharPos; --i >= mnMinCharPos; ++mnTrailingSpaces )
- if( !IsSpacingGlyph( rArgs.mpStr[i] | GF_ISCHAR ))
- break;
return true;
}
@@ -141,17 +132,10 @@ void CTLayout::AdjustLayout( ImplLayoutArgs& rArgs )
if( !mpCTLine)
return;
- // CoreText fills trailing space during justification so we have to
- // take that into account when requesting CT to justify something
- mfTrailingSpaceWidth = CTLineGetTrailingWhitespaceWidth( mpCTLine );
- const int nTrailingSpaceWidth = rint( mfFontScale * mfTrailingSpaceWidth );
-
int nOrigWidth = GetTextWidth();
- nOrigWidth -= nTrailingSpaceWidth;
int nPixelWidth = rArgs.mnLayoutWidth;
if( nPixelWidth )
{
- nPixelWidth -= nTrailingSpaceWidth;
if( nPixelWidth <= 0)
return;
}
@@ -159,13 +143,13 @@ void CTLayout::AdjustLayout( ImplLayoutArgs& rArgs )
{
// for now we are only interested in the layout width
// TODO: use all mpDXArray elements for layouting
- nPixelWidth = rArgs.mpDXArray[ mnCharCount - 1 - mnTrailingSpaces ];
+ nPixelWidth = rArgs.mpDXArray[ mnCharCount - 1 ];
}
// in RTL-layouts trailing spaces are leftmost
// TODO: use BiDi-algorithm to thoroughly check this assumption
if( rArgs.mnFlags & SAL_LAYOUT_BIDI_RTL)
- mnBaseAdv = nTrailingSpaceWidth;
+ mnBaseAdv = rint( CTLineGetTrailingWhitespaceWidth( mpCTLine ) * mfFontScale );
// return early if there is nothing to do
if( nPixelWidth <= 0 )
@@ -188,7 +172,6 @@ void CTLayout::AdjustLayout( ImplLayoutArgs& rArgs )
CFRelease( mpCTLine );
mpCTLine = pNewCTLine;
mfCachedWidth = -1; // TODO: can we set it directly to target width we requested? For now we re-measure
- mfTrailingSpaceWidth = 0;
}
// -----------------------------------------------------------------------
@@ -340,10 +323,9 @@ long CTLayout::GetTextWidth() const
if( mfCachedWidth < 0.0 ) {
mfCachedWidth = CTLineGetTypographicBounds( mpCTLine, NULL, NULL, NULL);
- mfTrailingSpaceWidth = CTLineGetTrailingWhitespaceWidth( mpCTLine);
}
- const long nScaledWidth = lrint( mfFontScale * (mfCachedWidth + mfTrailingSpaceWidth));
+ const long nScaledWidth = lrint( mfFontScale * mfCachedWidth );
return nScaledWidth;
}
@@ -355,9 +337,6 @@ long CTLayout::FillDXArray( sal_Int32* pDXArray ) const
if( !pDXArray )
return GetTextWidth();
- // check assumptions
- DBG_ASSERT( mfTrailingSpaceWidth==0.0, "CTLayout::FillDXArray() with fTSW!=0" );
-
long nPixWidth = GetTextWidth();
if( pDXArray ) {
// initialize the result array
More information about the Libreoffice-commits
mailing list