Fix text AutoScroll ellipsis issue
[platform/core/uifw/dali-toolkit.git] / automated-tests / src / dali-toolkit-internal / utc-Dali-Text-Layout.cpp
1 /*
2  * Copyright (c) 2022 Samsung Electronics Co., Ltd.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */
17
18 #include <stdlib.h>
19 #include <unistd.h>
20 #include <iostream>
21
22 #include <dali-toolkit-test-suite-utils.h>
23 #include <dali-toolkit/dali-toolkit.h>
24 #include <dali-toolkit/internal/text/layouts/layout-engine.h>
25 #include <dali-toolkit/internal/text/layouts/layout-parameters.h>
26 #include <dali-toolkit/internal/text/text-run-container.h>
27 #include <toolkit-text-utils.h>
28
29 using namespace Dali;
30 using namespace Toolkit;
31 using namespace Text;
32
33 // Tests the LayoutEngine methods.
34
35 //////////////////////////////////////////////////////////
36
37 namespace
38 {
39 const std::string DEFAULT_FONT_DIR("/resources/fonts");
40
41 struct LayoutTextData
42 {
43   std::string                       description;
44   std::string                       text;
45   Size                              textArea;
46   unsigned int                      numberOfFonts;
47   FontDescriptionRun*               fontDescriptions;
48   Size                              layoutSize;
49   unsigned int                      totalNumberOfGlyphs;
50   float*                            positions;
51   unsigned int                      numberOfLines;
52   LineRun*                          lines;
53   Layout::Engine::Type              layout;
54   unsigned int                      startIndex;
55   unsigned int                      numberOfGlyphs;
56   bool                              ellipsis : 1;
57   DevelText::EllipsisPosition::Type ellipsisPosition;
58   bool                              updated : 1;
59 };
60
61 void Print(const LineRun& line)
62 {
63   std::cout << "        glyph run, index : " << line.glyphRun.glyphIndex << ", num glyphs : " << line.glyphRun.numberOfGlyphs << std::endl;
64   std::cout << "    character run, index : " << line.characterRun.characterIndex << ", num chars : " << line.characterRun.numberOfCharacters << std::endl;
65   std::cout << "                   width : " << floor(line.width) << std::endl;
66   std::cout << "                ascender : " << line.ascender << std::endl;
67   std::cout << "               descender : " << line.descender << std::endl;
68   std::cout << "             extraLength : " << line.extraLength << std::endl;
69   std::cout << "         alignmentOffset : " << line.alignmentOffset << std::endl;
70   std::cout << "               direction : " << line.direction << std::endl;
71   std::cout << "                ellipsis : " << line.ellipsis << std::endl;
72 }
73
74 bool LayoutTextTest(const LayoutTextData& data)
75 {
76   // Load some fonts.
77   TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
78   fontClient.SetDpi(96u, 96u);
79
80   char*             pathNamePtr = get_current_dir_name();
81   const std::string pathName(pathNamePtr);
82   free(pathNamePtr);
83
84   fontClient.GetFontId(pathName + DEFAULT_FONT_DIR + "/tizen/TizenSansRegular.ttf");
85   fontClient.GetFontId(pathName + DEFAULT_FONT_DIR + "/tizen/TizenSansHebrewRegular.ttf");
86   fontClient.GetFontId(pathName + DEFAULT_FONT_DIR + "/tizen/TizenSansArabicRegular.ttf");
87   fontClient.GetFontId(pathName + DEFAULT_FONT_DIR + "/tizen/TizenSansHindiRegular.ttf");
88
89   // 1) Create the model.
90   ModelPtr   textModel;
91   MetricsPtr metrics;
92   Size       layoutSize;
93
94   Vector<FontDescriptionRun> fontDescriptionRuns;
95   if(0u != data.numberOfFonts)
96   {
97     fontDescriptionRuns.Insert(fontDescriptionRuns.End(),
98                                data.fontDescriptions,
99                                data.fontDescriptions + data.numberOfFonts);
100   }
101
102   LayoutOptions options;
103   options.align = false;
104   CreateTextModel(data.text,
105                   data.textArea,
106                   fontDescriptionRuns,
107                   options,
108                   layoutSize,
109                   textModel,
110                   metrics,
111                   false,
112                   LineWrap::WORD,
113                   false,
114                   Toolkit::DevelText::EllipsisPosition::END,
115                   0.0f, // lineSpacing
116                   0.0f  // characterSpacing
117   );
118
119   LogicalModelPtr logicalModel = textModel->mLogicalModel;
120   VisualModelPtr  visualModel  = textModel->mVisualModel;
121
122   // 2) Clear the layout.
123   Vector<LineRun>& lines = visualModel->mLines;
124
125   const Length     numberOfCharacters = logicalModel->mText.Count();
126   const bool       isLastNewParagraph = (0u == numberOfCharacters) ? false : TextAbstraction::IsNewParagraph(*(logicalModel->mText.Begin() + (numberOfCharacters - 1u)));
127   const GlyphIndex lastGlyphIndex     = data.startIndex + data.numberOfGlyphs - 1u;
128   const bool       removeLastLine     = isLastNewParagraph && (lastGlyphIndex + 1u == visualModel->mGlyphs.Count());
129
130   LineIndex startRemoveIndex = 0u;
131
132   if(0u != lines.Count())
133   {
134     startRemoveIndex         = lines.Count();
135     LineIndex endRemoveIndex = startRemoveIndex;
136     ClearGlyphRuns(data.startIndex,
137                    lastGlyphIndex + (removeLastLine ? 1u : 0u),
138                    lines,
139                    startRemoveIndex,
140                    endRemoveIndex);
141
142     // Update the character runs of the lines.
143     const CharacterIndex* const glyphsToCharactersBuffer = visualModel->mGlyphsToCharacters.Begin();
144     const Length* const         charactersPerGlyph       = visualModel->mCharactersPerGlyph.Begin();
145     const CharacterIndex        startCharacterIndex      = *(glyphsToCharactersBuffer + data.startIndex);
146     const CharacterIndex        lastCharacterIndex       = *(glyphsToCharactersBuffer + lastGlyphIndex) + *(charactersPerGlyph + lastGlyphIndex) - 1u;
147     ClearCharacterRuns(startCharacterIndex,
148                        lastCharacterIndex + (removeLastLine ? 1u : 0u),
149                        lines,
150                        startRemoveIndex,
151                        endRemoveIndex);
152
153     lines.Erase(lines.Begin() + startRemoveIndex,
154                 lines.Begin() + endRemoveIndex);
155   }
156
157   Vector<Vector2>& glyphPositions = visualModel->mGlyphPositions;
158
159   glyphPositions.Erase(glyphPositions.Begin() + data.startIndex,
160                        glyphPositions.Begin() + data.startIndex + data.numberOfGlyphs);
161
162   // 3) Layout
163   Layout::Engine engine;
164   engine.SetMetrics(metrics);
165   engine.SetLayout(data.layout);
166
167   textModel->mHorizontalAlignment   = Text::HorizontalAlignment::BEGIN;
168   textModel->mLineWrapMode          = LineWrap::WORD;
169   textModel->mIgnoreSpacesAfterText = true;
170   Layout::Parameters layoutParameters(data.textArea,
171                                       textModel);
172
173   layoutParameters.isLastNewParagraph = isLastNewParagraph;
174
175   // The initial glyph and the number of glyphs to layout.
176   layoutParameters.startGlyphIndex        = data.startIndex;
177   layoutParameters.numberOfGlyphs         = data.numberOfGlyphs;
178   layoutParameters.startLineIndex         = startRemoveIndex;
179   layoutParameters.estimatedNumberOfLines = logicalModel->mParagraphInfo.Count();
180
181   layoutSize = Vector2::ZERO;
182
183   bool       isAutoScroll                   = false;
184   bool       isAutoScrollMaxTextureExceeded = false;
185   const bool updated                        = engine.LayoutText(layoutParameters,
186                                          layoutSize,
187                                          data.ellipsis,
188                                          isAutoScroll,
189                                          isAutoScrollMaxTextureExceeded,
190                                          data.ellipsisPosition);
191
192   // 4) Compare the results.
193
194   if(updated != data.updated)
195   {
196     std::cout << "  Different updated bool : " << updated << ", expected : " << data.updated << std::endl;
197     return false;
198   }
199
200   if(layoutSize != data.layoutSize)
201   {
202     std::cout << "  Different layout size : " << layoutSize << ", expected : " << data.layoutSize << std::endl;
203     return false;
204   }
205
206   for(unsigned int index = 0u; index < data.totalNumberOfGlyphs; ++index)
207   {
208     const Vector2& position = *(glyphPositions.Begin() + index);
209
210     if(fabsf(std::round(position.x) - *(data.positions + 2u * index)) > Math::MACHINE_EPSILON_1000)
211     {
212       std::cout << "  Different position for glyph " << index << " x : " << position.x << ", expected : " << *(data.positions + 2u * index) << std::endl;
213       return false;
214     }
215     if(fabsf(position.y - *(data.positions + 2u * index + 1u)) > Math::MACHINE_EPSILON_1000)
216     {
217       std::cout << "  Different position for glyph " << index << " y : " << position.y << ", expected : " << *(data.positions + 2u * index + 1u) << std::endl;
218       return false;
219     }
220   }
221
222   if(lines.Count() != data.numberOfLines)
223   {
224     std::cout << "  Different number of lines : " << lines.Count() << ", expected : " << data.numberOfLines << std::endl;
225     return false;
226   }
227
228   for(unsigned int index = 0u; index < data.numberOfLines; ++index)
229   {
230     const LineRun& line         = *(lines.Begin() + index);
231     const LineRun& expectedLine = *(data.lines + index);
232
233     if(line.glyphRun.glyphIndex != expectedLine.glyphRun.glyphIndex)
234     {
235       std::cout << "  Different line info for line : " << index << std::endl;
236       Print(line);
237       std::cout << "  expected" << std::endl;
238       Print(expectedLine);
239       return false;
240     }
241     if(line.glyphRun.numberOfGlyphs != expectedLine.glyphRun.numberOfGlyphs)
242     {
243       std::cout << "  Different line info for line : " << index << std::endl;
244       Print(line);
245       std::cout << "  expected" << std::endl;
246       Print(expectedLine);
247       return false;
248     }
249
250     if(line.characterRun.characterIndex != expectedLine.characterRun.characterIndex)
251     {
252       std::cout << "  Different line info for line : " << index << std::endl;
253       Print(line);
254       std::cout << "  expected" << std::endl;
255       Print(expectedLine);
256       return false;
257     }
258     if(line.characterRun.numberOfCharacters != expectedLine.characterRun.numberOfCharacters)
259     {
260       std::cout << "  Different line info for line : " << index << std::endl;
261       Print(line);
262       std::cout << "  expected" << std::endl;
263       Print(expectedLine);
264       return false;
265     }
266
267     if(fabsf(floor(line.width) - expectedLine.width) > Math::MACHINE_EPSILON_1)
268     {
269       std::cout << "  Different line info for line : " << index << std::endl;
270       Print(line);
271       std::cout << "  expected" << std::endl;
272       Print(expectedLine);
273       return false;
274     }
275
276     if(fabsf(line.ascender - expectedLine.ascender) > Math::MACHINE_EPSILON_1)
277     {
278       std::cout << "  Different line info for line : " << index << std::endl;
279       Print(line);
280       std::cout << "  expected" << std::endl;
281       Print(expectedLine);
282       return false;
283     }
284
285     if(fabsf(line.descender - expectedLine.descender) > Math::MACHINE_EPSILON_1)
286     {
287       std::cout << "  Different line info for line : " << index << std::endl;
288       Print(line);
289       std::cout << "  expected" << std::endl;
290       Print(expectedLine);
291       return false;
292     }
293
294     if(fabsf(line.extraLength - expectedLine.extraLength) > Math::MACHINE_EPSILON_1)
295     {
296       std::cout << "  Different line info for line : " << index << std::endl;
297       Print(line);
298       std::cout << "  expected" << std::endl;
299       Print(expectedLine);
300       return false;
301     }
302
303     if(line.ellipsis != expectedLine.ellipsis)
304     {
305       std::cout << "  Different line info for line : " << index << std::endl;
306       Print(line);
307       std::cout << "  expected" << std::endl;
308       Print(expectedLine);
309       return false;
310     }
311
312     // Do not compare the alignment offset as it's not calculated in the layout.
313     // Do not compare the line direction as it's not set in the layout.
314   }
315
316   return true;
317 }
318
319 //////////////////////////////////////////////////////////
320
321 struct AlignData
322 {
323   std::string                     description;
324   std::string                     text;
325   Size                            textArea;
326   unsigned int                    numberOfFonts;
327   FontDescriptionRun*             fontDescriptions;
328   Text::HorizontalAlignment::Type horizontalAlignment;
329   Text::VerticalAlignment::Type   verticalAlignment;
330   unsigned int                    startIndex;
331   unsigned int                    numberOfCharacters;
332   unsigned int                    numberOfLines;
333   float*                          lineOffsets;
334   Dali::LayoutDirection::Type     layoutDirection;
335   bool                            matchSystemLanguageDirection;
336 };
337
338 bool AlignTest(const AlignData& data)
339 {
340   // Load some fonts.
341   TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
342   fontClient.SetDpi(96u, 96u);
343
344   char*             pathNamePtr = get_current_dir_name();
345   const std::string pathName(pathNamePtr);
346   free(pathNamePtr);
347
348   fontClient.GetFontId(pathName + DEFAULT_FONT_DIR + "/tizen/TizenSansRegular.ttf");
349   fontClient.GetFontId(pathName + DEFAULT_FONT_DIR + "/tizen/TizenSansHebrewRegular.ttf");
350   fontClient.GetFontId(pathName + DEFAULT_FONT_DIR + "/tizen/TizenSansArabicRegular.ttf");
351
352   // 1) Create the model.
353   ModelPtr   textModel;
354   MetricsPtr metrics;
355   Size       layoutSize;
356
357   Vector<FontDescriptionRun> fontDescriptionRuns;
358   if(0u != data.numberOfFonts)
359   {
360     fontDescriptionRuns.Insert(fontDescriptionRuns.End(),
361                                data.fontDescriptions,
362                                data.fontDescriptions + data.numberOfFonts);
363   }
364
365   LayoutOptions options;
366   options.align = false;
367   CreateTextModel(data.text,
368                   data.textArea,
369                   fontDescriptionRuns,
370                   options,
371                   layoutSize,
372                   textModel,
373                   metrics,
374                   false,
375                   LineWrap::WORD,
376                   false,
377                   Toolkit::DevelText::EllipsisPosition::END,
378                   0.0f, // lineSpacing
379                   0.0f  // characterSpacing
380   );
381
382   LogicalModelPtr logicalModel = textModel->mLogicalModel;
383   VisualModelPtr  visualModel  = textModel->mVisualModel;
384
385   // Call the Align method.
386   Layout::Engine engine;
387   engine.SetMetrics(metrics);
388
389   float alignmentOffset = 0.f;
390   engine.Align(data.textArea,
391                data.startIndex,
392                data.numberOfCharacters,
393                data.horizontalAlignment,
394                visualModel->mLines,
395                alignmentOffset,
396                data.layoutDirection,
397                data.matchSystemLanguageDirection);
398
399   // Compare results.
400   if(data.numberOfLines != visualModel->mLines.Count())
401   {
402     std::cout << "  Different number of lines : " << visualModel->mLines.Count() << ", expected : " << data.numberOfLines << std::endl;
403     return false;
404   }
405
406   const LineRun* const linesBuffer = visualModel->mLines.Begin();
407   for(unsigned int index = 0u; index < data.numberOfLines; ++index)
408   {
409     const LineRun& line = *(linesBuffer + index);
410
411     if(line.alignmentOffset != *(data.lineOffsets + index))
412     {
413       std::cout << "  different line offset for index " << index << " : " << line.alignmentOffset << ", expected : " << *(data.lineOffsets + index) << std::endl;
414       return false;
415     }
416   }
417   return true;
418 }
419
420 } // namespace
421
422 //////////////////////////////////////////////////////////
423 //
424 // UtcDaliTextLayoutSetGetLayout
425 // UtcDaliTextLayoutSetGetTextEllipsisEnabled
426 // UtcDaliTextLayoutSetGetHorizontalAlignment
427 // UtcDaliTextLayoutSetGetVerticalAlignment
428 // UtcDaliTextLayoutSetGetCursorWidth
429 // UtcDaliTextLayoutNoText
430 // UtcDaliTextLayoutSmallTextArea01
431 // UtcDaliTextLayoutSmallTextArea02
432 // UtcDaliTextLayoutMultilineText01
433 // UtcDaliTextLayoutMultilineText02
434 // UtcDaliTextLayoutMultilineText03
435 // UtcDaliTextLayoutMultilineText04
436 // UtcDaliTextLayoutMultilineText05
437 // UtcDaliTextLayoutMultilineText06
438 // UtcDaliTextUpdateLayout01
439 // UtcDaliTextUpdateLayout02
440 // UtcDaliTextUpdateLayout03
441 // UtcDaliTextLayoutEllipsis01
442 // UtcDaliTextLayoutEllipsis02
443 // UtcDaliTextLayoutEllipsis03
444 // UtcDaliTextLayoutEllipsis04
445 // UtcDaliTextLayoutEllipsis04
446 // UtcDaliTextReorderLayout01
447 // UtcDaliTextReorderLayout02
448 // UtcDaliTextReorderLayout03
449 // UtcDaliTextReorderLayout04
450 // UtcDaliTextAlign01
451 // UtcDaliTextAlign02
452 // UtcDaliTextAlign03
453 // UtcDaliTextAlign04
454 // UtcDaliTextAlign05
455 // UtcDaliTextAlign06
456 // UtcDaliTextAlign07
457 // UtcDaliTextAlign08
458 // UtcDaliTextAlign09
459 //
460 //////////////////////////////////////////////////////////
461
462 int UtcDaliTextLayoutSetGetLayout(void)
463 {
464   ToolkitTestApplication application;
465   tet_infoline(" UtcDaliTextLayoutSetGetLayout");
466
467   Layout::Engine engine;
468
469   DALI_TEST_CHECK(Layout::Engine::SINGLE_LINE_BOX == engine.GetLayout());
470
471   engine.SetLayout(Layout::Engine::MULTI_LINE_BOX);
472   DALI_TEST_CHECK(Layout::Engine::MULTI_LINE_BOX == engine.GetLayout());
473
474   tet_result(TET_PASS);
475   END_TEST;
476 }
477
478 int UtcDaliTextLayoutSetGetCursorWidth(void)
479 {
480   ToolkitTestApplication application;
481   tet_infoline(" ");
482
483   Layout::Engine engine;
484
485   DALI_TEST_EQUALS(0, engine.GetCursorWidth(), TEST_LOCATION);
486
487   engine.SetCursorWidth(2);
488   DALI_TEST_EQUALS(2, engine.GetCursorWidth(), TEST_LOCATION);
489
490   tet_result(TET_PASS);
491   END_TEST;
492 }
493
494 int UtcDaliTextLayoutNoText(void)
495 {
496   ToolkitTestApplication application;
497   tet_infoline(" UtcDaliTextLayoutNoText");
498
499   Size           textArea(100.f, 60.f);
500   Size           layoutSize = Vector2::ZERO;
501   LayoutTextData data =
502     {
503       "No text",
504       "",
505       textArea,
506       0u,
507       NULL,
508       layoutSize,
509       0u,
510       NULL,
511       0u,
512       NULL,
513       Layout::Engine::MULTI_LINE_BOX,
514       0u,
515       0u,
516       false,
517       DevelText::EllipsisPosition::END,
518       false};
519
520   if(!LayoutTextTest(data))
521   {
522     tet_result(TET_FAIL);
523   }
524
525   tet_result(TET_PASS);
526   END_TEST;
527 }
528
529 int UtcDaliTextLayoutSmallTextArea01(void)
530 {
531   ToolkitTestApplication application;
532   tet_infoline(" UtcDaliTextLayoutSmallTextArea01");
533
534   // Won't layout the text in multi-line if the width is too small.
535
536   const std::string fontFamily("TizenSans");
537
538   // Set a known font description
539   FontDescriptionRun fontDescriptionRun;
540   fontDescriptionRun.characterRun.characterIndex     = 0u;
541   fontDescriptionRun.characterRun.numberOfCharacters = 11u;
542   fontDescriptionRun.familyLength                    = fontFamily.size();
543   fontDescriptionRun.familyName                      = new char[fontDescriptionRun.familyLength];
544   memcpy(fontDescriptionRun.familyName, fontFamily.c_str(), fontDescriptionRun.familyLength);
545   fontDescriptionRun.familyDefined = true;
546   fontDescriptionRun.weightDefined = false;
547   fontDescriptionRun.widthDefined  = false;
548   fontDescriptionRun.slantDefined  = false;
549   fontDescriptionRun.sizeDefined   = false;
550
551   Vector<FontDescriptionRun> fontDescriptionRuns;
552   fontDescriptionRuns.PushBack(fontDescriptionRun);
553   Size           textArea(1.f, 1.f);
554   Size           layoutSize = Vector2::ZERO;
555   LayoutTextData data =
556     {
557       "Layout text in a small area",
558       "Hello world",
559       textArea,
560       1u,
561       fontDescriptionRuns.Begin(),
562       layoutSize,
563       0u,
564       NULL,
565       0u,
566       NULL,
567       Layout::Engine::MULTI_LINE_BOX,
568       0u,
569       11u,
570       false,
571       DevelText::EllipsisPosition::END,
572       false};
573
574   if(!LayoutTextTest(data))
575   {
576     tet_result(TET_FAIL);
577   }
578
579   tet_result(TET_PASS);
580   END_TEST;
581 }
582
583 int UtcDaliTextLayoutSmallTextArea02(void)
584 {
585   ToolkitTestApplication application;
586   tet_infoline(" UtcDaliTextLayoutSmallTextArea02");
587
588   // Will layout the text in single line as it can be scrolled.
589
590   const std::string fontFamily("TizenSans");
591
592   // Set a known font description
593   FontDescriptionRun fontDescriptionRun;
594   fontDescriptionRun.characterRun.characterIndex     = 0u;
595   fontDescriptionRun.characterRun.numberOfCharacters = 11u;
596   fontDescriptionRun.familyLength                    = fontFamily.size();
597   fontDescriptionRun.familyName                      = new char[fontDescriptionRun.familyLength];
598   memcpy(fontDescriptionRun.familyName, fontFamily.c_str(), fontDescriptionRun.familyLength);
599   fontDescriptionRun.familyDefined = true;
600   fontDescriptionRun.weightDefined = false;
601   fontDescriptionRun.widthDefined  = false;
602   fontDescriptionRun.slantDefined  = false;
603   fontDescriptionRun.sizeDefined   = false;
604
605   Vector<FontDescriptionRun> fontDescriptionRuns;
606   fontDescriptionRuns.PushBack(fontDescriptionRun);
607   Size           textArea(1.f, 1.f);
608   Size           layoutSize(81.f, 20.f);
609   float          positions[] = {0.f, -12.f, 10.f, -9.f, 20.f, -13.f, 24.f, -13.f, 27.f, -9.f, 36.f, -0.f, 40.f, -9.f, 52.f, -9.f, 62.f, -9.f, 69.f, -13.f, 72.f, -13.f};
610   struct LineRun line =
611     {
612       {0u, 11u},
613       {0u, 11u},
614       81.f,
615       15.f,
616       -5.f,
617       0.f,
618       0.f,
619       0.f,
620       false,
621       false};
622   Vector<LineRun> lines;
623   lines.PushBack(line);
624
625   LayoutTextData data =
626     {
627       "Layout text in a small area",
628       "Hello world",
629       textArea,
630       1u,
631       fontDescriptionRuns.Begin(),
632       layoutSize,
633       11u,
634       positions,
635       1u,
636       lines.Begin(),
637       Layout::Engine::SINGLE_LINE_BOX,
638       0u,
639       11u,
640       false,
641       DevelText::EllipsisPosition::END,
642       true};
643
644   if(!LayoutTextTest(data))
645   {
646     tet_result(TET_FAIL);
647   }
648
649   tet_result(TET_PASS);
650   END_TEST;
651 }
652
653 int UtcDaliTextLayoutMultilineText01(void)
654 {
655   ToolkitTestApplication application;
656   tet_infoline(" UtcDaliTextLayoutMultilineText01");
657
658   // Layout some lines of left to right text.
659
660   const std::string fontFamily("TizenSans");
661
662   // Set a known font description
663   FontDescriptionRun fontDescriptionRun1;
664   fontDescriptionRun1.characterRun.characterIndex     = 0u;
665   fontDescriptionRun1.characterRun.numberOfCharacters = 18u;
666   fontDescriptionRun1.familyLength                    = fontFamily.size();
667   fontDescriptionRun1.familyName                      = new char[fontDescriptionRun1.familyLength];
668   memcpy(fontDescriptionRun1.familyName, fontFamily.c_str(), fontDescriptionRun1.familyLength);
669   fontDescriptionRun1.familyDefined = true;
670   fontDescriptionRun1.weightDefined = false;
671   fontDescriptionRun1.widthDefined  = false;
672   fontDescriptionRun1.slantDefined  = false;
673   fontDescriptionRun1.sizeDefined   = false;
674
675   FontDescriptionRun fontDescriptionRun2;
676   fontDescriptionRun2.characterRun.characterIndex     = 18u;
677   fontDescriptionRun2.characterRun.numberOfCharacters = 31u;
678   fontDescriptionRun2.familyLength                    = fontFamily.size();
679   fontDescriptionRun2.familyName                      = new char[fontDescriptionRun2.familyLength];
680   memcpy(fontDescriptionRun2.familyName, fontFamily.c_str(), fontDescriptionRun2.familyLength);
681   fontDescriptionRun2.familyDefined = true;
682   fontDescriptionRun2.weightDefined = false;
683   fontDescriptionRun2.widthDefined  = false;
684   fontDescriptionRun2.slantDefined  = false;
685   fontDescriptionRun2.sizeDefined   = false;
686
687   Vector<FontDescriptionRun> fontDescriptionRuns;
688   fontDescriptionRuns.PushBack(fontDescriptionRun1);
689   fontDescriptionRuns.PushBack(fontDescriptionRun2);
690   Size  textArea(100.f, 300.f);
691   Size  layoutSize(98.f, 97.f);
692   float positions[] =
693     {
694       0.f, -12.f, 10.f, -9.f, 20.f, -13.f, 24.f, -13.f, 27.f, -9.f, 36.f, -0.f, 40.f, -9.f, 52.f, -9.f, 62.f, -9.f, 69.f, -13.f, 72.f, -13.f, 81.f, -0.f, 0.f, -13.f, 9.f, -9.f, 19.f, -9.f, 32.f, -9.f, 41.f, -2.f, 45.f, -12.f, 0.f, -12.f, 8.f, -9.f, 18.f, -9.f, 27.f, -9.f, 38.f, -9.f, 47.f, -11.f, 53.f, -0.f, 0.f, -12.f, 11.f, -12.f, 15.f, -12.f, 26.f, -9.f, 36.f, -9.f, 42.f, -9.f, 53.f, -9.f, 62.f, -11.f, 68.f, -0.f, 0.f, -12.f, 4.f, -12.f, 9.f, -9.f, 18.f, -9.f, 28.f, -9.f, 36.f, -0.f, 41.f, -9.f, 51.f, -12.f, 57.f, -0.f, 62.f, -11.f, 68.f, -9.f, 78.f, -9.f, 87.f, -11.f, 94.f, -2.f};
695   struct LineRun line0 =
696     {
697       {0u, 12u},
698       {0u, 12u},
699       81.f,
700       15.f,
701       -5.f,
702       4.f,
703       0.f,
704       0.f,
705       false,
706       false};
707   struct LineRun line1 =
708     {
709       {12u, 6u},
710       {12u, 6u},
711       44.f,
712       15.f,
713       -5.f,
714       0.f,
715       0.f,
716       0.f,
717       false,
718       false};
719   struct LineRun line2 =
720     {
721       {18u, 7u},
722       {18u, 7u},
723       54.f,
724       15.f,
725       -4.f,
726       6.f,
727       0.f,
728       0.f,
729       false,
730       false};
731   struct LineRun line3 =
732     {
733       {25u, 9u},
734       {25u, 10u},
735       68.f,
736       15.f,
737       -4.f,
738       6.f,
739       0.f,
740       0.f,
741       false,
742       false};
743   struct LineRun line4 =
744     {
745       {34u, 14u},
746       {35u, 14u},
747       98.f,
748       15.f,
749       -4.f,
750       0.f,
751       0.f,
752       0.f,
753       false,
754       false};
755   Vector<LineRun> lines;
756   lines.PushBack(line0);
757   lines.PushBack(line1);
758   lines.PushBack(line2);
759   lines.PushBack(line3);
760   lines.PushBack(line4);
761
762   LayoutTextData data =
763     {
764       "Layout simple multi-line text",
765       "Hello world demo.\n"
766       "Layout different lines of text.",
767       textArea,
768       1u,
769       fontDescriptionRuns.Begin(),
770       layoutSize,
771       48u,
772       positions,
773       5u,
774       lines.Begin(),
775       Layout::Engine::MULTI_LINE_BOX,
776       0u,
777       48u,
778       false,
779       DevelText::EllipsisPosition::END,
780       true};
781
782   if(!LayoutTextTest(data))
783   {
784     tet_result(TET_FAIL);
785   }
786
787   tet_result(TET_PASS);
788   END_TEST;
789 }
790
791 int UtcDaliTextLayoutMultilineText02(void)
792 {
793   ToolkitTestApplication application;
794   tet_infoline(" UtcDaliTextLayoutMultilineText02");
795
796   // Layout some lines of bidirectional text.
797
798   const std::string fontFamily1("TizenSans");
799
800   // Set a known font description
801   FontDescriptionRun fontDescriptionRun1;
802   fontDescriptionRun1.characterRun.characterIndex     = 0u;
803   fontDescriptionRun1.characterRun.numberOfCharacters = 17u;
804   fontDescriptionRun1.familyLength                    = fontFamily1.size();
805   fontDescriptionRun1.familyName                      = new char[fontDescriptionRun1.familyLength];
806   memcpy(fontDescriptionRun1.familyName, fontFamily1.c_str(), fontDescriptionRun1.familyLength);
807   fontDescriptionRun1.familyDefined = true;
808   fontDescriptionRun1.weightDefined = false;
809   fontDescriptionRun1.widthDefined  = false;
810   fontDescriptionRun1.slantDefined  = false;
811   fontDescriptionRun1.sizeDefined   = false;
812
813   const std::string fontFamily2("TizenSansHebrew");
814
815   // Set a known font description
816   FontDescriptionRun fontDescriptionRun2;
817   fontDescriptionRun2.characterRun.characterIndex     = 17u;
818   fontDescriptionRun2.characterRun.numberOfCharacters = 9u;
819   fontDescriptionRun2.familyLength                    = fontFamily2.size();
820   fontDescriptionRun2.familyName                      = new char[fontDescriptionRun2.familyLength];
821   memcpy(fontDescriptionRun2.familyName, fontFamily2.c_str(), fontDescriptionRun2.familyLength);
822   fontDescriptionRun2.familyDefined = true;
823   fontDescriptionRun2.weightDefined = false;
824   fontDescriptionRun2.widthDefined  = false;
825   fontDescriptionRun2.slantDefined  = false;
826   fontDescriptionRun2.sizeDefined   = false;
827
828   const std::string fontFamily3("TizenSans");
829
830   // Set a known font description
831   FontDescriptionRun fontDescriptionRun3;
832   fontDescriptionRun3.characterRun.characterIndex     = 26u;
833   fontDescriptionRun3.characterRun.numberOfCharacters = 2u;
834   fontDescriptionRun3.familyLength                    = fontFamily3.size();
835   fontDescriptionRun3.familyName                      = new char[fontDescriptionRun3.familyLength];
836   memcpy(fontDescriptionRun3.familyName, fontFamily3.c_str(), fontDescriptionRun3.familyLength);
837   fontDescriptionRun3.familyDefined = true;
838   fontDescriptionRun3.weightDefined = false;
839   fontDescriptionRun3.widthDefined  = false;
840   fontDescriptionRun3.slantDefined  = false;
841   fontDescriptionRun3.sizeDefined   = false;
842
843   const std::string fontFamily4("TizenSansHebrew");
844
845   // Set a known font description
846   FontDescriptionRun fontDescriptionRun4;
847   fontDescriptionRun4.characterRun.characterIndex     = 28u;
848   fontDescriptionRun4.characterRun.numberOfCharacters = 10u;
849   fontDescriptionRun4.familyLength                    = fontFamily4.size();
850   fontDescriptionRun4.familyName                      = new char[fontDescriptionRun4.familyLength];
851   memcpy(fontDescriptionRun4.familyName, fontFamily4.c_str(), fontDescriptionRun4.familyLength);
852   fontDescriptionRun4.familyDefined = true;
853   fontDescriptionRun4.weightDefined = false;
854   fontDescriptionRun4.widthDefined  = false;
855   fontDescriptionRun4.slantDefined  = false;
856   fontDescriptionRun4.sizeDefined   = false;
857
858   const std::string fontFamily5("TizenSans");
859
860   // Set a known font description
861   FontDescriptionRun fontDescriptionRun5;
862   fontDescriptionRun5.characterRun.characterIndex     = 38u;
863   fontDescriptionRun5.characterRun.numberOfCharacters = 17u;
864   fontDescriptionRun5.familyLength                    = fontFamily5.size();
865   fontDescriptionRun5.familyName                      = new char[fontDescriptionRun5.familyLength];
866   memcpy(fontDescriptionRun5.familyName, fontFamily5.c_str(), fontDescriptionRun5.familyLength);
867   fontDescriptionRun5.familyDefined = true;
868   fontDescriptionRun5.weightDefined = false;
869   fontDescriptionRun5.widthDefined  = false;
870   fontDescriptionRun5.slantDefined  = false;
871   fontDescriptionRun5.sizeDefined   = false;
872
873   Vector<FontDescriptionRun> fontDescriptionRuns;
874   fontDescriptionRuns.PushBack(fontDescriptionRun1);
875   fontDescriptionRuns.PushBack(fontDescriptionRun2);
876   fontDescriptionRuns.PushBack(fontDescriptionRun3);
877   fontDescriptionRuns.PushBack(fontDescriptionRun4);
878   fontDescriptionRuns.PushBack(fontDescriptionRun5);
879   Size  textArea(100.f, 300.f);
880   Size  layoutSize(81.f, 120.f);
881   float positions[] =
882     {
883       0.f, -12.f, 10.f, -9.f, 20.f, -13.f, 24.f, -13.f, 27.f, -9.f, 36.f, -0.f, 40.f, -9.f, 52.f, -9.f, 62.f, -9.f, 69.f, -13.f, 72.f, -13.f, 81.f, -0.f, //  0 .. 11
884       0.f,
885       -13.f,
886       9.f,
887       -9.f,
888       19.f,
889       -9.f,
890       32.f,
891       -9.f,
892       41.f,
893       -0.f,
894       68.f,
895       -10.f,
896       59.f,
897       -13.f,
898       54.f,
899       -10.f,
900       45.f,
901       -10.f,
902       79.f,
903       -0.f, // 12 .. 21
904       23.f,
905       -10.f,
906       19.f,
907       -10.f,
908       10.f,
909       -13.f,
910       0.f,
911       -10.f,
912       32.f,
913       -2.f,
914       36.f,
915       -12.f, // 22 .. 27
916       63.f,
917       -10.f,
918       54.f,
919       -13.f,
920       50.f,
921       -10.f,
922       41.f,
923       -10.f,
924       36.f,
925       -0.f,
926       27.f,
927       -10.f,
928       23.f,
929       -10.f,
930       14.f,
931       -13.f,
932       4.f,
933       -10.f,
934       0.f,
935       -0.f, // 28 .. 37
936       4.f,
937       -13.f,
938       12.f,
939       -9.f,
940       22.f,
941       -13.f,
942       26.f,
943       -13.f,
944       29.f,
945       -9.f,
946       38.f,
947       -0.f,
948       42.f,
949       -9.f,
950       54.f,
951       -9.f,
952       64.f,
953       -9.f,
954       70.f,
955       -13.f,
956       73.f,
957       -13.f,
958       0.f,
959       -0.f, // 38 .. 49
960       4.f,
961       -13.f,
962       13.f,
963       -9.f,
964       23.f,
965       -9.f,
966       36.f,
967       -9.f,
968       0.f,
969       -2.f, // 50 .. 54
970     };
971   struct LineRun line0 =
972     {
973       {0u, 12u},
974       {0u, 12u},
975       81.f,
976       15.f,
977       -5.f,
978       4.f,
979       0.f,
980       0.f,
981       false,
982       false};
983   struct LineRun line1 =
984     {
985       {12u, 10u},
986       {12u, 10u},
987       79.f,
988       15.f,
989       -5.f,
990       5.f,
991       0.f,
992       0.f,
993       false,
994       false};
995   struct LineRun line2 =
996     {
997       {22u, 6u},
998       {22u, 6u},
999       35.f,
1000       15.f,
1001       -5.f,
1002       0.f,
1003       0.f,
1004       0.f,
1005       false,
1006       false};
1007   struct LineRun line3 =
1008     {
1009       {28u, 10u},
1010       {28u, 10u},
1011       70.f,
1012       15.f,
1013       -5.f,
1014       5.f,
1015       0.f,
1016       0.f,
1017       false,
1018       false};
1019   struct LineRun line4 =
1020     {
1021       {38u, 12u},
1022       {38u, 12u},
1023       79.f,
1024       15.f,
1025       -5.f,
1026       4.f,
1027       0.f,
1028       0.f,
1029       false,
1030       false};
1031   struct LineRun line5 =
1032     {
1033       {50u, 5u},
1034       {50u, 5u},
1035       45.f,
1036       15.f,
1037       -5.f,
1038       0.f,
1039       0.f,
1040       0.f,
1041       false,
1042       false};
1043   Vector<LineRun> lines;
1044   lines.PushBack(line0);
1045   lines.PushBack(line1);
1046   lines.PushBack(line2);
1047   lines.PushBack(line3);
1048   lines.PushBack(line4);
1049   lines.PushBack(line5);
1050
1051   LayoutTextData data =
1052     {
1053       "Layout bidirectional text.",
1054       "Hello world demo שלום עולם.\n"
1055       "שלום עולם hello world demo.",
1056       textArea,
1057       5u,
1058       fontDescriptionRuns.Begin(),
1059       layoutSize,
1060       55u,
1061       positions,
1062       6u,
1063       lines.Begin(),
1064       Layout::Engine::MULTI_LINE_BOX,
1065       0u,
1066       55u,
1067       false,
1068       DevelText::EllipsisPosition::END,
1069       true};
1070
1071   if(!LayoutTextTest(data))
1072   {
1073     tet_result(TET_FAIL);
1074   }
1075
1076   tet_result(TET_PASS);
1077   END_TEST;
1078 }
1079
1080 int UtcDaliTextLayoutMultilineText03(void)
1081 {
1082   ToolkitTestApplication application;
1083   tet_infoline(" UtcDaliTextLayoutMultilineText03");
1084
1085   // Layout a long word which doesn't fit in the width of the text area.
1086
1087   const std::string fontFamily("TizenSans");
1088
1089   // Set a known font description
1090   FontDescriptionRun fontDescriptionRun;
1091   fontDescriptionRun.characterRun.characterIndex     = 0u;
1092   fontDescriptionRun.characterRun.numberOfCharacters = 29u;
1093   fontDescriptionRun.familyLength                    = fontFamily.size();
1094   fontDescriptionRun.familyName                      = new char[fontDescriptionRun.familyLength];
1095   memcpy(fontDescriptionRun.familyName, fontFamily.c_str(), fontDescriptionRun.familyLength);
1096   fontDescriptionRun.familyDefined = true;
1097   fontDescriptionRun.weightDefined = false;
1098   fontDescriptionRun.widthDefined  = false;
1099   fontDescriptionRun.slantDefined  = false;
1100   fontDescriptionRun.sizeDefined   = false;
1101
1102   Vector<FontDescriptionRun> fontDescriptionRuns;
1103   fontDescriptionRuns.PushBack(fontDescriptionRun);
1104   Size  textArea(100.f, 300.f);
1105   Size  layoutSize(98.f, 60.f);
1106   float positions[] =
1107     {
1108       0.f,
1109       -12.f,
1110       10.f,
1111       -9.f,
1112       20.f,
1113       -13.f,
1114       24.f,
1115       -13.f,
1116       27.f,
1117       -9.f,
1118       36.f,
1119       -9.f,
1120       48.f,
1121       -9.f,
1122       58.f,
1123       -9.f,
1124       65.f,
1125       -13.f,
1126       68.f,
1127       -13.f,
1128       77.f,
1129       -13.f,
1130       86.f,
1131       -9.f,
1132       0.f,
1133       -9.f,
1134       13.f,
1135       -9.f,
1136       23.f,
1137       -13.f,
1138       31.f,
1139       -9.f,
1140       41.f,
1141       -13.f,
1142       45.f,
1143       -13.f,
1144       48.f,
1145       -9.f,
1146       57.f,
1147       -9.f,
1148       69.f,
1149       -9.f,
1150       79.f,
1151       -9.f,
1152       85.f,
1153       -13.f,
1154       88.f,
1155       -13.f,
1156       0.f,
1157       -13.f,
1158       9.f,
1159       -9.f,
1160       19.f,
1161       -9.f,
1162       32.f,
1163       -9.f,
1164       41.f,
1165       -2.f,
1166     };
1167   struct LineRun line0 =
1168     {
1169       {0u, 12u},
1170       {0u, 12u},
1171       95.f,
1172       15.f,
1173       -5.f,
1174       0.f,
1175       0.f,
1176       0.f,
1177       false,
1178       false};
1179   struct LineRun line1 =
1180     {
1181       {12u, 12u},
1182       {12u, 12u},
1183       98.f,
1184       15.f,
1185       -5.f,
1186       0.f,
1187       0.f,
1188       0.f,
1189       false,
1190       false};
1191   struct LineRun line2 =
1192     {
1193       {24u, 5u},
1194       {24u, 5u},
1195       44.f,
1196       15.f,
1197       -5.f,
1198       0.f,
1199       0.f,
1200       0.f,
1201       false,
1202       false};
1203   Vector<LineRun> lines;
1204   lines.PushBack(line0);
1205   lines.PushBack(line1);
1206   lines.PushBack(line2);
1207
1208   LayoutTextData data =
1209     {
1210       "Layout a long word which doesn't fit in the width of the text area.",
1211       "Helloworlddemohelloworlddemo.",
1212       textArea,
1213       1u,
1214       fontDescriptionRuns.Begin(),
1215       layoutSize,
1216       29u,
1217       positions,
1218       3u,
1219       lines.Begin(),
1220       Layout::Engine::MULTI_LINE_BOX,
1221       0u,
1222       29u,
1223       false,
1224       DevelText::EllipsisPosition::END,
1225       true};
1226
1227   if(!LayoutTextTest(data))
1228   {
1229     tet_result(TET_FAIL);
1230   }
1231
1232   tet_result(TET_PASS);
1233   END_TEST;
1234 }
1235
1236 int UtcDaliTextLayoutMultilineText04(void)
1237 {
1238   ToolkitTestApplication application;
1239   tet_infoline(" UtcDaliTextLayoutMultilineText04");
1240
1241   // Layout simple text ending with a \n. It has to add a void line at the end.
1242
1243   const std::string fontFamily("TizenSans");
1244
1245   // Set a known font description
1246   FontDescriptionRun fontDescriptionRun;
1247   fontDescriptionRun.characterRun.characterIndex     = 0u;
1248   fontDescriptionRun.characterRun.numberOfCharacters = 13u;
1249   fontDescriptionRun.familyLength                    = fontFamily.size();
1250   fontDescriptionRun.familyName                      = new char[fontDescriptionRun.familyLength];
1251   memcpy(fontDescriptionRun.familyName, fontFamily.c_str(), fontDescriptionRun.familyLength);
1252   fontDescriptionRun.familyDefined = true;
1253   fontDescriptionRun.weightDefined = false;
1254   fontDescriptionRun.widthDefined  = false;
1255   fontDescriptionRun.slantDefined  = false;
1256   fontDescriptionRun.sizeDefined   = false;
1257
1258   Vector<FontDescriptionRun> fontDescriptionRuns;
1259   fontDescriptionRuns.PushBack(fontDescriptionRun);
1260   Size  textArea(100.f, 300.f);
1261   Size  layoutSize(84.f, 40.f);
1262   float positions[] =
1263     {
1264       0.f, -12.f, 10.f, -9.f, 20.f, -13.f, 24.f, -13.f, 27.f, -9.f, 36.f, -0.f, 40.f, -9.f, 52.f, -9.f, 62.f, -9.f, 69.f, -13.f, 72.f, -13.f, 81.f, -2.f, 85.f, -12.f};
1265   struct LineRun line0 =
1266     {
1267       {0u, 13u},
1268       {0u, 13u},
1269       84.f,
1270       15.f,
1271       -5.f,
1272       0.f,
1273       0.f,
1274       false,
1275       false};
1276   struct LineRun line1 =
1277     {
1278       {13u, 0u},
1279       {13u, 0u},
1280       0.f,
1281       15.f,
1282       -5.f,
1283       0.f,
1284       0.f,
1285       0.f,
1286       false,
1287       false};
1288   Vector<LineRun> lines;
1289   lines.PushBack(line0);
1290   lines.PushBack(line1);
1291
1292   LayoutTextData data =
1293     {
1294       "Layout simple text ending with a \n.",
1295       "Hello world.\n",
1296       textArea,
1297       1u,
1298       fontDescriptionRuns.Begin(),
1299       layoutSize,
1300       13u,
1301       positions,
1302       2u,
1303       lines.Begin(),
1304       Layout::Engine::MULTI_LINE_BOX,
1305       0u,
1306       13u,
1307       false,
1308       DevelText::EllipsisPosition::END,
1309       true};
1310
1311   if(!LayoutTextTest(data))
1312   {
1313     tet_result(TET_FAIL);
1314   }
1315
1316   tet_result(TET_PASS);
1317   END_TEST;
1318 }
1319
1320 int UtcDaliTextLayoutMultilineText05(void)
1321 {
1322   ToolkitTestApplication application;
1323   tet_infoline(" UtcDaliTextLayoutMultilineText05");
1324
1325   // Layout simple text with one character with a different font size.
1326
1327   const std::string fontFamily("TizenSans");
1328
1329   // Set a known font description
1330   FontDescriptionRun fontDescriptionRun1;
1331   fontDescriptionRun1.characterRun.characterIndex     = 0u;
1332   fontDescriptionRun1.characterRun.numberOfCharacters = 6u;
1333   fontDescriptionRun1.familyLength                    = fontFamily.size();
1334   fontDescriptionRun1.familyName                      = new char[fontDescriptionRun1.familyLength];
1335   memcpy(fontDescriptionRun1.familyName, fontFamily.c_str(), fontDescriptionRun1.familyLength);
1336   fontDescriptionRun1.familyDefined = true;
1337   fontDescriptionRun1.weightDefined = false;
1338   fontDescriptionRun1.widthDefined  = false;
1339   fontDescriptionRun1.slantDefined  = false;
1340   fontDescriptionRun1.sizeDefined   = false;
1341
1342   FontDescriptionRun fontDescriptionRun2;
1343   fontDescriptionRun2.characterRun.characterIndex     = 6u;
1344   fontDescriptionRun2.characterRun.numberOfCharacters = 1u;
1345   fontDescriptionRun2.familyLength                    = fontFamily.size();
1346   fontDescriptionRun2.familyName                      = new char[fontDescriptionRun2.familyLength];
1347   memcpy(fontDescriptionRun2.familyName, fontFamily.c_str(), fontDescriptionRun2.familyLength);
1348   fontDescriptionRun2.size          = 1280u;
1349   fontDescriptionRun2.familyDefined = true;
1350   fontDescriptionRun2.weightDefined = false;
1351   fontDescriptionRun2.widthDefined  = false;
1352   fontDescriptionRun2.slantDefined  = false;
1353   fontDescriptionRun2.sizeDefined   = true;
1354
1355   FontDescriptionRun fontDescriptionRun3;
1356   fontDescriptionRun3.characterRun.characterIndex     = 7u;
1357   fontDescriptionRun3.characterRun.numberOfCharacters = 10u;
1358   fontDescriptionRun3.familyLength                    = fontFamily.size();
1359   fontDescriptionRun3.familyName                      = new char[fontDescriptionRun3.familyLength];
1360   memcpy(fontDescriptionRun3.familyName, fontFamily.c_str(), fontDescriptionRun3.familyLength);
1361   fontDescriptionRun3.familyDefined = true;
1362   fontDescriptionRun3.weightDefined = false;
1363   fontDescriptionRun3.widthDefined  = false;
1364   fontDescriptionRun3.slantDefined  = false;
1365   fontDescriptionRun3.sizeDefined   = false;
1366
1367   Vector<FontDescriptionRun> fontDescriptionRuns;
1368   fontDescriptionRuns.PushBack(fontDescriptionRun1);
1369   fontDescriptionRuns.PushBack(fontDescriptionRun2);
1370   fontDescriptionRuns.PushBack(fontDescriptionRun3);
1371   Size  textArea(100.f, 300.f);
1372   Size  layoutSize(89.f, 53.f);
1373   float positions[] =
1374     {
1375       0.f, -12.f, 10.f, -9.f, 20.f, -13.f, 24.f, -13.f, 27.f, -9.f, 36.f, -0.f, 40.f, -14.f, 60.f, -9.f, 70.f, -9.f, 76.f, -13.f, 80.f, -13.f, 89.f, -0.f, 0.f, -13.f, 9.f, -9.f, 19.f, -9.f, 32.f, -9.f, 41.f, -2.f};
1376   struct LineRun line0 =
1377     {
1378       {0u, 12u},
1379       {0u, 12u},
1380       89.f,
1381       25.f,
1382       -8.f,
1383       4.f,
1384       0.f,
1385       0.f,
1386       false,
1387       false};
1388   struct LineRun line1 =
1389     {
1390       {12u, 5u},
1391       {12u, 5u},
1392       44.f,
1393       15.f,
1394       -5.f,
1395       0.f,
1396       0.f,
1397       0.f,
1398       false,
1399       false};
1400   Vector<LineRun> lines;
1401   lines.PushBack(line0);
1402   lines.PushBack(line1);
1403
1404   LayoutTextData data =
1405     {
1406       "Layout simple text with one character with a different font size.",
1407       "Hello world demo.",
1408       textArea,
1409       3u,
1410       fontDescriptionRuns.Begin(),
1411       layoutSize,
1412       17u,
1413       positions,
1414       2u,
1415       lines.Begin(),
1416       Layout::Engine::MULTI_LINE_BOX,
1417       0u,
1418       17u,
1419       false,
1420       DevelText::EllipsisPosition::END,
1421       true};
1422
1423   if(!LayoutTextTest(data))
1424   {
1425     tet_result(TET_FAIL);
1426   }
1427
1428   tet_result(TET_PASS);
1429   END_TEST;
1430 }
1431
1432 int UtcDaliTextLayoutMultilineText06(void)
1433 {
1434   ToolkitTestApplication application;
1435   tet_infoline(" UtcDaliTextLayoutMultilineText06");
1436
1437   const std::string fontFamily("TizenSansHebrew");
1438
1439   // Set a known font description
1440   FontDescriptionRun fontDescriptionRun;
1441   fontDescriptionRun.characterRun.characterIndex     = 0u;
1442   fontDescriptionRun.characterRun.numberOfCharacters = 10u;
1443   fontDescriptionRun.familyLength                    = fontFamily.size();
1444   fontDescriptionRun.familyName                      = new char[fontDescriptionRun.familyLength];
1445   memcpy(fontDescriptionRun.familyName, fontFamily.c_str(), fontDescriptionRun.familyLength);
1446   fontDescriptionRun.familyDefined = true;
1447   fontDescriptionRun.weightDefined = false;
1448   fontDescriptionRun.widthDefined  = false;
1449   fontDescriptionRun.slantDefined  = false;
1450   fontDescriptionRun.sizeDefined   = false;
1451
1452   Vector<FontDescriptionRun> fontDescriptionRuns;
1453   fontDescriptionRuns.PushBack(fontDescriptionRun);
1454
1455   Size  textArea(64.f, 100.f);
1456   Size  layoutSize(34.f, 40.f);
1457   float positions[] =
1458     {
1459       27.f, -13.f, 18.f, -10.f, 9.f, -10.f, 4.f, -10.f, 0.f, -0.f, 22.f, -10.f, 17.f, -10.f, 12.f, -10.f, 4.f, -10.f, 0.f, -10.f};
1460   struct LineRun line0 =
1461     {
1462       {0u, 5u},
1463       {0u, 5u},
1464       32.f,
1465       15.f,
1466       -5.f,
1467       5.f,
1468       0.f,
1469       0.f,
1470       true,
1471       false};
1472   struct LineRun line1 =
1473     {
1474       {5u, 5u},
1475       {5u, 5u},
1476       34.f,
1477       15.f,
1478       -5.f,
1479       0.f,
1480       0.f,
1481       0.f,
1482       true,
1483       false};
1484   Vector<LineRun> lines;
1485   lines.PushBack(line0);
1486   lines.PushBack(line1);
1487
1488   LayoutTextData data =
1489     {
1490       "Layout right to left text that doesn't fit in the text area after reordering.",
1491       "לכאן שנורו", // If this text is laid-out ltr the width is 64. When reordered, the length is 66. This might cause alignment issues.
1492       textArea,
1493       1u,
1494       fontDescriptionRuns.Begin(),
1495       layoutSize,
1496       10u,
1497       positions,
1498       2u,
1499       lines.Begin(),
1500       Layout::Engine::MULTI_LINE_BOX,
1501       0u,
1502       10u,
1503       false,
1504       DevelText::EllipsisPosition::END,
1505       true};
1506
1507   if(!LayoutTextTest(data))
1508   {
1509     tet_result(TET_FAIL);
1510   }
1511
1512   tet_result(TET_PASS);
1513   END_TEST;
1514 }
1515
1516 int UtcDaliTextLayoutMultilineText07(void)
1517 {
1518   ToolkitTestApplication application;
1519   tet_infoline(" UtcDaliTextLayoutMultilineText07");
1520
1521   const std::string fontFamily("TizenSansHebrew");
1522
1523   // Set a known font description
1524   FontDescriptionRun fontDescriptionRun;
1525   fontDescriptionRun.characterRun.characterIndex     = 0u;
1526   fontDescriptionRun.characterRun.numberOfCharacters = 9u;
1527   fontDescriptionRun.familyLength                    = fontFamily.size();
1528   fontDescriptionRun.familyName                      = new char[fontDescriptionRun.familyLength];
1529   memcpy(fontDescriptionRun.familyName, fontFamily.c_str(), fontDescriptionRun.familyLength);
1530   fontDescriptionRun.familyDefined = true;
1531   fontDescriptionRun.weightDefined = false;
1532   fontDescriptionRun.widthDefined  = false;
1533   fontDescriptionRun.slantDefined  = false;
1534   fontDescriptionRun.sizeDefined   = false;
1535
1536   Vector<FontDescriptionRun> fontDescriptionRuns;
1537   fontDescriptionRuns.PushBack(fontDescriptionRun);
1538
1539   Size  textArea(26.f, 100.f);
1540   Size  layoutSize(24.f, 60.f);
1541   float positions[] =
1542     {
1543       10.f, -10.f, 4.f, -10.f, 0.f, -10.f, 13.f, -10.f, 9.f, -10.f, 0.f, -13.f, 14.f, -10.f, 4.f, -10.f, 0.f, -10.f};
1544   struct LineRun line0 =
1545     {
1546       {0u, 3u},
1547       {0u, 3u},
1548       21.f,
1549       15.f,
1550       -5.f,
1551       0.f,
1552       0.f,
1553       0.f,
1554       true,
1555       false};
1556   struct LineRun line1 =
1557     {
1558       {3u, 3u},
1559       {3u, 3u},
1560       22.f,
1561       15.f,
1562       -5.f,
1563       0.f,
1564       0.f,
1565       0.f,
1566       true,
1567       false};
1568   struct LineRun line2 =
1569     {
1570       {6u, 3u},
1571       {6u, 3u},
1572       24.f,
1573       15.f,
1574       -5.f,
1575       0.f,
1576       0.f,
1577       0.f,
1578       true,
1579       false};
1580   Vector<LineRun> lines;
1581   lines.PushBack(line0);
1582   lines.PushBack(line1);
1583   lines.PushBack(line2);
1584
1585   LayoutTextData data =
1586     {
1587       "Layout a single word of right to left text that doesn't fit in one single line. When layouting ltr a piece of word fits in the line but it doesn't after reordering.",
1588       "שנורולכאן", // If a piece of this text is laid-out ltr the width is 26. When reordered, the length is 27. This might cause alignment issues.
1589       textArea,
1590       1u,
1591       fontDescriptionRuns.Begin(),
1592       layoutSize,
1593       9u,
1594       positions,
1595       3u,
1596       lines.Begin(),
1597       Layout::Engine::MULTI_LINE_BOX,
1598       0u,
1599       9u,
1600       false,
1601       DevelText::EllipsisPosition::END,
1602       true};
1603
1604   if(!LayoutTextTest(data))
1605   {
1606     tet_result(TET_FAIL);
1607   }
1608
1609   tet_result(TET_PASS);
1610   END_TEST;
1611 }
1612
1613 int UtcDaliTextUpdateLayout01(void)
1614 {
1615   ToolkitTestApplication application;
1616   tet_infoline(" UtcDaliTextUpdateLayout01");
1617
1618   // Layout some lines of bidirectional text. Update the paragraphs at the beginning.
1619
1620   const std::string fontLatin("TizenSans");
1621   const std::string fontHebrew("TizenSansHebrew");
1622   const std::string fontArabic("TizenSansArabic");
1623
1624   // Set a known font description
1625   FontDescriptionRun fontDescriptionRun01;
1626   fontDescriptionRun01.characterRun.characterIndex     = 0u;
1627   fontDescriptionRun01.characterRun.numberOfCharacters = 17u;
1628   fontDescriptionRun01.familyLength                    = fontLatin.size();
1629   fontDescriptionRun01.familyName                      = new char[fontDescriptionRun01.familyLength];
1630   memcpy(fontDescriptionRun01.familyName, fontLatin.c_str(), fontDescriptionRun01.familyLength);
1631   fontDescriptionRun01.familyDefined = true;
1632   fontDescriptionRun01.weightDefined = false;
1633   fontDescriptionRun01.widthDefined  = false;
1634   fontDescriptionRun01.slantDefined  = false;
1635   fontDescriptionRun01.sizeDefined   = false;
1636
1637   // Set a known font description
1638   FontDescriptionRun fontDescriptionRun02;
1639   fontDescriptionRun02.characterRun.characterIndex     = 17u;
1640   fontDescriptionRun02.characterRun.numberOfCharacters = 9u;
1641   fontDescriptionRun02.familyLength                    = fontHebrew.size();
1642   fontDescriptionRun02.familyName                      = new char[fontDescriptionRun02.familyLength];
1643   memcpy(fontDescriptionRun02.familyName, fontHebrew.c_str(), fontDescriptionRun02.familyLength);
1644   fontDescriptionRun02.familyDefined = true;
1645   fontDescriptionRun02.weightDefined = false;
1646   fontDescriptionRun02.widthDefined  = false;
1647   fontDescriptionRun02.slantDefined  = false;
1648   fontDescriptionRun02.sizeDefined   = false;
1649
1650   // Set a known font description
1651   FontDescriptionRun fontDescriptionRun03;
1652   fontDescriptionRun03.characterRun.characterIndex     = 26u;
1653   fontDescriptionRun03.characterRun.numberOfCharacters = 2u;
1654   fontDescriptionRun03.familyLength                    = fontLatin.size();
1655   fontDescriptionRun03.familyName                      = new char[fontDescriptionRun03.familyLength];
1656   memcpy(fontDescriptionRun03.familyName, fontLatin.c_str(), fontDescriptionRun03.familyLength);
1657   fontDescriptionRun03.familyDefined = true;
1658   fontDescriptionRun03.weightDefined = false;
1659   fontDescriptionRun03.widthDefined  = false;
1660   fontDescriptionRun03.slantDefined  = false;
1661   fontDescriptionRun03.sizeDefined   = false;
1662
1663   // Set a known font description
1664   FontDescriptionRun fontDescriptionRun04;
1665   fontDescriptionRun04.characterRun.characterIndex     = 28u;
1666   fontDescriptionRun04.characterRun.numberOfCharacters = 14u;
1667   fontDescriptionRun04.familyLength                    = fontArabic.size();
1668   fontDescriptionRun04.familyName                      = new char[fontDescriptionRun04.familyLength];
1669   memcpy(fontDescriptionRun04.familyName, fontArabic.c_str(), fontDescriptionRun04.familyLength);
1670   fontDescriptionRun04.familyDefined = true;
1671   fontDescriptionRun04.weightDefined = false;
1672   fontDescriptionRun04.widthDefined  = false;
1673   fontDescriptionRun04.slantDefined  = false;
1674   fontDescriptionRun04.sizeDefined   = false;
1675
1676   // Set a known font description
1677   FontDescriptionRun fontDescriptionRun05;
1678   fontDescriptionRun05.characterRun.characterIndex     = 42u;
1679   fontDescriptionRun05.characterRun.numberOfCharacters = 12u;
1680   fontDescriptionRun05.familyLength                    = fontLatin.size();
1681   fontDescriptionRun05.familyName                      = new char[fontDescriptionRun05.familyLength];
1682   memcpy(fontDescriptionRun05.familyName, fontLatin.c_str(), fontDescriptionRun05.familyLength);
1683   fontDescriptionRun05.familyDefined = true;
1684   fontDescriptionRun05.weightDefined = false;
1685   fontDescriptionRun05.widthDefined  = false;
1686   fontDescriptionRun05.slantDefined  = false;
1687   fontDescriptionRun05.sizeDefined   = false;
1688
1689   // Set a known font description
1690   FontDescriptionRun fontDescriptionRun06;
1691   fontDescriptionRun06.characterRun.characterIndex     = 54u;
1692   fontDescriptionRun06.characterRun.numberOfCharacters = 10u;
1693   fontDescriptionRun06.familyLength                    = fontHebrew.size();
1694   fontDescriptionRun06.familyName                      = new char[fontDescriptionRun06.familyLength];
1695   memcpy(fontDescriptionRun06.familyName, fontHebrew.c_str(), fontDescriptionRun06.familyLength);
1696   fontDescriptionRun06.familyDefined = true;
1697   fontDescriptionRun06.weightDefined = false;
1698   fontDescriptionRun06.widthDefined  = false;
1699   fontDescriptionRun06.slantDefined  = false;
1700   fontDescriptionRun06.sizeDefined   = false;
1701
1702   // Set a known font description
1703   FontDescriptionRun fontDescriptionRun07;
1704   fontDescriptionRun07.characterRun.characterIndex     = 64u;
1705   fontDescriptionRun07.characterRun.numberOfCharacters = 10u;
1706   fontDescriptionRun07.familyLength                    = fontHebrew.size();
1707   fontDescriptionRun07.familyName                      = new char[fontDescriptionRun07.familyLength];
1708   memcpy(fontDescriptionRun07.familyName, fontHebrew.c_str(), fontDescriptionRun07.familyLength);
1709   fontDescriptionRun07.familyDefined = true;
1710   fontDescriptionRun07.weightDefined = false;
1711   fontDescriptionRun07.widthDefined  = false;
1712   fontDescriptionRun07.slantDefined  = false;
1713   fontDescriptionRun07.sizeDefined   = false;
1714
1715   // Set a known font description
1716   FontDescriptionRun fontDescriptionRun08;
1717   fontDescriptionRun08.characterRun.characterIndex     = 74u;
1718   fontDescriptionRun08.characterRun.numberOfCharacters = 18u;
1719   fontDescriptionRun08.familyLength                    = fontLatin.size();
1720   fontDescriptionRun08.familyName                      = new char[fontDescriptionRun08.familyLength];
1721   memcpy(fontDescriptionRun08.familyName, fontLatin.c_str(), fontDescriptionRun08.familyLength);
1722   fontDescriptionRun08.familyDefined = true;
1723   fontDescriptionRun08.weightDefined = false;
1724   fontDescriptionRun08.widthDefined  = false;
1725   fontDescriptionRun08.slantDefined  = false;
1726   fontDescriptionRun08.sizeDefined   = false;
1727
1728   // Set a known font description
1729   FontDescriptionRun fontDescriptionRun09;
1730   fontDescriptionRun09.characterRun.characterIndex     = 92u;
1731   fontDescriptionRun09.characterRun.numberOfCharacters = 12u;
1732   fontDescriptionRun09.familyLength                    = fontLatin.size();
1733   fontDescriptionRun09.familyName                      = new char[fontDescriptionRun09.familyLength];
1734   memcpy(fontDescriptionRun09.familyName, fontLatin.c_str(), fontDescriptionRun09.familyLength);
1735   fontDescriptionRun09.familyDefined = true;
1736   fontDescriptionRun09.weightDefined = false;
1737   fontDescriptionRun09.widthDefined  = false;
1738   fontDescriptionRun09.slantDefined  = false;
1739   fontDescriptionRun09.sizeDefined   = false;
1740
1741   // Set a known font description
1742   FontDescriptionRun fontDescriptionRun10;
1743   fontDescriptionRun10.characterRun.characterIndex     = 104u;
1744   fontDescriptionRun10.characterRun.numberOfCharacters = 14u;
1745   fontDescriptionRun10.familyLength                    = fontArabic.size();
1746   fontDescriptionRun10.familyName                      = new char[fontDescriptionRun10.familyLength];
1747   memcpy(fontDescriptionRun10.familyName, fontArabic.c_str(), fontDescriptionRun10.familyLength);
1748   fontDescriptionRun10.familyDefined = true;
1749   fontDescriptionRun10.weightDefined = false;
1750   fontDescriptionRun10.widthDefined  = false;
1751   fontDescriptionRun10.slantDefined  = false;
1752   fontDescriptionRun10.sizeDefined   = false;
1753
1754   // Set a known font description
1755   FontDescriptionRun fontDescriptionRun11;
1756   fontDescriptionRun11.characterRun.characterIndex     = 118u;
1757   fontDescriptionRun11.characterRun.numberOfCharacters = 10u;
1758   fontDescriptionRun11.familyLength                    = fontHebrew.size();
1759   fontDescriptionRun11.familyName                      = new char[fontDescriptionRun11.familyLength];
1760   memcpy(fontDescriptionRun11.familyName, fontHebrew.c_str(), fontDescriptionRun11.familyLength);
1761   fontDescriptionRun11.familyDefined = true;
1762   fontDescriptionRun11.weightDefined = false;
1763   fontDescriptionRun11.widthDefined  = false;
1764   fontDescriptionRun11.slantDefined  = false;
1765   fontDescriptionRun11.sizeDefined   = false;
1766
1767   // Set a known font description
1768   FontDescriptionRun fontDescriptionRun12;
1769   fontDescriptionRun12.characterRun.characterIndex     = 128u;
1770   fontDescriptionRun12.characterRun.numberOfCharacters = 17u;
1771   fontDescriptionRun12.familyLength                    = fontLatin.size();
1772   fontDescriptionRun12.familyName                      = new char[fontDescriptionRun12.familyLength];
1773   memcpy(fontDescriptionRun12.familyName, fontLatin.c_str(), fontDescriptionRun12.familyLength);
1774   fontDescriptionRun12.familyDefined = true;
1775   fontDescriptionRun12.weightDefined = false;
1776   fontDescriptionRun12.widthDefined  = false;
1777   fontDescriptionRun12.slantDefined  = false;
1778   fontDescriptionRun12.sizeDefined   = false;
1779
1780   // Set a known font description
1781   FontDescriptionRun fontDescriptionRun13;
1782   fontDescriptionRun13.characterRun.characterIndex     = 145u;
1783   fontDescriptionRun13.characterRun.numberOfCharacters = 9u;
1784   fontDescriptionRun13.familyLength                    = fontHebrew.size();
1785   fontDescriptionRun13.familyName                      = new char[fontDescriptionRun13.familyLength];
1786   memcpy(fontDescriptionRun13.familyName, fontHebrew.c_str(), fontDescriptionRun13.familyLength);
1787   fontDescriptionRun13.familyDefined = true;
1788   fontDescriptionRun13.weightDefined = false;
1789   fontDescriptionRun13.widthDefined  = false;
1790   fontDescriptionRun13.slantDefined  = false;
1791   fontDescriptionRun13.sizeDefined   = false;
1792
1793   // Set a known font description
1794   FontDescriptionRun fontDescriptionRun14;
1795   fontDescriptionRun14.characterRun.characterIndex     = 154u;
1796   fontDescriptionRun14.characterRun.numberOfCharacters = 2u;
1797   fontDescriptionRun14.familyLength                    = fontLatin.size();
1798   fontDescriptionRun14.familyName                      = new char[fontDescriptionRun14.familyLength];
1799   memcpy(fontDescriptionRun14.familyName, fontLatin.c_str(), fontDescriptionRun14.familyLength);
1800   fontDescriptionRun14.familyDefined = true;
1801   fontDescriptionRun14.weightDefined = false;
1802   fontDescriptionRun14.widthDefined  = false;
1803   fontDescriptionRun14.slantDefined  = false;
1804   fontDescriptionRun14.sizeDefined   = false;
1805
1806   // Set a known font description
1807   FontDescriptionRun fontDescriptionRun15;
1808   fontDescriptionRun15.characterRun.characterIndex     = 156u;
1809   fontDescriptionRun15.characterRun.numberOfCharacters = 10u;
1810   fontDescriptionRun15.familyLength                    = fontHebrew.size();
1811   fontDescriptionRun15.familyName                      = new char[fontDescriptionRun15.familyLength];
1812   memcpy(fontDescriptionRun15.familyName, fontHebrew.c_str(), fontDescriptionRun15.familyLength);
1813   fontDescriptionRun15.familyDefined = true;
1814   fontDescriptionRun15.weightDefined = false;
1815   fontDescriptionRun15.widthDefined  = false;
1816   fontDescriptionRun15.slantDefined  = false;
1817   fontDescriptionRun15.sizeDefined   = false;
1818
1819   // Set a known font description
1820   FontDescriptionRun fontDescriptionRun16;
1821   fontDescriptionRun16.characterRun.characterIndex     = 166u;
1822   fontDescriptionRun16.characterRun.numberOfCharacters = 12u;
1823   fontDescriptionRun16.familyLength                    = fontLatin.size();
1824   fontDescriptionRun16.familyName                      = new char[fontDescriptionRun16.familyLength];
1825   memcpy(fontDescriptionRun16.familyName, fontLatin.c_str(), fontDescriptionRun16.familyLength);
1826   fontDescriptionRun16.familyDefined = true;
1827   fontDescriptionRun16.weightDefined = false;
1828   fontDescriptionRun16.widthDefined  = false;
1829   fontDescriptionRun16.slantDefined  = false;
1830   fontDescriptionRun16.sizeDefined   = false;
1831
1832   // Set a known font description
1833   FontDescriptionRun fontDescriptionRun17;
1834   fontDescriptionRun17.characterRun.characterIndex     = 178u;
1835   fontDescriptionRun17.characterRun.numberOfCharacters = 14u;
1836   fontDescriptionRun17.familyLength                    = fontArabic.size();
1837   fontDescriptionRun17.familyName                      = new char[fontDescriptionRun17.familyLength];
1838   memcpy(fontDescriptionRun17.familyName, fontArabic.c_str(), fontDescriptionRun17.familyLength);
1839   fontDescriptionRun17.familyDefined = true;
1840   fontDescriptionRun17.weightDefined = false;
1841   fontDescriptionRun17.widthDefined  = false;
1842   fontDescriptionRun17.slantDefined  = false;
1843   fontDescriptionRun17.sizeDefined   = false;
1844
1845   Vector<FontDescriptionRun> fontDescriptionRuns;
1846   fontDescriptionRuns.PushBack(fontDescriptionRun01);
1847   fontDescriptionRuns.PushBack(fontDescriptionRun02);
1848   fontDescriptionRuns.PushBack(fontDescriptionRun03);
1849   fontDescriptionRuns.PushBack(fontDescriptionRun04);
1850   fontDescriptionRuns.PushBack(fontDescriptionRun05);
1851   fontDescriptionRuns.PushBack(fontDescriptionRun06);
1852   fontDescriptionRuns.PushBack(fontDescriptionRun07);
1853   fontDescriptionRuns.PushBack(fontDescriptionRun08);
1854   fontDescriptionRuns.PushBack(fontDescriptionRun09);
1855   fontDescriptionRuns.PushBack(fontDescriptionRun10);
1856   fontDescriptionRuns.PushBack(fontDescriptionRun11);
1857   fontDescriptionRuns.PushBack(fontDescriptionRun12);
1858   fontDescriptionRuns.PushBack(fontDescriptionRun13);
1859   fontDescriptionRuns.PushBack(fontDescriptionRun14);
1860   fontDescriptionRuns.PushBack(fontDescriptionRun15);
1861   fontDescriptionRuns.PushBack(fontDescriptionRun16);
1862   fontDescriptionRuns.PushBack(fontDescriptionRun17);
1863   Size  textArea(100.f, 300.f);
1864   Size  layoutSize(100.f, 380.f);
1865   float positions[] =
1866     {
1867       0.f, -12.f, 10.f, -9.f, 20.f, -13.f, 24.f, -13.f, 27.f, -9.f, 36.f, -0.f, 40.f, -9.f, 52.f, -9.f, 62.f, -9.f, 69.f, -13.f, 72.f, -13.f, 81.f, -0.f, //   0 ..  11
1868       0.f,
1869       -13.f,
1870       9.f,
1871       -9.f,
1872       19.f,
1873       -9.f,
1874       32.f,
1875       -9.f,
1876       41.f,
1877       -0.f,
1878       68.f,
1879       -10.f,
1880       59.f,
1881       -13.f,
1882       54.f,
1883       -10.f,
1884       45.f,
1885       -10.f,
1886       79.f,
1887       -0.f, //  12 ..  21
1888       23.f,
1889       -10.f,
1890       19.f,
1891       -10.f,
1892       10.f,
1893       -13.f,
1894       0.f,
1895       -10.f,
1896       32.f,
1897       -2.f,
1898       36.f,
1899       -12.f, //  22 ..  27
1900       58.f,
1901       -8.f,
1902       52.f,
1903       -6.f,
1904       45.f,
1905       -8.f,
1906       41.f,
1907       -7.f,
1908       39.f,
1909       -11.f,
1910       34.f,
1911       -0.f,
1912       30.f,
1913       -7.f,
1914       28.f,
1915       -11.f,
1916       23.f,
1917       -11.f,
1918       16.f,
1919       -8.f,
1920       15.f,
1921       -11.f,
1922       9.f,
1923       -11.f,
1924       4.f,
1925       -8.f,
1926       0.f,
1927       -0.f,
1928       4.f,
1929       -13.f,
1930       12.f,
1931       -9.f,
1932       22.f,
1933       -13.f,
1934       26.f,
1935       -13.f,
1936       29.f,
1937       -9.f,
1938       38.f,
1939       -0.f, //  28 ..  47
1940       42.f,
1941       -9.f,
1942       54.f,
1943       -9.f,
1944       64.f,
1945       -9.f,
1946       70.f,
1947       -13.f,
1948       73.f,
1949       -13.f,
1950       0.f,
1951       -0.f,
1952       59.f,
1953       -10.f,
1954       50.f,
1955       -13.f,
1956       46.f,
1957       -10.f,
1958       36.f,
1959       -10.f,
1960       32.f,
1961       -0.f, //  48 ..  58
1962       23.f,
1963       -10.f,
1964       19.f,
1965       -10.f,
1966       10.f,
1967       -13.f,
1968       0.f,
1969       -10.f,
1970       0.f,
1971       -0.f, //  59 ..  63
1972       63.f,
1973       -10.f,
1974       54.f,
1975       -13.f,
1976       50.f,
1977       -10.f,
1978       41.f,
1979       -10.f,
1980       36.f,
1981       -0.f,
1982       27.f,
1983       -10.f,
1984       23.f,
1985       -10.f,
1986       14.f,
1987       -13.f,
1988       4.f,
1989       -10.f,
1990       0.f,
1991       -0.f, //  64 ..  73
1992       4.f,
1993       -13.f,
1994       12.f,
1995       -9.f,
1996       22.f,
1997       -13.f,
1998       26.f,
1999       -13.f,
2000       29.f,
2001       -9.f,
2002       38.f,
2003       -0.f,
2004       42.f,
2005       -9.f,
2006       54.f,
2007       -9.f,
2008       64.f,
2009       -9.f,
2010       70.f,
2011       -13.f,
2012       73.f,
2013       -13.f,
2014       0.f,
2015       -0.f, //  74 ..  85
2016       4.f,
2017       -13.f,
2018       13.f,
2019       -9.f,
2020       23.f,
2021       -9.f,
2022       36.f,
2023       -9.f,
2024       0.f,
2025       -2.f,
2026       0.f,
2027       -12.f, //  86 ..  91
2028       0.f,
2029       -13.f,
2030       8.f,
2031       -9.f,
2032       18.f,
2033       -13.f,
2034       22.f,
2035       -13.f,
2036       25.f,
2037       -9.f,
2038       34.f,
2039       -0.f,
2040       38.f,
2041       -9.f,
2042       50.f,
2043       -9.f,
2044       60.f,
2045       -9.f,
2046       66.f,
2047       -13.f,
2048       69.f,
2049       -13.f,
2050       79.f,
2051       -0.f, //  92 .. 103
2052       92.f,
2053       -8.f,
2054       86.f,
2055       -6.f,
2056       79.f,
2057       -8.f,
2058       75.f,
2059       -7.f,
2060       73.f,
2061       -11.f,
2062       68.f,
2063       -0.f,
2064       64.f,
2065       -7.f,
2066       62.f,
2067       -11.f,
2068       57.f,
2069       -11.f,
2070       50.f,
2071       -8.f,
2072       49.f,
2073       -11.f,
2074       43.f,
2075       -11.f,
2076       38.f,
2077       -8.f,
2078       34.f,
2079       -0.f,
2080       23.f,
2081       -10.f,
2082       14.f,
2083       -13.f,
2084       10.f,
2085       -10.f,
2086       0.f,
2087       -10.f,
2088       99.f,
2089       -0.f, // 104 .. 122
2090       23.f,
2091       -10.f,
2092       19.f,
2093       -10.f,
2094       10.f,
2095       -13.f,
2096       0.f,
2097       -10.f,
2098       32.f,
2099       -0.f, // 123 .. 127
2100       0.f,
2101       -12.f,
2102       10.f,
2103       -9.f,
2104       20.f,
2105       -13.f,
2106       24.f,
2107       -13.f,
2108       27.f,
2109       -9.f,
2110       36.f,
2111       -0.f,
2112       40.f,
2113       -9.f,
2114       52.f,
2115       -9.f,
2116       62.f,
2117       -9.f,
2118       69.f,
2119       -13.f,
2120       72.f,
2121       -13.f,
2122       81.f,
2123       -0.f, // 128 .. 139
2124       0.f,
2125       -13.f,
2126       9.f,
2127       -9.f,
2128       19.f,
2129       -9.f,
2130       32.f,
2131       -9.f,
2132       41.f,
2133       -0.f,
2134       68.f,
2135       -10.f,
2136       59.f,
2137       -13.f,
2138       54.f,
2139       -10.f,
2140       45.f,
2141       -10.f,
2142       79.f,
2143       -0.f, // 140 .. 149
2144       23.f,
2145       -10.f,
2146       19.f,
2147       -10.f,
2148       10.f,
2149       -13.f,
2150       0.f,
2151       -10.f,
2152       32.f,
2153       -2.f,
2154       36.f,
2155       -12.f, // 150 .. 155
2156       63.f,
2157       -10.f,
2158       54.f,
2159       -13.f,
2160       50.f,
2161       -10.f,
2162       41.f,
2163       -10.f,
2164       36.f,
2165       -0.f,
2166       27.f,
2167       -10.f,
2168       23.f,
2169       -10.f,
2170       14.f,
2171       -13.f,
2172       4.f,
2173       -10.f,
2174       0.f,
2175       -0.f, // 156 .. 165
2176       4.f,
2177       -13.f,
2178       12.f,
2179       -9.f,
2180       22.f,
2181       -13.f,
2182       26.f,
2183       -13.f,
2184       29.f,
2185       -9.f,
2186       38.f,
2187       -0.f,
2188       42.f,
2189       -9.f,
2190       54.f,
2191       -9.f,
2192       64.f,
2193       -9.f,
2194       70.f,
2195       -13.f,
2196       73.f,
2197       -13.f,
2198       0.f,
2199       -0.f, // 166 .. 177
2200       54.f,
2201       -8.f,
2202       49.f,
2203       -6.f,
2204       41.f,
2205       -8.f,
2206       37.f,
2207       -7.f,
2208       35.f,
2209       -11.f,
2210       31.f,
2211       -0.f,
2212       26.f,
2213       -7.f,
2214       24.f,
2215       -11.f,
2216       19.f,
2217       -11.f,
2218       12.f,
2219       -8.f,
2220       11.f,
2221       -11.f,
2222       5.f,
2223       -11.f,
2224       0.f,
2225       -8.f,
2226       0.f,
2227       -0.f, // 178 .. 191
2228     };
2229
2230   struct LineRun line01 =
2231     {
2232       {0u, 12u},
2233       {0u, 12u},
2234       81.f,
2235       15.f,
2236       -5.f,
2237       4.f,
2238       0.f,
2239       0.f,
2240       false,
2241       false};
2242   struct LineRun line02 =
2243     {
2244       {12u, 10u},
2245       {12u, 10u},
2246       79.f,
2247       15.f,
2248       -5.f,
2249       5.f,
2250       0.f,
2251       0.f,
2252       false,
2253       false};
2254   struct LineRun line03 =
2255     {
2256       {22u, 6u},
2257       {22u, 6u},
2258       35.f,
2259       15.f,
2260       -5.f,
2261       0.f,
2262       0.f,
2263       0.f,
2264       false,
2265       false};
2266   struct LineRun line04 =
2267     {
2268       {28u, 14u},
2269       {28u, 14u},
2270       63.f,
2271       15.f,
2272       -5.f,
2273       4.f,
2274       0.f,
2275       0.f,
2276       true,
2277       false};
2278   struct LineRun line05 =
2279     {
2280       {42, 12u},
2281       {42, 12u},
2282       79.f,
2283       15.f,
2284       -5.f,
2285       4.f,
2286       0.f,
2287       0.f,
2288       true,
2289       false};
2290   struct LineRun line06 =
2291     {
2292       {54u, 10u},
2293       {54u, 10u},
2294       70.f,
2295       15.f,
2296       -5.f,
2297       0.f,
2298       0.f,
2299       0.f,
2300       false,
2301       false};
2302   struct LineRun line07 =
2303     {
2304       {64u, 10u},
2305       {64u, 10u},
2306       70.f,
2307       15.f,
2308       -5.f,
2309       5.f,
2310       0.f,
2311       0.f,
2312       true,
2313       false};
2314   struct LineRun line08 =
2315     {
2316       {74u, 12u},
2317       {74u, 12u},
2318       79.f,
2319       15.f,
2320       -5.f,
2321       4.f,
2322       0.f,
2323       0.f,
2324       true,
2325       false};
2326   struct LineRun line09 =
2327     {
2328       {86u, 6u},
2329       {86u, 6u},
2330       45.f,
2331       15.f,
2332       -5.f,
2333       0.f,
2334       0.f,
2335       0.f,
2336       false,
2337       false};
2338   struct LineRun line10 =
2339     {
2340       {92u, 12u},
2341       {92u, 12u},
2342       79.f,
2343       15.f,
2344       -5.f,
2345       4.f,
2346       0.f,
2347       0.f,
2348       false,
2349       false};
2350   struct LineRun line11 =
2351     {
2352       {104u, 19u},
2353       {104u, 19u},
2354       100.f,
2355       15.f,
2356       -5.f,
2357       5.f,
2358       0.f,
2359       0.f,
2360       false,
2361       false};
2362   struct LineRun line12 =
2363     {
2364       {123u, 5u},
2365       {123u, 5u},
2366       32.f,
2367       15.f,
2368       -5.f,
2369       0.f,
2370       0.f,
2371       0.f,
2372       false,
2373       false};
2374   struct LineRun line13 =
2375     {
2376       {128u, 12u},
2377       {128u, 12u},
2378       81.f,
2379       15.f,
2380       -5.f,
2381       4.f,
2382       0.f,
2383       0.f,
2384       false,
2385       false};
2386   struct LineRun line14 =
2387     {
2388       {140u, 10u},
2389       {140u, 10u},
2390       79.f,
2391       15.f,
2392       -5.f,
2393       5.f,
2394       0.f,
2395       0.f,
2396       false,
2397       false};
2398   struct LineRun line15 =
2399     {
2400       {150u, 6u},
2401       {150u, 6u},
2402       35.f,
2403       15.f,
2404       -5.f,
2405       0.f,
2406       0.f,
2407       0.f,
2408       false,
2409       false};
2410   struct LineRun line16 =
2411     {
2412       {156u, 10u},
2413       {156u, 10u},
2414       70.f,
2415       15.f,
2416       -5.f,
2417       5.f,
2418       0.f,
2419       0.f,
2420       true,
2421       false};
2422   struct LineRun line17 =
2423     {
2424       {166u, 12u},
2425       {166u, 12u},
2426       79.f,
2427       15.f,
2428       -5.f,
2429       4.f,
2430       0.f,
2431       0.f,
2432       false,
2433       false};
2434   struct LineRun line18 =
2435     {
2436       {178u, 14u},
2437       {178u, 14u},
2438       63.f,
2439       15.f,
2440       -5.f,
2441       0.f,
2442       0.f,
2443       0.f,
2444       false,
2445       false};
2446   struct LineRun line19 =
2447     {
2448       {192u, 0u},
2449       {192u, 0u},
2450       0.f,
2451       15.f,
2452       -5.f,
2453       0.f,
2454       0.f,
2455       0.f,
2456       false,
2457       false};
2458   Vector<LineRun> lines;
2459   lines.PushBack(line01);
2460   lines.PushBack(line02);
2461   lines.PushBack(line03);
2462   lines.PushBack(line04);
2463   lines.PushBack(line05);
2464   lines.PushBack(line06);
2465   lines.PushBack(line07);
2466   lines.PushBack(line08);
2467   lines.PushBack(line09);
2468   lines.PushBack(line10);
2469   lines.PushBack(line11);
2470   lines.PushBack(line12);
2471   lines.PushBack(line13);
2472   lines.PushBack(line14);
2473   lines.PushBack(line15);
2474   lines.PushBack(line16);
2475   lines.PushBack(line17);
2476   lines.PushBack(line18);
2477   lines.PushBack(line19);
2478
2479   LayoutTextData data =
2480     {
2481       "Layout bidirectional text.",
2482       "Hello world demo שלום עולם.\n"
2483       "مرحبا بالعالم hello world שלום עולם\n"
2484       "שלום עולם hello world demo.\n"
2485       "hello world مرحبا بالعالم שלום עולם\n"
2486       "Hello world demo שלום עולם.\n"
2487       "שלום עולם hello world مرحبا بالعالم\n",
2488       textArea,
2489       17u,
2490       fontDescriptionRuns.Begin(),
2491       layoutSize,
2492       192u,
2493       positions,
2494       19u,
2495       lines.Begin(),
2496       Layout::Engine::MULTI_LINE_BOX,
2497       0u,
2498       64u,
2499       false,
2500       DevelText::EllipsisPosition::END,
2501       true};
2502
2503   if(!LayoutTextTest(data))
2504   {
2505     tet_result(TET_FAIL);
2506   }
2507
2508   tet_result(TET_PASS);
2509   END_TEST;
2510 }
2511
2512 int UtcDaliTextUpdateLayout02(void)
2513 {
2514   ToolkitTestApplication application;
2515   tet_infoline(" UtcDaliTextUpdateLayout02");
2516
2517   // Layout some lines of bidirectional text. Update the paragraphs at the middle.
2518
2519   const std::string fontLatin("TizenSans");
2520   const std::string fontHebrew("TizenSansHebrew");
2521   const std::string fontArabic("TizenSansArabic");
2522
2523   // Set a known font description
2524   FontDescriptionRun fontDescriptionRun01;
2525   fontDescriptionRun01.characterRun.characterIndex     = 0u;
2526   fontDescriptionRun01.characterRun.numberOfCharacters = 17u;
2527   fontDescriptionRun01.familyLength                    = fontLatin.size();
2528   fontDescriptionRun01.familyName                      = new char[fontDescriptionRun01.familyLength];
2529   memcpy(fontDescriptionRun01.familyName, fontLatin.c_str(), fontDescriptionRun01.familyLength);
2530   fontDescriptionRun01.familyDefined = true;
2531   fontDescriptionRun01.weightDefined = false;
2532   fontDescriptionRun01.widthDefined  = false;
2533   fontDescriptionRun01.slantDefined  = false;
2534   fontDescriptionRun01.sizeDefined   = false;
2535
2536   // Set a known font description
2537   FontDescriptionRun fontDescriptionRun02;
2538   fontDescriptionRun02.characterRun.characterIndex     = 17u;
2539   fontDescriptionRun02.characterRun.numberOfCharacters = 9u;
2540   fontDescriptionRun02.familyLength                    = fontHebrew.size();
2541   fontDescriptionRun02.familyName                      = new char[fontDescriptionRun02.familyLength];
2542   memcpy(fontDescriptionRun02.familyName, fontHebrew.c_str(), fontDescriptionRun02.familyLength);
2543   fontDescriptionRun02.familyDefined = true;
2544   fontDescriptionRun02.weightDefined = false;
2545   fontDescriptionRun02.widthDefined  = false;
2546   fontDescriptionRun02.slantDefined  = false;
2547   fontDescriptionRun02.sizeDefined   = false;
2548
2549   // Set a known font description
2550   FontDescriptionRun fontDescriptionRun03;
2551   fontDescriptionRun03.characterRun.characterIndex     = 26u;
2552   fontDescriptionRun03.characterRun.numberOfCharacters = 2u;
2553   fontDescriptionRun03.familyLength                    = fontLatin.size();
2554   fontDescriptionRun03.familyName                      = new char[fontDescriptionRun03.familyLength];
2555   memcpy(fontDescriptionRun03.familyName, fontLatin.c_str(), fontDescriptionRun03.familyLength);
2556   fontDescriptionRun03.familyDefined = true;
2557   fontDescriptionRun03.weightDefined = false;
2558   fontDescriptionRun03.widthDefined  = false;
2559   fontDescriptionRun03.slantDefined  = false;
2560   fontDescriptionRun03.sizeDefined   = false;
2561
2562   // Set a known font description
2563   FontDescriptionRun fontDescriptionRun04;
2564   fontDescriptionRun04.characterRun.characterIndex     = 28u;
2565   fontDescriptionRun04.characterRun.numberOfCharacters = 14u;
2566   fontDescriptionRun04.familyLength                    = fontArabic.size();
2567   fontDescriptionRun04.familyName                      = new char[fontDescriptionRun04.familyLength];
2568   memcpy(fontDescriptionRun04.familyName, fontArabic.c_str(), fontDescriptionRun04.familyLength);
2569   fontDescriptionRun04.familyDefined = true;
2570   fontDescriptionRun04.weightDefined = false;
2571   fontDescriptionRun04.widthDefined  = false;
2572   fontDescriptionRun04.slantDefined  = false;
2573   fontDescriptionRun04.sizeDefined   = false;
2574
2575   // Set a known font description
2576   FontDescriptionRun fontDescriptionRun05;
2577   fontDescriptionRun05.characterRun.characterIndex     = 42u;
2578   fontDescriptionRun05.characterRun.numberOfCharacters = 12u;
2579   fontDescriptionRun05.familyLength                    = fontLatin.size();
2580   fontDescriptionRun05.familyName                      = new char[fontDescriptionRun05.familyLength];
2581   memcpy(fontDescriptionRun05.familyName, fontLatin.c_str(), fontDescriptionRun05.familyLength);
2582   fontDescriptionRun05.familyDefined = true;
2583   fontDescriptionRun05.weightDefined = false;
2584   fontDescriptionRun05.widthDefined  = false;
2585   fontDescriptionRun05.slantDefined  = false;
2586   fontDescriptionRun05.sizeDefined   = false;
2587
2588   // Set a known font description
2589   FontDescriptionRun fontDescriptionRun06;
2590   fontDescriptionRun06.characterRun.characterIndex     = 54u;
2591   fontDescriptionRun06.characterRun.numberOfCharacters = 10u;
2592   fontDescriptionRun06.familyLength                    = fontHebrew.size();
2593   fontDescriptionRun06.familyName                      = new char[fontDescriptionRun06.familyLength];
2594   memcpy(fontDescriptionRun06.familyName, fontHebrew.c_str(), fontDescriptionRun06.familyLength);
2595   fontDescriptionRun06.familyDefined = true;
2596   fontDescriptionRun06.weightDefined = false;
2597   fontDescriptionRun06.widthDefined  = false;
2598   fontDescriptionRun06.slantDefined  = false;
2599   fontDescriptionRun06.sizeDefined   = false;
2600
2601   // Set a known font description
2602   FontDescriptionRun fontDescriptionRun07;
2603   fontDescriptionRun07.characterRun.characterIndex     = 64u;
2604   fontDescriptionRun07.characterRun.numberOfCharacters = 10u;
2605   fontDescriptionRun07.familyLength                    = fontHebrew.size();
2606   fontDescriptionRun07.familyName                      = new char[fontDescriptionRun07.familyLength];
2607   memcpy(fontDescriptionRun07.familyName, fontHebrew.c_str(), fontDescriptionRun07.familyLength);
2608   fontDescriptionRun07.familyDefined = true;
2609   fontDescriptionRun07.weightDefined = false;
2610   fontDescriptionRun07.widthDefined  = false;
2611   fontDescriptionRun07.slantDefined  = false;
2612   fontDescriptionRun07.sizeDefined   = false;
2613
2614   // Set a known font description
2615   FontDescriptionRun fontDescriptionRun08;
2616   fontDescriptionRun08.characterRun.characterIndex     = 74u;
2617   fontDescriptionRun08.characterRun.numberOfCharacters = 18u;
2618   fontDescriptionRun08.familyLength                    = fontLatin.size();
2619   fontDescriptionRun08.familyName                      = new char[fontDescriptionRun08.familyLength];
2620   memcpy(fontDescriptionRun08.familyName, fontLatin.c_str(), fontDescriptionRun08.familyLength);
2621   fontDescriptionRun08.familyDefined = true;
2622   fontDescriptionRun08.weightDefined = false;
2623   fontDescriptionRun08.widthDefined  = false;
2624   fontDescriptionRun08.slantDefined  = false;
2625   fontDescriptionRun08.sizeDefined   = false;
2626
2627   // Set a known font description
2628   FontDescriptionRun fontDescriptionRun09;
2629   fontDescriptionRun09.characterRun.characterIndex     = 92u;
2630   fontDescriptionRun09.characterRun.numberOfCharacters = 12u;
2631   fontDescriptionRun09.familyLength                    = fontLatin.size();
2632   fontDescriptionRun09.familyName                      = new char[fontDescriptionRun09.familyLength];
2633   memcpy(fontDescriptionRun09.familyName, fontLatin.c_str(), fontDescriptionRun09.familyLength);
2634   fontDescriptionRun09.familyDefined = true;
2635   fontDescriptionRun09.weightDefined = false;
2636   fontDescriptionRun09.widthDefined  = false;
2637   fontDescriptionRun09.slantDefined  = false;
2638   fontDescriptionRun09.sizeDefined   = false;
2639
2640   // Set a known font description
2641   FontDescriptionRun fontDescriptionRun10;
2642   fontDescriptionRun10.characterRun.characterIndex     = 104u;
2643   fontDescriptionRun10.characterRun.numberOfCharacters = 14u;
2644   fontDescriptionRun10.familyLength                    = fontArabic.size();
2645   fontDescriptionRun10.familyName                      = new char[fontDescriptionRun10.familyLength];
2646   memcpy(fontDescriptionRun10.familyName, fontArabic.c_str(), fontDescriptionRun10.familyLength);
2647   fontDescriptionRun10.familyDefined = true;
2648   fontDescriptionRun10.weightDefined = false;
2649   fontDescriptionRun10.widthDefined  = false;
2650   fontDescriptionRun10.slantDefined  = false;
2651   fontDescriptionRun10.sizeDefined   = false;
2652
2653   // Set a known font description
2654   FontDescriptionRun fontDescriptionRun11;
2655   fontDescriptionRun11.characterRun.characterIndex     = 118u;
2656   fontDescriptionRun11.characterRun.numberOfCharacters = 10u;
2657   fontDescriptionRun11.familyLength                    = fontHebrew.size();
2658   fontDescriptionRun11.familyName                      = new char[fontDescriptionRun11.familyLength];
2659   memcpy(fontDescriptionRun11.familyName, fontHebrew.c_str(), fontDescriptionRun11.familyLength);
2660   fontDescriptionRun11.familyDefined = true;
2661   fontDescriptionRun11.weightDefined = false;
2662   fontDescriptionRun11.widthDefined  = false;
2663   fontDescriptionRun11.slantDefined  = false;
2664   fontDescriptionRun11.sizeDefined   = false;
2665
2666   // Set a known font description
2667   FontDescriptionRun fontDescriptionRun12;
2668   fontDescriptionRun12.characterRun.characterIndex     = 128u;
2669   fontDescriptionRun12.characterRun.numberOfCharacters = 17u;
2670   fontDescriptionRun12.familyLength                    = fontLatin.size();
2671   fontDescriptionRun12.familyName                      = new char[fontDescriptionRun12.familyLength];
2672   memcpy(fontDescriptionRun12.familyName, fontLatin.c_str(), fontDescriptionRun12.familyLength);
2673   fontDescriptionRun12.familyDefined = true;
2674   fontDescriptionRun12.weightDefined = false;
2675   fontDescriptionRun12.widthDefined  = false;
2676   fontDescriptionRun12.slantDefined  = false;
2677   fontDescriptionRun12.sizeDefined   = false;
2678
2679   // Set a known font description
2680   FontDescriptionRun fontDescriptionRun13;
2681   fontDescriptionRun13.characterRun.characterIndex     = 145u;
2682   fontDescriptionRun13.characterRun.numberOfCharacters = 9u;
2683   fontDescriptionRun13.familyLength                    = fontHebrew.size();
2684   fontDescriptionRun13.familyName                      = new char[fontDescriptionRun13.familyLength];
2685   memcpy(fontDescriptionRun13.familyName, fontHebrew.c_str(), fontDescriptionRun13.familyLength);
2686   fontDescriptionRun13.familyDefined = true;
2687   fontDescriptionRun13.weightDefined = false;
2688   fontDescriptionRun13.widthDefined  = false;
2689   fontDescriptionRun13.slantDefined  = false;
2690   fontDescriptionRun13.sizeDefined   = false;
2691
2692   // Set a known font description
2693   FontDescriptionRun fontDescriptionRun14;
2694   fontDescriptionRun14.characterRun.characterIndex     = 154u;
2695   fontDescriptionRun14.characterRun.numberOfCharacters = 2u;
2696   fontDescriptionRun14.familyLength                    = fontLatin.size();
2697   fontDescriptionRun14.familyName                      = new char[fontDescriptionRun14.familyLength];
2698   memcpy(fontDescriptionRun14.familyName, fontLatin.c_str(), fontDescriptionRun14.familyLength);
2699   fontDescriptionRun14.familyDefined = true;
2700   fontDescriptionRun14.weightDefined = false;
2701   fontDescriptionRun14.widthDefined  = false;
2702   fontDescriptionRun14.slantDefined  = false;
2703   fontDescriptionRun14.sizeDefined   = false;
2704
2705   // Set a known font description
2706   FontDescriptionRun fontDescriptionRun15;
2707   fontDescriptionRun15.characterRun.characterIndex     = 156u;
2708   fontDescriptionRun15.characterRun.numberOfCharacters = 10u;
2709   fontDescriptionRun15.familyLength                    = fontHebrew.size();
2710   fontDescriptionRun15.familyName                      = new char[fontDescriptionRun15.familyLength];
2711   memcpy(fontDescriptionRun15.familyName, fontHebrew.c_str(), fontDescriptionRun15.familyLength);
2712   fontDescriptionRun15.familyDefined = true;
2713   fontDescriptionRun15.weightDefined = false;
2714   fontDescriptionRun15.widthDefined  = false;
2715   fontDescriptionRun15.slantDefined  = false;
2716   fontDescriptionRun15.sizeDefined   = false;
2717
2718   // Set a known font description
2719   FontDescriptionRun fontDescriptionRun16;
2720   fontDescriptionRun16.characterRun.characterIndex     = 166u;
2721   fontDescriptionRun16.characterRun.numberOfCharacters = 12u;
2722   fontDescriptionRun16.familyLength                    = fontLatin.size();
2723   fontDescriptionRun16.familyName                      = new char[fontDescriptionRun16.familyLength];
2724   memcpy(fontDescriptionRun16.familyName, fontLatin.c_str(), fontDescriptionRun16.familyLength);
2725   fontDescriptionRun16.familyDefined = true;
2726   fontDescriptionRun16.weightDefined = false;
2727   fontDescriptionRun16.widthDefined  = false;
2728   fontDescriptionRun16.slantDefined  = false;
2729   fontDescriptionRun16.sizeDefined   = false;
2730
2731   // Set a known font description
2732   FontDescriptionRun fontDescriptionRun17;
2733   fontDescriptionRun17.characterRun.characterIndex     = 178u;
2734   fontDescriptionRun17.characterRun.numberOfCharacters = 14u;
2735   fontDescriptionRun17.familyLength                    = fontArabic.size();
2736   fontDescriptionRun17.familyName                      = new char[fontDescriptionRun17.familyLength];
2737   memcpy(fontDescriptionRun17.familyName, fontArabic.c_str(), fontDescriptionRun17.familyLength);
2738   fontDescriptionRun17.familyDefined = true;
2739   fontDescriptionRun17.weightDefined = false;
2740   fontDescriptionRun17.widthDefined  = false;
2741   fontDescriptionRun17.slantDefined  = false;
2742   fontDescriptionRun17.sizeDefined   = false;
2743
2744   Vector<FontDescriptionRun> fontDescriptionRuns;
2745   fontDescriptionRuns.PushBack(fontDescriptionRun01);
2746   fontDescriptionRuns.PushBack(fontDescriptionRun02);
2747   fontDescriptionRuns.PushBack(fontDescriptionRun03);
2748   fontDescriptionRuns.PushBack(fontDescriptionRun04);
2749   fontDescriptionRuns.PushBack(fontDescriptionRun05);
2750   fontDescriptionRuns.PushBack(fontDescriptionRun06);
2751   fontDescriptionRuns.PushBack(fontDescriptionRun07);
2752   fontDescriptionRuns.PushBack(fontDescriptionRun08);
2753   fontDescriptionRuns.PushBack(fontDescriptionRun09);
2754   fontDescriptionRuns.PushBack(fontDescriptionRun10);
2755   fontDescriptionRuns.PushBack(fontDescriptionRun11);
2756   fontDescriptionRuns.PushBack(fontDescriptionRun12);
2757   fontDescriptionRuns.PushBack(fontDescriptionRun13);
2758   fontDescriptionRuns.PushBack(fontDescriptionRun14);
2759   fontDescriptionRuns.PushBack(fontDescriptionRun15);
2760   fontDescriptionRuns.PushBack(fontDescriptionRun16);
2761   fontDescriptionRuns.PushBack(fontDescriptionRun17);
2762   Size  textArea(100.f, 300.f);
2763   Size  layoutSize(100.f, 380.f);
2764   float positions[] =
2765     {
2766       0.f, -12.f, 10.f, -9.f, 20.f, -13.f, 24.f, -13.f, 27.f, -9.f, 36.f, -0.f, 40.f, -9.f, 52.f, -9.f, 62.f, -9.f, 69.f, -13.f, 72.f, -13.f, 81.f, -0.f, //   0 ..  11
2767       0.f,
2768       -13.f,
2769       9.f,
2770       -9.f,
2771       19.f,
2772       -9.f,
2773       32.f,
2774       -9.f,
2775       41.f,
2776       -0.f,
2777       68.f,
2778       -10.f,
2779       59.f,
2780       -13.f,
2781       54.f,
2782       -10.f,
2783       45.f,
2784       -10.f,
2785       79.f,
2786       -0.f, //  12 ..  21
2787       23.f,
2788       -10.f,
2789       19.f,
2790       -10.f,
2791       10.f,
2792       -13.f,
2793       0.f,
2794       -10.f,
2795       32.f,
2796       -2.f,
2797       36.f,
2798       -12.f, //  22 ..  27
2799       58.f,
2800       -8.f,
2801       52.f,
2802       -6.f,
2803       45.f,
2804       -8.f,
2805       41.f,
2806       -7.f,
2807       39.f,
2808       -11.f,
2809       34.f,
2810       -0.f,
2811       30.f,
2812       -7.f,
2813       28.f,
2814       -11.f,
2815       23.f,
2816       -11.f,
2817       16.f,
2818       -8.f,
2819       15.f,
2820       -11.f,
2821       9.f,
2822       -11.f,
2823       4.f,
2824       -8.f,
2825       0.f,
2826       -0.f,
2827       4.f,
2828       -13.f,
2829       12.f,
2830       -9.f,
2831       22.f,
2832       -13.f,
2833       26.f,
2834       -13.f,
2835       29.f,
2836       -9.f,
2837       38.f,
2838       -0.f, //  28 ..  47
2839       42.f,
2840       -9.f,
2841       54.f,
2842       -9.f,
2843       64.f,
2844       -9.f,
2845       70.f,
2846       -13.f,
2847       73.f,
2848       -13.f,
2849       0.f,
2850       -0.f,
2851       59.f,
2852       -10.f,
2853       50.f,
2854       -13.f,
2855       46.f,
2856       -10.f,
2857       36.f,
2858       -10.f,
2859       32.f,
2860       -0.f, //  48 ..  58
2861       23.f,
2862       -10.f,
2863       19.f,
2864       -10.f,
2865       10.f,
2866       -13.f,
2867       0.f,
2868       -10.f,
2869       0.f,
2870       -0.f, //  59 ..  63
2871       63.f,
2872       -10.f,
2873       54.f,
2874       -13.f,
2875       50.f,
2876       -10.f,
2877       41.f,
2878       -10.f,
2879       36.f,
2880       -0.f,
2881       27.f,
2882       -10.f,
2883       23.f,
2884       -10.f,
2885       14.f,
2886       -13.f,
2887       4.f,
2888       -10.f,
2889       0.f,
2890       -0.f, //  64 ..  73
2891       4.f,
2892       -13.f,
2893       12.f,
2894       -9.f,
2895       22.f,
2896       -13.f,
2897       26.f,
2898       -13.f,
2899       29.f,
2900       -9.f,
2901       38.f,
2902       -0.f,
2903       42.f,
2904       -9.f,
2905       54.f,
2906       -9.f,
2907       64.f,
2908       -9.f,
2909       70.f,
2910       -13.f,
2911       73.f,
2912       -13.f,
2913       0.f,
2914       -0.f, //  74 ..  85
2915       4.f,
2916       -13.f,
2917       13.f,
2918       -9.f,
2919       23.f,
2920       -9.f,
2921       36.f,
2922       -9.f,
2923       0.f,
2924       -2.f,
2925       0.f,
2926       -12.f, //  86 ..  91
2927       0.f,
2928       -13.f,
2929       8.f,
2930       -9.f,
2931       18.f,
2932       -13.f,
2933       22.f,
2934       -13.f,
2935       25.f,
2936       -9.f,
2937       34.f,
2938       -0.f,
2939       38.f,
2940       -9.f,
2941       50.f,
2942       -9.f,
2943       60.f,
2944       -9.f,
2945       66.f,
2946       -13.f,
2947       69.f,
2948       -13.f,
2949       79.f,
2950       -0.f, //  92 .. 103
2951       92.f,
2952       -8.f,
2953       86.f,
2954       -6.f,
2955       79.f,
2956       -8.f,
2957       75.f,
2958       -7.f,
2959       73.f,
2960       -11.f,
2961       68.f,
2962       -0.f,
2963       64.f,
2964       -7.f,
2965       62.f,
2966       -11.f,
2967       57.f,
2968       -11.f,
2969       50.f,
2970       -8.f,
2971       49.f,
2972       -11.f,
2973       43.f,
2974       -11.f,
2975       38.f,
2976       -8.f,
2977       34.f,
2978       -0.f,
2979       23.f,
2980       -10.f,
2981       14.f,
2982       -13.f,
2983       10.f,
2984       -10.f,
2985       0.f,
2986       -10.f,
2987       99.f,
2988       -0.f, // 104 .. 122
2989       23.f,
2990       -10.f,
2991       19.f,
2992       -10.f,
2993       10.f,
2994       -13.f,
2995       0.f,
2996       -10.f,
2997       32.f,
2998       -0.f, // 123 .. 127
2999       0.f,
3000       -12.f,
3001       10.f,
3002       -9.f,
3003       20.f,
3004       -13.f,
3005       24.f,
3006       -13.f,
3007       27.f,
3008       -9.f,
3009       36.f,
3010       -0.f,
3011       40.f,
3012       -9.f,
3013       52.f,
3014       -9.f,
3015       62.f,
3016       -9.f,
3017       69.f,
3018       -13.f,
3019       72.f,
3020       -13.f,
3021       81.f,
3022       -0.f, // 128 .. 139
3023       0.f,
3024       -13.f,
3025       9.f,
3026       -9.f,
3027       19.f,
3028       -9.f,
3029       32.f,
3030       -9.f,
3031       41.f,
3032       -0.f,
3033       68.f,
3034       -10.f,
3035       59.f,
3036       -13.f,
3037       54.f,
3038       -10.f,
3039       45.f,
3040       -10.f,
3041       79.f,
3042       -0.f, // 140 .. 149
3043       23.f,
3044       -10.f,
3045       19.f,
3046       -10.f,
3047       10.f,
3048       -13.f,
3049       0.f,
3050       -10.f,
3051       32.f,
3052       -2.f,
3053       36.f,
3054       -12.f, // 150 .. 155
3055       63.f,
3056