Lines 1105-1110
private:
Link Here
|
1105 |
GOFFSET* mpGlyphOffsets; // glyph offsets to the "naive" layout |
1105 |
GOFFSET* mpGlyphOffsets; // glyph offsets to the "naive" layout |
1106 |
SCRIPT_VISATTR* mpVisualAttrs; // glyph visual attributes |
1106 |
SCRIPT_VISATTR* mpVisualAttrs; // glyph visual attributes |
1107 |
mutable int* mpGlyphs2Chars; // map from absolute_glyph_pos to absolute_char_pos |
1107 |
mutable int* mpGlyphs2Chars; // map from absolute_glyph_pos to absolute_char_pos |
|
|
1108 |
|
1109 |
// font specific info |
1110 |
int mnMinKashidaWidth; // minimal Kashida width allowed by font |
1108 |
}; |
1111 |
}; |
1109 |
|
1112 |
|
1110 |
// ----------------------------------------------------------------------- |
1113 |
// ----------------------------------------------------------------------- |
Lines 1670-1680
bool UniscribeLayout::LayoutText( ImplLa
Link Here
|
1670 |
} |
1673 |
} |
1671 |
} |
1674 |
} |
1672 |
|
1675 |
|
|
|
1676 |
//ScriptGetFontProperties |
1677 |
|
1678 |
SCRIPT_FONTPROPERTIES aFontProperties; |
1679 |
aFontProperties.cBytes = sizeof (aFontProperties); // don't forget to initialize |
1680 |
mnMinKashidaWidth = 0; |
1681 |
HRESULT nRC = (*pScriptGetFontProperties)( mhDC, &rScriptCache, &aFontProperties ); |
1682 |
if( !nRC ) |
1683 |
{ |
1684 |
mnMinKashidaWidth = aFontProperties.iKashidaWidth; |
1685 |
} |
1686 |
|
1687 |
|
1673 |
// scale layout metrics if needed |
1688 |
// scale layout metrics if needed |
1674 |
if( mfFontScale != 1.0 ) |
1689 |
if( mfFontScale != 1.0 ) |
1675 |
{ |
1690 |
{ |
1676 |
mnBaseAdv = (int)((double)mnBaseAdv*mfFontScale); |
1691 |
mnBaseAdv = (int)((double)mnBaseAdv*mfFontScale); |
1677 |
|
1692 |
mnMinKashidaWidth = (int)((double)mnMinKashidaWidth*mfFontScale); |
1678 |
for( i = 0; i < mnItemCount; ++i ) |
1693 |
for( i = 0; i < mnItemCount; ++i ) |
1679 |
mpVisualItems[i].mnXOffset = (int)((double)mpVisualItems[i].mnXOffset*mfFontScale); |
1694 |
mpVisualItems[i].mnXOffset = (int)((double)mpVisualItems[i].mnXOffset*mfFontScale); |
1680 |
|
1695 |
|
Lines 2342-2357
void UniscribeLayout::ApplyDXArray( cons
Link Here
|
2342 |
if( rVisualItem.mpScriptItem->a.fRTL ) |
2357 |
if( rVisualItem.mpScriptItem->a.fRTL ) |
2343 |
{ |
2358 |
{ |
2344 |
for( i = rVisualItem.mnMinGlyphPos; i < rVisualItem.mnEndGlyphPos; ++i ) |
2359 |
for( i = rVisualItem.mnMinGlyphPos; i < rVisualItem.mnEndGlyphPos; ++i ) |
2345 |
if ( (1U << mpVisualAttrs[i].uJustification) & 0x7F89 ) // any Arabic justification ? |
2360 |
if ( (1U << mpVisualAttrs[i].uJustification) & 0xFF89 ) // any Arabic justification ? |
2346 |
{ |
2361 |
{ // the last SCRIPT_JUSTIFY_xxx |
2347 |
// yes |
2362 |
// yes // == 15 (usp 1.6) |
2348 |
bHasKashida = true; |
2363 |
bHasKashida = true; |
2349 |
break; |
2364 |
break; |
2350 |
} |
2365 |
} |
2351 |
if ( bHasKashida ) |
2366 |
if ( bHasKashida ) |
2352 |
for( i = rVisualItem.mnMinGlyphPos; i < rVisualItem.mnEndGlyphPos; ++i ) |
2367 |
for( i = rVisualItem.mnMinGlyphPos; i < rVisualItem.mnEndGlyphPos; ++i ) |
2353 |
{ |
2368 |
{ |
2354 |
if ( mpVisualAttrs[i].uJustification == SCRIPT_JUSTIFY_NONE ) |
2369 |
// check if we still need this hack after correction of kashida placing? |
|
|
2370 |
// (i87688): apparently yes, we still need it! |
2371 |
if ( mpVisualAttrs[i].uJustification == SCRIPT_JUSTIFY_NONE ) |
2355 |
// usp decided that justification can't be applied here |
2372 |
// usp decided that justification can't be applied here |
2356 |
// but maybe our Kashida algorithm thinks differently. |
2373 |
// but maybe our Kashida algorithm thinks differently. |
2357 |
// To avoid trouble (gaps within words, last character of |
2374 |
// To avoid trouble (gaps within words, last character of |
Lines 2385-2390
void UniscribeLayout::ApplyDXArray( cons
Link Here
|
2385 |
break; |
2402 |
break; |
2386 |
} |
2403 |
} |
2387 |
|
2404 |
|
|
|
2405 |
// to prepare for the next visual item |
2406 |
// update nXOffset to the next items position |
2407 |
// before the mpJustifications[] array gets modified |
2408 |
int nMinGlyphPos, nEndGlyphPos; |
2409 |
if( GetItemSubrange( rVisualItem, nMinGlyphPos, nEndGlyphPos ) ) |
2410 |
{ |
2411 |
for( i = nMinGlyphPos; i < nEndGlyphPos; ++i ) |
2412 |
nXOffset += mpJustifications[ i ]; |
2413 |
|
2388 |
// TODO: for kashida justification |
2414 |
// TODO: for kashida justification |
2389 |
// check the widths which are added to mpJustification |
2415 |
// check the widths which are added to mpJustification |
2390 |
// if added width is smaller than iKashidaWidth returned by |
2416 |
// if added width is smaller than iKashidaWidth returned by |
Lines 2393-2405
void UniscribeLayout::ApplyDXArray( cons
Link Here
|
2393 |
// Need to think of a way to compensate the change in overall |
2419 |
// Need to think of a way to compensate the change in overall |
2394 |
// width. |
2420 |
// width. |
2395 |
|
2421 |
|
2396 |
// to prepare for the next visual item |
2422 |
if ( bHasKashida && mnMinKashidaWidth ) |
2397 |
// update nXOffset to the next items position |
2423 |
{ |
2398 |
// before the mpJustifications[] array gets modified |
2424 |
int nSpaceAdded; |
2399 |
int nMinGlyphPos, nEndGlyphPos; |
2425 |
for ( i = nMinGlyphPos; i < nEndGlyphPos; ++i ) |
2400 |
if( GetItemSubrange( rVisualItem, nMinGlyphPos, nEndGlyphPos ) ) |
2426 |
{ |
2401 |
for( i = nMinGlyphPos; i < nEndGlyphPos; ++i ) |
2427 |
nSpaceAdded = mpJustifications[ i ] - mpGlyphAdvances[ i ]; |
2402 |
nXOffset += mpJustifications[ i ]; |
2428 |
if ( nSpaceAdded && ((1U << mpVisualAttrs[i].uJustification) & 0xFF89 )) |
|
|
2429 |
{ |
2430 |
if ( i > nMinGlyphPos && ! mpGlyphAdvances [ i - 1 ] && nSpaceAdded >= mnMinKashidaWidth) |
2431 |
{ |
2432 |
// vowel, we do it like ScriptJustify does |
2433 |
// this works great !!! |
2434 |
mpJustifications [ i ] = mpGlyphAdvances [ i ]; |
2435 |
mpJustifications [ i - 1 ] += nSpaceAdded; |
2436 |
} |
2437 |
|
2438 |
if ( nSpaceAdded < mnMinKashidaWidth ) |
2439 |
{ |
2440 |
mpJustifications[ i ] = mpGlyphAdvances[ i ]; // overriding; |
2441 |
/*for ( int j = i; j >= nMinGlyphPos; --j ) |
2442 |
{ |
2443 |
if ( mpVisualAttrs[ j ].uJustification == SCRIPT_JUSTIFY_ARABIC_BLANK ) |
2444 |
{ |
2445 |
mpJustifications [ j ] += nSpaceAdded; // padding a blank instead |
2446 |
nSpaceAdded = 0; |
2447 |
break; |
2448 |
} |
2449 |
}*/ |
2450 |
|
2451 |
// no blank found |
2452 |
// try the other side |
2453 |
for ( int j = i; j < nEndGlyphPos; ++j ) |
2454 |
{ |
2455 |
if ( mpVisualAttrs[ j ].uJustification == SCRIPT_JUSTIFY_ARABIC_BLANK ) |
2456 |
{ |
2457 |
mpJustifications [ j ] += nSpaceAdded; // padding a blank instead |
2458 |
nSpaceAdded = 0; |
2459 |
break; |
2460 |
} |
2461 |
} |
2462 |
|
2463 |
if ( nSpaceAdded ) |
2464 |
{ |
2465 |
// no blank found |
2466 |
// right align |
2467 |
// rVisualItem.mnXOffset += nSpaceAdded; |
2468 |
} |
2469 |
} |
2470 |
} |
2471 |
} |
2472 |
} |
2473 |
} |
2474 |
|
2475 |
|
2403 |
|
2476 |
|
2404 |
// right align the justification-adjusted glyphs in their cells for RTL-items |
2477 |
// right align the justification-adjusted glyphs in their cells for RTL-items |
2405 |
if( bManualCellAlign && rVisualItem.mpScriptItem->a.fRTL && !bHasKashida ) |
2478 |
if( bManualCellAlign && rVisualItem.mpScriptItem->a.fRTL && !bHasKashida ) |
Lines 2454-2459
void UniscribeLayout::Justify( long nNew
Link Here
|
2454 |
nItemWidth = (int)((fStretch - 1.0) * nItemWidth + 0.5); |
2527 |
nItemWidth = (int)((fStretch - 1.0) * nItemWidth + 0.5); |
2455 |
|
2528 |
|
2456 |
SCRIPT_FONTPROPERTIES aFontProperties; |
2529 |
SCRIPT_FONTPROPERTIES aFontProperties; |
|
|
2530 |
aFontProperties.cBytes = sizeof (aFontProperties); // don't forget to initialize |
2457 |
int nMinKashida = 1; |
2531 |
int nMinKashida = 1; |
2458 |
HRESULT nRC = (*pScriptGetFontProperties)( mhDC, &rScriptCache, &aFontProperties ); |
2532 |
HRESULT nRC = (*pScriptGetFontProperties)( mhDC, &rScriptCache, &aFontProperties ); |
2459 |
if( !nRC ) |
2533 |
if( !nRC ) |