const Vector<ScriptRun>& scripts,
const Vector<FontRun>& fonts,
Vector<GlyphInfo>& glyphs,
- Vector<CharacterIndex>& characterIndices,
+ Vector<CharacterIndex>& glyphToCharacterMap,
Vector<Length>& charactersPerGlyph )
{
const Length numberOfCharacters = text.Count();
Length numberOfGlyphsReserved = static_cast<Length>( numberOfCharacters * 1.3f );
glyphs.Resize( numberOfGlyphsReserved );
- charactersPerGlyph.Resize( numberOfGlyphsReserved );
+ glyphToCharacterMap.Resize( numberOfGlyphsReserved );
// The actual number of glyphs.
Length totalNumberOfGlyphs = 0u;
const Character* textBuffer = text.Begin();
const LineBreakInfo* lineBreakInfoBuffer = lineBreakInfo.Begin();
GlyphInfo* glyphsBuffer = glyphs.Begin();
- Length* charactersPerGlyphBuffer = charactersPerGlyph.Begin();
+ CharacterIndex* glyphToCharacterMapBuffer = glyphToCharacterMap.Begin();
// Traverse the characters and shape the text.
for( previousIndex = 0; previousIndex < numberOfCharacters; )
// Resize the vectors to get enough space.
numberOfGlyphsReserved = static_cast<Length>( totalNumberOfGlyphs * 1.3f );
glyphs.Resize( numberOfGlyphsReserved );
- charactersPerGlyph.Resize( numberOfGlyphsReserved );
+ glyphToCharacterMap.Resize( numberOfGlyphsReserved );
// Iterators are not valid anymore, set them again.
glyphsBuffer = glyphs.Begin();
- charactersPerGlyphBuffer = charactersPerGlyph.Begin();
+ glyphToCharacterMapBuffer = glyphToCharacterMap.Begin();
}
// Retrieve the glyphs and the glyph to character conversion map.
shaping.GetGlyphs( glyphsBuffer + glyphIndex,
- charactersPerGlyphBuffer + glyphIndex );
+ glyphToCharacterMapBuffer + glyphIndex );
+
+ // Update indices.
+ if( 0u != glyphIndex )
+ {
+ for( Length index = glyphIndex; index < glyphIndex + numberOfGlyphs; ++index )
+ {
+ CharacterIndex& characterIndex = *( glyphToCharacterMapBuffer + index );
+ characterIndex += previousIndex;
+ }
+ }
// Update the iterators to get the next font or script run.
if( currentIndex == fontRun.characterRun.characterIndex + fontRun.characterRun.numberOfCharacters )
previousIndex = mustBreak ? currentIndex + 1u : currentIndex;
}
- characterIndices.Reserve( totalNumberOfGlyphs );
- CharacterIndex characterIndex = 0u;
- characterIndices.PushBack( characterIndex );
- for( Length index = 0u, length = totalNumberOfGlyphs - 1u; index < length; ++index )
+ // Add the number of characters per glyph.
+ charactersPerGlyph.Reserve( totalNumberOfGlyphs );
+ previousIndex = 0u;
+ for( Length index = 1u; index < totalNumberOfGlyphs; ++index )
{
- characterIndex += *( charactersPerGlyphBuffer + index );
- characterIndices.PushBack( characterIndex );
+ const CharacterIndex characterIndex = *( glyphToCharacterMapBuffer + index );
+
+ charactersPerGlyph.PushBack( characterIndex - previousIndex );
+
+ previousIndex = characterIndex;
}
+ charactersPerGlyph.PushBack( numberOfCharacters - previousIndex );
+
// Resize the vectors to set the right number of items.
glyphs.Resize( totalNumberOfGlyphs );
- // characterIndices.Resize( totalNumberOfGlyphs );
- charactersPerGlyph.Resize( totalNumberOfGlyphs );
+ glyphToCharacterMap.Resize( totalNumberOfGlyphs );
}
void ShapeText( const LogicalModel& logicalModel,
* @param[in] scripts Vector containing the script runs for the whole text.
* @param[in] fonts Vector with validated fonts.
* @param[out] glyphs Vector of glyphs in the visual order.
- * @param[out] characterIndices Vector containing the first character in the logical model that each glyph relates to.
+ * @param[out] glyphToCharacterMap Vector containing the first character in the logical model that each glyph relates to.
* @param[out] charactersPerGlyph Vector containing the number of characters per glyph.
*/
void ShapeText( const Vector<Character>& text,
const Vector<ScriptRun>& scripts,
const Vector<FontRun>& fonts,
Vector<GlyphInfo>& glyphs,
- Vector<CharacterIndex>& characterIndices,
+ Vector<CharacterIndex>& glyphToCharacterMap,
Vector<Length>& charactersPerGlyph );
/**
}
Vector<GlyphInfo> glyphs;
- Vector<CharacterIndex> characterIndices;
+ Vector<CharacterIndex> glyphsToCharactersMap;
Vector<Length> charactersPerGlyph;
if( SHAPE_TEXT & operations )
{
scripts,
fonts,
glyphs,
- characterIndices,
+ glyphsToCharactersMap,
charactersPerGlyph );
}
const Length numberOfGlyphs = mImpl->mVisualModel->GetNumberOfGlyphs();
glyphs.Resize( numberOfGlyphs );
- characterIndices.Resize( numberOfGlyphs );
+ glyphsToCharactersMap.Resize( numberOfGlyphs );
charactersPerGlyph.Resize( numberOfGlyphs );
mImpl->mVisualModel->GetGlyphs( glyphs.Begin(),
0u,
numberOfGlyphs );
- mImpl->mVisualModel->GetGlyphToCharacterMap( characterIndices.Begin(),
+ mImpl->mVisualModel->GetGlyphToCharacterMap( glyphsToCharactersMap.Begin(),
0u,
numberOfGlyphs );
// Update the visual model
mImpl->mLayoutEngine.UpdateVisualModel( size,
glyphs,
- characterIndices,
+ glyphsToCharactersMap,
charactersPerGlyph,
*mImpl->mVisualModel );