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;
}
/**
}
else
{
- lineLayout.length = length;
+ lineLayout.length = std::max( length, lineLayout.length );
}
}
}
tmpLineLayout.penX += tmpLineLayout.previousAdvance + tmpLineLayout.whiteSpaceLengthEndOfLine;
tmpLineLayout.previousAdvance = ( glyphMetrics.advance + parameters.interGlyphExtraAdvance );
- tmpLineLayout.length = tmpLineLayout.penX + glyphMetrics.xBearing + glyphMetrics.width;
+ tmpLineLayout.length = std::max( tmpLineLayout.length, tmpLineLayout.penX + glyphMetrics.xBearing + glyphMetrics.width );
// Clear the white space length at the end of the line.
tmpLineLayout.whiteSpaceLengthEndOfLine = 0.f;
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;
}
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