diff options
| author | Tamas Bunth <tamas.bunth@collabora.co.uk> | 2018-02-10 17:11:37 +0100 |
|---|---|---|
| committer | Miklos Vajna <vmiklos@collabora.co.uk> | 2018-03-20 09:55:29 +0100 |
| commit | c5f0c10b3cb3d7014bb127e8d811377279ab5228 (patch) | |
| tree | 6e656fb6a618658304f5cdbc4d94f37f5ca8b90b | |
| parent | 21f220fce05bb99964f098247786eec014e56902 (diff) | |
tdf#115353 tdf#114743 Use first valid glyph
in AdjustLayout.
Change-Id: Iaa9a0cde2bd35fed5cbc9ebf0690341812679b6f
Reviewed-on: https://gerrit.libreoffice.org/49542
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk>
| -rw-r--r-- | vcl/source/gdi/sallayout.cxx | 34 |
1 files changed, 23 insertions, 11 deletions
diff --git a/vcl/source/gdi/sallayout.cxx b/vcl/source/gdi/sallayout.cxx index b8957ae14eb3..403d0b64c723 100644 --- a/vcl/source/gdi/sallayout.cxx +++ b/vcl/source/gdi/sallayout.cxx @@ -1206,15 +1206,27 @@ void MultiSalLayout::AdjustLayout( ImplLayoutArgs& rArgs ) double fUnitMul = 1.0; for( n = 0; n < nLevel; ++n ) maFallbackRuns[n].ResetPos(); + + int nFirstValid = -1; + for( n = 0; n < nLevel; ++n ) + { + if(nValid[n] > 0) + { + nFirstValid = n; + break; + } + } + assert(nFirstValid >= 0); + // get the next codepoint index that needs fallback - int nActiveCharPos = pGlyphs[0]->mnCharPos; + int nActiveCharPos = pGlyphs[nFirstValid]->mnCharPos; int nActiveCharIndex = nActiveCharPos - mnMinCharPos; // get the end index of the active run int nLastRunEndChar = (nActiveCharIndex >= 0 && vRtl[nActiveCharIndex]) ? rArgs.mnEndCharPos : rArgs.mnMinCharPos - 1; - int nRunVisibleEndChar = pGlyphs[0]->mnCharPos; + int nRunVisibleEndChar = pGlyphs[nFirstValid]->mnCharPos; // merge the fallback levels - while( nValid[0] && (nLevel > 0)) + while( nValid[nFirstValid] && (nLevel > 0)) { // find best fallback level for( n = 0; n < nLevel; ++n ) @@ -1241,15 +1253,15 @@ void MultiSalLayout::AdjustLayout( ImplLayoutArgs& rArgs ) { // drop the NotDef glyphs in the base layout run if a fallback run exists while ( - (maFallbackRuns[n-1].PosIsInRun(pGlyphs[0]->mnCharPos)) && - (!maFallbackRuns[n].PosIsInAnyRun(pGlyphs[0]->mnCharPos)) + (maFallbackRuns[n-1].PosIsInRun(pGlyphs[nFirstValid]->mnCharPos)) && + (!maFallbackRuns[n].PosIsInAnyRun(pGlyphs[nFirstValid]->mnCharPos)) ) { mpLayouts[0]->DropGlyph( nStartOld[0] ); nStartOld[0] = nStartNew[0]; - nValid[0] = mpLayouts[0]->GetNextGlyphs(1, &pGlyphs[0], aPos, nStartNew[0]); + nValid[nFirstValid] = mpLayouts[0]->GetNextGlyphs(1, &pGlyphs[nFirstValid], aPos, nStartNew[0]); - if( !nValid[0] ) + if( !nValid[nFirstValid] ) break; } } @@ -1301,9 +1313,9 @@ void MultiSalLayout::AdjustLayout( ImplLayoutArgs& rArgs ) else { // break when a fallback is needed and available - bool bNeedFallback = maFallbackRuns[0].PosIsInRun(pGlyphs[0]->mnCharPos); + bool bNeedFallback = maFallbackRuns[0].PosIsInRun(pGlyphs[nFirstValid]->mnCharPos); if( bNeedFallback ) - if (!maFallbackRuns[nLevel-1].PosIsInRun(pGlyphs[0]->mnCharPos)) + if (!maFallbackRuns[nLevel-1].PosIsInRun(pGlyphs[nFirstValid]->mnCharPos)) break; // break when change from resolved to unresolved base layout run if( bKeepNotDef && !bNeedFallback ) @@ -1356,7 +1368,7 @@ void MultiSalLayout::AdjustLayout( ImplLayoutArgs& rArgs ) nRunAdvance -= aMultiArgs.mpDXArray[nLastRunEndChar - mnMinCharPos]; } nLastRunEndChar = nRunVisibleEndChar; - nRunVisibleEndChar = pGlyphs[0]->mnCharPos; + nRunVisibleEndChar = pGlyphs[nFirstValid]->mnCharPos; // the requested width is still in pixel units // => convert it to base level font units nRunAdvance *= mnUnitsPerPixel; @@ -1373,7 +1385,7 @@ void MultiSalLayout::AdjustLayout( ImplLayoutArgs& rArgs ) nXPos += nRunAdvance; // prepare for next fallback run - nActiveCharPos = pGlyphs[0]->mnCharPos; + nActiveCharPos = pGlyphs[nFirstValid]->mnCharPos; // it essential that the runs don't get ahead of themselves and in the // if( bKeepNotDef && !bNeedFallback ) statement above, the next run may // have already been reached on the base level |
