1 --- vcl/source/glyphs/gcach_layout.cxx 2009-08-11 12:51:42.000000000 +0200
2 +++ vcl/source/glyphs/gcach_layout.cxx 2009-08-13 15:51:34.000000000 +0200
4 #include <vcl/sallayout.hxx>
5 #include <vcl/salgdi.hxx>
7 +#include <unicode/uchar.h>
9 #include <vcl/svapp.hxx>
11 #include <sal/alloca.h>
16 - for( int nCharPos = -1; rArgs.GetNextPos( &nCharPos, &bRightToLeft ); )
19 + bool hasNextPos = rArgs.GetNextPos( &nCharPos, &bRightToLeft );
20 + bool isAfterEnd = false;
21 + bool bFoundPrintable = false;
22 + while ( hasNextPos || ( isAfterEnd && ( !bFoundPrintable || nCharPos < rArgs.mnLength ) ) )
24 sal_UCS4 cChar = rArgs.mpStr[ nCharPos ];
25 if( (cChar >= 0xD800) && (cChar <= 0xDFFF) )
29 cChar = GetMirroredChar( cChar );
30 - int nGlyphIndex = rFont.GetGlyphIndex( cChar );
31 - // when glyph fallback is needed update LayoutArgs
32 - if( !nGlyphIndex ) {
33 - rArgs.NeedFallback( nCharPos, bRightToLeft );
34 - if( cChar >= 0x10000 ) // handle surrogate pairs
35 - rArgs.NeedFallback( nCharPos+1, bRightToLeft );
38 - // apply pair kerning to prev glyph if requested
39 - if( SAL_LAYOUT_KERNING_PAIRS & rArgs.mnFlags )
40 + // Only handle the printable characters
41 + if ( u_isprint( UChar32( cChar ) ) )
43 - int nKernValue = rFont.GetGlyphKernValue( nOldGlyphId, nGlyphIndex );
44 - nGlyphWidth += nKernValue;
45 - aPrevItem.mnNewWidth = nGlyphWidth;
46 + int nGlyphIndex = rFont.GetGlyphIndex( cChar );
47 + // when glyph fallback is needed update LayoutArgs
50 + rArgs.NeedFallback( nCharPos, bRightToLeft );
51 + if( cChar >= 0x10000 ) // handle surrogate pairs
52 + rArgs.NeedFallback( nCharPos+1, bRightToLeft );
55 + // apply pair kerning to prev glyph if requested
56 + if( SAL_LAYOUT_KERNING_PAIRS & rArgs.mnFlags )
58 + int nKernValue = rFont.GetGlyphKernValue( nOldGlyphId, nGlyphIndex );
59 + nGlyphWidth += nKernValue;
60 + aPrevItem.mnNewWidth = nGlyphWidth;
63 + // finish previous glyph
64 + if( nOldGlyphId >= 0 )
66 + rLayout.AppendGlyph( aPrevItem );
69 + aNewPos.X() += nGlyphWidth;
71 + // prepare GlyphItem for appending it in next round
74 + nOldGlyphId = nGlyphIndex;
75 + const GlyphMetric& rGM = rFont.GetGlyphMetric( nGlyphIndex );
76 + nGlyphWidth = rGM.GetCharWidth();
77 + int nGlyphFlags = bRightToLeft ? GlyphItem::IS_RTL_GLYPH : 0;
79 + aPrevItem = GlyphItem( nCharPos, nGlyphIndex, aNewPos, nGlyphFlags, nGlyphWidth );
82 + // No need to signal the printable chars before the end of the runs
83 + bFoundPrintable = isAfterEnd;
86 - // finish previous glyph
87 - if( nOldGlyphId >= 0 )
88 - rLayout.AppendGlyph( aPrevItem );
89 - aNewPos.X() += nGlyphWidth;
91 - // prepare GlyphItem for appending it in next round
92 - nOldGlyphId = nGlyphIndex;
93 - const GlyphMetric& rGM = rFont.GetGlyphMetric( nGlyphIndex );
94 - nGlyphWidth = rGM.GetCharWidth();
95 - int nGlyphFlags = bRightToLeft ? GlyphItem::IS_RTL_GLYPH : 0;
96 - aPrevItem = GlyphItem( nCharPos, nGlyphIndex, aNewPos, nGlyphFlags, nGlyphWidth );
99 + // Check if we have some more characters
100 + // Get the next position
101 + hasNextPos = rArgs.GetNextPos( &nCharPos, &bRightToLeft );
103 + if ( !hasNextPos && nCharPos < rArgs.mnLength )
109 + if ( bFoundPrintable )
111 + isAfterEnd = false;
117 // append last glyph item if any