+ modelCharactersPerGlyph.Resize( numberOfGlyphs );
+ memcpy( modelCharactersPerGlyph.Begin(), charactersPerGlyph, numberOfGlyphs * sizeof( Length ) );
+
+ // Build the characters to glyph conversion table.
+
+ // 1) Reserve some space for the characters to avoid reallocations.
+ modelCharactersToGlyph.Reserve( static_cast<Length> ( static_cast<float>( numberOfGlyphs ) * 1.3f ) );
+
+ // 2) Traverse the glyphs and set the glyph indices.
+ GlyphIndex glyphIndex = 0u;
+ Length totalNumberOfCharacters = 0u;
+ for( Vector<Length>::ConstIterator it = modelCharactersPerGlyph.Begin(),
+ endIt = modelCharactersPerGlyph.End();
+ it != endIt;
+ ++it, ++glyphIndex )
+ {
+ const Length numberOfCharacters = *it;
+
+ for( Length index = 0u; index < numberOfCharacters; ++index, ++totalNumberOfCharacters )
+ {
+ modelCharactersToGlyph.PushBack( glyphIndex );
+ }
+ }