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

Attempt to fix Core Text full justification

Apparently we need to subtract the trailing white space from the desired
line length or text will sometimes protrude to the margin.

Change-Id: Iee5ef40670c2fefc189afa319387b180c4ed648d
üst ecdd9d1a
...@@ -140,10 +140,11 @@ void CTLayout::AdjustLayout( ImplLayoutArgs& rArgs ) ...@@ -140,10 +140,11 @@ void CTLayout::AdjustLayout( ImplLayoutArgs& rArgs )
nPixelWidth = rArgs.mpDXArray[ mnCharCount - 1 ]; nPixelWidth = rArgs.mpDXArray[ mnCharCount - 1 ];
} }
float fTrailingSpace = CTLineGetTrailingWhitespaceWidth( mpCTLine );
// 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 ) ); mnBaseAdv = rint( fTrailingSpace );
// return early if there is nothing to do // return early if there is nothing to do
if( nPixelWidth <= 0 ) if( nPixelWidth <= 0 )
...@@ -154,7 +155,7 @@ void CTLayout::AdjustLayout( ImplLayoutArgs& rArgs ) ...@@ -154,7 +155,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 ); CTLineRef pNewCTLine = CTLineCreateJustifiedLine( mpCTLine, 1.0, nPixelWidth - fTrailingSpace );
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
......
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