logicalModel->mScriptRuns.Clear();
logicalModel->mFontRuns.Clear();
- logicalModel->mWordBreakInfo.Clear();
logicalModel->mBidirectionalParagraphInfo.Clear();
logicalModel->mCharacterDirections.Clear();
logicalModel->mBidirectionalLineInfo.Clear();
const Vector<FontDescriptionRun>& fontDescriptions,
const LayoutOptions& options,
Size& layoutSize,
- LogicalModelPtr& logicalModel,
- VisualModelPtr& visualModel,
+ ModelPtr& textModel,
MetricsPtr& metrics,
bool markupProcessorEnabled )
{
- logicalModel = LogicalModel::New();
- visualModel = VisualModel::New();
+ textModel = Model::New(); ///< Pointer to the text's model.
+ LogicalModelPtr logicalModel = textModel->mLogicalModel;
+ VisualModelPtr visualModel = textModel->mVisualModel;
MarkupProcessData markupProcessData( logicalModel->mColorRuns,
logicalModel->mFontDescriptionRuns,
return;
}
- // Retrieves the word break info. The word break info is used to layout the text (where to wrap the text in lines).
- Vector<WordBreakInfo>& wordBreakInfo = logicalModel->mWordBreakInfo;
- wordBreakInfo.Resize( characterCount );
-
- SetWordBreakInfo( utf32Characters,
- 0u,
- characterCount,
- wordBreakInfo );
-
// 3) Set the script info.
MultilanguageSupport multilanguageSupport = MultilanguageSupport::Get();
layoutEngine.SetLayout( Layout::Engine::MULTI_LINE_BOX );
// Set the layout parameters.
- const Vector<GlyphIndex>& charactersToGlyph = visualModel->mCharactersToGlyph;
- const Vector<Length>& glyphsPerCharacter = visualModel->mGlyphsPerCharacter;
- float outlineWidth = visualModel->GetOutlineWidth();
+ textModel->mHorizontalAlignment = Text::HorizontalAlignment::BEGIN;
+ textModel->mLineWrapMode = LineWrap::WORD;
+ textModel->mIgnoreSpacesAfterText = true;
+ textModel->mMatchSystemLanguageDirection = false;
Layout::Parameters layoutParameters( textArea,
- utf32Characters.Begin(),
- lineBreakInfo.Begin(),
- wordBreakInfo.Begin(),
- ( 0u != characterDirections.Count() ) ? characterDirections.Begin() : NULL,
- glyphs.Begin(),
- glyphsToCharactersMap.Begin(),
- charactersPerGlyph.Begin(),
- charactersToGlyph.Begin(),
- glyphsPerCharacter.Begin(),
- numberOfGlyphs,
- Text::HorizontalAlignment::BEGIN,
- Text::LineWrap::WORD,
- outlineWidth,
- true,
- false );
+ textModel );
Vector<LineRun>& lines = visualModel->mLines;
*/
// INTERNAL INCLUDES
-#include <dali-toolkit/internal/text/logical-model-impl.h>
#include <dali-toolkit/internal/text/metrics.h>
-#include <dali-toolkit/internal/text/visual-model-impl.h>
#include <dali-toolkit/internal/text/text-controller.h>
+#include <dali-toolkit/internal/text/text-model.h>
namespace Dali
{
* @param[in] fontDescriptions The fonts to be used.
* @param[in] options Layout options.
* @param[out] layoutSize The laid-out size.
- * @param[out] logicalModel Pointer to a logical text model instance.
- * @param[out] visualModel Pointer to a visual text model instance.
+ * @param[out] textModel Pointer to a text model instance.
* @param[out] metrics Pointer to a wrapper around FontClient used to get metrics.
* @param[in] markupProcessorEnabled Enable markup processor to use markup text.
*/
const Vector<FontDescriptionRun>& fontDescriptions,
const LayoutOptions& options,
Size& layoutSize,
- LogicalModelPtr& logicalModel,
- VisualModelPtr& visualModel,
+ ModelPtr& textModel,
MetricsPtr& metrics,
bool markupProcessorEnabled );
bool SetBidirectionalInfoTest( const SetBidirectionalInfoData& data )
{
// 1) Create the model.
- LogicalModelPtr logicalModel;
- VisualModelPtr visualModel;
+ ModelPtr textModel;
MetricsPtr metrics;
Size textArea(100.f, 60.f);
Size layoutSize;
fontDescriptions,
options,
layoutSize,
- logicalModel,
- visualModel,
+ textModel,
metrics,
false );
+ LogicalModelPtr logicalModel = textModel->mLogicalModel;
+ VisualModelPtr visualModel = textModel->mVisualModel;
+
// 2) Clear the bidirectional paragraph info data.
Vector<BidirectionalParagraphInfoRun>& bidirectionalInfo = logicalModel->mBidirectionalParagraphInfo;
if( 0u != data.numberOfCharacters )
bool ReorderLinesTest( const ReorderLinesData& data )
{
// 1) Create the model.
- LogicalModelPtr logicalModel;
- VisualModelPtr visualModel;
+ ModelPtr textModel;
MetricsPtr metrics;
Size textArea(100.f, 300.f);
Size layoutSize;
fontDescriptions,
options,
layoutSize,
- logicalModel,
- visualModel,
+ textModel,
metrics,
false );
+ LogicalModelPtr logicalModel = textModel->mLogicalModel;
+ VisualModelPtr visualModel = textModel->mVisualModel;
+
// 2) Clear the bidirectional line info data.
uint32_t startRemoveIndex = logicalModel->mBidirectionalLineInfo.Count();
uint32_t endRemoveIndex = startRemoveIndex;
bool GetMirroredTextTest( const GetMirroredTextData& data )
{
// 1) Create the model.
- LogicalModelPtr logicalModel;
- VisualModelPtr visualModel;
+ ModelPtr textModel;
MetricsPtr metrics;
Size textArea(100.f, 60.f);
Size layoutSize;
fontDescriptions,
options,
layoutSize,
- logicalModel,
- visualModel,
+ textModel,
metrics,
false );
+ LogicalModelPtr logicalModel = textModel->mLogicalModel;
+ VisualModelPtr visualModel = textModel->mVisualModel;
+
// 2) Call the GetMirroredText() function for the whole text
Vector<Character> mirroredText;
bool mirrored = false;
bool GetCharactersDirectionTest( const GetCharactersDirectionData& data )
{
// 1) Create the model.
- LogicalModelPtr logicalModel;
- VisualModelPtr visualModel;
+ ModelPtr textModel;
MetricsPtr metrics;
Size textArea(100.f, 60.f);
Size layoutSize;
fontDescriptions,
options,
layoutSize,
- logicalModel,
- visualModel,
+ textModel,
metrics,
data.markupProcessorEnabled );
+ LogicalModelPtr logicalModel = textModel->mLogicalModel;
+ VisualModelPtr visualModel = textModel->mVisualModel;
+
Vector<BidirectionalParagraphInfoRun>& bidirectionalInfo = logicalModel->mBidirectionalParagraphInfo;
// 2) Clear the direction info data.
bool CreateParagraphTest( const CreateParagraphData& data )
{
// 1) Create the model.
- LogicalModelPtr logicalModel;
- VisualModelPtr visualModel;
+ ModelPtr textModel;
MetricsPtr metrics;
Size textArea(100.f, 60.f);
Size layoutSize;
fontDescriptionRuns,
options,
layoutSize,
- logicalModel,
- visualModel,
+ textModel,
metrics,
false );
+ LogicalModelPtr logicalModel = textModel->mLogicalModel;
+ VisualModelPtr visualModel = textModel->mVisualModel;
+
// 2) Clear the paragraphs.
Vector<ParagraphRun>& paragraphs = logicalModel->mParagraphInfo;
ClearCharacterRuns( data.index,
bool FindParagraphTest( const FindParagraphData& data )
{
// 1) Create the model.
- LogicalModelPtr logicalModel;
- VisualModelPtr visualModel;
+ ModelPtr textModel;
MetricsPtr metrics;
Size textArea(100.f, 60.f);
Size layoutSize;
fontDescriptionRuns,
options,
layoutSize,
- logicalModel,
- visualModel,
+ textModel,
metrics,
false );
+ LogicalModelPtr logicalModel = textModel->mLogicalModel;
+ VisualModelPtr visualModel = textModel->mVisualModel;
+
// 2) Find the paragraphs.
Vector<ParagraphRunIndex> paragraphs;
logicalModel->FindParagraphs( data.index, data.numberOfCharacters, paragraphs );
{
std::cout << " testing : " << data.description << std::endl;
// Create the model.
- LogicalModelPtr logicalModel;
- VisualModelPtr visualModel;
+ ModelPtr textModel;
MetricsPtr metrics;
Size textArea( 100.f, 300.f );
Size layoutSize;
fontDescriptions,
options,
layoutSize,
- logicalModel,
- visualModel,
+ textModel,
metrics,
false );
+ LogicalModelPtr logicalModel = textModel->mLogicalModel;
+ VisualModelPtr visualModel = textModel->mVisualModel;
+
for( unsigned int index = 0; index < data.numberOfTests; ++index )
{
const bool fetched = logicalModel->FetchBidirectionalLineInfo( data.characterIndex[index] );
{
std::cout << " testing : " << data.description << std::endl;
// Create the model.
- LogicalModelPtr logicalModel;
- VisualModelPtr visualModel;
+ ModelPtr textModel;
MetricsPtr metrics;
Size layoutSize;
fontDescriptions,
options,
layoutSize,
- logicalModel,
- visualModel,
+ textModel,
metrics,
false );
+ LogicalModelPtr logicalModel = textModel->mLogicalModel;
+ VisualModelPtr visualModel = textModel->mVisualModel;
+
for( unsigned int index = 0u; index < data.numberOfIndices; ++index )
{
// Check the current cached bidi line index. (Check it before call the GetLogicalCharacterIndex() method )
fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/tizen/TizenSansHebrewRegular.ttf" );
// Create the model.
- LogicalModelPtr logicalModel;
- VisualModelPtr visualModel;
+ ModelPtr textModel;
MetricsPtr metrics;
Size layoutSize;
fontDescriptionRuns,
options,
layoutSize,
- logicalModel,
- visualModel,
+ textModel,
metrics,
false );
+ LogicalModelPtr logicalModel = textModel->mLogicalModel;
+ VisualModelPtr visualModel = textModel->mVisualModel;
+
for( unsigned int index = 0u; index < data.numberOfIndices; ++index )
{
const bool fetched = logicalModel->FetchBidirectionalLineInfo( data.characterIndex[index] );
std::cout << " testing : " << data.description << std::endl;
// 1) Create the model.
- LogicalModelPtr logicalModel;
- VisualModelPtr visualModel;
+ ModelPtr textModel;
MetricsPtr metrics;
Size textArea(400.f, 600.f);
Size layoutSize;
fontDescriptionRuns,
options,
layoutSize,
- logicalModel,
- visualModel,
+ textModel,
metrics,
false );
+ LogicalModelPtr logicalModel = textModel->mLogicalModel;
+ VisualModelPtr visualModel = textModel->mVisualModel;
+
for( unsigned int index = 0; index < data.numberOfTests; ++index )
{
bool isLineHit = false;
std::cout << " testing : " << data.description << std::endl;
// 1) Create the model.
- LogicalModelPtr logicalModel;
- VisualModelPtr visualModel;
+ ModelPtr textModel;
MetricsPtr metrics;
Size textArea(400.f, 600.f);
Size layoutSize;
fontDescriptionRuns,
options,
layoutSize,
- logicalModel,
- visualModel,
+ textModel,
metrics,
false );
+ LogicalModelPtr logicalModel = textModel->mLogicalModel;
+ VisualModelPtr visualModel = textModel->mVisualModel;
+
for( unsigned int index = 0; index < data.numberOfTests; ++index )
{
bool isCharacterHit = false;
std::cout << " testing : " << data.description << std::endl;
// 1) Create the model.
- LogicalModelPtr logicalModel;
- VisualModelPtr visualModel;
+ ModelPtr textModel;
MetricsPtr metrics;
Size textArea(400.f, 600.f);
Size layoutSize;
fontDescriptionRuns,
options,
layoutSize,
- logicalModel,
- visualModel,
+ textModel,
metrics,
false );
+ LogicalModelPtr logicalModel = textModel->mLogicalModel;
+ VisualModelPtr visualModel = textModel->mVisualModel;
+
GetCursorPositionParameters parameters;
parameters.visualModel = visualModel;
parameters.logicalModel = logicalModel;
std::cout << " testing : " << data.description << std::endl;
// 1) Create the model.
- LogicalModelPtr logicalModel;
- VisualModelPtr visualModel;
+ ModelPtr textModel;
MetricsPtr metrics;
Size textArea(400.f, 600.f);
Size layoutSize;
fontDescriptionRuns,
options,
layoutSize,
- logicalModel,
- visualModel,
+ textModel,
metrics,
false );
+ LogicalModelPtr logicalModel = textModel->mLogicalModel;
+ VisualModelPtr visualModel = textModel->mVisualModel;
+
for( unsigned int index = 0; index < data.numberOfTests; ++index )
{
CharacterIndex startIndex = 0;
fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/tizen/TizenSansHindiRegular.ttf" );
// 1) Create the model.
- LogicalModelPtr logicalModel;
- VisualModelPtr visualModel;
+ ModelPtr textModel;
MetricsPtr metrics;
Size layoutSize;
fontDescriptionRuns,
options,
layoutSize,
- logicalModel,
- visualModel,
+ textModel,
metrics,
false );
+ LogicalModelPtr logicalModel = textModel->mLogicalModel;
+ VisualModelPtr visualModel = textModel->mVisualModel;
+
// 2) Clear the layout.
Vector<LineRun>& lines = visualModel->mLines;
engine.SetMetrics( metrics );
engine.SetLayout( data.layout );
- const Length totalNumberOfGlyphs = visualModel->mGlyphs.Count();
- float outlineWidth = visualModel->GetOutlineWidth();
-
+ textModel->mHorizontalAlignment = Text::HorizontalAlignment::BEGIN;
+ textModel->mLineWrapMode = LineWrap::WORD;
+ textModel->mIgnoreSpacesAfterText = true;
+ textModel->mMatchSystemLanguageDirection = false;
Layout::Parameters layoutParameters( data.textArea,
- logicalModel->mText.Begin(),
- logicalModel->mLineBreakInfo.Begin(),
- logicalModel->mWordBreakInfo.Begin(),
- ( 0u != logicalModel->mCharacterDirections.Count() ) ? logicalModel->mCharacterDirections.Begin() : NULL,
- visualModel->mGlyphs.Begin(),
- visualModel->mGlyphsToCharacters.Begin(),
- visualModel->mCharactersPerGlyph.Begin(),
- visualModel->mCharactersToGlyph.Begin(),
- visualModel->mGlyphsPerCharacter.Begin(),
- totalNumberOfGlyphs,
- Text::HorizontalAlignment::BEGIN,
- Text::LineWrap::WORD,
- outlineWidth,
- true,
- false );
+ textModel );
layoutParameters.isLastNewParagraph = isLastNewParagraph;
fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/tizen/TizenSansArabicRegular.ttf" );
// 1) Create the model.
- LogicalModelPtr logicalModel;
- VisualModelPtr visualModel;
+ ModelPtr textModel;
MetricsPtr metrics;
Size layoutSize;
fontDescriptionRuns,
options,
layoutSize,
- logicalModel,
- visualModel,
+ textModel,
metrics,
false );
+ LogicalModelPtr logicalModel = textModel->mLogicalModel;
+ VisualModelPtr visualModel = textModel->mVisualModel;
+
// 2) Call the ReLayoutRightToLeftLines() method.
Layout::Engine engine;
engine.SetMetrics( metrics );
- float outlineWidth = visualModel->GetOutlineWidth();
+ textModel->mHorizontalAlignment = Text::HorizontalAlignment::BEGIN;
+ textModel->mLineWrapMode = LineWrap::WORD;
+ textModel->mIgnoreSpacesAfterText = true;
+ textModel->mMatchSystemLanguageDirection = false;
Layout::Parameters layoutParameters( data.textArea,
- logicalModel->mText.Begin(),
- logicalModel->mLineBreakInfo.Begin(),
- logicalModel->mWordBreakInfo.Begin(),
- ( 0u != logicalModel->mCharacterDirections.Count() ) ? logicalModel->mCharacterDirections.Begin() : NULL,
- visualModel->mGlyphs.Begin(),
- visualModel->mGlyphsToCharacters.Begin(),
- visualModel->mCharactersPerGlyph.Begin(),
- visualModel->mCharactersToGlyph.Begin(),
- visualModel->mGlyphsPerCharacter.Begin(),
- visualModel->mGlyphs.Count(),
- Text::HorizontalAlignment::BEGIN,
- Text::LineWrap::WORD,
- outlineWidth,
- true,
- false );
+ textModel );
layoutParameters.numberOfBidirectionalInfoRuns = logicalModel->mBidirectionalLineInfo.Count();
layoutParameters.lineBidirectionalInfoRunsBuffer = logicalModel->mBidirectionalLineInfo.Begin();
fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/tizen/TizenSansArabicRegular.ttf" );
// 1) Create the model.
- LogicalModelPtr logicalModel;
- VisualModelPtr visualModel;
+ ModelPtr textModel;
MetricsPtr metrics;
Size layoutSize;
fontDescriptionRuns,
options,
layoutSize,
- logicalModel,
- visualModel,
+ textModel,
metrics,
false );
+ LogicalModelPtr logicalModel = textModel->mLogicalModel;
+ VisualModelPtr visualModel = textModel->mVisualModel;
+
// Call the Align method.
Layout::Engine engine;
engine.SetMetrics( metrics );
bool ShapeInfoTest( const ShapeInfoData& data )
{
// 1) Create the model.
- LogicalModelPtr logicalModel;
- VisualModelPtr visualModel;
+ ModelPtr textModel;
MetricsPtr metrics;
Size textArea(100.f, 60.f);
Size layoutSize;
data.fontDescriptions,
options,
layoutSize,
- logicalModel,
- visualModel,
+ textModel,
metrics,
false );
+ LogicalModelPtr logicalModel = textModel->mLogicalModel;
+ VisualModelPtr visualModel = textModel->mVisualModel;
+
// 2) Clear the model.
Vector<GlyphInfo>& glyphs = visualModel->mGlyphs;
bool SetGlyphsPerCharacterTest( const SetGlyphsPerCharacterData& data )
{
// 1) Create the model.
- LogicalModelPtr logicalModel;
- VisualModelPtr visualModel;
+ ModelPtr textModel;
MetricsPtr metrics;
Size textArea(100.f, 60.f);
Size layoutSize;
fontDescriptions,
options,
layoutSize,
- logicalModel,
- visualModel,
+ textModel,
metrics,
false );
+ LogicalModelPtr logicalModel = textModel->mLogicalModel;
+ VisualModelPtr visualModel = textModel->mVisualModel;
+
Vector<GlyphIndex>& charactersToGlyph = visualModel->mCharactersToGlyph;
Vector<Length>& glyphsPerCharacter = visualModel->mGlyphsPerCharacter;
bool SetCharacterToGlyphTest( const SetCharacterToGlyphData& data )
{
// 1) Create the model.
- LogicalModelPtr logicalModel;
- VisualModelPtr visualModel;
+ ModelPtr textModel;
MetricsPtr metrics;
Size textArea(100.f, 60.f);
Size layoutSize;
fontDescriptions,
options,
layoutSize,
- logicalModel,
- visualModel,
+ textModel,
metrics,
false );
+ LogicalModelPtr logicalModel = textModel->mLogicalModel;
+ VisualModelPtr visualModel = textModel->mVisualModel;
+
Vector<GlyphIndex>& charactersToGlyph = visualModel->mCharactersToGlyph;
Vector<Length>& glyphsPerCharacter = visualModel->mGlyphsPerCharacter;
#include <dali-toolkit/internal/text/color-segmentation.h>
#include <dali-toolkit/internal/text/layouts/layout-engine.h>
#include <dali-toolkit/internal/text/layouts/layout-parameters.h>
-#include <dali-toolkit/internal/text/logical-model-impl.h>
#include <dali-toolkit/internal/text/markup-processor.h>
#include <dali-toolkit/internal/text/multi-language-support.h>
#include <dali-toolkit/internal/text/segmentation.h>
#include <dali-toolkit/internal/text/shaper.h>
#include <dali-toolkit/internal/text/text-enumerations-impl.h>
#include <dali-toolkit/internal/text/text-font-style.h>
-#include <dali-toolkit/internal/text/visual-model-impl.h>
+#include <dali-toolkit/internal/text/text-model.h>
namespace Dali
{
MultilanguageSupport multilanguageSupport = MultilanguageSupport::Get();
FontClient fontClient = FontClient::Get();
MetricsPtr metrics;
- Text::Layout::Engine layoutEngine; ///< The layout engine.
- LogicalModelPtr logicalModel = LogicalModel::New(); ///< Pointer to the logical model.
- VisualModelPtr visualModel = VisualModel::New(); ///< Pointer to the visual model.
- Vector<ColorBlendingMode> blendingMode; ///< How embedded items and bitmap font glyphs are blended with color text.
- Vector<bool> isEmoji; ///< Whether the glyph is an emoji.
+ Text::Layout::Engine layoutEngine; ///< The layout engine.
+ Text::ModelPtr textModel = Text::Model::New(); ///< Pointer to the text's model.
+ Vector<ColorBlendingMode> blendingMode; ///< How embedded items and bitmap font glyphs are blended with color text.
+ Vector<bool> isEmoji; ///< Whether the glyph is an emoji.
// Use this to access FontClient i.e. to get down-scaled Emoji metrics.
metrics = Metrics::New( fontClient );
layoutEngine.SetMetrics( metrics );
- TextAbstraction::TextRenderer::Parameters rendererParameters( visualModel->mGlyphs,
- visualModel->mGlyphPositions,
- visualModel->mColors,
- visualModel->mColorIndices,
+ TextAbstraction::TextRenderer::Parameters rendererParameters( textModel->mVisualModel->mGlyphs,
+ textModel->mVisualModel->mGlyphPositions,
+ textModel->mVisualModel->mColors,
+ textModel->mVisualModel->mColorIndices,
blendingMode,
isEmoji );
rendererParameters.height = textParameters.textHeight;
rendererParameters.pixelFormat = TextAbstraction::TextRenderer::Parameters::RGBA8888; // @note: At the moment all textures are generated RGBA8888
- Vector<Character>& utf32Characters = logicalModel->mText; // Characters encoded in utf32.
- Vector<Character> mirroredUtf32Characters; // The utf32Characters Characters but mirrored if there are RTL text.
- Vector<LineBreakInfo>& lineBreakInfo = logicalModel->mLineBreakInfo; // The line break info.
- Vector<ScriptRun>& scripts = logicalModel->mScriptRuns; // Charactes's script.
- Vector<FontDescriptionRun>& fontDescriptionRuns = logicalModel->mFontDescriptionRuns; // Desired font descriptions.
- Vector<FontRun>& validFonts = logicalModel->mFontRuns; // Validated fonts.
- Vector<BidirectionalParagraphInfoRun>& bidirectionalInfo = logicalModel->mBidirectionalParagraphInfo; // The bidirectional info per paragraph.
- Vector<BidirectionalLineInfoRun>& bidirectionalLineInfo = logicalModel->mBidirectionalLineInfo; // The bidirectional info per line.
- Vector<CharacterDirection>& directions = logicalModel->mCharacterDirections; // Character's directions.
- Vector<ColorRun>& colorRuns = logicalModel->mColorRuns; // colors of the text.
-
- Vector<CharacterIndex>& glyphsToCharacters = visualModel->mGlyphsToCharacters; // Glyphs to character map.
- Vector<GlyphIndex>& charactersToGlyph = visualModel->mCharactersToGlyph; // Characters to glyphs map.
- Vector<Length>& charactersPerGlyph = visualModel->mCharactersPerGlyph; // Number of characters per glyph.
- Vector<Length>& glyphsPerCharacter = visualModel->mGlyphsPerCharacter; // The number of glyphs that are shaped.
- Vector<LineRun>& lines = visualModel->mLines; // The laid out lines.
+ Vector<Character>& utf32Characters = textModel->mLogicalModel->mText; // Characters encoded in utf32.
+ Vector<Character> mirroredUtf32Characters; // The utf32Characters Characters but mirrored if there are RTL text.
+ Vector<LineBreakInfo>& lineBreakInfo = textModel->mLogicalModel->mLineBreakInfo; // The line break info.
+ Vector<ScriptRun>& scripts = textModel->mLogicalModel->mScriptRuns; // Charactes's script.
+ Vector<FontDescriptionRun>& fontDescriptionRuns = textModel->mLogicalModel->mFontDescriptionRuns; // Desired font descriptions.
+ Vector<FontRun>& validFonts = textModel->mLogicalModel->mFontRuns; // Validated fonts.
+ Vector<BidirectionalParagraphInfoRun>& bidirectionalInfo = textModel->mLogicalModel->mBidirectionalParagraphInfo; // The bidirectional info per paragraph.
+ //Vector<BidirectionalLineInfoRun>& bidirectionalLineInfo = textModel->mLogicalModel->mBidirectionalLineInfo; // The bidirectional info per line.
+ Vector<CharacterDirection>& directions = textModel->mLogicalModel->mCharacterDirections; // Character's directions.
+ Vector<ColorRun>& colorRuns = textModel->mLogicalModel->mColorRuns; // colors of the text.
+
+ Vector<CharacterIndex>& glyphsToCharacters = textModel->mVisualModel->mGlyphsToCharacters; // Glyphs to character map.
+ Vector<GlyphIndex>& charactersToGlyph = textModel->mVisualModel->mCharactersToGlyph; // Characters to glyphs map.
+ Vector<Length>& charactersPerGlyph = textModel->mVisualModel->mCharactersPerGlyph; // Number of characters per glyph.
+ Vector<Length>& glyphsPerCharacter = textModel->mVisualModel->mGlyphsPerCharacter; // The number of glyphs that are shaped.
+ Vector<LineRun>& lines = textModel->mVisualModel->mLines; // The laid out lines.
Vector<GlyphIndex> newParagraphGlyphs; // Glyphs for the new paragraph characters.
MarkupProcessData markupProcessData( colorRuns,
fontDescriptionRuns,
- logicalModel->mEmbeddedItems );
+ textModel->mLogicalModel->mEmbeddedItems );
if (textParameters.markupEnabled)
{
newParagraphGlyphs );
// Create the 'number of glyphs' per character and the glyph to character conversion tables.
- visualModel->CreateGlyphsPerCharacterTable( 0u, 0u, numberOfCharacters );
- visualModel->CreateCharacterToGlyphTable( 0u, 0u, numberOfCharacters );
+ textModel->mVisualModel->CreateGlyphsPerCharacterTable( 0u, 0u, numberOfCharacters );
+ textModel->mVisualModel->CreateCharacterToGlyphTable( 0u, 0u, numberOfCharacters );
const Length numberOfGlyphs = rendererParameters.glyphs.Count();
// Once the text has been shaped and the glyphs created it's possible to replace the font id of those glyphs
// that represent an image or an item and create the embedded item layout info.
// Note: the position of the embedded item can't be set until the text is laid-out.
- embeddedItemLayout.Reserve( logicalModel->mEmbeddedItems.Count() );
- for( const auto& item : logicalModel->mEmbeddedItems )
+ embeddedItemLayout.Reserve( textModel->mLogicalModel->mEmbeddedItems.Count() );
+ for( const auto& item : textModel->mLogicalModel->mEmbeddedItems )
{
// Get the glyph that matches with the character index.
- const GlyphIndex glyphIndex = visualModel->mCharactersToGlyph[item.characterIndex];
+ const GlyphIndex glyphIndex = textModel->mVisualModel->mCharactersToGlyph[item.characterIndex];
GlyphInfo& glyph = rendererParameters.glyphs[glyphIndex];
glyph.fontId = 0u;
0u,
0u,
numberOfCharacters,
- visualModel->mColors,
- visualModel->mColorIndices );
+ textModel->mVisualModel->mColors,
+ textModel->mVisualModel->mColorIndices );
// Insert the default color at the beginning of the vector.
- visualModel->mColors.Insert( visualModel->mColors.Begin(),textParameters.textColor );
+ textModel->mVisualModel->mColors.Insert( textModel->mVisualModel->mColors.Begin(),textParameters.textColor );
// Set how the embedded items are blended with text color.
blendingMode.Resize( numberOfGlyphs, textParameters.isTextColorSet ? ColorBlendingMode::MULTIPLY : ColorBlendingMode::NONE );
// Traverse the color runs.
for( const auto& run : colorRuns )
{
- const GlyphIndex firstGlyph = visualModel->mCharactersToGlyph[run.characterRun.characterIndex];
+ const GlyphIndex firstGlyph = textModel->mVisualModel->mCharactersToGlyph[run.characterRun.characterIndex];
const CharacterIndex lastCharacter = run.characterRun.characterIndex + run.characterRun.numberOfCharacters - 1u;
- const GlyphIndex lastGlyphPlusOne = visualModel->mCharactersToGlyph[lastCharacter] + visualModel->mGlyphsPerCharacter[lastCharacter];
+ const GlyphIndex lastGlyphPlusOne = textModel->mVisualModel->mCharactersToGlyph[lastCharacter] + textModel->mVisualModel->mGlyphsPerCharacter[lastCharacter];
for( GlyphIndex index = firstGlyph; index < lastGlyphPlusOne; ++index )
{
}
// Traverse the embedded items and update the blending mode vector.
- for( const auto& item : logicalModel->mEmbeddedItems )
+ for( const auto& item : textModel->mLogicalModel->mEmbeddedItems )
{
- const GlyphIndex glyphIndex = visualModel->mCharactersToGlyph[item.characterIndex];
+ const GlyphIndex glyphIndex = textModel->mVisualModel->mCharactersToGlyph[item.characterIndex];
blendingMode[glyphIndex] = item.colorBlendingMode;
}
{
if( run.script == TextAbstraction::Script::EMOJI )
{
- const GlyphIndex firstGlyph = visualModel->mCharactersToGlyph[run.characterRun.characterIndex];
+ const GlyphIndex firstGlyph = textModel->mVisualModel->mCharactersToGlyph[run.characterRun.characterIndex];
const CharacterIndex lastCharacter = run.characterRun.characterIndex + run.characterRun.numberOfCharacters - 1u;
- const GlyphIndex lastGlyphPlusOne = visualModel->mCharactersToGlyph[lastCharacter] + visualModel->mGlyphsPerCharacter[lastCharacter];
+ const GlyphIndex lastGlyphPlusOne = textModel->mVisualModel->mCharactersToGlyph[lastCharacter] + textModel->mVisualModel->mGlyphsPerCharacter[lastCharacter];
for( GlyphIndex index = firstGlyph; index < lastGlyphPlusOne; ++index )
{
textLayoutArea.width = fabs( Radian( Degree( textParameters.incrementAngle ) ) * static_cast<float>( rendererParameters.radius ) );
}
+ textModel->mHorizontalAlignment = isCircularTextLayout ? horizontalCircularAlignment : horizontalAlignment;
+ textModel->mLineWrapMode = LineWrap::WORD;
+ textModel->mIgnoreSpacesAfterText = false;
+ textModel->mMatchSystemLanguageDirection = false;
Text::Layout::Parameters layoutParameters( textLayoutArea,
- textToShape.Begin(),
- lineBreakInfo.Begin(),
- nullptr,
- ( 0u != directions.Count() ) ? directions.Begin() : nullptr,
- rendererParameters.glyphs.Begin(),
- glyphsToCharacters.Begin(),
- charactersPerGlyph.Begin(),
- charactersToGlyph.Begin(),
- glyphsPerCharacter.Begin(),
- numberOfGlyphs,
- isCircularTextLayout ? horizontalCircularAlignment : horizontalAlignment,
- LineWrap::WORD,
- 0.f,
- false,
- false ); // Outline's width
+ textModel );
// Resize the vector of positions to have the same size than the vector of glyphs.
rendererParameters.positions.Resize( numberOfGlyphs );
if( hasBidirectionalText )
{
+ Vector<BidirectionalLineInfoRun>& bidirectionalLineInfo = textModel->mLogicalModel->mBidirectionalLineInfo;
// Reorder the line.
bidirectionalLineInfo.Reserve( 1u );
#endif
const float MAX_FLOAT = std::numeric_limits<float>::max();
-const bool RTL = true;
+const CharacterDirection LTR = false;
+const CharacterDirection RTL = !LTR;
const float LINE_SPACING= 0.f;
inline bool isEmptyLineAtLast( const Vector<LineRun>& lines, const Vector<LineRun>::Iterator& line )
DALI_LOG_INFO( gLogFilter, Debug::Verbose, "-->GetLineLayoutForBox\n" );
DALI_LOG_INFO( gLogFilter, Debug::Verbose, " initial glyph index : %d\n", lineLayout.glyphIndex );
+ const Character* const textBuffer = parameters.textModel->mLogicalModel->mText.Begin();
+ const Length* const charactersPerGlyphBuffer = parameters.textModel->mVisualModel->mCharactersPerGlyph.Begin();
+ const GlyphInfo* const glyphsBuffer = parameters.textModel->mVisualModel->mGlyphs.Begin();
+ const CharacterIndex* const glyphsToCharactersBuffer = parameters.textModel->mVisualModel->mGlyphsToCharacters.Begin();
+ const LineBreakInfo* const lineBreakInfoBuffer = parameters.textModel->mLogicalModel->mLineBreakInfo.Begin();
+
+ const bool hasBidiParagraphs = !parameters.textModel->mLogicalModel->mBidirectionalParagraphInfo.Empty();
+ const CharacterDirection* const characterDirectionBuffer = hasBidiParagraphs ? parameters.textModel->mLogicalModel->mCharacterDirections.Begin() : nullptr;
+
+ const float outlineWidth = static_cast<float>( parameters.textModel->GetOutlineWidth() );
+ const Length totalNumberOfGlyphs = parameters.textModel->mVisualModel->mGlyphs.Count();
+
const bool isMultiline = mLayout == MULTI_LINE_BOX;
- const bool isWordLaidOut = parameters.lineWrapMode == Text::LineWrap::WORD;
+ const bool isWordLaidOut = parameters.textModel->mLineWrapMode == Text::LineWrap::WORD;
// The last glyph to be laid-out.
const GlyphIndex lastGlyphOfParagraphPlusOne = parameters.startGlyphIndex + parameters.numberOfGlyphs;
// Check whether the first glyph comes from a character that is shaped in multiple glyphs.
const Length numberOfGLyphsInGroup = GetNumberOfGlyphsOfGroup( lineLayout.glyphIndex,
lastGlyphOfParagraphPlusOne,
- parameters.charactersPerGlyphBuffer );
+ charactersPerGlyphBuffer );
GlyphMetrics glyphMetrics;
GetGlyphsMetrics( lineLayout.glyphIndex,
numberOfGLyphsInGroup,
glyphMetrics,
- parameters.glyphsBuffer,
+ glyphsBuffer,
mMetrics );
// Set the direction of the first character of the line.
- lineLayout.characterIndex = *( parameters.glyphsToCharactersBuffer + lineLayout.glyphIndex );
+ lineLayout.characterIndex = *( glyphsToCharactersBuffer + lineLayout.glyphIndex );
// Stores temporary line layout which has not been added to the final line layout.
LineLayout tmpLineLayout;
// The initial start point is zero. However it needs a correction according the 'x' bearing of the first glyph.
// i.e. if the bearing of the first glyph is negative it may exceed the boundaries of the text area.
// It needs to add as well space for the cursor if the text is in edit mode and extra space in case the text is outlined.
- tmpLineLayout.penX = -glyphMetrics.xBearing + mCursorWidth + parameters.outlineWidth;
+ tmpLineLayout.penX = -glyphMetrics.xBearing + mCursorWidth + outlineWidth;
// Initialize the advance of the previous glyph.
tmpLineLayout.previousAdvance = 0.f;
// Check whether this glyph comes from a character that is shaped in multiple glyphs.
const Length numberOfGLyphsInGroup = GetNumberOfGlyphsOfGroup( glyphIndex,
lastGlyphOfParagraphPlusOne,
- parameters.charactersPerGlyphBuffer );
+ charactersPerGlyphBuffer );
GlyphMetrics glyphMetrics;
GetGlyphsMetrics( glyphIndex,
numberOfGLyphsInGroup,
glyphMetrics,
- parameters.glyphsBuffer,
+ glyphsBuffer,
mMetrics );
- const bool isLastGlyph = glyphIndex + numberOfGLyphsInGroup == parameters.totalNumberOfGlyphs;
+ const bool isLastGlyph = glyphIndex + numberOfGLyphsInGroup == totalNumberOfGlyphs;
// Check if the font of the current glyph is the same of the previous one.
// If it's different the ascender and descender need to be updated.
// Get the character indices for the current glyph. The last character index is needed
// because there are glyphs formed by more than one character but their break info is
// given only for the last character.
- const Length charactersPerGlyph = *( parameters.charactersPerGlyphBuffer + glyphIndex + numberOfGLyphsInGroup - 1u );
+ const Length charactersPerGlyph = *( charactersPerGlyphBuffer + glyphIndex + numberOfGLyphsInGroup - 1u );
const bool hasCharacters = charactersPerGlyph > 0u;
- const CharacterIndex characterFirstIndex = *( parameters.glyphsToCharactersBuffer + glyphIndex );
+ const CharacterIndex characterFirstIndex = *( glyphsToCharactersBuffer + glyphIndex );
const CharacterIndex characterLastIndex = characterFirstIndex + ( hasCharacters ? charactersPerGlyph - 1u : 0u );
// Get the line break info for the current character.
- const LineBreakInfo lineBreakInfo = hasCharacters ? *( parameters.lineBreakInfoBuffer + characterLastIndex ) : TextAbstraction::LINE_NO_BREAK;
+ const LineBreakInfo lineBreakInfo = hasCharacters ? *( lineBreakInfoBuffer + characterLastIndex ) : TextAbstraction::LINE_NO_BREAK;
// Increase the number of characters.
tmpLineLayout.numberOfCharacters += charactersPerGlyph;
tmpLineLayout.numberOfGlyphs += numberOfGLyphsInGroup;
// Check whether is a white space.
- const Character character = *( parameters.textBuffer + characterFirstIndex );
+ const Character character = *( textBuffer + characterFirstIndex );
const bool isWhiteSpace = TextAbstraction::IsWhiteSpace( character );
// Calculate the length of the line.
// Set the next paragraph's direction.
if( !isLastGlyph &&
- ( NULL != parameters.characterDirectionBuffer ) )
+ ( nullptr != characterDirectionBuffer ) )
{
- paragraphDirection = *( parameters.characterDirectionBuffer + 1u + characterLastIndex );
+ paragraphDirection = *( characterDirectionBuffer + 1u + characterLastIndex );
}
DALI_LOG_INFO( gLogFilter, Debug::Verbose, " Must break\n" );
Length& linesCapacity,
bool updateCurrentBuffer )
{
- LineRun* linesBuffer = NULL;
+ LineRun* linesBuffer = nullptr;
// Reserve more space for the next lines.
linesCapacity *= 2u;
if( updateCurrentBuffer )
// The last line needs to be completely filled with characters.
// Part of a word may be used.
- LineRun* lineRun = NULL;
+ LineRun* lineRun = nullptr;
LineLayout ellipsisLayout;
if( 0u != numberOfLines )
{
lineRun->extraLength = std::ceil( ellipsisLayout.wsLengthEndOfLine );
lineRun->ascender = ellipsisLayout.ascender;
lineRun->descender = ellipsisLayout.descender;
- lineRun->direction = !RTL;
+ lineRun->direction = LTR;
lineRun->ellipsis = true;
layoutSize.width = layoutParameters.boundingBox.width;
layoutSize.height += ( lineRun->ascender + -lineRun->descender ) + lineRun->lineSpacing;
}
- SetGlyphPositions( layoutParameters.glyphsBuffer + lineRun->glyphRun.glyphIndex,
+ const GlyphInfo* const glyphsBuffer = layoutParameters.textModel->mVisualModel->mGlyphs.Begin();
+ const float outlineWidth = static_cast<float>( layoutParameters.textModel->GetOutlineWidth() );
+
+ SetGlyphPositions( glyphsBuffer + lineRun->glyphRun.glyphIndex,
ellipsisLayout.numberOfGlyphs,
- layoutParameters.outlineWidth,
+ outlineWidth,
layoutParameters.interGlyphExtraAdvance,
glyphPositionsBuffer + lineRun->glyphRun.glyphIndex - layoutParameters.startGlyphIndex );
}
lineRun.ascender = layout.ascender;
lineRun.descender = layout.descender;
- lineRun.direction = !RTL;
+ lineRun.direction = LTR;
lineRun.ellipsis = false;
// Update the actual size.
LineRun* linesBuffer,
Length& numberOfLines )
{
+ const Vector<GlyphInfo>& glyphs = layoutParameters.textModel->mVisualModel->mGlyphs;
+
// Need to add a new line with no characters but with height to increase the layoutSize.height
- const GlyphInfo& glyphInfo = *( layoutParameters.glyphsBuffer + layoutParameters.totalNumberOfGlyphs - 1u );
+ const GlyphInfo& glyphInfo = glyphs[glyphs.Count() - 1u];
Text::FontMetrics fontMetrics;
if( 0u != glyphInfo.fontId )
lineRun.descender = fontMetrics.descender;
lineRun.extraLength = 0.f;
lineRun.alignmentOffset = 0.f;
- lineRun.direction = !RTL;
+ lineRun.direction = LTR;
lineRun.ellipsis = false;
lineRun.lineSpacing = mDefaultLineSpacing;
}
const GlyphIndex lastGlyphPlusOne = layoutParameters.startGlyphIndex + layoutParameters.numberOfGlyphs;
+ const Length totalNumberOfGlyphs = layoutParameters.textModel->mVisualModel->mGlyphs.Count();
// In a previous layout, an extra line with no characters may have been added if the text ended with a new paragraph character.
// This extra line needs to be removed.
Vector<LineRun>::Iterator lastLine = lines.End() - 1u;
if( ( 0u == lastLine->characterRun.numberOfCharacters ) &&
- ( lastGlyphPlusOne == layoutParameters.totalNumberOfGlyphs ) )
+ ( lastGlyphPlusOne == totalNumberOfGlyphs ) )
{
lines.Remove( lastLine );
}
}
+ // Retrieve BiDi info.
+ const bool hasBidiParagraphs = !layoutParameters.textModel->mLogicalModel->mBidirectionalParagraphInfo.Empty();
+
+ const CharacterDirection* const characterDirectionBuffer = hasBidiParagraphs ? layoutParameters.textModel->mLogicalModel->mCharacterDirections.Begin() : nullptr;
+
// Set the first paragraph's direction.
- CharacterDirection paragraphDirection = ( NULL != layoutParameters.characterDirectionBuffer ) ? *layoutParameters.characterDirectionBuffer : !RTL;
+ CharacterDirection paragraphDirection = ( nullptr != characterDirectionBuffer ) ? *characterDirectionBuffer : LTR;
// Whether the layout is being updated or set from scratch.
- const bool updateCurrentBuffer = layoutParameters.numberOfGlyphs < layoutParameters.totalNumberOfGlyphs;
+ const bool updateCurrentBuffer = layoutParameters.numberOfGlyphs < totalNumberOfGlyphs;
- Vector2* glyphPositionsBuffer = NULL;
+ Vector2* glyphPositionsBuffer = nullptr;
Vector<Vector2> newGlyphPositions;
- LineRun* linesBuffer = NULL;
+ LineRun* linesBuffer = nullptr;
Vector<LineRun> newLines;
// Estimate the number of lines.
linesBuffer = lines.Begin();
}
+
+ const GlyphInfo* const glyphsBuffer = layoutParameters.textModel->mVisualModel->mGlyphs.Begin();
+ const float outlineWidth = static_cast<float>( layoutParameters.textModel->GetOutlineWidth() );
+
float penY = CalculateLineOffset( lines,
layoutParameters.startLineIndex );
+
for( GlyphIndex index = layoutParameters.startGlyphIndex; index < lastGlyphPlusOne; )
{
CharacterDirection currentParagraphDirection = paragraphDirection;
else
{
// Whether the last line has been laid-out.
- const bool isLastLine = index + layout.numberOfGlyphs == layoutParameters.totalNumberOfGlyphs;
+ const bool isLastLine = index + layout.numberOfGlyphs == totalNumberOfGlyphs;
if( numberOfLines == linesCapacity )
{
const GlyphIndex nextIndex = index + layout.numberOfGlyphs;
- if( ( nextIndex == layoutParameters.totalNumberOfGlyphs ) &&
+ if( ( nextIndex == totalNumberOfGlyphs ) &&
layoutParameters.isLastNewParagraph &&
( mLayout == MULTI_LINE_BOX ) )
{
} // whether to add a last line.
// Sets the positions of the glyphs.
- SetGlyphPositions( layoutParameters.glyphsBuffer + index,
+ SetGlyphPositions( glyphsBuffer + index,
layout.numberOfGlyphs,
- layoutParameters.outlineWidth,
+ outlineWidth,
layoutParameters.interGlyphExtraAdvance,
glyphPositionsBuffer + index - layoutParameters.startGlyphIndex );
glyphPositions.Insert( glyphPositions.Begin() + layoutParameters.startGlyphIndex,
newGlyphPositions.Begin(),
newGlyphPositions.End() );
- glyphPositions.Resize( layoutParameters.totalNumberOfGlyphs );
+ glyphPositions.Resize( totalNumberOfGlyphs );
newLines.Resize( numberOfLines );
Length numberOfCharacters,
Vector<Vector2>& glyphPositions )
{
+ const GlyphInfo* const glyphsBuffer = layoutParameters.textModel->mVisualModel->mGlyphs.Begin();
+ const GlyphIndex* const charactersToGlyphsBuffer = layoutParameters.textModel->mVisualModel->mCharactersToGlyph.Begin();
+ const Length* const glyphsPerCharacterBuffer = layoutParameters.textModel->mVisualModel->mGlyphsPerCharacter.Begin();
+ const float outlineWidth = static_cast<float>( layoutParameters.textModel->GetOutlineWidth() );
+
const CharacterIndex lastCharacterIndex = startIndex + numberOfCharacters;
// Traverses the paragraphs with right to left characters.
}
const CharacterIndex characterVisualIndex = bidiLine.characterRun.characterIndex + *bidiLine.visualToLogicalMap;
- const GlyphInfo& glyph = *( layoutParameters.glyphsBuffer + *( layoutParameters.charactersToGlyphsBuffer + characterVisualIndex ) );
+ const GlyphInfo& glyph = *( glyphsBuffer + *( charactersToGlyphsBuffer + characterVisualIndex ) );
- float penX = -glyph.xBearing + layoutParameters.outlineWidth + mCursorWidth;
+ float penX = -glyph.xBearing + outlineWidth + mCursorWidth;
Vector2* glyphPositionsBuffer = glyphPositions.Begin();
const CharacterIndex characterVisualIndex = bidiLine.characterRun.characterIndex + *( bidiLine.visualToLogicalMap + characterLogicalIndex );
// Get the number of glyphs of the character.
- const Length numberOfGlyphs = *( layoutParameters.glyphsPerCharacterBuffer + characterVisualIndex );
+ const Length numberOfGlyphs = *( glyphsPerCharacterBuffer + characterVisualIndex );
for( GlyphIndex index = 0u; index < numberOfGlyphs; ++index )
{
// Convert the character in the visual order into the glyph in the visual order.
- const GlyphIndex glyphIndex = *( layoutParameters.charactersToGlyphsBuffer + characterVisualIndex ) + index;
+ const GlyphIndex glyphIndex = *( charactersToGlyphsBuffer + characterVisualIndex ) + index;
- DALI_ASSERT_DEBUG( 0u <= glyphIndex && glyphIndex < layoutParameters.totalNumberOfGlyphs );
+ DALI_ASSERT_DEBUG( 0u <= glyphIndex && glyphIndex < layoutParameters.textModel->mVisualModel->mGlyphs.Count() );
- const GlyphInfo& glyph = *( layoutParameters.glyphsBuffer + glyphIndex );
+ const GlyphInfo& glyph = *( glyphsBuffer + glyphIndex );
Vector2& position = *( glyphPositionsBuffer + glyphIndex );
position.x = std::round( penX + glyph.xBearing );
line.descender = 0.f;
line.extraLength = 0.f;
line.alignmentOffset = 0.f;
- line.direction = !RTL;
+ line.direction = LTR;
line.ellipsis = false;
line.lineSpacing = mDefaultLineSpacing;
}
};
Engine::Engine()
-: mImpl( NULL )
+: mImpl( nullptr )
{
mImpl = new Engine::Impl();
}
// INTERNAL INCLUDES
#include <dali-toolkit/public-api/text/text-enumerations.h>
#include <dali-toolkit/internal/text/text-definitions.h>
+#include <dali-toolkit/internal/text/text-model.h>
namespace Dali
{
* Constructor with the needed parameters to layout the text.
*
* @param[in] boundingBox The size of the box containing the text.
- * @param[in] textBuffer The text buffer.
- * @param[in] lineBreakInfoBuffer The line break info.
- * @param[in] wordBreakInfoBuffer The word break info.
- * @param[in] characterDirectionBuffer Vector with the direction of each character.
- * @param[in] glyphsBuffer Vector with glyphs.
- * @param[in] glyphsToCharactersBuffer Vector with indices pointing the first character of each glyph.
- * @param[in] charactersPerGlyphBuffer Vector with the number of characters that forms each glyph.
- * @param[in] charactersToGlyphsBuffer Vector with indices pointing the first glyph of each character.
- * @param[in] glyphsPerCharacterBuffer Vector with the number of glyphs shaped from the character.
- * @param[in] totalNumberOfGlyphs The number of glyphs.
- * @param[in] horizontalAlignment The horizontal alignment.
- * @param[in] lineWrapMode The text wrap mode.
- * @param[in] outlineWidth The outline width.
- * @param[in] ignoreSpaceAfterText Whether ignoring spaces after text or not.
- * @param[in] matchSystemLanguageDirection Whether match align for system language direction or not..
+ * @param[in,out] textModel The text's model.
*/
Parameters( const Vector2& boundingBox,
- const Character* const textBuffer,
- const LineBreakInfo* const lineBreakInfoBuffer,
- const WordBreakInfo* const wordBreakInfoBuffer,
- const CharacterDirection* const characterDirectionBuffer,
- const GlyphInfo* const glyphsBuffer,
- const CharacterIndex* const glyphsToCharactersBuffer,
- const Length* const charactersPerGlyphBuffer,
- const GlyphIndex* const charactersToGlyphsBuffer,
- const Length* const glyphsPerCharacterBuffer,
- Length totalNumberOfGlyphs,
- Text::HorizontalAlignment::Type horizontalAlignment,
- Text::LineWrap::Mode lineWrapMode,
- float outlineWidth,
- bool ignoreSpaceAfterText,
- bool matchSystemLanguageDirection )
- : boundingBox( boundingBox ),
- textBuffer( textBuffer ),
- lineBreakInfoBuffer( lineBreakInfoBuffer ),
- wordBreakInfoBuffer( wordBreakInfoBuffer ),
- characterDirectionBuffer( characterDirectionBuffer ),
- glyphsBuffer( glyphsBuffer ),
- glyphsToCharactersBuffer( glyphsToCharactersBuffer ),
- charactersPerGlyphBuffer( charactersPerGlyphBuffer ),
- charactersToGlyphsBuffer( charactersToGlyphsBuffer ),
- glyphsPerCharacterBuffer( glyphsPerCharacterBuffer ),
- lineBidirectionalInfoRunsBuffer( NULL ),
- numberOfBidirectionalInfoRuns( 0u ),
- startGlyphIndex( 0u ),
- numberOfGlyphs( 0u ),
- totalNumberOfGlyphs( totalNumberOfGlyphs ),
- horizontalAlignment( horizontalAlignment ),
- startLineIndex( 0u ),
- estimatedNumberOfLines( 0u ),
- lineWrapMode( lineWrapMode ),
- outlineWidth( outlineWidth ),
- ignoreSpaceAfterText( ignoreSpaceAfterText ),
- matchSystemLanguageDirection ( matchSystemLanguageDirection ),
- interGlyphExtraAdvance( 0.f ),
- isLastNewParagraph( false )
+ ModelPtr textModel )
+ : boundingBox{ boundingBox },
+ textModel{ textModel },
+ lineBidirectionalInfoRunsBuffer{ nullptr },
+ numberOfBidirectionalInfoRuns{ 0u },
+ startGlyphIndex{ 0u },
+ numberOfGlyphs{ 0u },
+ startLineIndex{ 0u },
+ estimatedNumberOfLines{ 0u },
+ interGlyphExtraAdvance{ 0.f },
+ isLastNewParagraph{ false }
{}
Vector2 boundingBox; ///< The size of the box containing the text.
- const Character* const textBuffer; ///< The text buffer.
- const LineBreakInfo* const lineBreakInfoBuffer; ///< The line break info.
- const WordBreakInfo* const wordBreakInfoBuffer; ///< The word break info.
- const CharacterDirection* const characterDirectionBuffer; ///< Vector with the direction of each character.
- const GlyphInfo* const glyphsBuffer; ///< Vector with glyphs.
- const CharacterIndex* const glyphsToCharactersBuffer; ///< Vector with indices pointing the first character of each glyph.
- const Length* const charactersPerGlyphBuffer; ///< Vector with the number of characters that forms each glyph.
- const GlyphIndex* const charactersToGlyphsBuffer; ///< Vector with indices pointing the first glyph of each character.
- const Length* const glyphsPerCharacterBuffer; ///< Vector with the number of glyphs shaped from the character.
+ ModelPtr textModel;
BidirectionalLineInfoRun* lineBidirectionalInfoRunsBuffer; ///< Bidirectional conversion tables per line.
Length numberOfBidirectionalInfoRuns; ///< The number of lines with bidirectional info.
GlyphIndex startGlyphIndex; ///< Index to the first glyph to layout.
Length numberOfGlyphs; ///< The number of glyphs to layout.
- Length totalNumberOfGlyphs; ///< The number of glyphs.
- HorizontalAlignment::Type horizontalAlignment; ///< The horizontal alignment.
LineIndex startLineIndex; ///< The line index where to insert the new lines.
Length estimatedNumberOfLines; ///< The estimated number of lines.
- Text::LineWrap::Mode lineWrapMode; ///< The line wrap mode for moving to next line.
- float outlineWidth; ///< The outline width.
- bool ignoreSpaceAfterText:1; ///< Whether ignoring spaces after text or not. Default is true.
- bool matchSystemLanguageDirection:1; ///< Whether match align for system language direction or not. Default is false.
float interGlyphExtraAdvance; ///< Extra advance added to each glyph.
bool isLastNewParagraph:1; ///< Whether the last character is a new paragraph character.
};
Vector<ColorRun> mColorRuns;
Vector<FontDescriptionRun> mFontDescriptionRuns;
Vector<LineBreakInfo> mLineBreakInfo;
- Vector<WordBreakInfo> mWordBreakInfo;
Vector<ParagraphRun> mParagraphInfo;
Vector<BidirectionalParagraphInfoRun> mBidirectionalParagraphInfo;
Vector<CharacterDirection> mCharacterDirections; ///< For each character, whether is right to left. ( @e flase is left to right, @e true right to left ).
mModel->mLogicalModel->mParagraphInfo.Clear();
}
- if( NO_OPERATION != ( GET_WORD_BREAKS & operations ) )
- {
- mModel->mLogicalModel->mLineBreakInfo.Clear();
- }
-
if( NO_OPERATION != ( GET_SCRIPTS & operations ) )
{
mModel->mLogicalModel->mScriptRuns.Clear();
mModel->mLogicalModel->mParagraphInfo );
}
- if( NO_OPERATION != ( GET_WORD_BREAKS & operations ) )
- {
- // Clear the word break info.
- WordBreakInfo* wordBreakInfoBuffer = mModel->mLogicalModel->mWordBreakInfo.Begin();
-
- mModel->mLogicalModel->mWordBreakInfo.Erase( wordBreakInfoBuffer + startIndex,
- wordBreakInfoBuffer + endIndexPlusOne );
- }
-
if( NO_OPERATION != ( GET_SCRIPTS & operations ) )
{
// Clear the scripts.
updated = true;
}
- Vector<WordBreakInfo>& wordBreakInfo = mModel->mLogicalModel->mWordBreakInfo;
- if( NO_OPERATION != ( GET_WORD_BREAKS & operations ) )
- {
- // Retrieves the word break info. The word break info is used to layout the text (where to wrap the text in lines).
- wordBreakInfo.Resize( numberOfCharacters, TextAbstraction::WORD_NO_BREAK );
-
- SetWordBreakInfo( utf32Characters,
- startIndex,
- requestedNumberOfCharacters,
- wordBreakInfo );
- updated = true;
- }
-
const bool getScripts = NO_OPERATION != ( GET_SCRIPTS & operations );
const bool validateFonts = NO_OPERATION != ( VALIDATE_FONTS & operations );
GET_SCRIPTS |
VALIDATE_FONTS |
GET_LINE_BREAKS |
- GET_WORD_BREAKS |
BIDI_INFO |
SHAPE_TEXT |
GET_GLYPH_METRICS );
GET_SCRIPTS |
VALIDATE_FONTS |
GET_LINE_BREAKS |
- GET_WORD_BREAKS |
BIDI_INFO |
SHAPE_TEXT|
GET_GLYPH_METRICS );
GET_SCRIPTS |
VALIDATE_FONTS |
GET_LINE_BREAKS |
- GET_WORD_BREAKS |
BIDI_INFO |
SHAPE_TEXT |
GET_GLYPH_METRICS );
GET_SCRIPTS |
VALIDATE_FONTS |
GET_LINE_BREAKS |
- GET_WORD_BREAKS |
BIDI_INFO |
SHAPE_TEXT |
GET_GLYPH_METRICS );
return true;
}
- const Vector<LineBreakInfo>& lineBreakInfo = mImpl->mModel->mLogicalModel->mLineBreakInfo;
- const Vector<WordBreakInfo>& wordBreakInfo = mImpl->mModel->mLogicalModel->mWordBreakInfo;
- const Vector<CharacterDirection>& characterDirection = mImpl->mModel->mLogicalModel->mCharacterDirections;
- const Vector<GlyphInfo>& glyphs = mImpl->mModel->mVisualModel->mGlyphs;
- const Vector<CharacterIndex>& glyphsToCharactersMap = mImpl->mModel->mVisualModel->mGlyphsToCharacters;
- const Vector<Length>& charactersPerGlyph = mImpl->mModel->mVisualModel->mCharactersPerGlyph;
const Character* const textBuffer = mImpl->mModel->mLogicalModel->mText.Begin();
- const float outlineWidth = static_cast<float>( mImpl->mModel->GetOutlineWidth() );
// Set the layout parameters.
Layout::Parameters layoutParameters( size,
- textBuffer,
- lineBreakInfo.Begin(),
- wordBreakInfo.Begin(),
- ( 0u != characterDirection.Count() ) ? characterDirection.Begin() : NULL,
- glyphs.Begin(),
- glyphsToCharactersMap.Begin(),
- charactersPerGlyph.Begin(),
- charactersToGlyphBuffer,
- glyphsPerCharacterBuffer,
- totalNumberOfGlyphs,
- mImpl->mModel->mHorizontalAlignment,
- mImpl->mModel->mLineWrapMode,
- outlineWidth,
- mImpl->mModel->mIgnoreSpacesAfterText,
- mImpl->mModel->mMatchSystemLanguageDirection );
+ mImpl->mModel );
// Resize the vector of positions to have the same size than the vector of glyphs.
Vector<Vector2>& glyphPositions = mImpl->mModel->mVisualModel->mGlyphPositions;
GET_SCRIPTS = 0x0002,
VALIDATE_FONTS = 0x0004,
GET_LINE_BREAKS = 0x0008,
- GET_WORD_BREAKS = 0x0010,
- BIDI_INFO = 0x0020,
- SHAPE_TEXT = 0x0040,
- GET_GLYPH_METRICS = 0x0080,
- LAYOUT = 0x0100,
- UPDATE_LAYOUT_SIZE = 0x0200,
- REORDER = 0x0400,
- ALIGN = 0x0800,
- COLOR = 0x1000,
- UPDATE_DIRECTION = 0x2000,
+ BIDI_INFO = 0x0010,
+ SHAPE_TEXT = 0x0020,
+ GET_GLYPH_METRICS = 0x0040,
+ LAYOUT = 0x0080,
+ UPDATE_LAYOUT_SIZE = 0x0100,
+ REORDER = 0x0200,
+ ALIGN = 0x0400,
+ COLOR = 0x0800,
+ UPDATE_DIRECTION = 0x1000,
ALL_OPERATIONS = 0xFFFF
};