2 * Copyright (c) 2015 Samsung Electronics Co., Ltd.
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
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>
33 using namespace Toolkit;
36 // Tests the following functions with different scripts.
38 // void MergeFontDescriptions( const Vector<FontDescriptionRun>& fontDescriptions,
39 // Vector<FontId>& fontIds,
40 // Vector<bool>& isDefaultFont,
41 // const TextAbstraction::FontDescription& defaultFontDescription,
42 // TextAbstraction::PointSize26Dot6 defaultPointSize,
43 // CharacterIndex startIndex,
44 // Length numberOfCharacters );
46 // Script GetScript( Length index,
47 // Vector<ScriptRun>::ConstIterator& scriptRunIt,
48 // const Vector<ScriptRun>::ConstIterator& scriptRunEndIt );
50 // Constructor, destructor and MultilanguageSupport::Get()
52 // void MultilanguageSupport::SetScripts( const Vector<Character>& text,
53 // CharacterIndex startIndex,
54 // Length numberOfCharacters,
55 // Vector<ScriptRun>& scripts );
57 // void MultilanguageSupport::ValidateFonts( const Vector<Character>& text,
58 // const Vector<ScriptRun>& scripts,
59 // const Vector<FontDescriptionRun>& fontDescriptions,
60 // FontId defaultFontId,
61 // CharacterIndex startIndex,
62 // Length numberOfCharacters,
63 // Vector<FontRun>& fonts );
65 //////////////////////////////////////////////////////////
70 const std::string DEFAULT_FONT_DIR( "/resources/fonts" );
71 const unsigned int EMOJI_FONT_SIZE = 3968u;
72 const unsigned int NON_DEFAULT_FONT_SIZE = 40u;
74 struct MergeFontDescriptionsData
76 std::string description; ///< Description of the experiment.
77 Vector<FontDescriptionRun> fontDescriptionRuns; ///< The font description runs.
78 TextAbstraction::FontDescription defaultFontDescription; ///< The default font description.
79 TextAbstraction::PointSize26Dot6 defaultPointSize; ///< The default point size.
80 unsigned int startIndex; ///< The start index.
81 unsigned int numberOfCharacters; ///< The number of characters.
82 Vector<FontId> expectedFontIds; ///< The expected font ids.
83 Vector<bool> expectedIsDefault; ///< The expected font ids.
88 std::string description; ///< Description of the experiment.
89 std::string text; ///< Input text.
90 unsigned int index; ///< The index of the first character to update the script.
91 unsigned int numberOfCharacters; ///< The numbers of characters to update the script.
92 Vector<ScriptRun> scriptRuns; ///< Expected script runs.
95 struct ValidateFontsData
97 std::string description; ///< Description of the experiment.
98 std::string text; ///< Input text.
99 std::string defaultFont; ///< The default font.
100 unsigned int defaultFontSize; ///< The default font size.
101 unsigned int index; ///< The index of the first character to update the script.
102 unsigned int numberOfCharacters; ///< The numbers of characters to update the script.
103 Vector<FontDescriptionRun> fontDescriptionRuns; ///< The font description runs.
104 Vector<FontRun> fontRuns; ///< The expected font runs.
107 //////////////////////////////////////////////////////////
109 bool MergeFontDescriptionsTest( const MergeFontDescriptionsData& data )
111 Vector<FontId> fontIds;
112 fontIds.Resize( data.startIndex + data.numberOfCharacters, 0u );
113 Vector<bool> isDefaultFont;
114 isDefaultFont.Resize( data.startIndex + data.numberOfCharacters, true );
116 MergeFontDescriptions( data.fontDescriptionRuns,
119 data.defaultFontDescription,
120 data.defaultPointSize,
122 data.numberOfCharacters );
124 if( fontIds.Count() != data.expectedFontIds.Count() )
126 std::cout << data.description << " Different number of font ids : " << fontIds.Count() << ", expected : " << data.expectedFontIds.Count() << std::endl;
130 for( unsigned int index = 0u; index < fontIds.Count(); ++index )
132 if( fontIds[index] != data.expectedFontIds[index] )
134 std::cout << data.description << " Different font id at index : " << index << ", font id : " << fontIds[index] << ", expected : " << data.expectedFontIds[index] << std::endl;
135 std::cout << " font ids : ";
136 for( unsigned int i=0;i<fontIds.Count();++i)
138 std::cout << fontIds[i] << " ";
140 std::cout << std::endl;
141 std::cout << " expected font ids : ";
142 for( unsigned int i=0;i<data.expectedFontIds.Count();++i)
144 std::cout << data.expectedFontIds[i] << " ";
146 std::cout << std::endl;
150 if( isDefaultFont[index] != data.expectedIsDefault[index] )
152 std::cout << data.description << " Different 'is font default' at index : " << index << ", is font default : " << isDefaultFont[index] << ", expected : " << data.expectedIsDefault[index] << std::endl;
160 bool ScriptsTest( const ScriptsData& data )
162 MultilanguageSupport multilanguageSupport = MultilanguageSupport::Get();
164 // 1) Convert to utf32
165 Vector<Character> utf32;
166 utf32.Resize( data.text.size() );
168 const uint32_t numberOfCharacters = Utf8ToUtf32( reinterpret_cast<const uint8_t* const>( data.text.c_str() ),
171 utf32.Resize( numberOfCharacters );
173 // 2) Set the script info.
174 Vector<ScriptRun> scripts;
175 multilanguageSupport.SetScripts( utf32,
180 if( ( 0u != data.index ) ||
181 ( numberOfCharacters != data.numberOfCharacters ) )
183 // 3) Clear the scripts.
184 ClearCharacterRuns( data.index,
185 data.index + data.numberOfCharacters - 1u,
188 multilanguageSupport.SetScripts( utf32,
190 data.numberOfCharacters,
194 // 4) Compare the results.
196 tet_printf( "Testing %s\n", data.description.c_str() );
197 if( scripts.Count() != data.scriptRuns.Count() )
199 tet_printf("ScriptsTest FAIL: different number of scripts. %d, should be %d\n", scripts.Count(), data.scriptRuns.Count() );
203 for( unsigned int index = 0u; index < scripts.Count(); ++index )
205 const ScriptRun& scriptRun1 = scripts[index];
206 const ScriptRun& scriptRun2 = data.scriptRuns[index];
208 if( scriptRun1.characterRun.characterIndex != scriptRun2.characterRun.characterIndex )
210 tet_printf("ScriptsTest FAIL: different character index. %d, should be %d\n", scriptRun1.characterRun.characterIndex, scriptRun2.characterRun.characterIndex );
214 if( scriptRun1.characterRun.numberOfCharacters != scriptRun2.characterRun.numberOfCharacters )
216 tet_printf("ScriptsTest FAIL: different number of characters. %d, should be %d\n", scriptRun1.characterRun.numberOfCharacters, scriptRun2.characterRun.numberOfCharacters );
220 if( scriptRun1.script != scriptRun2.script )
222 tet_printf("ScriptsTest FAIL: different script. %s, should be %s\n", TextAbstraction::ScriptName[scriptRun1.script], TextAbstraction::ScriptName[scriptRun2.script] );
230 bool ValidateFontTest( const ValidateFontsData& data )
232 MultilanguageSupport multilanguageSupport = MultilanguageSupport::Get();
233 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
235 // 1) Convert to utf32
236 Vector<Character> utf32;
237 utf32.Resize( data.text.size() );
239 const uint32_t numberOfCharacters = Utf8ToUtf32( reinterpret_cast<const uint8_t* const>( data.text.c_str() ),
242 utf32.Resize( numberOfCharacters );
244 // 2) Set the script info.
245 Vector<ScriptRun> scripts;
246 multilanguageSupport.SetScripts( utf32,
251 char* pathNamePtr = get_current_dir_name();
252 const std::string pathName( pathNamePtr );
255 // Get the default font id.
256 const FontId defaultFontId = fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + data.defaultFont,
257 data.defaultFontSize );
259 Vector<FontRun> fontRuns;
261 // 3) Validate the fonts.
262 multilanguageSupport.ValidateFonts( utf32,
264 data.fontDescriptionRuns,
270 if( ( 0u != data.index ) ||
271 ( numberOfCharacters != data.numberOfCharacters ) )
273 // 4) Clear the fonts.
274 ClearCharacterRuns( data.index,
275 data.index + data.numberOfCharacters - 1u,
278 multilanguageSupport.ValidateFonts( utf32,
280 data.fontDescriptionRuns,
283 data.numberOfCharacters,
287 // 5) Compare the results.
288 if( data.fontRuns.Count() != fontRuns.Count() )
290 std::cout << " Different number of font runs : " << fontRuns.Count() << ", expected : " << data.fontRuns.Count() << std::endl;
295 for( unsigned int index = 0; index < data.fontRuns.Count(); ++index )
297 const FontRun& run = fontRuns[index];
298 const FontRun& expectedRun = data.fontRuns[index];
300 if( run.characterRun.characterIndex != expectedRun.characterRun.characterIndex )
302 std::cout << " character run : " << index << ", index : " << run.characterRun.characterIndex << ", expected : " << expectedRun.characterRun.characterIndex << std::endl;
305 if( run.characterRun.numberOfCharacters != expectedRun.characterRun.numberOfCharacters )
307 std::cout << " character run : " << index << ", num chars : " << run.characterRun.numberOfCharacters << ", expected : " << expectedRun.characterRun.numberOfCharacters << std::endl;
310 if( run.fontId != expectedRun.fontId )
312 std::cout << " character run : " << index << ", font : " << run.fontId << ", expected : " << expectedRun.fontId << std::endl;
322 int UtcDaliTextGetScript(void)
324 ToolkitTestApplication application;
325 tet_infoline(" UtcDaliTextGetScript");
327 Script script = TextAbstraction::LATIN;
329 // Text with no scripts.
330 Vector<ScriptRun> scriptRuns;
331 Vector<ScriptRun>::ConstIterator scriptRunIt = scriptRuns.Begin();
332 script = GetScript( 0u,
336 DALI_TEST_CHECK( TextAbstraction::UNKNOWN == script );
338 const unsigned int numberOfCharacters = 7u;
340 ScriptRun scriptRun01 =
346 TextAbstraction::LATIN
348 ScriptRun scriptRun02 =
354 TextAbstraction::HEBREW
356 ScriptRun scriptRun03 =
362 TextAbstraction::ARABIC
364 scriptRuns.PushBack( scriptRun01 );
365 scriptRuns.PushBack( scriptRun02 );
366 scriptRuns.PushBack( scriptRun03 );
369 TextAbstraction::Script expectedScripts[]=
371 TextAbstraction::LATIN,
372 TextAbstraction::LATIN,
373 TextAbstraction::HEBREW,
374 TextAbstraction::HEBREW,
375 TextAbstraction::ARABIC,
376 TextAbstraction::ARABIC,
377 TextAbstraction::UNKNOWN
380 scriptRunIt = scriptRuns.Begin();
381 for( unsigned int index = 0u; index < numberOfCharacters; ++index )
383 script = GetScript( index,
387 DALI_TEST_CHECK( expectedScripts[index] == script );
389 DALI_TEST_CHECK( scriptRunIt == scriptRuns.End() );
391 tet_result(TET_PASS);
395 int UtcDaliTextMergeFontDescriptions(void)
397 ToolkitTestApplication application;
398 tet_infoline(" UtcDaliTextMergeFontDescriptions");
402 char* pathNamePtr = get_current_dir_name();
403 const std::string pathName( pathNamePtr );
406 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
407 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSans.ttf" );
408 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf" );
409 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", NON_DEFAULT_FONT_SIZE );
410 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf" );
411 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Italic.ttf" );
413 // To test the font width as GetFontId() with the font file path can't cache the width property.
414 TextAbstraction::FontDescription widthDescription;
415 widthDescription.path = "";
416 widthDescription.family = "DejaVu Serif";
417 widthDescription.weight = TextAbstraction::FontWeight::NORMAL;
418 widthDescription.width = TextAbstraction::FontWidth::EXPANDED;
419 widthDescription.slant = TextAbstraction::FontSlant::NORMAL;
420 fontClient.GetFontId( widthDescription );
424 TextAbstraction::FontDescription defaultFontDescription01;
425 Vector<FontDescriptionRun> fontDescriptionRuns01;
426 Vector<FontId> expectedFontIds01;
427 Vector<bool> expectedIsFontDefault01;
429 TextAbstraction::FontDescription defaultFontDescription02;
430 Vector<FontDescriptionRun> fontDescriptionRuns02;
431 Vector<FontId> expectedFontIds02;
432 expectedFontIds02.PushBack( 0u );
433 expectedFontIds02.PushBack( 0u );
434 Vector<bool> expectedIsFontDefault02;
435 expectedIsFontDefault02.PushBack( true );
436 expectedIsFontDefault02.PushBack( true );
438 TextAbstraction::FontDescription defaultFontDescription03;
439 defaultFontDescription03.family = "DejaVu Serif";
440 Vector<FontDescriptionRun> fontDescriptionRuns03;
442 FontDescriptionRun fontDescription0301 =
448 const_cast<char*>( "DejaVu Sans" ),
450 TextAbstraction::FontWeight::NORMAL,
451 TextAbstraction::FontWidth::NORMAL,
452 TextAbstraction::FontSlant::NORMAL,
453 TextAbstraction::FontClient::DEFAULT_POINT_SIZE,
460 FontDescriptionRun fontDescription0302 =
468 TextAbstraction::FontWeight::NORMAL,
469 TextAbstraction::FontWidth::NORMAL,
470 TextAbstraction::FontSlant::ITALIC,
471 TextAbstraction::FontClient::DEFAULT_POINT_SIZE,
478 FontDescriptionRun fontDescription0303 =
486 TextAbstraction::FontWeight::BOLD,
487 TextAbstraction::FontWidth::NORMAL,
488 TextAbstraction::FontSlant::NORMAL,
489 TextAbstraction::FontClient::DEFAULT_POINT_SIZE,
496 FontDescriptionRun fontDescription0304 =
504 TextAbstraction::FontWeight::NORMAL,
505 TextAbstraction::FontWidth::NORMAL,
506 TextAbstraction::FontSlant::NORMAL,
507 NON_DEFAULT_FONT_SIZE,
514 FontDescriptionRun fontDescription0305 =
522 TextAbstraction::FontWeight::NORMAL,
523 TextAbstraction::FontWidth::EXPANDED,
524 TextAbstraction::FontSlant::NORMAL,
525 TextAbstraction::FontClient::DEFAULT_POINT_SIZE,
533 fontDescriptionRuns03.PushBack( fontDescription0301 );
534 fontDescriptionRuns03.PushBack( fontDescription0302 );
535 fontDescriptionRuns03.PushBack( fontDescription0303 );
536 fontDescriptionRuns03.PushBack( fontDescription0304 );
537 fontDescriptionRuns03.PushBack( fontDescription0305 );
539 Vector<FontId> expectedFontIds03;
540 expectedFontIds03.PushBack( 1u );
541 expectedFontIds03.PushBack( 1u );
542 expectedFontIds03.PushBack( 5u );
543 expectedFontIds03.PushBack( 5u );
544 expectedFontIds03.PushBack( 4u );
545 expectedFontIds03.PushBack( 4u );
546 expectedFontIds03.PushBack( 3u );
547 expectedFontIds03.PushBack( 3u );
548 expectedFontIds03.PushBack( 6u );
549 expectedFontIds03.PushBack( 6u );
550 Vector<bool> expectedIsFontDefault03;
551 expectedIsFontDefault03.PushBack( false );
552 expectedIsFontDefault03.PushBack( false );
553 expectedIsFontDefault03.PushBack( false );
554 expectedIsFontDefault03.PushBack( false );
555 expectedIsFontDefault03.PushBack( false );
556 expectedIsFontDefault03.PushBack( false );
557 expectedIsFontDefault03.PushBack( false );
558 expectedIsFontDefault03.PushBack( false );
559 expectedIsFontDefault03.PushBack( false );
560 expectedIsFontDefault03.PushBack( false );
562 const MergeFontDescriptionsData data[] =
566 fontDescriptionRuns01,
567 defaultFontDescription01,
568 TextAbstraction::FontClient::DEFAULT_POINT_SIZE,
572 expectedIsFontDefault01
575 "No description runs.",
576 fontDescriptionRuns02,
577 defaultFontDescription02,
578 TextAbstraction::FontClient::DEFAULT_POINT_SIZE,
582 expectedIsFontDefault02
585 "Some description runs.",
586 fontDescriptionRuns03,
587 defaultFontDescription03,
588 TextAbstraction::FontClient::DEFAULT_POINT_SIZE,
592 expectedIsFontDefault03
595 const unsigned int numberOfTests = 3u;
597 for( unsigned int index = 0u; index < numberOfTests; ++index )
599 if( !MergeFontDescriptionsTest( data[index] ) )
601 tet_result(TET_FAIL);
605 tet_result(TET_PASS);
609 int UtcDaliTextMultiLanguageConstructor(void)
611 ToolkitTestApplication application;
612 tet_infoline(" UtcDaliTextMultiLanguageConstructor");
614 MultilanguageSupport multilanguageSupport;
615 DALI_TEST_CHECK( !multilanguageSupport );
617 MultilanguageSupport multilanguageSupport1 = MultilanguageSupport::Get();
618 DALI_TEST_CHECK( multilanguageSupport1 );
620 // To increase coverage.
621 MultilanguageSupport multilanguageSupport2 = MultilanguageSupport::Get();
622 DALI_TEST_CHECK( multilanguageSupport2 );
624 DALI_TEST_CHECK( multilanguageSupport1 == multilanguageSupport2 );
626 tet_result(TET_PASS);
630 int UtcDaliTextMultiLanguageSetScripts(void)
632 ToolkitTestApplication application;
633 tet_infoline(" UtcDaliTextMultiLanguageSetScripts" );
636 Vector<ScriptRun> scriptRuns00;
639 Vector<ScriptRun> scriptRuns01;
640 ScriptRun scriptRun0100 =
646 TextAbstraction::LATIN
648 scriptRuns01.PushBack( scriptRun0100 );
650 // Mix of LTR '\n'and RTL
651 Vector<ScriptRun> scriptRuns02;
652 ScriptRun scriptRun0200 =
658 TextAbstraction::LATIN
660 ScriptRun scriptRun0201 =
666 TextAbstraction::ARABIC
668 scriptRuns02.PushBack( scriptRun0200 );
669 scriptRuns02.PushBack( scriptRun0201 );
671 // Mix of RTL '\n'and LTR
672 Vector<ScriptRun> scriptRuns03;
673 ScriptRun scriptRun0300 =
679 TextAbstraction::ARABIC
681 ScriptRun scriptRun0301 =
687 TextAbstraction::LATIN
689 scriptRuns03.PushBack( scriptRun0300 );
690 scriptRuns03.PushBack( scriptRun0301 );
692 // White spaces. At the beginning of the text.
693 Vector<ScriptRun> scriptRuns04;
694 ScriptRun scriptRun0400 =
700 TextAbstraction::LATIN
702 scriptRuns04.PushBack( scriptRun0400 );
704 // White spaces. At the end of the text.
705 Vector<ScriptRun> scriptRuns05;
706 ScriptRun scriptRun0500 =
712 TextAbstraction::LATIN
714 scriptRuns05.PushBack( scriptRun0500 );
716 // White spaces. At the middle of the text.
717 Vector<ScriptRun> scriptRuns06;
718 ScriptRun scriptRun0600 =
724 TextAbstraction::LATIN
726 scriptRuns06.PushBack( scriptRun0600 );
728 // White spaces between different scripts.
729 Vector<ScriptRun> scriptRuns07;
730 ScriptRun scriptRun0700 =
736 TextAbstraction::LATIN
738 ScriptRun scriptRun0701 =
744 TextAbstraction::HANGUL
746 scriptRuns07.PushBack( scriptRun0700 );
747 scriptRuns07.PushBack( scriptRun0701 );
749 // White spaces between different scripts and differetn directions. Starting LTR.
750 Vector<ScriptRun> scriptRuns08;
751 ScriptRun scriptRun0800 =
757 TextAbstraction::LATIN
759 ScriptRun scriptRun0801 =
765 TextAbstraction::ARABIC
767 ScriptRun scriptRun0802 =
773 TextAbstraction::HANGUL
775 scriptRuns08.PushBack( scriptRun0800 );
776 scriptRuns08.PushBack( scriptRun0801 );
777 scriptRuns08.PushBack( scriptRun0802 );
779 // White spaces between different scripts and differetn directions. Starting RTL.
780 Vector<ScriptRun> scriptRuns09;
781 ScriptRun scriptRun0900 =
787 TextAbstraction::ARABIC
789 ScriptRun scriptRun0901 =
795 TextAbstraction::LATIN
797 ScriptRun scriptRun0902 =
803 TextAbstraction::HANGUL
805 ScriptRun scriptRun0903 =
811 TextAbstraction::ARABIC
813 scriptRuns09.PushBack( scriptRun0900 );
814 scriptRuns09.PushBack( scriptRun0901 );
815 scriptRuns09.PushBack( scriptRun0902 );
816 scriptRuns09.PushBack( scriptRun0903 );
818 // Paragraphs with different directions.
819 Vector<ScriptRun> scriptRuns10;
820 ScriptRun scriptRun1000 =
826 TextAbstraction::ARABIC
828 ScriptRun scriptRun1001 =
834 TextAbstraction::HEBREW
836 ScriptRun scriptRun1002 =
842 TextAbstraction::ARABIC
844 ScriptRun scriptRun1003 =
850 TextAbstraction::LATIN
852 ScriptRun scriptRun1004 =
858 TextAbstraction::HANGUL
860 ScriptRun scriptRun1005 =
866 TextAbstraction::ARABIC
868 ScriptRun scriptRun1006 =
874 TextAbstraction::LATIN
876 ScriptRun scriptRun1007 =
882 TextAbstraction::HEBREW
884 ScriptRun scriptRun1008 =
890 TextAbstraction::LATIN
892 ScriptRun scriptRun1009 =
898 TextAbstraction::ARABIC
900 ScriptRun scriptRun1010 =
906 TextAbstraction::HANGUL
908 ScriptRun scriptRun1011 =
914 TextAbstraction::HANGUL
916 scriptRuns10.PushBack( scriptRun1000 );
917 scriptRuns10.PushBack( scriptRun1001 );
918 scriptRuns10.PushBack( scriptRun1002 );
919 scriptRuns10.PushBack( scriptRun1003 );
920 scriptRuns10.PushBack( scriptRun1004 );
921 scriptRuns10.PushBack( scriptRun1005 );
922 scriptRuns10.PushBack( scriptRun1006 );
923 scriptRuns10.PushBack( scriptRun1007 );
924 scriptRuns10.PushBack( scriptRun1008 );
925 scriptRuns10.PushBack( scriptRun1009 );
926 scriptRuns10.PushBack( scriptRun1010 );
927 scriptRuns10.PushBack( scriptRun1011 );
929 // Paragraphs with no scripts mixed with paragraphs with scripts.
930 Vector<ScriptRun> scriptRuns11;
931 ScriptRun scriptRun1100 =
937 TextAbstraction::LATIN
939 ScriptRun scriptRun1101 =
945 TextAbstraction::LATIN
947 ScriptRun scriptRun1102 =
953 TextAbstraction::LATIN
955 ScriptRun scriptRun1103 =
961 TextAbstraction::LATIN
963 ScriptRun scriptRun1104 =
969 TextAbstraction::LATIN
971 ScriptRun scriptRun1105 =
977 TextAbstraction::HEBREW
979 ScriptRun scriptRun1106 =
985 TextAbstraction::LATIN
987 ScriptRun scriptRun1107 =
993 TextAbstraction::LATIN
995 ScriptRun scriptRun1108 =
1001 TextAbstraction::LATIN
1003 scriptRuns11.PushBack( scriptRun1100 );
1004 scriptRuns11.PushBack( scriptRun1101 );
1005 scriptRuns11.PushBack( scriptRun1102 );
1006 scriptRuns11.PushBack( scriptRun1103 );
1007 scriptRuns11.PushBack( scriptRun1104 );
1008 scriptRuns11.PushBack( scriptRun1105 );
1009 scriptRuns11.PushBack( scriptRun1106 );
1010 scriptRuns11.PushBack( scriptRun1107 );
1011 scriptRuns11.PushBack( scriptRun1108 );
1013 // Paragraphs with no scripts.
1014 Vector<ScriptRun> scriptRuns12;
1015 ScriptRun scriptRun1200 =
1021 TextAbstraction::LATIN
1023 ScriptRun scriptRun1201 =
1029 TextAbstraction::LATIN
1031 ScriptRun scriptRun1202 =
1037 TextAbstraction::LATIN
1039 ScriptRun scriptRun1203 =
1045 TextAbstraction::LATIN
1047 scriptRuns12.PushBack( scriptRun1200 );
1048 scriptRuns12.PushBack( scriptRun1201 );
1049 scriptRuns12.PushBack( scriptRun1202 );
1050 scriptRuns12.PushBack( scriptRun1203 );
1052 Vector<ScriptRun> scriptRuns13;
1053 ScriptRun scriptRun1301 =
1059 TextAbstraction::LATIN // An unknown script is transformed to LATIN
1061 scriptRuns13.PushBack( scriptRun1301 );
1063 const ScriptsData data[] =
1073 "Easy latin script",
1080 "Mix of LTR '\\n'and RTL",
1081 "Hello world\nمرحبا بالعالم",
1087 "Update mix of LTR '\\n'and RTL. Update LTR",
1088 "Hello world\nمرحبا بالعالم",
1094 "Update mix of LTR '\\n'and RTL. Update RTL",
1095 "Hello world\nمرحبا بالعالم",
1101 "Mix of RTL '\\n'and LTR",
1102 "مرحبا بالعالم\nHello world",
1108 "Update mix of RTL '\\n'and LTR. Update RTL",
1109 "مرحبا بالعالم\nHello world",
1115 "Update mix of RTL '\\n'and LTR. Update LTR",
1116 "مرحبا بالعالم\nHello world",
1122 "White spaces. At the beginning of the text.",
1129 "White spaces. At the end of the text.",
1136 "White spaces. At the middle of the text.",
1143 "White spaces between different scripts.",
1150 "White spaces between different scripts and differetn directions. Starting LTR.",
1151 " Hello world مرحبا بالعالم 안녕하세요 세계 ",
1157 "White spaces between different scripts and differetn directions. Starting RTL.",
1158 " مرحبا بالعالم Hello world 안녕하세요 세계 مرحبا بالعالم ",
1164 "Paragraphs with different directions.",
1165 " مرحبا بالعالم שלום עולם مرحبا بالعالم \n "
1166 " Hello world 안녕하세요 세계 \n "
1167 " مرحبا بالعالم Hello world שלום עולם \n "
1168 " Hello world مرحبا بالعالم 안녕하세요 세계 \n "
1175 "Update paragraphs with different directions. Update initial paragraphs.",
1176 " مرحبا بالعالم שלום עולם مرحبا بالعالم \n "
1177 " Hello world 안녕하세요 세계 \n "
1178 " مرحبا بالعالم Hello world שלום עולם \n "
1179 " Hello world مرحبا بالعالم 안녕하세요 세계 \n "
1186 "Update paragraphs with different directions. Update middle paragraphs.",
1187 " مرحبا بالعالم שלום עולם مرحبا بالعالم \n "
1188 " Hello world 안녕하세요 세계 \n "
1189 " مرحبا بالعالم Hello world שלום עולם \n "
1190 " Hello world مرحبا بالعالم 안녕하세요 세계 \n "
1197 "Update paragraphs with different directions. Update final paragraphs.",
1198 " مرحبا بالعالم שלום עולם مرحبا بالعالم \n "
1199 " Hello world 안녕하세요 세계 \n "
1200 " مرحبا بالعالم Hello world שלום עולם \n "
1201 " Hello world مرحبا بالعالم 안녕하세요 세계 \n "
1208 "Paragraphs with no scripts mixed with paragraphs with scripts.",
1209 " \n \n Hello world \n \n \n שלום עולם \n \n \n ",
1215 "Paragraphs with no scripts.",
1222 "Update paragraphs with no scripts. Update initial paragraphs.",
1229 "Update paragraphs with no scripts. Update middle paragraphs.",
1236 "Update paragraphs with no scripts. Update final paragraphs.",
1244 "ᚩᚯᚱᚸ", // Runic script not currentlu supported.
1250 const unsigned int numberOfTests = 24u;
1252 for( unsigned int index = 0u; index < numberOfTests; ++index )
1254 if( !ScriptsTest( data[index] ) )
1256 tet_result(TET_FAIL);
1260 tet_result(TET_PASS);
1264 int UtcDaliTextMultiLanguageValidateFonts01(void)
1266 ToolkitTestApplication application;
1267 tet_infoline(" UtcDaliTextMultiLanguageValidateFonts");
1269 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1271 char* pathNamePtr = get_current_dir_name();
1272 const std::string pathName( pathNamePtr );
1273 free( pathNamePtr );
1275 const PointSize26Dot6 pointSize01 = static_cast<PointSize26Dot6>( 21.f * 64.f );
1276 const PointSize26Dot6 pointSize02 = static_cast<PointSize26Dot6>( 35.f * 64.f );
1279 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/tizen/TizenSansArabicRegular.ttf" );
1280 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/tizen/TizenSansHebrewRegular.ttf" );
1281 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/tizen/TizenColorEmoji.ttf", EMOJI_FONT_SIZE );
1282 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/tizen/TizenSansRegular.ttf", pointSize01 );
1283 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/tizen/TizenSansRegular.ttf", pointSize02 );
1284 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/tizen/TizenSansHebrewRegular.ttf", pointSize01 );
1285 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/tizen/TizenSansHebrewRegular.ttf", pointSize02 );
1287 // Font id 1 --> TizenSansArabicRegular.ttf
1288 // Font id 2 --> TizenSansHebrewRegular.ttf
1289 // Font id 3 --> TizenColorEmoji.ttf
1290 // Font id 4 --> TizenSansRegular.ttf, size 8
1291 // Font id 5 --> TizenSansRegular.ttf, size 16
1292 // Font id 6 --> TizenSansHebrewRegular.ttf, size 8
1293 // Font id 7 --> TizenSansHebrewRegular.ttf, size 16
1294 // Font id 8 --> (default)
1296 Vector<FontRun> fontRuns01;
1297 Vector<FontDescriptionRun> fontDescriptions01;
1299 FontRun fontRun0201 =
1307 Vector<FontRun> fontRuns02;
1308 fontRuns02.PushBack( fontRun0201 );
1310 FontDescriptionRun fontDescription0201 =
1316 const_cast<char*>( "TizenSans" ),
1318 TextAbstraction::FontWeight::NORMAL,
1319 TextAbstraction::FontWidth::NORMAL,
1320 TextAbstraction::FontSlant::NORMAL,
1328 Vector<FontDescriptionRun> fontDescriptions02;
1329 fontDescriptions02.PushBack( fontDescription0201 );
1331 FontRun fontRun0301 =
1339 FontRun fontRun0302 =
1347 FontRun fontRun0303 =
1355 Vector<FontRun> fontRuns03;
1356 fontRuns03.PushBack( fontRun0301 );
1357 fontRuns03.PushBack( fontRun0302 );
1358 fontRuns03.PushBack( fontRun0303 );
1360 Vector<FontDescriptionRun> fontDescriptions03;
1362 FontRun fontRun0701 =
1370 FontRun fontRun0702 =
1378 FontRun fontRun0703 =
1386 Vector<FontRun> fontRuns07;
1387 fontRuns07.PushBack( fontRun0701 );
1388 fontRuns07.PushBack( fontRun0702 );
1389 fontRuns07.PushBack( fontRun0703 );
1391 FontDescriptionRun fontDescription0701 =
1397 const_cast<char*>( "TizenSansHebrew" ),
1399 TextAbstraction::FontWeight::NORMAL,
1400 TextAbstraction::FontWidth::NORMAL,
1401 TextAbstraction::FontSlant::NORMAL,
1409 FontDescriptionRun fontDescription0702 =
1415 const_cast<char*>( "TizenSansHebrew" ),
1417 TextAbstraction::FontWeight::NORMAL,
1418 TextAbstraction::FontWidth::NORMAL,
1419 TextAbstraction::FontSlant::NORMAL,
1427 Vector<FontDescriptionRun> fontDescriptions07;
1428 fontDescriptions07.PushBack( fontDescription0701 );
1429 fontDescriptions07.PushBack( fontDescription0702 );
1431 FontRun fontRun0801 =
1439 Vector<FontRun> fontRuns08;
1440 fontRuns08.PushBack( fontRun0801 );
1442 Vector<FontDescriptionRun> fontDescriptions08;
1444 FontRun fontRun0901 =
1452 Vector<FontRun> fontRuns09;
1453 fontRuns09.PushBack( fontRun0901 );
1455 Vector<FontDescriptionRun> fontDescriptions09;
1456 FontDescriptionRun fontDescription0901 =
1462 const_cast<char*>( "TizenColorEmoji" ),
1464 TextAbstraction::FontWeight::NORMAL,
1465 TextAbstraction::FontWidth::NORMAL,
1466 TextAbstraction::FontSlant::NORMAL,
1474 fontDescriptions09.PushBack( fontDescription0901 );
1476 FontRun fontRun1001 =
1484 FontRun fontRun1002 =
1492 FontRun fontRun1003 =
1500 FontRun fontRun1004 =
1508 Vector<FontRun> fontRuns10;
1509 fontRuns10.PushBack( fontRun1001 );
1510 fontRuns10.PushBack( fontRun1002 );
1511 fontRuns10.PushBack( fontRun1003 );
1512 fontRuns10.PushBack( fontRun1004 );
1514 FontDescriptionRun fontDescription1001 =
1520 const_cast<char*>( "TizenSans" ),
1522 TextAbstraction::FontWeight::NORMAL,
1523 TextAbstraction::FontWidth::NORMAL,
1524 TextAbstraction::FontSlant::NORMAL,
1532 FontDescriptionRun fontDescription1002 =
1538 const_cast<char*>( "TizenSansHebrew" ),
1540 TextAbstraction::FontWeight::NORMAL,
1541 TextAbstraction::FontWidth::NORMAL,
1542 TextAbstraction::FontSlant::NORMAL,
1550 FontDescriptionRun fontDescription1003 =
1556 const_cast<char*>( "TizenSans" ),
1558 TextAbstraction::FontWeight::NORMAL,
1559 TextAbstraction::FontWidth::NORMAL,
1560 TextAbstraction::FontSlant::NORMAL,
1568 FontDescriptionRun fontDescription1004 =
1574 const_cast<char*>( "TizenSansHebrew" ),
1576 TextAbstraction::FontWeight::NORMAL,
1577 TextAbstraction::FontWidth::NORMAL,
1578 TextAbstraction::FontSlant::NORMAL,
1586 Vector<FontDescriptionRun> fontDescriptions10;
1587 fontDescriptions10.PushBack( fontDescription1001 );
1588 fontDescriptions10.PushBack( fontDescription1002 );
1589 fontDescriptions10.PushBack( fontDescription1003 );
1590 fontDescriptions10.PushBack( fontDescription1004 );
1592 const ValidateFontsData data[] =
1597 "/tizen/TizenSansRegular.ttf",
1598 TextAbstraction::FontClient::DEFAULT_POINT_SIZE,
1605 "Easy latin script.",
1607 "/tizen/TizenSansRegular.ttf",
1608 TextAbstraction::FontClient::DEFAULT_POINT_SIZE,
1615 "Different paragraphs.",
1616 "Hello world\nhello world\ndemo",
1617 "/tizen/TizenSansRegular.ttf",
1618 TextAbstraction::FontClient::DEFAULT_POINT_SIZE,
1625 "Different paragraphs. Update the initial paragraph.",
1626 "Hello world\nhello world\ndemo",
1627 "/tizen/TizenSansRegular.ttf",
1628 TextAbstraction::FontClient::DEFAULT_POINT_SIZE,
1635 "Different paragraphs. Update the middle paragraph.",
1636 "Hello world\nhello world\ndemo",
1637 "/tizen/TizenSansRegular.ttf",
1638 TextAbstraction::FontClient::DEFAULT_POINT_SIZE,
1645 "Different paragraphs. Update the final paragraph.",
1646 "Hello world\nhello world\ndemo",
1647 "/tizen/TizenSansRegular.ttf",
1648 TextAbstraction::FontClient::DEFAULT_POINT_SIZE,
1655 "Hebrew text. Default font: latin",
1657 "/tizen/TizenSansRegular.ttf",
1658 TextAbstraction::FontClient::DEFAULT_POINT_SIZE,
1665 "Hebrew text. Default font: hebrew",
1667 "/tizen/TizenSansHebrewRegular.ttf",
1668 TextAbstraction::FontClient::DEFAULT_POINT_SIZE,
1676 "\xF0\x9F\x98\x81\xF0\x9F\x98\x82\xF0\x9F\x98\x83\xF0\x9F\x98\x84",
1677 "/tizen/TizenColorEmoji.ttf",
1685 "Mix text. Default font: latin. Different font sizes",
1686 "Hello world, שלום עולם, hello world, שלום עולם",
1687 "/tizen/TizenSansRegular.ttf",
1688 TextAbstraction::FontClient::DEFAULT_POINT_SIZE,
1695 const unsigned int numberOfTests = 10u;
1697 for( unsigned int index = 0u; index < numberOfTests; ++index )
1699 if( !ValidateFontTest( data[index] ) )
1701 tet_result(TET_FAIL);
1705 tet_result(TET_PASS);