- if( direction0 == direction1 )
- {
- // Both glyphs have the same direction.
- if( direction0 )
- {
- *( modelVisualToLogicalCursorMap + index ) = logicalPosition0;
- }
- else
- {
- *( modelVisualToLogicalCursorMap + index ) = logicalPosition1;
- }
- }
- else
- {
- if( isRightToLeftParagraph )
- {
- if( direction1 )
- {
- *( modelVisualToLogicalCursorMap + index ) = logicalPosition1 + 1u;
- }
- else
- {
- *( modelVisualToLogicalCursorMap + index ) = logicalPosition0;
- }
- }
- else
- {
- if( direction0 )
- {
- *( modelVisualToLogicalCursorMap + index ) = logicalPosition1;
- }
- else
- {
- *( modelVisualToLogicalCursorMap + index ) = logicalPosition0 + 1u;
- }
- }
- }
- }
+ style.familyName = std::string( fontDescriptionRun.familyName, fontDescriptionRun.familyLength );
+ style.isFamilyDefined = true;
+ }
+
+ // Set the font's weight if it's overriden.
+ if( weightOverriden )
+ {
+ const FontDescriptionRun& fontDescriptionRun = *( fontDescriptionRunsBuffer + weightIndex );
+
+ style.weight = fontDescriptionRun.weight;
+ style.isWeightDefined = true;
+ }
+
+ // Set the font's width if it's overriden.
+ if( widthOverriden )
+ {
+ const FontDescriptionRun& fontDescriptionRun = *( fontDescriptionRunsBuffer + widthIndex );
+
+ style.width = fontDescriptionRun.width;
+ style.isWidthDefined = true;
+ }
+
+ // Set the font's slant if it's overriden.
+ if( slantOverriden )
+ {
+ const FontDescriptionRun& fontDescriptionRun = *( fontDescriptionRunsBuffer + slantIndex );
+
+ style.slant = fontDescriptionRun.slant;
+ style.isSlantDefined = true;
+ }
+
+ // Set the font's size if it's overriden.
+ if( sizeOverriden )
+ {
+ const FontDescriptionRun& fontDescriptionRun = *( fontDescriptionRunsBuffer + sizeIndex );
+
+ style.size = static_cast<float>( fontDescriptionRun.size ) / 64.f;
+ style.isSizeDefined = true;
+ }
+}
+
+void LogicalModel::ClearFontDescriptionRuns()
+{
+ FreeFontFamilyNames( mFontDescriptionRuns );
+}
+
+void LogicalModel::CreateParagraphInfo( CharacterIndex startIndex,
+ Length numberOfCharacters )
+{
+ const Length totalNumberOfCharacters = mLineBreakInfo.Count();
+
+ // Count the number of LINE_MUST_BREAK to reserve some space for the vector of paragraph's info.
+ Vector<CharacterIndex> paragraphs;
+ paragraphs.Reserve( numberOfCharacters );
+ const TextAbstraction::LineBreakInfo* lineBreakInfoBuffer = mLineBreakInfo.Begin();
+ const CharacterIndex lastCharacterIndexPlusOne = startIndex + numberOfCharacters;
+ for( Length index = startIndex; index < lastCharacterIndexPlusOne; ++index )
+ {
+ if( TextAbstraction::LINE_MUST_BREAK == *( lineBreakInfoBuffer + index ) )
+ {
+ paragraphs.PushBack( index );
+ }
+ }
+
+ // Whether the current paragraphs are updated or set from scratch.
+ const bool updateCurrentParagraphs = numberOfCharacters < totalNumberOfCharacters;
+
+ // Reserve space for current paragraphs plus new ones.
+ const Length numberOfNewParagraphs = paragraphs.Count();
+ const Length totalNumberOfParagraphs = mParagraphInfo.Count() + numberOfNewParagraphs;
+ mParagraphInfo.Resize( totalNumberOfParagraphs );
+
+ ParagraphRun* paragraphInfoBuffer = NULL;
+ Vector<ParagraphRun> newParagraphs;
+
+ if( updateCurrentParagraphs )
+ {
+ newParagraphs.Resize( numberOfNewParagraphs );
+ paragraphInfoBuffer = newParagraphs.Begin();
+ }
+ else
+ {
+ paragraphInfoBuffer = mParagraphInfo.Begin();
+ }
+
+ // Find where to insert the new paragraphs.
+ ParagraphRunIndex paragraphIndex = 0u;
+ CharacterIndex firstIndex = startIndex;