- In a text with different scripts, the text is shaped in runs of
characters with the same script. Adpator return the character
index of each glyph starting always by 0. Toolkit was not
updating the indices given by the adaptor for the runs after the
first one.
- characterIndices renamed to glyphsToCharactersMap.
- Adaptor retrieves the glyphsToCharactersMap. Toolkit was setting
the glyphsToCharactersMap to the charactersPerGlyph vector.
Change-Id: I9c74741fadb6d68bca29629ff79ed7bc48dd2840
Signed-off-by: Victor Cebollada <v.cebollada@samsung.com>
const Vector<ScriptRun>& scripts,
const Vector<FontRun>& fonts,
Vector<GlyphInfo>& glyphs,
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();
Vector<Length>& charactersPerGlyph )
{
const Length numberOfCharacters = text.Count();
Length numberOfGlyphsReserved = static_cast<Length>( numberOfCharacters * 1.3f );
glyphs.Resize( numberOfGlyphsReserved );
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;
// The actual number of glyphs.
Length totalNumberOfGlyphs = 0u;
const Character* textBuffer = text.Begin();
const LineBreakInfo* lineBreakInfoBuffer = lineBreakInfo.Begin();
GlyphInfo* glyphsBuffer = glyphs.Begin();
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; )
// 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 );
// 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();
// 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,
}
// 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 )
// Update the iterators to get the next font or script run.
if( currentIndex == fontRun.characterRun.characterIndex + fontRun.characterRun.numberOfCharacters )
previousIndex = mustBreak ? currentIndex + 1u : currentIndex;
}
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 );
// 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,
}
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[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,
* @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,
const Vector<ScriptRun>& scripts,
const Vector<FontRun>& fonts,
Vector<GlyphInfo>& glyphs,
- Vector<CharacterIndex>& characterIndices,
+ Vector<CharacterIndex>& glyphToCharacterMap,
Vector<Length>& charactersPerGlyph );
/**
Vector<Length>& charactersPerGlyph );
/**
}
Vector<GlyphInfo> glyphs;
}
Vector<GlyphInfo> glyphs;
- Vector<CharacterIndex> characterIndices;
+ Vector<CharacterIndex> glyphsToCharactersMap;
Vector<Length> charactersPerGlyph;
if( SHAPE_TEXT & operations )
{
Vector<Length> charactersPerGlyph;
if( SHAPE_TEXT & operations )
{
const Length numberOfGlyphs = mImpl->mVisualModel->GetNumberOfGlyphs();
glyphs.Resize( numberOfGlyphs );
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 );
charactersPerGlyph.Resize( numberOfGlyphs );
mImpl->mVisualModel->GetGlyphs( glyphs.Begin(),
0u,
numberOfGlyphs );
- mImpl->mVisualModel->GetGlyphToCharacterMap( characterIndices.Begin(),
+ mImpl->mVisualModel->GetGlyphToCharacterMap( glyphsToCharactersMap.Begin(),
// Update the visual model
mImpl->mLayoutEngine.UpdateVisualModel( size,
glyphs,
// Update the visual model
mImpl->mLayoutEngine.UpdateVisualModel( size,
glyphs,
charactersPerGlyph,
*mImpl->mVisualModel );
charactersPerGlyph,
*mImpl->mVisualModel );