projects
/
platform
/
core
/
uifw
/
dali-toolkit.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Text improvement
[platform/core/uifw/dali-toolkit.git]
/
dali-toolkit
/
internal
/
text
/
layouts
/
layout-engine.cpp
diff --git
a/dali-toolkit/internal/text/layouts/layout-engine.cpp
b/dali-toolkit/internal/text/layouts/layout-engine.cpp
index
f97a8ea
..
5594c01
100755
(executable)
--- a/
dali-toolkit/internal/text/layouts/layout-engine.cpp
+++ b/
dali-toolkit/internal/text/layouts/layout-engine.cpp
@@
-117,26
+117,31
@@
struct Engine::Impl
/**
* @brief Updates the line ascender and descender with the metrics of a new font.
*
/**
* @brief Updates the line ascender and descender with the metrics of a new font.
*
- * @param[in]
fontId The id
of the new font.
+ * @param[in]
glyphMetrics The metrics
of the new font.
* @param[in,out] lineLayout The line layout.
*/
* @param[in,out] lineLayout The line layout.
*/
- void UpdateLineHeight(
FontId fontId
, LineLayout& lineLayout )
+ void UpdateLineHeight(
const GlyphMetrics& glyphMetrics
, LineLayout& lineLayout )
{
Text::FontMetrics fontMetrics;
{
Text::FontMetrics fontMetrics;
- mMetrics->GetFontMetrics( fontId, fontMetrics );
-
- // Sets the maximum ascender.
- if( fontMetrics.ascender > lineLayout.ascender )
+ if( 0u != glyphMetrics.fontId )
{
{
-
lineLayout.ascender = fontMetrics.ascender
;
+
mMetrics->GetFontMetrics( glyphMetrics.fontId, fontMetrics )
;
}
}
-
- // Sets the minimum descender.
- if( fontMetrics.descender < lineLayout.descender )
+ else
{
{
- lineLayout.descender = fontMetrics.descender;
+ fontMetrics.ascender = glyphMetrics.fontHeight;
+ fontMetrics.descender = 0.f;
+ fontMetrics.height = fontMetrics.ascender;
+ fontMetrics.underlinePosition = 0.f;
+ fontMetrics.underlineThickness = 1.f;
}
}
+ // Sets the maximum ascender.
+ lineLayout.ascender = std::max( lineLayout.ascender, fontMetrics.ascender );
+
+ // Sets the minimum descender.
+ lineLayout.descender = std::min( lineLayout.descender, fontMetrics.descender );
+
// set the line spacing
lineLayout.lineSpacing = mDefaultLineSpacing;
}
// set the line spacing
lineLayout.lineSpacing = mDefaultLineSpacing;
}
@@
-158,22
+163,18
@@
struct Engine::Impl
{
lineLayout.length += lineLayout.wsLengthEndOfLine;
{
lineLayout.length += lineLayout.wsLengthEndOfLine;
-
lineLayout.wsLengthEndOfLine = tmpLineLayout.wsLengthEndOfLine;
+ lineLayout.wsLengthEndOfLine = tmpLineLayout.wsLengthEndOfLine;
}
else
{
lineLayout.wsLengthEndOfLine += tmpLineLayout.wsLengthEndOfLine;
}
}
else
{
lineLayout.wsLengthEndOfLine += tmpLineLayout.wsLengthEndOfLine;
}
- if( tmpLineLayout.ascender > lineLayout.ascender )
- {
- lineLayout.ascender = tmpLineLayout.ascender;
- }
+ // Sets the maximum ascender.
+ lineLayout.ascender = std::max( lineLayout.ascender, tmpLineLayout.ascender );
- if( tmpLineLayout.descender < lineLayout.descender )
- {
- lineLayout.descender = tmpLineLayout.descender;
- }
+ // Sets the minimum descender.
+ lineLayout.descender = std::min( lineLayout.descender, tmpLineLayout.descender );
}
/**
}
/**
@@
-239,7
+240,7
@@
struct Engine::Impl
// Calculate the line height if there is no characters.
FontId lastFontId = glyphMetrics.fontId;
// Calculate the line height if there is no characters.
FontId lastFontId = glyphMetrics.fontId;
- UpdateLineHeight(
lastFontId
, tmpLineLayout );
+ UpdateLineHeight(
glyphMetrics
, tmpLineLayout );
bool oneWordLaidOut = false;
bool oneWordLaidOut = false;
@@
-266,7
+267,7
@@
struct Engine::Impl
// If it's different the ascender and descender need to be updated.
if( lastFontId != glyphMetrics.fontId )
{
// If it's different the ascender and descender need to be updated.
if( lastFontId != glyphMetrics.fontId )
{
- UpdateLineHeight( glyphMetrics
.fontId
, tmpLineLayout );
+ UpdateLineHeight( glyphMetrics, tmpLineLayout );
lastFontId = glyphMetrics.fontId;
}
lastFontId = glyphMetrics.fontId;
}
@@
-572,7
+573,7
@@
struct Engine::Impl
const bool ellipsis = isAutoScrollEnabled ? ( penY - layout.descender > layoutParameters.boundingBox.height ) :
( ( penY - layout.descender > layoutParameters.boundingBox.height ) ||
( ( mLayout == SINGLE_LINE_BOX ) &&
const bool ellipsis = isAutoScrollEnabled ? ( penY - layout.descender > layoutParameters.boundingBox.height ) :
( ( penY - layout.descender > layoutParameters.boundingBox.height ) ||
( ( mLayout == SINGLE_LINE_BOX ) &&
-
( layout.extraBearing + layout.length + layout.extraWid
th > layoutParameters.boundingBox.width ) ) );
+
( layout.leng
th > layoutParameters.boundingBox.width ) ) );
if( ellipsis )
{
if( ellipsis )
{
@@
-613,7
+614,7
@@
struct Engine::Impl
lineRun->characterRun.characterIndex = ellipsisLayout.characterIndex;
lineRun->characterRun.numberOfCharacters = ellipsisLayout.numberOfCharacters;
lineRun->width = ellipsisLayout.length;
lineRun->characterRun.characterIndex = ellipsisLayout.characterIndex;
lineRun->characterRun.numberOfCharacters = ellipsisLayout.numberOfCharacters;
lineRun->width = ellipsisLayout.length;
- lineRun->extraLength =
( ellipsisLayout.wsLengthEndOfLine > 0.f ) ? ellipsisLayout.wsLengthEndOfLine - ellipsisLayout.extraWidth : 0.f
;
+ lineRun->extraLength =
std::ceil( ( ellipsisLayout.wsLengthEndOfLine > 0.f ) ? ellipsisLayout.wsLengthEndOfLine - ellipsisLayout.extraWidth : 0.f )
;
lineRun->ascender = ellipsisLayout.ascender;
lineRun->descender = ellipsisLayout.descender;
lineRun->direction = !RTL;
lineRun->ascender = ellipsisLayout.ascender;
lineRun->descender = ellipsisLayout.descender;
lineRun->direction = !RTL;
@@
-679,8
+680,12
@@
struct Engine::Impl
else
{
lineRun.width = layout.extraBearing + layout.length + layout.extraWidth;
else
{
lineRun.width = layout.extraBearing + layout.length + layout.extraWidth;
- lineRun.extraLength =
( layout.wsLengthEndOfLine > 0.f ) ? layout.wsLengthEndOfLine - layout.extraWidth : 0.f
;
+ lineRun.extraLength =
std::ceil( ( layout.wsLengthEndOfLine > 0.f ) ? layout.wsLengthEndOfLine - layout.extraWidth : 0.f )
;
}
}
+
+ // Rounds upward to avoid a non integer size.
+ lineRun.width = std::ceil( lineRun.width );
+
lineRun.ascender = layout.ascender;
lineRun.descender = layout.descender;
lineRun.direction = !RTL;
lineRun.ascender = layout.ascender;
lineRun.descender = layout.descender;
lineRun.direction = !RTL;
@@
-716,7
+721,10
@@
struct Engine::Impl
const GlyphInfo& glyphInfo = *( layoutParameters.glyphsBuffer + layoutParameters.totalNumberOfGlyphs - 1u );
Text::FontMetrics fontMetrics;
const GlyphInfo& glyphInfo = *( layoutParameters.glyphsBuffer + layoutParameters.totalNumberOfGlyphs - 1u );
Text::FontMetrics fontMetrics;
- mMetrics->GetFontMetrics( glyphInfo.fontId, fontMetrics );
+ if( 0u != glyphInfo.fontId )
+ {
+ mMetrics->GetFontMetrics( glyphInfo.fontId, fontMetrics );
+ }
LineRun& lineRun = *( linesBuffer + numberOfLines );
++numberOfLines;
LineRun& lineRun = *( linesBuffer + numberOfLines );
++numberOfLines;
@@
-832,6
+840,9
@@
struct Engine::Impl
UpdateLayoutSize( lines,
layoutSize );
UpdateLayoutSize( lines,
layoutSize );
+ // Rounds upward to avoid a non integer size.
+ layoutSize.height = std::ceil( layoutSize.height );
+
// Nothing else do if there are no glyphs to layout.
return false;
}
// Nothing else do if there are no glyphs to layout.
return false;
}
@@
-910,6
+921,10
@@
struct Engine::Impl
DALI_LOG_INFO( gLogFilter, Debug::Verbose, "<--LayoutText width too small!\n\n" );
lines.Resize( numberOfLines );
DALI_LOG_INFO( gLogFilter, Debug::Verbose, "<--LayoutText width too small!\n\n" );
lines.Resize( numberOfLines );
+
+ // Rounds upward to avoid a non integer size.
+ layoutSize.height = std::ceil( layoutSize.height );
+
return false;
}
return false;
}
@@
-1041,6
+1056,9
@@
struct Engine::Impl
lines.Resize( numberOfLines );
}
lines.Resize( numberOfLines );
}
+ // Rounds upward to avoid a non integer size.
+ layoutSize.height = std::ceil( layoutSize.height );
+
DALI_LOG_INFO( gLogFilter, Debug::Verbose, "<--LayoutText\n\n" );
return true;
DALI_LOG_INFO( gLogFilter, Debug::Verbose, "<--LayoutText\n\n" );
return true;