+ // TODO - Rewrite this to handle bidi
+ bool SingleLineLayout( const LayoutParameters& layoutParameters,
+ Vector<Vector2>& glyphPositions,
+ Vector<LineRun>& lines,
+ Size& actualSize )
+ {
+ LineLayout layout;
+ layout.glyphIndex = 0u;
+ GetLineLayoutForBox( layoutParameters,
+ layout );
+
+ // Create a line run and add it to the lines.
+ const GlyphIndex lastGlyphIndex = layoutParameters.totalNumberOfGlyphs - 1u;
+
+ LineRun lineRun;
+ lineRun.glyphIndex = 0u;
+ lineRun.numberOfGlyphs = layoutParameters.totalNumberOfGlyphs;
+ lineRun.characterRun.characterIndex = 0u;
+ lineRun.characterRun.numberOfCharacters = *( layoutParameters.glyphsToCharactersBuffer + lastGlyphIndex ) + *( layoutParameters.charactersPerGlyphBuffer + lastGlyphIndex );
+ lineRun.lineSize.width = layout.length;
+ lineRun.lineSize.height = layout.height;
+
+ lines.PushBack( lineRun );
+
+ // Update the actual size.
+ actualSize.width = layout.length;
+ actualSize.height = layout.height;
+
+ float penX = 0.f;
+ float penY = layout.height;
+
+ Vector2* glyphPositionsBuffer = glyphPositions.Begin();
+ for( GlyphIndex glyphIndex = 0u; glyphIndex < layout.numberOfGlyphs; ++glyphIndex )
+ {
+ const GlyphInfo& glyph = *( layoutParameters.glyphsBuffer + glyphIndex );
+ Vector2& position = *( glyphPositionsBuffer + glyphIndex );
+
+ position.x = penX + glyph.xBearing;
+ position.y = penY - glyph.yBearing;
+
+ penX += glyph.advance;
+ }
+
+ return true;
+ }
+
+ // TODO - Rewrite this to handle bidi
+ bool MultiLineLayout( const LayoutParameters& layoutParameters,
+ Vector<Vector2>& glyphPositions,
+ Vector<LineRun>& lines,
+ Size& actualSize )
+ {
+ float penY = 0.f;
+ for( GlyphIndex index = 0u; index < layoutParameters.totalNumberOfGlyphs; )
+ {
+ float penX = 0.f;
+
+ // Get the layout for the line.
+ LineLayout layout;
+ layout.glyphIndex = index;
+ GetMultiLineLayoutForBox( layoutParameters,
+ layout );
+
+ if( 0u == layout.numberOfGlyphs )
+ {
+ // The width is too small and no characters are laid-out.
+ return false;
+ }
+
+ // Create a line run and add it to the lines.
+ const GlyphIndex lastGlyphIndex = index + layout.numberOfGlyphs - 1u;
+
+ LineRun lineRun;
+ lineRun.glyphIndex = index;
+ lineRun.numberOfGlyphs = layout.numberOfGlyphs;
+ lineRun.characterRun.characterIndex = *( layoutParameters.glyphsToCharactersBuffer + index );
+ lineRun.characterRun.numberOfCharacters = ( *( layoutParameters.glyphsToCharactersBuffer + lastGlyphIndex ) + *( layoutParameters.charactersPerGlyphBuffer + lastGlyphIndex ) ) - lineRun.characterRun.characterIndex;
+ lineRun.lineSize.width = layout.length;
+ lineRun.lineSize.height = layout.height;
+
+ lines.PushBack( lineRun );
+
+ // Update the actual size.
+ if( layout.length > actualSize.width )
+ {
+ actualSize.width = layout.length;