-// TODO - Move this with LayoutEngine
-void Controller::UpdateVisualModel()
-{
- if( mImpl->mLogicalModel &&
- mImpl->mVisualModel )
- {
- const LogicalModel& logicalModel = *(mImpl->mLogicalModel);
- VisualModel& visualModel = *(mImpl->mVisualModel);
-
- TextAbstraction::FontId fontId = mImpl->mFontClient.GetFontId( "/usr/share/fonts/truetype/ubuntu-font-family/UbuntuMono-R.ttf", 13*64 );
-
- const Length characterCount = logicalModel.GetNumberOfCharacters();
-
- Vector<GlyphInfo> glyphs;
- glyphs.Reserve( characterCount );
-
- Vector<CharacterIndex> characterIndices;
- characterIndices.Reserve( characterCount );
-
- std::vector<Length> charactersPerGlyph;
- charactersPerGlyph.assign( characterCount, 1 );
-
- for( unsigned int i=0; i<characterCount; ++i )
- {
- Character charcode;
- logicalModel.GetText( i, &charcode, 1 );
-
- // TODO - Perform shaping to get correct glyph indices
- GlyphIndex glyphIndex = mImpl->mFontClient.GetGlyphIndex( fontId, charcode );
-
- glyphs.PushBack( GlyphInfo(fontId, glyphIndex) );
- characterIndices.PushBack( 1 );
- }
-
- if( mImpl->mFontClient.GetGlyphMetrics( &glyphs[0], glyphs.Size() ) )
- {
- visualModel.SetGlyphs( &glyphs[0],
- &characterIndices[0],
- &charactersPerGlyph[0],
- characterCount );
-
- UpdateVisualPositions();
- }
- }
-}
-
-// TODO - Move this with LayoutEngine
-void Controller::UpdateVisualPositions()
-{
- if( mImpl->mVisualModel )
- {
- VisualModel& visualModel = *(mImpl->mVisualModel);
-
- Length glyphCount = visualModel.GetNumberOfGlyphs();
-
- std::vector<Vector2> glyphPositions;
- glyphPositions.reserve( glyphCount );
-
- if( glyphCount > 0 )
- {
- // FIXME Single font assumption
- Text::FontMetrics fontMetrics;
- GlyphInfo firstGlyph;
- visualModel.GetGlyphs( 0, &firstGlyph, 1 );
- mImpl->mFontClient.GetFontMetrics( firstGlyph.fontId, fontMetrics );
-
- float penX( 0 );
- float penY( fontMetrics.ascender ); // Move to baseline
-
- for( unsigned int i=0; i<glyphCount; ++i )
- {
- GlyphInfo glyph;
- visualModel.GetGlyphs( i, &glyph, 1 );
-
- glyphPositions.push_back( Vector2( penX + glyph.xBearing,
- penY - glyph.yBearing ) );
-
- penX += glyph.advance;
- }
-
- visualModel.SetGlyphPositions( &glyphPositions[0], glyphCount );
- }
- }
-}
-