const float MAX_FLOAT = std::numeric_limits<float>::max();
const CharacterDirection LTR = false;
const CharacterDirection RTL = !LTR;
-const float LINE_SPACING= 0.f;
+const float LINE_SPACING = 0.f;
+const float MIN_LINE_SIZE = 0.f;
inline bool isEmptyLineAtLast( const Vector<LineRun>& lines, const Vector<LineRun>::Iterator& line )
{
Impl()
: mLayout{ Layout::Engine::SINGLE_LINE_BOX },
mCursorWidth{ 0.f },
- mDefaultLineSpacing{ LINE_SPACING }
+ mDefaultLineSpacing{ LINE_SPACING },
+ mDefaultLineSize{ MIN_LINE_SIZE }
{
}
// Sets the minimum descender.
lineLayout.descender = std::min( lineLayout.descender, fontMetrics.descender );
- // set the line spacing
- lineLayout.lineSpacing = mDefaultLineSpacing;
+ // Sets the line size
+ lineLayout.lineSpacing = mDefaultLineSize - ( lineLayout.ascender + -lineLayout.descender );
+ lineLayout.lineSpacing = lineLayout.lineSpacing < 0.f ? 0.f : lineLayout.lineSpacing;
+
+ // Add the line spacing
+ lineLayout.lineSpacing += mDefaultLineSpacing;
}
/**
const GlyphInfo& glyph = *( glyphsBuffer + i );
Vector2& position = *( glyphPositionsBuffer + i );
- position.x = std::roundf( penX + glyph.xBearing );
+ position.x = penX + glyph.xBearing;
position.y = -glyph.yBearing;
penX += ( glyph.advance + interGlyphExtraAdvance );
const GlyphInfo& glyph = *( glyphsBuffer + glyphIndex );
Vector2& position = *( glyphPositionsBuffer + glyphIndex - layoutParameters.startGlyphIndex );
- position.x = std::round( penX + glyph.xBearing );
+ position.x = penX + glyph.xBearing;
position.y = -glyph.yBearing;
penX += ( glyph.advance + layoutParameters.interGlyphExtraAdvance );
lineRun.glyphRun.numberOfGlyphs = layout.numberOfGlyphs;
lineRun.characterRun.characterIndex = layout.characterIndex;
lineRun.characterRun.numberOfCharacters = layout.numberOfCharacters;
- lineRun.lineSpacing = mDefaultLineSpacing;
+ lineRun.width = layout.length;
+ lineRun.extraLength = std::ceil( layout.whiteSpaceLengthEndOfLine );
- if( isLastLine && !layoutParameters.isLastNewParagraph )
- {
- lineRun.width = layout.length;
- if( LTR == layout.direction )
- {
- lineRun.width += layout.whiteSpaceLengthEndOfLine;
- lineRun.extraLength = 0.f;
- }
- else
- {
- lineRun.extraLength = layout.whiteSpaceLengthEndOfLine;
- }
- }
- else
- {
- lineRun.width = layout.length;
- lineRun.extraLength = std::ceil( layout.whiteSpaceLengthEndOfLine );
- }
// Rounds upward to avoid a non integer size.
lineRun.width = std::ceil( lineRun.width );
lineRun.direction = layout.direction;
lineRun.ellipsis = false;
+ lineRun.lineSpacing = mDefaultLineSize - ( lineRun.ascender + -lineRun.descender );
+ lineRun.lineSpacing = lineRun.lineSpacing < 0.f ? 0.f : lineRun.lineSpacing;
+
+ lineRun.lineSpacing += mDefaultLineSpacing;
+
+
// Update the actual size.
if( lineRun.width > layoutSize.width )
{
lineRun.alignmentOffset = 0.f;
lineRun.direction = LTR;
lineRun.ellipsis = false;
- lineRun.lineSpacing = mDefaultLineSpacing;
+
+ lineRun.lineSpacing = mDefaultLineSize - ( lineRun.ascender + -lineRun.descender );
+ lineRun.lineSpacing = lineRun.lineSpacing < 0.f ? 0.f : lineRun.lineSpacing;
+
+ lineRun.lineSpacing += mDefaultLineSpacing;
layoutSize.height += ( lineRun.ascender + -lineRun.descender ) + lineRun.lineSpacing;
}
return false;
}
- // Set the line position. Discard if ellipsis is enabled and the position exceeds the boundaries
+ // Set the line position. DISCARD if ellipsis is enabled and the position exceeds the boundaries
// of the box.
penY += layout.ascender;
// Updates the vertical pen's position.
penY += -layout.descender + layout.lineSpacing + mDefaultLineSpacing;
+ // If there is a defaultLineSize, updates the pen's position.
+ if( mDefaultLineSize > 0.f )
+ {
+ float lineSpacing = mDefaultLineSize - ( layout.ascender + -layout.descender );
+ lineSpacing = lineSpacing < 0.f ? 0.f : lineSpacing;
+ penY += lineSpacing;
+ }
// Increase the glyph index.
index = nextIndex;
Type mLayout;
float mCursorWidth;
float mDefaultLineSpacing;
+ float mDefaultLineSize;
IntrusivePtr<Metrics> mMetrics;
};
return mImpl->mDefaultLineSpacing;
}
+void Engine::SetDefaultLineSize( float lineSize )
+{
+ mImpl->mDefaultLineSize = lineSize;
+}
+
+float Engine::GetDefaultLineSize() const
+{
+ return mImpl->mDefaultLineSize;
+}
+
} // namespace Layout
} // namespace Text