Merge "Apply font size scale to markup text" into devel/master
[platform/core/uifw/dali-toolkit.git] / automated-tests / src / dali-toolkit-internal / utc-Dali-Text-MultiLanguage.cpp
1 /*
2  * Copyright (c) 2018 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 <iostream>
19 #include <stdlib.h>
20 #include <unistd.h>
21
22 #include <dali/devel-api/text-abstraction/font-client.h>
23 #include <dali-toolkit/internal/text/character-set-conversion.h>
24 #include <dali-toolkit/internal/text/logical-model-impl.h>
25 #include <dali-toolkit/internal/text/multi-language-helper-functions.h>
26 #include <dali-toolkit/internal/text/multi-language-support.h>
27 #include <dali-toolkit/internal/text/segmentation.h>
28 #include <dali-toolkit/internal/text/text-run-container.h>
29 #include <dali-toolkit-test-suite-utils.h>
30 #include <dali-toolkit/dali-toolkit.h>
31
32 using namespace Dali;
33 using namespace Toolkit;
34 using namespace Text;
35
36 // Tests the following functions with different scripts.
37 //
38 // void MergeFontDescriptions(const Vector<FontDescriptionRun>&       fontDescriptions,
39 //                            const TextAbstraction::FontDescription& defaultFontDescription,
40 //                            TextAbstraction::PointSize26Dot6        defaultPointSize,
41 //                            float                                   fontSizeScale,
42 //                            CharacterIndex                          characterIndex,
43 //                            TextAbstraction::FontDescription&       fontDescription,
44 //                            TextAbstraction::PointSize26Dot6&       fontPointSize,
45 //                            bool&                                   isDefaultFont);
46 //
47 // Script GetScript(Length                                  index,
48 //                  Vector<ScriptRun>::ConstIterator&       scriptRunIt,
49 //                  const Vector<ScriptRun>::ConstIterator& scriptRunEndIt);
50 //
51 // Constructor, destructor and MultilanguageSupport::Get()
52 //
53 // void MultilanguageSupport::SetScripts(const Vector<Character>& text,
54 //                                       CharacterIndex           startIndex,
55 //                                       Length                   numberOfCharacters,
56 //                                       Vector<ScriptRun>&       scripts);
57 //
58 // void MultilanguageSupport::ValidateFonts(const Vector<Character>&                text,
59 //                                          const Vector<ScriptRun>&                scripts,
60 //                                          const Vector<FontDescriptionRun>&       fontDescriptions,
61 //                                          const TextAbstraction::FontDescription& defaultFontDescription,
62 //                                          TextAbstraction::PointSize26Dot6        defaultFontPointSize,
63 //                                          float                                   fontSizeScale,
64 //                                          CharacterIndex                          startIndex,
65 //                                          Length                                  numberOfCharacters,
66 //                                          Vector<FontRun>&                        fonts);
67
68 //////////////////////////////////////////////////////////
69
70 namespace
71 {
72
73 const std::string DEFAULT_FONT_DIR( "/resources/fonts" );
74 const unsigned int EMOJI_FONT_SIZE = 3840u; // 60 * 64
75 const unsigned int NON_DEFAULT_FONT_SIZE = 40u;
76
77 struct MergeFontDescriptionsData
78 {
79   std::string description;                                 ///< Description of the experiment.
80   Vector<FontDescriptionRun> fontDescriptionRuns;          ///< The font description runs.
81   TextAbstraction::FontDescription defaultFontDescription; ///< The default font description.
82   TextAbstraction::PointSize26Dot6 defaultPointSize;       ///< The default point size.
83   float        fontSizeScale;                              ///< The font's size scale.
84   unsigned int startIndex;                                 ///< The start index.
85   unsigned int numberOfCharacters;                         ///< The number of characters.
86   Vector<FontId> expectedFontIds;                          ///< The expected font ids.
87   Vector<bool> expectedIsDefault;                          ///< The expected font ids.
88 };
89
90 struct ScriptsData
91 {
92   std::string description;         ///< Description of the experiment.
93   std::string text;                ///< Input text.
94   unsigned int index;              ///< The index of the first character to update the script.
95   unsigned int numberOfCharacters; ///< The numbers of characters to update the script.
96   Vector<ScriptRun> scriptRuns;    ///< Expected script runs.
97 };
98
99 struct ValidateFontsData
100 {
101   std::string                description;         ///< Description of the experiment.
102   std::string                text;                ///< Input text.
103   std::string                defaultFont;         ///< The default font.
104   unsigned int               defaultFontSize;     ///< The default font size.
105   float                      fontSizeScale;       ///< The font's size scale.
106   unsigned int               index;               ///< The index of the first character to update the script.
107   unsigned int               numberOfCharacters;  ///< The numbers of characters to update the script.
108   Vector<FontDescriptionRun> fontDescriptionRuns; ///< The font description runs.
109   Vector<FontRun>            fontRuns;            ///< The expected font runs.
110 };
111
112 //////////////////////////////////////////////////////////
113 bool MergeFontDescriptionsTest( const MergeFontDescriptionsData& data )
114 {
115   TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
116
117   Vector<FontId> fontIds;
118   fontIds.Resize( data.startIndex + data.numberOfCharacters, 0u );
119   Vector<bool> isDefaultFont;
120   isDefaultFont.Resize( data.startIndex + data.numberOfCharacters, true );
121
122   for( unsigned int index = data.startIndex; index < data.startIndex + data.numberOfCharacters; ++index )
123   {
124     TextAbstraction::FontDescription fontDescription;
125     TextAbstraction::PointSize26Dot6 fontPointSize = TextAbstraction::FontClient::DEFAULT_POINT_SIZE;
126
127     MergeFontDescriptions( data.fontDescriptionRuns,
128                            data.defaultFontDescription,
129                            data.defaultPointSize,
130                            data.fontSizeScale,
131                            index,
132                            fontDescription,
133                            fontPointSize,
134                            isDefaultFont[index] );
135
136     if( !isDefaultFont[index] )
137     {
138       fontIds[index] = fontClient.GetFontId( fontDescription, fontPointSize );
139     }
140   }
141
142   if( fontIds.Count() != data.expectedFontIds.Count() )
143   {
144     std::cout << data.description << " Different number of font ids : " << fontIds.Count() << ", expected : " << data.expectedFontIds.Count() << std::endl;
145     return false;
146   }
147
148   for( unsigned int index = 0u; index < fontIds.Count(); ++index )
149   {
150     if( fontIds[index] != data.expectedFontIds[index] )
151     {
152       std::cout << data.description << " Different font id at index : " << index << ", font id : " << fontIds[index] << ", expected : " << data.expectedFontIds[index] << std::endl;
153       std::cout << "           font ids : ";
154       for( unsigned int i=0;i<fontIds.Count();++i)
155       {
156         std::cout << fontIds[i] << " ";
157       }
158       std::cout << std::endl;
159       std::cout << "  expected font ids : ";
160       for( unsigned int i=0;i<data.expectedFontIds.Count();++i)
161       {
162         std::cout << data.expectedFontIds[i] << " ";
163       }
164       std::cout << std::endl;
165       return false;
166     }
167
168     if( isDefaultFont[index] != data.expectedIsDefault[index] )
169     {
170       std::cout << data.description << " Different 'is font default' at index : " << index << ", is font default : " << isDefaultFont[index] << ", expected : " << data.expectedIsDefault[index] << std::endl;
171       return false;
172     }
173   }
174
175   return true;
176 }
177
178 bool ScriptsTest( const ScriptsData& data )
179 {
180   MultilanguageSupport multilanguageSupport = MultilanguageSupport::Get();
181
182   // 1) Convert to utf32
183   Vector<Character> utf32;
184   utf32.Resize( data.text.size() );
185
186   const uint32_t numberOfCharacters = ( data.text.size() == 0 ) ? 0 :
187     Utf8ToUtf32( reinterpret_cast<const uint8_t* const>( data.text.c_str() ),
188                  data.text.size(),
189                  &utf32[0u] );
190
191   utf32.Resize( numberOfCharacters );
192
193   // 2) Set the script info.
194   Vector<ScriptRun> scripts;
195   multilanguageSupport.SetScripts( utf32,
196                                    0u,
197                                    numberOfCharacters,
198                                    scripts );
199
200   if( ( 0u != data.index ) ||
201       ( numberOfCharacters != data.numberOfCharacters ) )
202   {
203     // 3) Clear the scripts.
204     ClearCharacterRuns( data.index,
205                         data.index + data.numberOfCharacters - 1u,
206                         scripts );
207
208     multilanguageSupport.SetScripts( utf32,
209                                      data.index,
210                                      data.numberOfCharacters,
211                                      scripts );
212   }
213
214   // 4) Compare the results.
215
216   tet_printf( "Testing %s\n", data.description.c_str() );
217   if( scripts.Count() != data.scriptRuns.Count() )
218   {
219     tet_printf("ScriptsTest FAIL: different number of scripts. %d, should be %d\n", scripts.Count(), data.scriptRuns.Count() );
220     for( Vector<ScriptRun>::ConstIterator it = scripts.Begin(); it != scripts.End(); ++it)
221     {
222       const ScriptRun& run = *it;
223
224       std::cout << "  index : " << run.characterRun.characterIndex << ", num chars : " << run.characterRun.numberOfCharacters << ", script : [" << TextAbstraction::ScriptName[run.script] << "]" << std::endl;
225     }
226     return false;
227   }
228
229   for( unsigned int index = 0u; index < scripts.Count(); ++index )
230   {
231     const ScriptRun& scriptRun1 = scripts[index];
232     const ScriptRun& scriptRun2 = data.scriptRuns[index];
233
234     if( scriptRun1.characterRun.characterIndex != scriptRun2.characterRun.characterIndex )
235     {
236       tet_printf("ScriptsTest FAIL: different character index. %d, should be %d\n", scriptRun1.characterRun.characterIndex, scriptRun2.characterRun.characterIndex );
237       return false;
238     }
239
240     if( scriptRun1.characterRun.numberOfCharacters != scriptRun2.characterRun.numberOfCharacters )
241     {
242       tet_printf("ScriptsTest FAIL: different number of characters. %d, should be %d\n", scriptRun1.characterRun.numberOfCharacters, scriptRun2.characterRun.numberOfCharacters );
243       return false;
244     }
245
246     if( scriptRun1.script != scriptRun2.script )
247     {
248       tet_printf("ScriptsTest FAIL: script index: %u, different script. %s, should be %s\n", index, TextAbstraction::ScriptName[scriptRun1.script], TextAbstraction::ScriptName[scriptRun2.script] );
249       return false;
250     }
251   }
252
253   return true;
254 }
255
256 bool ValidateFontTest( const ValidateFontsData& data )
257 {
258   MultilanguageSupport multilanguageSupport = MultilanguageSupport::Get();
259   TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
260
261   // 1) Convert to utf32
262   Vector<Character> utf32;
263   utf32.Resize( data.text.size() );
264
265   const uint32_t numberOfCharacters = (data.text.size() == 0 ) ? 0 :
266     Utf8ToUtf32( reinterpret_cast<const uint8_t* const>( data.text.c_str() ),
267                                                    data.text.size(),
268                                                    &utf32[0u] );
269   utf32.Resize( numberOfCharacters );
270
271   // 2) Set the script info.
272   Vector<ScriptRun> scripts;
273   multilanguageSupport.SetScripts( utf32,
274                                    0u,
275                                    numberOfCharacters,
276                                    scripts );
277
278   char* pathNamePtr = get_current_dir_name();
279   const std::string pathName( pathNamePtr );
280   free( pathNamePtr );
281
282   // Get the default font id.
283   const FontId defaultFontId = fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + data.defaultFont,
284                                                      data.defaultFontSize );
285   TextAbstraction::FontDescription defaultFontDescription;
286   fontClient.GetDescription( defaultFontId, defaultFontDescription );
287
288   const TextAbstraction::PointSize26Dot6 defaultPointSize = fontClient.GetPointSize( defaultFontId );
289
290   Vector<FontRun> fontRuns;
291
292   // 3) Validate the fonts.
293   multilanguageSupport.ValidateFonts( utf32,
294                                       scripts,
295                                       data.fontDescriptionRuns,
296                                       defaultFontDescription,
297                                       defaultPointSize,
298                                       data.fontSizeScale,
299                                       0u,
300                                       numberOfCharacters,
301                                       fontRuns );
302
303   if( ( 0u != data.index ) ||
304       ( numberOfCharacters != data.numberOfCharacters ) )
305   {
306     // 4) Clear the fonts.
307     ClearCharacterRuns( data.index,
308                         data.index + data.numberOfCharacters - 1u,
309                         fontRuns );
310
311     multilanguageSupport.ValidateFonts( utf32,
312                                         scripts,
313                                         data.fontDescriptionRuns,
314                                         defaultFontDescription,
315                                         defaultPointSize,
316                                         data.fontSizeScale,
317                                         data.index,
318                                         data.numberOfCharacters,
319                                         fontRuns );
320   }
321
322   // 5) Compare the results.
323   if( data.fontRuns.Count() != fontRuns.Count() )
324   {
325     std::cout << "  Different number of font runs : " << fontRuns.Count() << ", expected : " << data.fontRuns.Count() << std::endl;
326     return false;
327   }
328
329
330   for( unsigned int index = 0; index < data.fontRuns.Count(); ++index )
331   {
332     const FontRun& run = fontRuns[index];
333     const FontRun& expectedRun = data.fontRuns[index];
334
335     if( run.characterRun.characterIndex != expectedRun.characterRun.characterIndex )
336     {
337       std::cout << "  character run : " << index << ", index : " << run.characterRun.characterIndex << ", expected : " << expectedRun.characterRun.characterIndex << std::endl;
338       return false;
339     }
340     if( run.characterRun.numberOfCharacters != expectedRun.characterRun.numberOfCharacters )
341     {
342       std::cout << "  character run : " << index << ", num chars : " << run.characterRun.numberOfCharacters << ", expected : " << expectedRun.characterRun.numberOfCharacters << std::endl;
343       return false;
344     }
345     if( run.fontId != expectedRun.fontId )
346     {
347       std::cout << "  character run : " << index << ", font : " << run.fontId << ", expected : " << expectedRun.fontId << std::endl;
348       return false;
349     }
350   }
351
352   return true;
353 }
354
355 } // namespace
356
357 int UtcDaliTextGetScript(void)
358 {
359   ToolkitTestApplication application;
360   tet_infoline(" UtcDaliTextGetScript");
361
362   Script script = TextAbstraction::LATIN;
363
364   // Text with no scripts.
365   Vector<ScriptRun> scriptRuns;
366   Vector<ScriptRun>::ConstIterator scriptRunIt = scriptRuns.Begin();
367   script = GetScript( 0u,
368                       scriptRunIt,
369                       scriptRuns.End() );
370
371   DALI_TEST_CHECK( TextAbstraction::UNKNOWN == script );
372
373   const unsigned int numberOfCharacters = 7u;
374   // Add scripts.
375   ScriptRun scriptRun01 =
376   {
377     {
378       0u,
379       2u,
380     },
381     TextAbstraction::LATIN
382   };
383   ScriptRun scriptRun02 =
384   {
385     {
386       2u,
387       2u,
388     },
389     TextAbstraction::HEBREW
390   };
391   ScriptRun scriptRun03 =
392   {
393     {
394       4u,
395       2u,
396     },
397     TextAbstraction::ARABIC
398   };
399   scriptRuns.PushBack( scriptRun01 );
400   scriptRuns.PushBack( scriptRun02 );
401   scriptRuns.PushBack( scriptRun03 );
402
403   // Expected results
404   TextAbstraction::Script expectedScripts[]=
405   {
406     TextAbstraction::LATIN,
407     TextAbstraction::LATIN,
408     TextAbstraction::HEBREW,
409     TextAbstraction::HEBREW,
410     TextAbstraction::ARABIC,
411     TextAbstraction::ARABIC,
412     TextAbstraction::UNKNOWN
413   };
414
415   scriptRunIt = scriptRuns.Begin();
416   for( unsigned int index = 0u; index < numberOfCharacters; ++index )
417   {
418     script = GetScript( index,
419                         scriptRunIt,
420                         scriptRuns.End() );
421
422     DALI_TEST_CHECK( expectedScripts[index] == script );
423   }
424   DALI_TEST_CHECK( scriptRunIt == scriptRuns.End() );
425
426   tet_result(TET_PASS);
427   END_TEST;
428 }
429
430 int UtcDaliTextMergeFontDescriptions(void)
431 {
432   ToolkitTestApplication application;
433   tet_infoline(" UtcDaliTextMergeFontDescriptions");
434
435   // Load some fonts.
436
437   char* pathNamePtr = get_current_dir_name();
438   const std::string pathName( pathNamePtr );
439   free( pathNamePtr );
440
441   TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
442   fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSans.ttf" );
443   fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf" );
444   fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", NON_DEFAULT_FONT_SIZE );
445   fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf" );
446   fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Italic.ttf" );
447
448   // To test the font width as GetFontId() with the font file path can't cache the width property.
449   TextAbstraction::FontDescription widthDescription;
450   widthDescription.path = "";
451   widthDescription.family = "DejaVu Serif";
452   widthDescription.weight = TextAbstraction::FontWeight::NORMAL;
453   widthDescription.width = TextAbstraction::FontWidth::EXPANDED;
454   widthDescription.slant = TextAbstraction::FontSlant::NORMAL;
455   fontClient.GetFontId( widthDescription );
456
457   // Test.
458
459   TextAbstraction::FontDescription defaultFontDescription01;
460   Vector<FontDescriptionRun> fontDescriptionRuns01;
461   Vector<FontId> expectedFontIds01;
462   Vector<bool> expectedIsFontDefault01;
463
464   TextAbstraction::FontDescription defaultFontDescription02;
465   Vector<FontDescriptionRun> fontDescriptionRuns02;
466   Vector<FontId> expectedFontIds02;
467   expectedFontIds02.PushBack( 0u );
468   expectedFontIds02.PushBack( 0u );
469   Vector<bool> expectedIsFontDefault02;
470   expectedIsFontDefault02.PushBack( true );
471   expectedIsFontDefault02.PushBack( true );
472
473   TextAbstraction::FontDescription defaultFontDescription03;
474   defaultFontDescription03.family = "DejaVu Serif";
475   Vector<FontDescriptionRun> fontDescriptionRuns03;
476
477   FontDescriptionRun fontDescription0301 =
478   {
479     {
480       0u,
481       2u
482     },
483     const_cast<char*>( "DejaVu Sans" ),
484     11u,
485     TextAbstraction::FontWeight::NONE,
486     TextAbstraction::FontWidth::NONE,
487     TextAbstraction::FontSlant::NONE,
488     TextAbstraction::FontClient::DEFAULT_POINT_SIZE,
489     true,
490     false,
491     false,
492     false,
493     false
494   };
495   FontDescriptionRun fontDescription0302 =
496   {
497     {
498       2u,
499       2u
500     },
501     NULL,
502     0u,
503     TextAbstraction::FontWeight::NONE,
504     TextAbstraction::FontWidth::NONE,
505     TextAbstraction::FontSlant::ITALIC,
506     TextAbstraction::FontClient::DEFAULT_POINT_SIZE,
507     false,
508     false,
509     false,
510     true,
511     false
512   };
513   FontDescriptionRun fontDescription0303 =
514   {
515     {
516       4u,
517       2u
518     },
519     NULL,
520     0u,
521     TextAbstraction::FontWeight::BOLD,
522     TextAbstraction::FontWidth::NONE,
523     TextAbstraction::FontSlant::NONE,
524     TextAbstraction::FontClient::DEFAULT_POINT_SIZE,
525     false,
526     true,
527     false,
528     false,
529     false
530   };
531   FontDescriptionRun fontDescription0304 =
532   {
533     {
534       6u,
535       2u
536     },
537     NULL,
538     0u,
539     TextAbstraction::FontWeight::NONE,
540     TextAbstraction::FontWidth::NONE,
541     TextAbstraction::FontSlant::NONE,
542     NON_DEFAULT_FONT_SIZE,
543     false,
544     false,
545     false,
546     false,
547     true
548   };
549   FontDescriptionRun fontDescription0305 =
550   {
551     {
552       8u,
553       2u
554     },
555     NULL,
556     0u,
557     TextAbstraction::FontWeight::NONE,
558     TextAbstraction::FontWidth::EXPANDED,
559     TextAbstraction::FontSlant::NONE,
560     TextAbstraction::FontClient::DEFAULT_POINT_SIZE,
561     false,
562     false,
563     true,
564     false,
565     false
566   };
567
568   fontDescriptionRuns03.PushBack( fontDescription0301 );
569   fontDescriptionRuns03.PushBack( fontDescription0302 );
570   fontDescriptionRuns03.PushBack( fontDescription0303 );
571   fontDescriptionRuns03.PushBack( fontDescription0304 );
572   fontDescriptionRuns03.PushBack( fontDescription0305 );
573
574   Vector<FontId> expectedFontIds03;
575   expectedFontIds03.PushBack( 1u );
576   expectedFontIds03.PushBack( 1u );
577   expectedFontIds03.PushBack( 5u );
578   expectedFontIds03.PushBack( 5u );
579   expectedFontIds03.PushBack( 4u );
580   expectedFontIds03.PushBack( 4u );
581   expectedFontIds03.PushBack( 3u );
582   expectedFontIds03.PushBack( 3u );
583   expectedFontIds03.PushBack( 6u );
584   expectedFontIds03.PushBack( 6u );
585   Vector<bool> expectedIsFontDefault03;
586   expectedIsFontDefault03.PushBack( false );
587   expectedIsFontDefault03.PushBack( false );
588   expectedIsFontDefault03.PushBack( false );
589   expectedIsFontDefault03.PushBack( false );
590   expectedIsFontDefault03.PushBack( false );
591   expectedIsFontDefault03.PushBack( false );
592   expectedIsFontDefault03.PushBack( false );
593   expectedIsFontDefault03.PushBack( false );
594   expectedIsFontDefault03.PushBack( false );
595   expectedIsFontDefault03.PushBack( false );
596
597   const MergeFontDescriptionsData data[] =
598   {
599     {
600       "void text.",
601       fontDescriptionRuns01,
602       defaultFontDescription01,
603       TextAbstraction::FontClient::DEFAULT_POINT_SIZE,
604       1.0f,
605       0u,
606       0u,
607       expectedFontIds01,
608       expectedIsFontDefault01
609     },
610     {
611       "No description runs.",
612       fontDescriptionRuns02,
613       defaultFontDescription02,
614       TextAbstraction::FontClient::DEFAULT_POINT_SIZE,
615       1.0f,
616       0u,
617       2u,
618       expectedFontIds02,
619       expectedIsFontDefault02
620     },
621     {
622       "Some description runs.",
623       fontDescriptionRuns03,
624       defaultFontDescription03,
625       TextAbstraction::FontClient::DEFAULT_POINT_SIZE,
626       1.0f,
627       0u,
628       10u,
629       expectedFontIds03,
630       expectedIsFontDefault03
631     }
632   };
633   const unsigned int numberOfTests = 3u;
634
635   for( unsigned int index = 0u; index < numberOfTests; ++index )
636   {
637     if( !MergeFontDescriptionsTest( data[index] ) )
638     {
639       tet_result(TET_FAIL);
640     }
641   }
642
643   tet_result(TET_PASS);
644   END_TEST;
645 }
646
647 int UtcDaliTextMultiLanguageConstructor(void)
648 {
649   ToolkitTestApplication application;
650   tet_infoline(" UtcDaliTextMultiLanguageConstructor");
651
652   MultilanguageSupport multilanguageSupport;
653   DALI_TEST_CHECK( !multilanguageSupport );
654
655   MultilanguageSupport multilanguageSupport1 = MultilanguageSupport::Get();
656   DALI_TEST_CHECK( multilanguageSupport1 );
657
658   // To increase coverage.
659   MultilanguageSupport multilanguageSupport2 = MultilanguageSupport::Get();
660   DALI_TEST_CHECK( multilanguageSupport2 );
661
662   DALI_TEST_CHECK( multilanguageSupport1 == multilanguageSupport2 );
663
664   tet_result(TET_PASS);
665   END_TEST;
666 }
667
668 int UtcDaliTextMultiLanguageSetScripts(void)
669 {
670   ToolkitTestApplication application;
671   tet_infoline(" UtcDaliTextMultiLanguageSetScripts" );
672
673   // Void text.
674   Vector<ScriptRun> scriptRuns00;
675
676   // Hello world.
677   Vector<ScriptRun> scriptRuns01;
678   ScriptRun scriptRun0100 =
679   {
680     {
681       0u,
682       11u,
683     },
684     TextAbstraction::LATIN
685   };
686   scriptRuns01.PushBack( scriptRun0100 );
687
688   // Mix of LTR '\n'and RTL
689   Vector<ScriptRun> scriptRuns02;
690   ScriptRun scriptRun0200 =
691   {
692     {
693       0u,
694       12u,
695     },
696     TextAbstraction::LATIN
697   };
698   ScriptRun scriptRun0201 =
699   {
700     {
701       12u,
702       13u,
703     },
704     TextAbstraction::ARABIC
705   };
706   scriptRuns02.PushBack( scriptRun0200 );
707   scriptRuns02.PushBack( scriptRun0201 );
708
709   // Mix of RTL '\n'and LTR
710   Vector<ScriptRun> scriptRuns03;
711   ScriptRun scriptRun0300 =
712   {
713     {
714       0u,
715       14u,
716     },
717     TextAbstraction::ARABIC
718   };
719   ScriptRun scriptRun0301 =
720   {
721     {
722       14u,
723       11u,
724     },
725     TextAbstraction::LATIN
726   };
727   scriptRuns03.PushBack( scriptRun0300 );
728   scriptRuns03.PushBack( scriptRun0301 );
729
730   // White spaces. At the beginning of the text.
731   Vector<ScriptRun> scriptRuns04;
732   ScriptRun scriptRun0400 =
733   {
734     {
735       0u,
736       15u,
737     },
738     TextAbstraction::LATIN
739   };
740   scriptRuns04.PushBack( scriptRun0400 );
741
742   // White spaces. At the end of the text.
743   Vector<ScriptRun> scriptRuns05;
744   ScriptRun scriptRun0500 =
745   {
746     {
747       0u,
748       15u,
749     },
750     TextAbstraction::LATIN
751   };
752   scriptRuns05.PushBack( scriptRun0500 );
753
754   // White spaces. At the middle of the text.
755   Vector<ScriptRun> scriptRuns06;
756   ScriptRun scriptRun0600 =
757   {
758     {
759       0u,
760       15u,
761     },
762     TextAbstraction::LATIN
763   };
764   scriptRuns06.PushBack( scriptRun0600 );
765
766   // White spaces between different scripts.
767   Vector<ScriptRun> scriptRuns07;
768   ScriptRun scriptRun0700 =
769   {
770     {
771       0u,
772       8u,
773     },
774     TextAbstraction::LATIN
775   };
776   ScriptRun scriptRun0701 =
777   {
778     {
779       8u,
780       5u,
781     },
782     TextAbstraction::HANGUL
783   };
784   scriptRuns07.PushBack( scriptRun0700 );
785   scriptRuns07.PushBack( scriptRun0701 );
786
787   // White spaces between different scripts and differetn directions. Starting LTR.
788   Vector<ScriptRun> scriptRuns08;
789   ScriptRun scriptRun0800 =
790   {
791     {
792       0u,
793       18u,
794     },
795     TextAbstraction::LATIN
796   };
797   ScriptRun scriptRun0801 =
798   {
799     {
800       18u,
801       14u,
802     },
803     TextAbstraction::ARABIC
804   };
805   ScriptRun scriptRun0802 =
806   {
807     {
808       32u,
809       18u,
810     },
811     TextAbstraction::HANGUL
812   };
813   scriptRuns08.PushBack( scriptRun0800 );
814   scriptRuns08.PushBack( scriptRun0801 );
815   scriptRuns08.PushBack( scriptRun0802 );
816
817   // White spaces between different scripts and differetn directions. Starting RTL.
818   Vector<ScriptRun> scriptRuns09;
819   ScriptRun scriptRun0900 =
820   {
821     {
822       0u,
823       21u,
824     },
825     TextAbstraction::ARABIC
826   };
827   ScriptRun scriptRun0901 =
828   {
829     {
830       21u,
831       16u,
832     },
833     TextAbstraction::LATIN
834   };
835   ScriptRun scriptRun0902 =
836   {
837     {
838       37u,
839       10u,
840     },
841     TextAbstraction::HANGUL
842   };
843   ScriptRun scriptRun0903 =
844   {
845     {
846       47u,
847       20u,
848     },
849     TextAbstraction::ARABIC
850   };
851   scriptRuns09.PushBack( scriptRun0900 );
852   scriptRuns09.PushBack( scriptRun0901 );
853   scriptRuns09.PushBack( scriptRun0902 );
854   scriptRuns09.PushBack( scriptRun0903 );
855
856   // Paragraphs with different directions.
857   Vector<ScriptRun> scriptRuns10;
858   ScriptRun scriptRun1000 =
859   {
860     {
861       0u,
862       20u,
863     },
864     TextAbstraction::ARABIC
865   };
866   ScriptRun scriptRun1001 =
867   {
868     {
869       20u,
870       12u,
871     },
872     TextAbstraction::HEBREW
873   };
874   ScriptRun scriptRun1002 =
875   {
876     {
877       32u,
878       17u,
879     },
880     TextAbstraction::ARABIC
881   };
882   ScriptRun scriptRun1003 =
883   {
884     {
885       49u,
886       18u,
887     },
888     TextAbstraction::LATIN
889   };
890   ScriptRun scriptRun1004 =
891   {
892     {
893       67u,
894       14u,
895     },
896     TextAbstraction::HANGUL
897   };
898   ScriptRun scriptRun1005 =
899   {
900     {
901       81u,
902       19u,
903     },
904     TextAbstraction::ARABIC
905   };
906   ScriptRun scriptRun1006 =
907   {
908     {
909       100u,
910       13u,
911     },
912     TextAbstraction::LATIN
913   };
914   ScriptRun scriptRun1007 =
915   {
916     {
917       113u,
918       16u,
919     },
920     TextAbstraction::HEBREW
921   };
922   ScriptRun scriptRun1008 =
923   {
924     {
925       129u,
926       20u,
927     },
928     TextAbstraction::LATIN
929   };
930   ScriptRun scriptRun1009 =
931   {
932     {
933       149u,
934       14u,
935     },
936     TextAbstraction::ARABIC
937   };
938   ScriptRun scriptRun1010 =
939   {
940     {
941       163u,
942       18u,
943     },
944     TextAbstraction::HANGUL
945   };
946   ScriptRun scriptRun1011 =
947   {
948     {
949       181u,
950       17u,
951     },
952     TextAbstraction::HANGUL
953   };
954   scriptRuns10.PushBack( scriptRun1000 );
955   scriptRuns10.PushBack( scriptRun1001 );
956   scriptRuns10.PushBack( scriptRun1002 );
957   scriptRuns10.PushBack( scriptRun1003 );
958   scriptRuns10.PushBack( scriptRun1004 );
959   scriptRuns10.PushBack( scriptRun1005 );
960   scriptRuns10.PushBack( scriptRun1006 );
961   scriptRuns10.PushBack( scriptRun1007 );
962   scriptRuns10.PushBack( scriptRun1008 );
963   scriptRuns10.PushBack( scriptRun1009 );
964   scriptRuns10.PushBack( scriptRun1010 );
965   scriptRuns10.PushBack( scriptRun1011 );
966
967   // Paragraphs with no scripts mixed with paragraphs with scripts.
968   Vector<ScriptRun> scriptRuns11;
969   ScriptRun scriptRun1100 =
970   {
971     {
972       0u,
973       3u,
974     },
975     TextAbstraction::UNKNOWN
976   };
977   ScriptRun scriptRun1101 =
978   {
979     {
980       3u,
981       3u,
982     },
983     TextAbstraction::UNKNOWN
984   };
985   ScriptRun scriptRun1102 =
986   {
987     {
988       6u,
989       19u,
990     },
991     TextAbstraction::LATIN
992   };
993   ScriptRun scriptRun1103 =
994   {
995     {
996       25u,
997       3u,
998     },
999     TextAbstraction::UNKNOWN
1000   };
1001   ScriptRun scriptRun1104 =
1002   {
1003     {
1004       28u,
1005       3u,
1006     },
1007     TextAbstraction::UNKNOWN
1008   };
1009   ScriptRun scriptRun1105 =
1010   {
1011     {
1012       31u,
1013       15u,
1014     },
1015     TextAbstraction::HEBREW
1016   };
1017   ScriptRun scriptRun1106 =
1018   {
1019     {
1020       46u,
1021       2u,
1022     },
1023     TextAbstraction::UNKNOWN
1024   };
1025   ScriptRun scriptRun1107 =
1026   {
1027     {
1028       48u,
1029       2u,
1030     },
1031     TextAbstraction::UNKNOWN
1032   };
1033   ScriptRun scriptRun1108 =
1034   {
1035     {
1036       50u,
1037       2u,
1038     },
1039     TextAbstraction::UNKNOWN
1040   };
1041   scriptRuns11.PushBack( scriptRun1100 );
1042   scriptRuns11.PushBack( scriptRun1101 );
1043   scriptRuns11.PushBack( scriptRun1102 );
1044   scriptRuns11.PushBack( scriptRun1103 );
1045   scriptRuns11.PushBack( scriptRun1104 );
1046   scriptRuns11.PushBack( scriptRun1105 );
1047   scriptRuns11.PushBack( scriptRun1106 );
1048   scriptRuns11.PushBack( scriptRun1107 );
1049   scriptRuns11.PushBack( scriptRun1108 );
1050
1051   // Paragraphs with no scripts.
1052   Vector<ScriptRun> scriptRuns12;
1053   ScriptRun scriptRun1200 =
1054   {
1055     {
1056       0u,
1057       3u,
1058     },
1059     TextAbstraction::UNKNOWN
1060   };
1061   ScriptRun scriptRun1201 =
1062   {
1063     {
1064       3u,
1065       3u,
1066     },
1067     TextAbstraction::UNKNOWN
1068   };
1069   ScriptRun scriptRun1202 =
1070   {
1071     {
1072       6u,
1073       3u,
1074     },
1075     TextAbstraction::UNKNOWN
1076   };
1077   ScriptRun scriptRun1203 =
1078   {
1079     {
1080       9u,
1081       2u,
1082     },
1083     TextAbstraction::UNKNOWN
1084   };
1085   scriptRuns12.PushBack( scriptRun1200 );
1086   scriptRuns12.PushBack( scriptRun1201 );
1087   scriptRuns12.PushBack( scriptRun1202 );
1088   scriptRuns12.PushBack( scriptRun1203 );
1089
1090   Vector<ScriptRun> scriptRuns13;
1091   ScriptRun scriptRun1301 =
1092   {
1093     {
1094       0u,
1095       4u,
1096     },
1097     TextAbstraction::UNKNOWN
1098   };
1099   scriptRuns13.PushBack( scriptRun1301 );
1100
1101   const ScriptsData data[] =
1102   {
1103     {
1104       "void text",
1105       "",
1106       0u,
1107       0u,
1108       scriptRuns00,
1109     },
1110     {
1111       "Easy latin script",
1112       "Hello world",
1113       0u,
1114       11u,
1115       scriptRuns01,
1116     },
1117     {
1118       "Mix of LTR '\\n'and RTL",
1119       "Hello world\nمرحبا بالعالم",
1120       0u,
1121       25u,
1122       scriptRuns02,
1123     },
1124     {
1125       "Update mix of LTR '\\n'and RTL. Update LTR",
1126       "Hello world\nمرحبا بالعالم",
1127       0u,
1128       12u,
1129       scriptRuns02,
1130     },
1131     {
1132       "Update mix of LTR '\\n'and RTL. Update RTL",
1133       "Hello world\nمرحبا بالعالم",
1134       12u,
1135       13u,
1136       scriptRuns02,
1137     },
1138     {
1139       "Mix of RTL '\\n'and LTR",
1140       "مرحبا بالعالم\nHello world",
1141       0u,
1142       25u,
1143       scriptRuns03,
1144     },
1145     {
1146       "Update mix of RTL '\\n'and LTR. Update RTL",
1147       "مرحبا بالعالم\nHello world",
1148       0u,
1149       14u,
1150       scriptRuns03,
1151     },
1152     {
1153       "Update mix of RTL '\\n'and LTR. Update LTR",
1154       "مرحبا بالعالم\nHello world",
1155       14u,
1156       11u,
1157       scriptRuns03,
1158     },
1159     {
1160       "White spaces. At the beginning of the text.",
1161       "    Hello world",
1162       0u,
1163       15u,
1164       scriptRuns04,
1165     },
1166     {
1167       "White spaces. At the end of the text.",
1168       "Hello world    ",
1169       0u,
1170       15u,
1171       scriptRuns05,
1172     },
1173     {
1174       "White spaces. At the middle of the text.",
1175       "Hello     world",
1176       0u,
1177       15u,
1178       scriptRuns06,
1179     },
1180     {
1181       "White spaces between different scripts.",
1182       "  Hel   세계   ",
1183       0u,
1184       13u,
1185       scriptRuns07,
1186     },
1187     {
1188       "White spaces between different scripts and differetn directions. Starting LTR.",
1189       "  Hello   world   مرحبا  بالعالم     안녕하세요   세계   ",
1190       0u,
1191       50u,
1192       scriptRuns08,
1193     },
1194     {
1195       "White spaces between different scripts and differetn directions. Starting RTL.",
1196       "   مرحبا  بالعالم    Hello   world   안녕하세요   세계   مرحبا  بالعالم   ",
1197       0u,
1198       67u,
1199       scriptRuns09
1200     },
1201     {
1202       "Paragraphs with different directions.",
1203       "   مرحبا  بالعالم   שלום עולם   مرحبا  بالعالم  \n "
1204       " Hello   world   안녕하세요   세계   \n "
1205       "  مرحبا  بالعالم  Hello   world    שלום עולם  \n  "
1206       " Hello   world    مرحبا  بالعالم    안녕하세요   세계   \n "
1207       "   안녕하세요   세계   ",
1208       0u,
1209       198u,
1210       scriptRuns10
1211     },
1212     {
1213       "Update paragraphs with different directions. Update initial paragraphs.",
1214       "   مرحبا  بالعالم   שלום עולם   مرحبا  بالعالم  \n "
1215       " Hello   world   안녕하세요   세계   \n "
1216       "  مرحبا  بالعالم  Hello   world    שלום עולם  \n  "
1217       " Hello   world    مرحبا  بالعالم    안녕하세요   세계   \n "
1218       "   안녕하세요   세계   ",
1219       0u,
1220       81u,
1221       scriptRuns10
1222     },
1223     {
1224       "Update paragraphs with different directions. Update middle paragraphs.",
1225       "   مرحبا  بالعالم   שלום עולם   مرحبا  بالعالم  \n "
1226       " Hello   world   안녕하세요   세계   \n "
1227       "  مرحبا  بالعالم  Hello   world    שלום עולם  \n  "
1228       " Hello   world    مرحبا  بالعالم    안녕하세요   세계   \n "
1229       "   안녕하세요   세계   ",
1230       49u,
1231       80u,
1232       scriptRuns10
1233     },
1234     {
1235       "Update paragraphs with different directions. Update final paragraphs.",
1236       "   مرحبا  بالعالم   שלום עולם   مرحبا  بالعالم  \n "
1237       " Hello   world   안녕하세요   세계   \n "
1238       "  مرحبا  بالعالم  Hello   world    שלום עולם  \n  "
1239       " Hello   world    مرحبا  بالعالم    안녕하세요   세계   \n "
1240       "   안녕하세요   세계   ",
1241       129u,
1242       69u,
1243       scriptRuns10
1244     },
1245     {
1246       "Paragraphs with no scripts mixed with paragraphs with scripts.",
1247       "  \n  \n   Hello   world  \n  \n  \n   שלום עולם  \n \n \n  ",
1248       0u,
1249       52u,
1250       scriptRuns11
1251     },
1252     {
1253       "Paragraphs with no scripts.",
1254       "  \n  \n  \n  ",
1255       0u,
1256       11u,
1257       scriptRuns12
1258     },
1259     {
1260       "Update paragraphs with no scripts. Update initial paragraphs.",
1261       "  \n  \n  \n  ",
1262       0u,
1263       3u,
1264       scriptRuns12
1265     },
1266     {
1267       "Update paragraphs with no scripts. Update middle paragraphs.",
1268       "  \n  \n  \n  ",
1269       3u,
1270       6u,
1271       scriptRuns12
1272     },
1273     {
1274       "Update paragraphs with no scripts. Update final paragraphs.",
1275       "  \n  \n  \n  ",
1276       9u,
1277       2u,
1278       scriptRuns12
1279     },
1280     {
1281       "Unknown scripts.",
1282       "ᚩᚯᚱᚸ", // Runic script not currentlu supported.
1283       0u,
1284       4u,
1285       scriptRuns13
1286     }
1287   };
1288   const unsigned int numberOfTests = 24u;
1289
1290   for( unsigned int index = 0u; index < numberOfTests; ++index )
1291   {
1292     if( !ScriptsTest( data[index] ) )
1293     {
1294       tet_result(TET_FAIL);
1295     }
1296   }
1297
1298   tet_result(TET_PASS);
1299   END_TEST;
1300 }
1301
1302 int UtcDaliTextMultiLanguageValidateFonts01(void)
1303 {
1304   ToolkitTestApplication application;
1305   tet_infoline(" UtcDaliTextMultiLanguageValidateFonts");
1306
1307   TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1308
1309   char* pathNamePtr = get_current_dir_name();
1310   const std::string pathName( pathNamePtr );
1311   free( pathNamePtr );
1312
1313   const PointSize26Dot6 pointSize01 = static_cast<PointSize26Dot6>( 21.f * 64.f );
1314   const PointSize26Dot6 pointSize02 = static_cast<PointSize26Dot6>( 35.f * 64.f );
1315
1316   // Load some fonts.
1317   fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/tizen/TizenSansArabicRegular.ttf" );
1318   fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/tizen/TizenSansHebrewRegular.ttf" );
1319   fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/tizen/BreezeColorEmoji.ttf", EMOJI_FONT_SIZE );
1320   fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/tizen/TizenSansRegular.ttf", pointSize01 );
1321   fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/tizen/TizenSansRegular.ttf", pointSize02 );
1322   fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/tizen/TizenSansHebrewRegular.ttf", pointSize01 );
1323   fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/tizen/TizenSansHebrewRegular.ttf", pointSize02 );
1324
1325   // Font id 1 --> TizenSansArabicRegular.ttf
1326   // Font id 2 --> TizenSansHebrewRegular.ttf
1327   // Font id 3 --> BreezeColorEmoji.ttf
1328   // Font id 4 --> TizenSansRegular.ttf, size 8
1329   // Font id 5 --> TizenSansRegular.ttf, size 16
1330   // Font id 6 --> TizenSansHebrewRegular.ttf, size 8
1331   // Font id 7 --> TizenSansHebrewRegular.ttf, size 16
1332   // Font id 8 --> (default)
1333
1334   Vector<FontRun> fontRuns01;
1335   Vector<FontDescriptionRun> fontDescriptions01;
1336
1337   FontRun fontRun0201 =
1338   {
1339     {
1340       0u,
1341       11u
1342     },
1343     8u
1344   };
1345   Vector<FontRun> fontRuns02;
1346   fontRuns02.PushBack( fontRun0201 );
1347
1348   FontDescriptionRun fontDescription0201 =
1349   {
1350     {
1351       0u,
1352       11u
1353     },
1354     const_cast<char*>( "TizenSans" ),
1355     9u,
1356     TextAbstraction::FontWeight::NORMAL,
1357     TextAbstraction::FontWidth::NORMAL,
1358     TextAbstraction::FontSlant::NORMAL,
1359     0u,
1360     true,
1361     false,
1362     false,
1363     false,
1364     false
1365   };
1366   Vector<FontDescriptionRun> fontDescriptions02;
1367   fontDescriptions02.PushBack( fontDescription0201 );
1368
1369   FontRun fontRun0301 =
1370   {
1371     {
1372       0u,
1373       12u
1374     },
1375     8u
1376   };
1377   FontRun fontRun0302 =
1378   {
1379     {
1380       12u,
1381       12u
1382     },
1383     8u
1384   };
1385   FontRun fontRun0303 =
1386   {
1387     {
1388       24u,
1389       4u
1390     },
1391     8u
1392   };
1393   Vector<FontRun> fontRuns03;
1394   fontRuns03.PushBack( fontRun0301 );
1395   fontRuns03.PushBack( fontRun0302 );
1396   fontRuns03.PushBack( fontRun0303 );
1397
1398   Vector<FontDescriptionRun> fontDescriptions03;
1399
1400   FontRun fontRun0701 =
1401   {
1402     {
1403       0u,
1404       4u
1405     },
1406     2u
1407   };
1408   FontRun fontRun0702 =
1409   {
1410     {
1411       4u,
1412       1u
1413     },
1414     8u
1415   };
1416   FontRun fontRun0703 =
1417   {
1418     {
1419       5u,
1420       4u
1421     },
1422     2u
1423   };
1424   Vector<FontRun> fontRuns07;
1425   fontRuns07.PushBack( fontRun0701 );
1426   fontRuns07.PushBack( fontRun0702 );
1427   fontRuns07.PushBack( fontRun0703 );
1428
1429   FontDescriptionRun fontDescription0701 =
1430   {
1431     {
1432       0u,
1433       4u
1434     },
1435     const_cast<char*>( "TizenSansHebrew" ),
1436     15u,
1437     TextAbstraction::FontWeight::NORMAL,
1438     TextAbstraction::FontWidth::NORMAL,
1439     TextAbstraction::FontSlant::NORMAL,
1440     0u,
1441     true,
1442     false,
1443     false,
1444     false,
1445     false
1446   };
1447   FontDescriptionRun fontDescription0702 =
1448   {
1449     {
1450       5u,
1451       4u
1452     },
1453     const_cast<char*>( "TizenSansHebrew" ),
1454     15u,
1455     TextAbstraction::FontWeight::NORMAL,
1456     TextAbstraction::FontWidth::NORMAL,
1457     TextAbstraction::FontSlant::NORMAL,
1458     0u,
1459     true,
1460     false,
1461     false,
1462     false,
1463     false
1464   };
1465   Vector<FontDescriptionRun> fontDescriptions07;
1466   fontDescriptions07.PushBack( fontDescription0701 );
1467   fontDescriptions07.PushBack( fontDescription0702 );
1468
1469   FontRun fontRun0801 =
1470   {
1471     {
1472       0u,
1473       9u
1474     },
1475     2u
1476   };
1477   Vector<FontRun> fontRuns08;
1478   fontRuns08.PushBack( fontRun0801 );
1479
1480   Vector<FontDescriptionRun> fontDescriptions08;
1481
1482   FontRun fontRun0901 =
1483   {
1484     {
1485       0u,
1486       4u
1487     },
1488     3u
1489   };
1490   Vector<FontRun> fontRuns09;
1491   fontRuns09.PushBack( fontRun0901 );
1492
1493   Vector<FontDescriptionRun> fontDescriptions09;
1494   FontDescriptionRun fontDescription0901 =
1495   {
1496     {
1497       0u,
1498       4u
1499     },
1500     const_cast<char*>( "BreezeColorEmoji" ),
1501     16u,
1502     TextAbstraction::FontWeight::NORMAL,
1503     TextAbstraction::FontWidth::NORMAL,
1504     TextAbstraction::FontSlant::NORMAL,
1505     EMOJI_FONT_SIZE,
1506     true,
1507     false,
1508     false,
1509     false,
1510     true
1511   };
1512   fontDescriptions09.PushBack( fontDescription0901 );
1513
1514   FontRun fontRun1001 =
1515   {
1516     {
1517       0u,
1518       13u
1519     },
1520     4u
1521   };
1522   FontRun fontRun1002 =
1523   {
1524     {
1525       13u,
1526       9u
1527     },
1528     6u
1529   };
1530   FontRun fontRun1003 =
1531   {
1532     {
1533       22u,
1534       15u
1535     },
1536     5u
1537   };
1538   FontRun fontRun1004 =
1539   {
1540     {
1541       37u,
1542       9u
1543     },
1544     7u
1545   };
1546   Vector<FontRun> fontRuns10;
1547   fontRuns10.PushBack( fontRun1001 );
1548   fontRuns10.PushBack( fontRun1002 );
1549   fontRuns10.PushBack( fontRun1003 );
1550   fontRuns10.PushBack( fontRun1004 );
1551
1552   FontDescriptionRun fontDescription1001 =
1553   {
1554     {
1555       0u,
1556       13u
1557     },
1558     const_cast<char*>( "TizenSans" ),
1559     9u,
1560     TextAbstraction::FontWeight::NORMAL,
1561     TextAbstraction::FontWidth::NORMAL,
1562     TextAbstraction::FontSlant::NORMAL,
1563     pointSize01,
1564     true,
1565     false,
1566     false,
1567     false,
1568     true
1569   };
1570   FontDescriptionRun fontDescription1002 =
1571   {
1572     {
1573       13u,
1574       9u
1575     },
1576     const_cast<char*>( "TizenSansHebrew" ),
1577     15u,
1578     TextAbstraction::FontWeight::NORMAL,
1579     TextAbstraction::FontWidth::NORMAL,
1580     TextAbstraction::FontSlant::NORMAL,
1581     pointSize01,
1582     true,
1583     false,
1584     false,
1585     false,
1586     true
1587   };
1588   FontDescriptionRun fontDescription1003 =
1589   {
1590     {
1591       22u,
1592       15u
1593     },
1594     const_cast<char*>( "TizenSans" ),
1595     9u,
1596     TextAbstraction::FontWeight::NORMAL,
1597     TextAbstraction::FontWidth::NORMAL,
1598     TextAbstraction::FontSlant::NORMAL,
1599     pointSize02,
1600     true,
1601     false,
1602     false,
1603     false,
1604     true
1605   };
1606   FontDescriptionRun fontDescription1004 =
1607   {
1608     {
1609       37u,
1610       9u
1611     },
1612     const_cast<char*>( "TizenSansHebrew" ),
1613     15u,
1614     TextAbstraction::FontWeight::NORMAL,
1615     TextAbstraction::FontWidth::NORMAL,
1616     TextAbstraction::FontSlant::NORMAL,
1617     pointSize02,
1618     true,
1619     false,
1620     false,
1621     false,
1622     true
1623   };
1624   Vector<FontDescriptionRun> fontDescriptions10;
1625   fontDescriptions10.PushBack( fontDescription1001 );
1626   fontDescriptions10.PushBack( fontDescription1002 );
1627   fontDescriptions10.PushBack( fontDescription1003 );
1628   fontDescriptions10.PushBack( fontDescription1004 );
1629
1630   FontRun fontRun1101 =
1631   {
1632     {
1633       0u,
1634       22u
1635     },
1636     5u
1637   };
1638   Vector<FontRun> fontRuns11;
1639   fontRuns11.PushBack( fontRun1101 );
1640
1641   FontDescriptionRun fontDescription1101 =
1642   {
1643     {
1644       0,
1645       22u
1646     },
1647     const_cast<char*>( "TizenSans" ),
1648     9u,
1649     TextAbstraction::FontWeight::NORMAL,
1650     TextAbstraction::FontWidth::NORMAL,
1651     TextAbstraction::FontSlant::NORMAL,
1652     pointSize02,
1653     true,
1654     false,
1655     false,
1656     false,
1657     true
1658   };
1659   Vector<FontDescriptionRun> fontDescriptions11;
1660   fontDescriptions11.PushBack( fontDescription1101 );
1661
1662   FontRun fontRun1201 =
1663   {
1664     {
1665       0u,
1666       6u
1667     },
1668     8u
1669   };
1670   FontRun fontRun1202 =
1671   {
1672     {
1673       6u,
1674       1u
1675     },
1676     9u
1677   };
1678   FontRun fontRun1203 =
1679   {
1680     {
1681       7u,
1682       5u
1683     },
1684     8u
1685   };
1686   Vector<FontRun> fontRuns12;
1687   fontRuns12.PushBack( fontRun1201 );
1688   fontRuns12.PushBack( fontRun1202 );
1689   fontRuns12.PushBack( fontRun1203 );
1690
1691   FontDescriptionRun fontDescription1201 =
1692   {
1693     {
1694       0u,
1695       6u
1696     },
1697     const_cast<char*>( "TizenSans" ),
1698     9u,
1699     TextAbstraction::FontWeight::NORMAL,
1700     TextAbstraction::FontWidth::NORMAL,
1701     TextAbstraction::FontSlant::NORMAL,
1702     0u,
1703     true,
1704     false,
1705     false,
1706     false,
1707     false
1708   };
1709   FontDescriptionRun fontDescription1202 =
1710   {
1711     {
1712       6u,
1713       1u
1714     },
1715     const_cast<char*>( "TizenSans" ),
1716     9u,
1717     TextAbstraction::FontWeight::NORMAL,
1718     TextAbstraction::FontWidth::NORMAL,
1719     TextAbstraction::FontSlant::NORMAL,
1720     0u,
1721     true,
1722     false,
1723     false,
1724     false,
1725     false
1726   };
1727   FontDescriptionRun fontDescription1203 =
1728   {
1729     {
1730       7u,
1731       5u
1732     },
1733     const_cast<char*>( "TizenSans" ),
1734     9u,
1735     TextAbstraction::FontWeight::NORMAL,
1736     TextAbstraction::FontWidth::NORMAL,
1737     TextAbstraction::FontSlant::NORMAL,
1738     0u,
1739     true,
1740     false,
1741     false,
1742     false,
1743     false
1744   };
1745   Vector<FontDescriptionRun> fontDescriptions12;
1746   fontDescriptions12.PushBack( fontDescription1201 );
1747   fontDescriptions12.PushBack( fontDescription1202 );
1748   fontDescriptions12.PushBack( fontDescription1203 );
1749
1750   const ValidateFontsData data[] =
1751   {
1752     {
1753       "void text.",
1754       "",
1755       "/tizen/TizenSansRegular.ttf",
1756       TextAbstraction::FontClient::DEFAULT_POINT_SIZE,
1757       1.0f,
1758       0u,
1759       0u,
1760       fontDescriptions01,
1761       fontRuns01
1762     },
1763     {
1764       "Easy latin script.",
1765       "Hello world",
1766       "/tizen/TizenSansRegular.ttf",
1767       TextAbstraction::FontClient::DEFAULT_POINT_SIZE,
1768       1.0f,
1769       0u,
1770       11u,
1771       fontDescriptions02,
1772       fontRuns02
1773     },
1774     {
1775       "Different paragraphs.",
1776       "Hello world\nhello world\ndemo",
1777       "/tizen/TizenSansRegular.ttf",
1778       TextAbstraction::FontClient::DEFAULT_POINT_SIZE,
1779       1.0f,
1780       0u,
1781       28u,
1782       fontDescriptions03,
1783       fontRuns03
1784     },
1785     {
1786       "Different paragraphs. Update the initial paragraph.",
1787       "Hello world\nhello world\ndemo",
1788       "/tizen/TizenSansRegular.ttf",
1789       TextAbstraction::FontClient::DEFAULT_POINT_SIZE,
1790       1.0f,
1791       0u,
1792       12u,
1793       fontDescriptions03,
1794       fontRuns03
1795     },
1796     {
1797       "Different paragraphs. Update the middle paragraph.",
1798       "Hello world\nhello world\ndemo",
1799       "/tizen/TizenSansRegular.ttf",
1800       TextAbstraction::FontClient::DEFAULT_POINT_SIZE,
1801       1.0f,
1802       12u,
1803       12u,
1804       fontDescriptions03,
1805       fontRuns03
1806     },
1807     {
1808       "Different paragraphs. Update the final paragraph.",
1809       "Hello world\nhello world\ndemo",
1810       "/tizen/TizenSansRegular.ttf",
1811       TextAbstraction::FontClient::DEFAULT_POINT_SIZE,
1812       1.0f,
1813       24u,
1814       4u,
1815       fontDescriptions03,
1816       fontRuns03
1817     },
1818     {
1819       "Hebrew text. Default font: latin",
1820       "שלום עולם",
1821       "/tizen/TizenSansRegular.ttf",
1822       TextAbstraction::FontClient::DEFAULT_POINT_SIZE,
1823       1.0f,
1824       0u,
1825       9u,
1826       fontDescriptions07,
1827       fontRuns07
1828     },
1829     {
1830       "Hebrew text. Default font: hebrew",
1831       "שלום עולם",
1832       "/tizen/TizenSansHebrewRegular.ttf",
1833       TextAbstraction::FontClient::DEFAULT_POINT_SIZE,
1834       1.0f,
1835       0u,
1836       9u,
1837       fontDescriptions08,
1838       fontRuns08
1839     },
1840     {
1841       "Emojis",
1842       "\xF0\x9F\x98\x81\xF0\x9F\x98\x82\xF0\x9F\x98\x83\xF0\x9F\x98\x84",
1843       "/tizen/BreezeColorEmoji.ttf",
1844       EMOJI_FONT_SIZE,
1845       1.0f,
1846       0u,
1847       4u,
1848       fontDescriptions09,
1849       fontRuns09
1850     },
1851     {
1852       "Mix text. Default font: latin. Different font sizes",
1853       "Hello world, שלום עולם, hello world, שלום עולם",
1854       "/tizen/TizenSansRegular.ttf",
1855       TextAbstraction::FontClient::DEFAULT_POINT_SIZE,
1856       1.0f,
1857       0u,
1858       46u,
1859       fontDescriptions10,
1860       fontRuns10
1861     },
1862     {
1863       "Unknown script -> changed to LATIN",
1864       "WRC – The Official App",
1865       "/tizen/TizenSansRegular.ttf",
1866       TextAbstraction::FontClient::DEFAULT_POINT_SIZE,
1867       1.0f,
1868       0u,
1869       22u,
1870       fontDescriptions11,
1871       fontRuns11
1872     },
1873     {
1874       "Common script.",
1875       "Hello \tworld",
1876       "/tizen/TizenSansRegular.ttf",
1877       TextAbstraction::FontClient::DEFAULT_POINT_SIZE,
1878       1.0f,
1879       0u,
1880       12u,
1881       fontDescriptions12,
1882       fontRuns12
1883     },
1884   };
1885   const unsigned int numberOfTests = 12u;
1886
1887   for( unsigned int index = 0u; index < numberOfTests; ++index )
1888   {
1889     if( !ValidateFontTest( data[index] ) )
1890     {
1891       tet_result(TET_FAIL);
1892     }
1893   }
1894
1895   tet_result(TET_PASS);
1896   END_TEST;
1897 }