diff options
author | Tor Lillqvist <tml@iki.fi> | 2013-04-08 16:47:03 +0300 |
---|---|---|
committer | Tor Lillqvist <tml@iki.fi> | 2013-04-08 16:53:55 +0300 |
commit | 50977ad9ce8767562903cacf6084323ab4a21202 (patch) | |
tree | f674fa99e4c7458ef8ffed32de5958c66efa444f /vcl | |
parent | e32e8d0314e30475419f5108e8bc65bba9fc779c (diff) |
More fixes to the CoreText code
Disregard trailing whitespace from the target width when justifying.
Justifying can change the number of glyps (especially with complex
scripts).
Now it works much better than before. Still a small amount of
character dance.
Change-Id: I7ca87e6c767ada257cc072d1dfbbe3f7d4354e42
Diffstat (limited to 'vcl')
-rw-r--r-- | vcl/coretext/salcoretextlayout.cxx | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/vcl/coretext/salcoretextlayout.cxx b/vcl/coretext/salcoretextlayout.cxx index 4dd4ff469d16..6832bdb08fe6 100644 --- a/vcl/coretext/salcoretextlayout.cxx +++ b/vcl/coretext/salcoretextlayout.cxx @@ -165,15 +165,19 @@ void CoreTextLayout::ApplyDXArray( ImplLayoutArgs& rArgs ) void CoreTextLayout::Justify( long nNewWidth ) { - CTLineRef justifiedLine = CTLineCreateJustifiedLine( mpLine, 1.0, nNewWidth ); + CTLineRef justifiedLine = CTLineCreateJustifiedLine( mpLine, 1.0, nNewWidth - CTLineGetTrailingWhitespaceWidth( mpLine ) ); if ( !justifiedLine ) { - SAL_INFO( "vcl.coretext.layout", "ApplyDXArray(): CTLineCreateJustifiedLine() failed" ); + SAL_INFO( "vcl.coretext.layout", "Justify(): CTLineCreateJustifiedLine() failed" ); } else { CFRelease( mpLine ); mpLine = justifiedLine; + // Justification can change the number of glyphs! + int oldGLyphCount = mnGlyphCount; + mnGlyphCount = CTLineGetGlyphCount( mpLine ); + if ( mnGlyphCount != oldGLyphCount ) + SAL_INFO( "vcl.coretext.layout", " glyph count changed, mnGlyphCount=" << mnGlyphCount ); + GetMeasurements(); } - - GetMeasurements(); } void CoreTextLayout::InvalidateMeasurements() @@ -375,7 +379,7 @@ int CoreTextLayout::GetNextGlyphs( int nLen, sal_GlyphId* pGlyphIDs, Point& rPos if( !mpRuns ) { mpRuns = CTLineGetGlyphRuns(mpLine); } - CFIndex nb_runs = CFArrayGetCount( mpRuns ); + CFIndex nRuns = CFArrayGetCount( mpRuns ); CTRunRef run = (CTRunRef)CFArrayGetValueAtIndex( mpRuns, mnCurrentRunIndex ); CFIndex nb_glyphs = CTRunGetGlyphCount( run ); @@ -384,7 +388,7 @@ int CoreTextLayout::GetNextGlyphs( int nLen, sal_GlyphId* pGlyphIDs, Point& rPos while( i < nLen ) { if( mnCurrentGlyphRunIndex >= nb_glyphs ) { mnCurrentRunIndex += 1; - if( mnCurrentRunIndex >= nb_runs ) { + if( mnCurrentRunIndex >= nRuns ) { break; } run = (CTRunRef)CFArrayGetValueAtIndex( mpRuns, mnCurrentRunIndex ); @@ -568,10 +572,10 @@ void CoreTextLayout::GetMeasurements() mpGlyphPositions = new CGPoint[ mnGlyphCount ]; CFArrayRef runs = CTLineGetGlyphRuns( mpLine ); - CFIndex nb_runs = CFArrayGetCount( runs ); + const CFIndex nRuns = CFArrayGetCount( runs ); CFIndex lineGlyphIx = 0; - for ( CFIndex runIx = 0; runIx < nb_runs; runIx++ ) + for ( CFIndex runIx = 0; runIx < nRuns; runIx++ ) { CTRunRef run = (CTRunRef)CFArrayGetValueAtIndex( runs, runIx ); if ( !run ) |