+ // Retrieve from the visual model the glyphs and positions.
+ mImpl->mVisualModel->GetGlyphs( glyphs,
+ glyphIndex,
+ numberOfLaidOutGlyphs );
+
+ mImpl->mVisualModel->GetGlyphPositions( glyphPositions,
+ glyphIndex,
+ numberOfLaidOutGlyphs );
+
+ // Get the lines for the given range of glyphs.
+ // The lines contain the alignment offset which needs to be added to the glyph's position.
+ LineIndex firstLine = 0u;
+ Length numberOfLines = 0u;
+ mImpl->mVisualModel->GetNumberOfLines( glyphIndex,
+ numberOfLaidOutGlyphs,
+ firstLine,
+ numberOfLines );
+
+ Vector<LineRun> lines;
+ lines.Resize( numberOfLines );
+ LineRun* lineBuffer = lines.Begin();
+
+ mImpl->mVisualModel->GetLinesOfGlyphRange( lineBuffer,
+ glyphIndex,
+ numberOfLaidOutGlyphs );
+
+ // Get the first line for the given glyph range.
+ LineIndex lineIndex = firstLine;
+ LineRun* line = lineBuffer + lineIndex;
+
+ // Index of the last glyph of the line.
+ GlyphIndex lastGlyphIndexOfLine = line->glyphRun.glyphIndex + line->glyphRun.numberOfGlyphs - 1u;
+
+ // Add the alignment offset to the glyph's position.
+
+ float penY = line->ascender;
+ for( Length index = 0u; index < numberOfLaidOutGlyphs; ++index )