- // firstPenX, penY and firstPenSet are used to position the ellipsis glyph if needed.
- float firstPenX = 0.f; // Used if rtl text is elided.
- float penY = 0.f;
- bool firstPenSet = false;
-
- // Add the ellipsis glyph.
- bool inserted = false;
- float removedGlypsWidth = 0.f;
- Length numberOfRemovedGlyphs = 0u;
- GlyphIndex index = numberOfLaidOutGlyphs - 1u;
-
- // The ellipsis glyph has to fit in the place where the last glyph(s) is(are) removed.
- while( !inserted )
+ // 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 )