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 shaper interface
[platform/core/uifw/dali-toolkit.git]
/
dali-toolkit
/
public-api
/
text
/
shaper.cpp
diff --git
a/dali-toolkit/public-api/text/shaper.cpp
b/dali-toolkit/public-api/text/shaper.cpp
index
54444ac
..
376a1b7
100644
(file)
--- a/
dali-toolkit/public-api/text/shaper.cpp
+++ b/
dali-toolkit/public-api/text/shaper.cpp
@@
-18,10
+18,13
@@
// CLASS HEADER
#include <dali-toolkit/public-api/text/shaper.h>
// CLASS HEADER
#include <dali-toolkit/public-api/text/shaper.h>
-//
IN
TERNAL INCLUDES
+//
EX
TERNAL INCLUDES
#include <dali/public-api/text-abstraction/shaping.h>
#include <dali/public-api/text-abstraction/shaping.h>
+
+// INTERNAL INCLUDES
#include <dali-toolkit/public-api/text/font-run.h>
#include <dali-toolkit/public-api/text/logical-model.h>
#include <dali-toolkit/public-api/text/font-run.h>
#include <dali-toolkit/public-api/text/logical-model.h>
+#include <dali-toolkit/public-api/text/script.h>
#include <dali-toolkit/public-api/text/script-run.h>
#include <dali-toolkit/public-api/text/visual-model.h>
#include <dali-toolkit/public-api/text/script-run.h>
#include <dali-toolkit/public-api/text/visual-model.h>
@@
-56,14
+59,15
@@
void ShapeText( const Vector<Character>& text,
return;
}
return;
}
+#ifdef DEBUG_ENABLED
const Length numberOfFontRuns = fonts.Count();
const Length numberOfFontRuns = fonts.Count();
+ const Length numberOfScriptRuns = scripts.Count();
+#endif
DALI_ASSERT_DEBUG( ( 0u != numberOfFontRuns ) &&
( numberOfCharacters == fonts[numberOfFontRuns - 1u].characterRun.characterIndex + fonts[numberOfFontRuns - 1u].characterRun.numberOfCharacters ) &&
"Toolkit::Text::ShapeText. All characters must have a font set." );
DALI_ASSERT_DEBUG( ( 0u != numberOfFontRuns ) &&
( numberOfCharacters == fonts[numberOfFontRuns - 1u].characterRun.characterIndex + fonts[numberOfFontRuns - 1u].characterRun.numberOfCharacters ) &&
"Toolkit::Text::ShapeText. All characters must have a font set." );
- const Length numberOfScriptRuns = scripts.Count();
-
DALI_ASSERT_DEBUG( ( 0u != numberOfScriptRuns ) &&
( numberOfCharacters == scripts[numberOfScriptRuns - 1u].characterRun.characterIndex + scripts[numberOfScriptRuns - 1u].characterRun.numberOfCharacters ) &&
"Toolkit::Text::ShapeText. All characters must have a script set." );
DALI_ASSERT_DEBUG( ( 0u != numberOfScriptRuns ) &&
( numberOfCharacters == scripts[numberOfScriptRuns - 1u].characterRun.characterIndex + scripts[numberOfScriptRuns - 1u].characterRun.numberOfCharacters ) &&
"Toolkit::Text::ShapeText. All characters must have a script set." );
@@
-78,9
+82,6
@@
void ShapeText( const Vector<Character>& text,
Vector<FontRun>::ConstIterator fontRunIt = fonts.Begin();
Vector<ScriptRun>::ConstIterator scriptRunIt = scripts.Begin();
Vector<FontRun>::ConstIterator fontRunIt = fonts.Begin();
Vector<ScriptRun>::ConstIterator scriptRunIt = scripts.Begin();
- // The line must break token converted to LineBreakInfo to be compared and avoid a compile error.
- const LineBreakInfo MUST_BREAK = static_cast<LineBreakInfo>( TextAbstraction::LINE_MUST_BREAK );
-
// Index to the the next one to be shaped. Is pointing the character after the last one it was shaped.
CharacterIndex previousIndex = 0u;
// Index to the the next one to be shaped. Is pointing the character after the last one it was shaped.
CharacterIndex previousIndex = 0u;
@@
-99,6
+100,11
@@
void ShapeText( const Vector<Character>& text,
// The actual number of glyphs.
Length totalNumberOfGlyphs = 0u;
// The actual number of glyphs.
Length totalNumberOfGlyphs = 0u;
+ const Character* textBuffer = text.Begin();
+ const LineBreakInfo* lineBreakInfoBuffer = lineBreakInfo.Begin();
+ GlyphInfo* glyphsBuffer = glyphs.Begin();
+ Length* charactersPerGlyphBuffer = charactersPerGlyph.Begin();
+
// Traverse the characters and shape the text.
for( previousIndex = 0; previousIndex < numberOfCharacters; )
{
// Traverse the characters and shape the text.
for( previousIndex = 0; previousIndex < numberOfCharacters; )
{
@@
-114,18
+120,28
@@
void ShapeText( const Vector<Character>& text,
scriptRun.characterRun.characterIndex + scriptRun.characterRun.numberOfCharacters );
// Check if there is a line must break.
scriptRun.characterRun.characterIndex + scriptRun.characterRun.numberOfCharacters );
// Check if there is a line must break.
+ bool mustBreak = false;
for( CharacterIndex index = previousIndex; index < currentIndex; ++index )
{
for( CharacterIndex index = previousIndex; index < currentIndex; ++index )
{
- if( MUST_BREAK == lineBreakInfo.Begin() + index )
+ mustBreak = TextAbstraction::LINE_MUST_BREAK == *( lineBreakInfoBuffer + index );
+ if( mustBreak )
{
currentIndex = index;
break;
}
}
{
currentIndex = index;
break;
}
}
+ // Check if the current index is a white space. Do not want to shape a \n.
+ // The last character is always a must-break even if it's not a \n.
+ Length numberOfCharactersToShape = currentIndex - previousIndex;
+ if( mustBreak && !IsWhiteSpace( *( textBuffer + currentIndex ) ) )
+ {
+ ++numberOfCharactersToShape;
+ }
+
// Shape the text for the current chunk.
// Shape the text for the current chunk.
- const Length numberOfGlyphs = shaping.Shape( text
.Begin()
+ previousIndex,
-
currentIndex - previousIndex
,
+ const Length numberOfGlyphs = shaping.Shape( text
Buffer
+ previousIndex,
+
numberOfCharactersToShape
,
currentFontId,
currentScript );
currentFontId,
currentScript );
@@
-138,11
+154,15
@@
void ShapeText( const Vector<Character>& text,
numberOfGlyphsReserved = static_cast<Length>( totalNumberOfGlyphs * 1.3f );
glyphs.Resize( numberOfGlyphsReserved );
charactersPerGlyph.Resize( numberOfGlyphsReserved );
numberOfGlyphsReserved = static_cast<Length>( totalNumberOfGlyphs * 1.3f );
glyphs.Resize( numberOfGlyphsReserved );
charactersPerGlyph.Resize( numberOfGlyphsReserved );
+
+ // Iterators are not valid anymore, set them again.
+ glyphsBuffer = glyphs.Begin();
+ charactersPerGlyphBuffer = charactersPerGlyph.Begin();
}
// Retrieve the glyphs and the glyph to character conversion map.
}
// Retrieve the glyphs and the glyph to character conversion map.
- shaping.GetGlyphs( glyphs
.Begin()
+ glyphIndex,
- charactersPerGlyph
.Begin()
+ glyphIndex );
+ shaping.GetGlyphs( glyphs
Buffer
+ glyphIndex,
+ charactersPerGlyph
Buffer
+ glyphIndex );
// Update the iterators to get the next font or script run.
if( currentIndex == fontRun.characterRun.characterIndex + fontRun.characterRun.numberOfCharacters )
// Update the iterators to get the next font or script run.
if( currentIndex == fontRun.characterRun.characterIndex + fontRun.characterRun.numberOfCharacters )
@@
-154,8
+174,8
@@
void ShapeText( const Vector<Character>& text,
++scriptRunIt;
}
++scriptRunIt;
}
- // Update the previous index.
- previousIndex = currentIndex;
+ // Update the previous index.
Jumps the \n if needed.
+ previousIndex =
mustBreak ? currentIndex + 1u :
currentIndex;
}
characterIndices.Reserve( totalNumberOfGlyphs );
}
characterIndices.Reserve( totalNumberOfGlyphs );
@@
-163,7
+183,7
@@
void ShapeText( const Vector<Character>& text,
characterIndices.PushBack( characterIndex );
for( Length index = 0u, length = totalNumberOfGlyphs - 1u; index < length; ++index )
{
characterIndices.PushBack( characterIndex );
for( Length index = 0u, length = totalNumberOfGlyphs - 1u; index < length; ++index )
{
- characterIndex += *( charactersPerGlyph
.Begin()
+ index );
+ characterIndex += *( charactersPerGlyph
Buffer
+ index );
characterIndices.PushBack( characterIndex );
}
characterIndices.PushBack( characterIndex );
}
@@
-173,6
+193,14
@@
void ShapeText( const Vector<Character>& text,
charactersPerGlyph.Resize( totalNumberOfGlyphs );
}
charactersPerGlyph.Resize( totalNumberOfGlyphs );
}
+void ShapeText( const LogicalModel& logicalModel,
+ VisualModel& visualModel,
+ CharacterIndex characterIndex,
+ Length numberOfCharactersToRemove,
+ Length numberOfCharactersToInsert )
+{
+}
+
} // namespace Text
} // namespace Toolkit
} // namespace Text
} // namespace Toolkit