--- winlayout1.108.cxx 2007-12-18 19:35:24.679000000 +0000 +++ winlayout.cxx 2008-01-07 10:28:52.751000000 +0000 @@ -2093,9 +2093,16 @@ void UniscribeLayout::DrawText( SalGraph Point aRelPos( rVisualItem.mnXOffset + nBaseClusterOffset, 0 ); Point aPos = GetDrawPosition( aRelPos ); SCRIPT_CACHE& rScriptCache = GetScriptCache(); + + // hack to correct different behaviour of Vista USP (ver 1.6) + SCRIPT_ANALYSIS a = rVisualItem.mpScriptItem->a; + // if using manual right justification in ApplyDXArray, + // don't let ScriptTextOut do this (only usp ver 1.6?) + // TODO: verify different usp versions + a.fRTL = 0; (*pScriptTextOut)( mhDC, &rScriptCache, aPos.X(), aPos.Y(), 0, NULL, - &rVisualItem.mpScriptItem->a, NULL, 0, + &a, NULL, 0, mpOutGlyphs + nMinGlyphPos, nEndGlyphPos - nMinGlyphPos, mpGlyphAdvances + nMinGlyphPos, @@ -2293,7 +2300,7 @@ void UniscribeLayout::ApplyDXArray( cons for( int nItem = 0; nItem < mnItemCount; ++nItem ) { VisualItem& rVisualItem = mpVisualItems[ nItem ]; - + // set the position of this visual item rVisualItem.mnXOffset = nXOffset; @@ -2334,20 +2341,36 @@ void UniscribeLayout::ApplyDXArray( cons break; } - // update nXOffset to the position of the next visual item + // update nXOffset to the position of the next visual item int nEndGlyphPos; if( GetItemSubrange( rVisualItem, i, nEndGlyphPos ) ) for(; i < nEndGlyphPos; ++i ) nXOffset += mpJustifications[ i ]; - if( rVisualItem.mpScriptItem->a.fRTL ) + // TODO: check for Vista-USP (ver >= 1.6 ???) and let do + // ScriptTextOut perform the right align for you + if( rVisualItem.mpScriptItem->a.fRTL ) { // right align adjusted glyph positions for RTL item // exception: kashida aligned glyphs // TODO: make sure this works on all usp versions - for( i = rVisualItem.mnMinGlyphPos+1; i < rVisualItem.mnEndGlyphPos; ++i ) + // + + // as RTL lines might be split into several items, + // try to perform the justification across items + int nXOffsetAdjust = 0; + for( i = rVisualItem.mnMinGlyphPos; i < rVisualItem.mnEndGlyphPos; ++i ) if( mpVisualAttrs[i].uJustification != SCRIPT_JUSTIFY_ARABIC_KASHIDA ) { + if (i == rVisualItem.mnMinGlyphPos) + { + // the first glyphs position is set by mnXOffset + // and not by the mpJustifications array + nXOffsetAdjust = mpJustifications[ i ] - mpGlyphAdvances[ i ]; + rVisualItem.mnXOffset += nXOffsetAdjust; // for this item + mpJustifications [i] = mpGlyphAdvances [i]; + continue; + } mpJustifications[i-1] += mpJustifications[ i ] - mpGlyphAdvances[ i ]; mpJustifications[ i ] = mpGlyphAdvances[ i ]; }