2 * Copyright (c) 2021 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-toolkit/internal/text/shaper.h>
23 #include <dali-toolkit-test-suite-utils.h>
24 #include <dali-toolkit/dali-toolkit.h>
25 #include <toolkit-text-utils.h>
28 using namespace Toolkit;
31 // Tests the following function.
32 // void ShapeText( const Vector<Character>& text,
33 // const Vector<LineBreakInfo>& lineBreakInfo,
34 // const Vector<ScriptRun>& scripts,
35 // const Vector<FontRun>& fonts,
36 // CharacterIndex startCharacterIndex,
37 // GlyphIndex startGlyphIndex,
38 // Length numberOfCharacters,
39 // Vector<GlyphInfo>& glyphs,
40 // Vector<CharacterIndex>& glyphToCharacterMap,
41 // Vector<Length>& charactersPerGlyph,
42 // Vector<GlyphIndex>& newParagraphGlyphs );
44 //////////////////////////////////////////////////////////
48 const std::string DEFAULT_FONT_DIR( "/resources/fonts" );
52 FontId fontId; ///< Identifies the font containing the glyph
53 GlyphIndex index; ///< Uniquely identifies a glyph for a given FontId
54 float width; ///< The width of the glyph
55 float height; ///< The height of the glyph
56 float xBearing; ///< The distance from the cursor position to the leftmost border of the glyph
57 float yBearing; ///< The distance from the baseline to the topmost border of the glyph
58 float advance; ///< The distance to move the cursor for this glyph
59 float scaleFactor; ///< The scaling applied (fixed-size fonts only)
60 bool isItalicRequired; ///< Whether the italic style is required.
61 bool isBoldRequired; ///< Whether the bold style is required.
64 bool IsEqualGlyph ( const GlyphInfoData& glyphData, const GlyphInfo& glyph )
66 if( glyphData.fontId != glyph.fontId )
70 if( glyphData.index != glyph.index )
74 if( fabsf( glyphData.width - glyph.width ) > Math::MACHINE_EPSILON_1000 )
78 if( fabsf( glyphData.height - glyph.height ) > Math::MACHINE_EPSILON_1000 )
82 if( fabsf( glyphData.xBearing - glyph.xBearing ) > Math::MACHINE_EPSILON_1000 )
86 if( fabsf( glyphData.yBearing - glyph.yBearing ) > Math::MACHINE_EPSILON_1000 )
90 if( fabsf( glyphData.advance - floor(glyph.advance) ) > Math::MACHINE_EPSILON_1000 )
94 if( fabsf( glyphData.scaleFactor - glyph.scaleFactor ) > Math::MACHINE_EPSILON_1000 )
98 if( glyphData.isItalicRequired != glyph.isItalicRequired )
102 if( glyphData.isBoldRequired != glyph.isBoldRequired )
112 std::string description; ///< Description of the test.
113 std::string text; ///< input text.
114 uint32_t index; ///< The index from where to start to query the break info.
115 uint32_t numberOfCharacters; ///< The requested number of characters.
116 uint32_t expectedNumberOfGlyphs; ///< The expected number of glyphs.
117 GlyphInfoData* glyphs; ///< The glyphs.
118 CharacterIndex* characterIndices; ///< The character index for each glyph.
119 Length* charactersPerGlyph; ///< The characters per glyph.
120 uint32_t expectedNumberOfNewParagraphGlyphs; ///< The expected number of glyphs.
121 GlyphIndex* newParagraphGlyphs; ///< Indices to the new paragraphs glyphs.
122 Vector<FontDescriptionRun> fontDescriptions; ///< Fonts which is used for text.
125 bool ShapeInfoTest( const ShapeInfoData& data )
127 // 1) Create the model.
130 Size textArea(100.f, 60.f);
133 const Vector<FontDescriptionRun> fontDescriptions;
134 const LayoutOptions options;
136 CreateTextModel( data.text,
138 data.fontDescriptions,
146 Toolkit::DevelText::EllipsisPosition::END );
148 LogicalModelPtr logicalModel = textModel->mLogicalModel;
149 VisualModelPtr visualModel = textModel->mVisualModel;
151 // 2) Clear the model.
153 Vector<GlyphInfo>& glyphs = visualModel->mGlyphs;
154 Vector<CharacterIndex>& glyphToCharacter = visualModel->mGlyphsToCharacters;
155 Vector<Length>& charactersPerGlyph = visualModel->mCharactersPerGlyph;
156 Vector<GlyphIndex>& charactersToGlyph = visualModel->mCharactersToGlyph;
157 Vector<Length>& glyphsPerCharacter = visualModel->mGlyphsPerCharacter;
159 // Get the glyph index.
160 GlyphIndex glyphIndex = 0u;
161 if( 0u != visualModel->mCharactersToGlyph.Count() )
163 glyphIndex = *( visualModel->mCharactersToGlyph.Begin() + data.index );
165 const CharacterIndex lastCharacterIndex = data.index + data.numberOfCharacters - 1u;
166 const Length numberOfGlyphs = *( visualModel->mCharactersToGlyph.Begin() + lastCharacterIndex ) + *( visualModel->mGlyphsPerCharacter.Begin() + lastCharacterIndex ) - glyphIndex;
168 // Erase the glyph info from the text model.
169 // Got from the ShapeText() function.
170 glyphs.Erase( glyphs.Begin() + glyphIndex, glyphs.Begin() + glyphIndex + numberOfGlyphs );
171 glyphToCharacter.Erase( glyphToCharacter.Begin() + glyphIndex, glyphToCharacter.Begin() + glyphIndex + numberOfGlyphs );
172 charactersPerGlyph.Erase( charactersPerGlyph.Begin() + glyphIndex, charactersPerGlyph.Begin() + glyphIndex + numberOfGlyphs );
174 // Got from the VisualModel::CreateCharacterToGlyphTable() and the VisualModel::CreateGlyphsPerCharacterTable() methods.
175 charactersToGlyph.Erase( charactersToGlyph.Begin() + data.index,
176 charactersToGlyph.Begin() + data.index + data.numberOfCharacters );
177 glyphsPerCharacter.Erase( glyphsPerCharacter.Begin() + data.index,
178 glyphsPerCharacter.Begin() + data.index + data.numberOfCharacters );
180 // Update the glyph to character indices.
181 for( Vector<CharacterIndex>::Iterator it = glyphToCharacter.Begin() + glyphIndex,
182 endIt = glyphToCharacter.End();
186 CharacterIndex& index = *it;
187 index -= data.numberOfCharacters;
192 // Reset the metrics got from the model as the ShapeText() function doesn't retrieve them.
193 for( Vector<GlyphInfo>::Iterator it = glyphs.Begin(),
194 endIt = glyphs.End();
198 GlyphInfo& info = *it;
203 info.scaleFactor = 0.f;
206 // 3) Call the ShapeText() function.
208 Vector<GlyphIndex> newParagraphGlyphs;
210 ShapeText( logicalModel->mText,
211 logicalModel->mLineBreakInfo,
212 logicalModel->mScriptRuns,
213 logicalModel->mFontRuns,
216 data.numberOfCharacters,
220 newParagraphGlyphs );
222 // Clear the advance of the new paragraph glyphs.
223 for( Vector<GlyphIndex>::Iterator it = newParagraphGlyphs.Begin(),
224 endIt = newParagraphGlyphs.End();
228 GlyphInfo& info = *( glyphs.Begin() + *it );
232 // 4) Compare the results.
234 if( data.expectedNumberOfGlyphs != glyphs.Count() )
236 std::cout << " Different number of glyphs : " << glyphs.Count() << ", expected : " << data.expectedNumberOfGlyphs << std::endl;
240 for( unsigned int index = 0u; index < data.expectedNumberOfGlyphs; ++index )
242 if( !IsEqualGlyph( data.glyphs[index], glyphs[index] ) )
244 std::cout << " different glyph info, index : " << index << std::endl;
246 const GlyphInfo& glyphInfo = glyphs[index];
247 std::cout << " fontId : " << glyphInfo.fontId << std::endl;
248 std::cout << " index : " << glyphInfo.index << std::endl;
249 std::cout << " width : " << glyphInfo.width << std::endl;
250 std::cout << " height : " << glyphInfo.height << std::endl;
251 std::cout << " xBearing : " << glyphInfo.xBearing << std::endl;
252 std::cout << " yBearing : " << glyphInfo.yBearing << std::endl;
253 std::cout << " advance : " << floor(glyphInfo.advance) << std::endl;
254 std::cout << " scaleFactor : " << glyphInfo.scaleFactor << std::endl;
255 std::cout << " isItalicRequired : " << glyphInfo.isItalicRequired << std::endl;
256 std::cout << " isBoldRequired : " << glyphInfo.isBoldRequired << std::endl;
258 std::cout << " Expected : " << std::endl;
259 const GlyphInfoData& expectedGlyphInfo = data.glyphs[index];
260 std::cout << " fontId : " << expectedGlyphInfo.fontId << std::endl;
261 std::cout << " index : " << expectedGlyphInfo.index << std::endl;
262 std::cout << " width : " << expectedGlyphInfo.width << std::endl;
263 std::cout << " height : " << expectedGlyphInfo.height << std::endl;
264 std::cout << " xBearing : " << expectedGlyphInfo.xBearing << std::endl;
265 std::cout << " yBearing : " << expectedGlyphInfo.yBearing << std::endl;
266 std::cout << " advance : " << expectedGlyphInfo.advance << std::endl;
267 std::cout << " scaleFactor : " << expectedGlyphInfo.scaleFactor << std::endl;
268 std::cout << " isItalicRequired : " << expectedGlyphInfo.isItalicRequired << std::endl;
269 std::cout << " isBoldRequired : " << expectedGlyphInfo.isBoldRequired << std::endl;
276 for( unsigned int index = 0u; index < data.expectedNumberOfGlyphs; ++index )
278 if( data.characterIndices[index] != glyphToCharacter[index] )
280 std::cout << " different character index, index : " << index << std::endl;
285 for( unsigned int index = 0u; index < data.expectedNumberOfGlyphs; ++index )
287 if( data.charactersPerGlyph[index] != charactersPerGlyph[index] )
289 std::cout << " different character per glyph, index : " << index << std::endl;
294 if( data.expectedNumberOfNewParagraphGlyphs != newParagraphGlyphs.Count() )
296 std::cout << " Different number of new paragraph glyphs : " << newParagraphGlyphs.Count() << ", expected : " << data.expectedNumberOfNewParagraphGlyphs << std::endl;
300 for( unsigned int index = 0u; index < data.expectedNumberOfNewParagraphGlyphs; ++index )
302 if( data.newParagraphGlyphs[index] != newParagraphGlyphs[index] )
304 std::cout << " different new paragraph glyph, index : " << index << std::endl;
312 void LoadTextShapeFonts()
314 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
315 fontClient.SetDpi( 96u, 96u );
317 char* pathNamePtr = get_current_dir_name();
318 const std::string pathName( pathNamePtr );
321 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/tizen/TizenSansRegular.ttf" );
322 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/noto/NotoSansMalayalam-Regular.ttf" );
325 void LoadSoftwareStylingFonts()
327 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
328 fontClient.SetDpi( 96u, 96u );
330 char* pathNamePtr = get_current_dir_name();
331 const std::string pathName( pathNamePtr );
334 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/roboto/Roboto-Regular.ttf" );
335 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/roboto/Roboto-Bold.ttf" );
336 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/roboto/Roboto-Italic.ttf" );
337 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/roboto/Roboto-BoldItalic.ttf" );
342 //////////////////////////////////////////////////////////
344 int UtcDaliTextShape(void)
346 tet_infoline(" UtcDaliTextShape");
348 struct GlyphInfoData glyphs02[] =
350 { 1u, 276u, 0.f, 0.f, 0.f, 0.f, 11.f, 0.f },
351 { 1u, 299u, 0.f, 0.f, 0.f, 0.f, 8.f, 0.f },
352 { 1u, 306u, 0.f, 0.f, 0.f, 0.f, 4.f, 0.f },
353 { 1u, 306u, 0.f, 0.f, 0.f, 0.f, 4.f, 0.f },
354 { 1u, 309u, 0.f, 0.f, 0.f, 0.f, 9.f, 0.f },
355 { 1u, 3u, 0.f, 0.f, 0.f, 0.f, 4.f, 0.f },
356 { 1u, 317u, 0.f, 0.f, 0.f, 0.f, 11.f, 0.f },
357 { 1u, 309u, 0.f, 0.f, 0.f, 0.f, 9.f, 0.f },
358 { 1u, 312u, 0.f, 0.f, 0.f, 0.f, 6.f, 0.f },
359 { 1u, 306u, 0.f, 0.f, 0.f, 0.f, 4.f, 0.f },
360 { 1u, 298u, 0.f, 0.f, 0.f, 0.f, 9.f, 0.f },
363 CharacterIndex characterIndices02[] = { 0u, 1u, 2u, 3u, 4u, 5u, 6u, 7u, 8u, 9u, 10u };
364 Length charactersPerGlyph02[] = { 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u };
366 struct GlyphInfoData glyphs03[] =
368 { 1u, 276u, 0.f, 0.f, 0.f, 0.f, 11.f, 0.f },
369 { 1u, 299u, 0.f, 0.f, 0.f, 0.f, 8.f, 0.f },
370 { 1u, 306u, 0.f, 0.f, 0.f, 0.f, 4.f, 0.f },
371 { 1u, 306u, 0.f, 0.f, 0.f, 0.f, 4.f, 0.f },
372 { 1u, 309u, 0.f, 0.f, 0.f, 0.f, 9.f, 0.f },
373 { 1u, 3u, 0.f, 0.f, 0.f, 0.f, 4.f, 0.f },
374 { 1u, 317u, 0.f, 0.f, 0.f, 0.f, 11.f, 0.f },
375 { 1u, 309u, 0.f, 0.f, 0.f, 0.f, 9.f, 0.f },
376 { 1u, 312u, 0.f, 0.f, 0.f, 0.f, 6.f, 0.f },
377 { 1u, 306u, 0.f, 0.f, 0.f, 0.f, 4.f, 0.f },
378 { 1u, 298u, 0.f, 0.f, 0.f, 0.f, 9.f, 0.f },
379 { 1u, 0u, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f },
380 { 1u, 298u, 0.f, 0.f, 0.f, 0.f, 9.f, 0.f },
381 { 1u, 299u, 0.f, 0.f, 0.f, 0.f, 8.f, 0.f },
382 { 1u, 307u, 0.f, 0.f, 0.f, 0.f, 13.f, 0.f },
383 { 1u, 309u, 0.f, 0.f, 0.f, 0.f, 9.f, 0.f },
384 { 1u, 0u, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f },
387 CharacterIndex characterIndices03[] = { 0u, 1u, 2u, 3u, 4u, 5u, 6u, 7u, 8u, 9u, 10u, 11u, 12u, 13u, 14u, 15u, 16u };
388 Length charactersPerGlyph03[] = { 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u };
389 CharacterIndex newParagraphGlyphs03[] = { 11u, 16u };
391 struct GlyphInfoData glyphs04[] =
393 { 2u, 67u, 0.f, 0.f, 0.f, 0.f, 9.f, 0.f },
394 { 2u, 27u, 0.f, 0.f, 0.f, 0.f, 15.f, 0.f },
395 { 2u, 59u, 0.f, 0.f, 0.f, 0.f, 8.f, 0.f },
396 { 2u, 67u, 0.f, 0.f, 0.f, 0.f, 9.f, 0.f },
397 { 2u, 55u, 0.f, 0.f, 0.f, 0.f, 19.f, 0.f },
398 { 2u, 59u, 0.f, 0.f, 0.f, 0.f, 8.f, 0.f },
399 { 2u, 67u, 0.f, 0.f, 0.f, 0.f, 9.f, 0.f },
400 { 2u, 56u, 0.f, 0.f, 0.f, 0.f, 19.f, 0.f },
401 { 2u, 59u, 0.f, 0.f, 0.f, 0.f, 8.f, 0.f },
402 { 2u, 67u, 0.f, 0.f, 0.f, 0.f, 9.f, 0.f },
403 { 2u, 52u, 0.f, 0.f, 0.f, 0.f, 15.f, 0.f },
404 { 2u, 59u, 0.f, 0.f, 0.f, 0.f, 8.f, 0.f },
407 CharacterIndex characterIndices04[] = { 0u, 0u, 0u, 2u, 2u, 2u, 4u, 4u, 4u, 6u, 6u, 6u };
408 Length charactersPerGlyph04[] = { 0u, 0u, 2u, 0u, 0u, 2u, 0u, 0u, 2u, 0u, 0u, 2u };
410 struct GlyphInfoData glyphs05[] =
412 { 1u, 280u, 0.f, 0.f, 0.f, 0.f, 8.f, 0.f },
413 { 1u, 309u, 0.f, 0.f, 0.f, 0.f, 9.f, 0.f },
414 { 1u, 312u, 0.f, 0.f, 0.f, 0.f, 5.f, 0.f },
415 { 1u, 299u, 0.f, 0.f, 0.f, 0.f, 8.f, 0.f },
416 { 1u, 307u, 0.f, 0.f, 0.f, 0.f, 13.f, 0.f },
417 { 1u, 3u, 0.f, 0.f, 0.f, 0.f, 4.f, 0.f },
418 { 1u, 303u, 0.f, 0.f, 0.f, 0.f, 4.f, 0.f },
419 { 1u, 310u, 0.f, 0.f, 0.f, 0.f, 9.f, 0.f },
420 { 1u, 313u, 0.f, 0.f, 0.f, 0.f, 7.f, 0.f },
421 { 1u, 315u, 0.f, 0.f, 0.f, 0.f, 8.f, 0.f },
422 { 1u, 307u, 0.f, 0.f, 0.f, 0.f, 13.f, 0.f },
423 { 1u, 3u, 0.f, 0.f, 0.f, 0.f, 4.f, 0.f },
424 { 1u, 298u, 0.f, 0.f, 0.f, 0.f, 9.f, 0.f },
425 { 1u, 309u, 0.f, 0.f, 0.f, 0.f, 9.f, 0.f },
426 { 1u, 306u, 0.f, 0.f, 0.f, 0.f, 4.f, 0.f },
427 { 1u, 309u, 0.f, 0.f, 0.f, 0.f, 9.f, 0.f },
428 { 1u, 312u, 0.f, 0.f, 0.f, 0.f, 6.f, 0.f },
429 { 1u, 3u, 0.f, 0.f, 0.f, 0.f, 4.f, 0.f },
430 { 1u, 313u, 0.f, 0.f, 0.f, 0.f, 7.f, 0.f },
431 { 1u, 303u, 0.f, 0.f, 0.f, 0.f, 4.f, 0.f },
432 { 1u, 314u, 0.f, 0.f, 0.f, 0.f, 6.f, 0.f },
433 { 1u, 3u, 0.f, 0.f, 0.f, 0.f, 4.f, 0.f },
434 { 1u, 295u, 0.f, 0.f, 0.f, 0.f, 8.f, 0.f },
435 { 1u, 307u, 0.f, 0.f, 0.f, 0.f, 13.f, 0.f },
436 { 1u, 299u, 0.f, 0.f, 0.f, 0.f, 8.f, 0.f },
437 { 1u, 314u, 0.f, 0.f, 0.f, 0.f, 6.f, 0.f },
438 { 1u, 0u, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f },
439 { 1u, 295u, 0.f, 0.f, 0.f, 0.f, 8.f, 0.f },
440 { 1u, 299u, 0.f, 0.f, 0.f, 0.f, 8.f, 0.f },
441 { 1u, 311u, 0.f, 0.f, 0.f, 0.f, 9.f, 0.f },
442 { 1u, 315u, 0.f, 0.f, 0.f, 0.f, 8.f, 0.f },
443 { 1u, 299u, 0.f, 0.f, 0.f, 0.f, 8.f, 0.f },
444 { 1u, 3u, 0.f, 0.f, 0.f, 0.f, 4.f, 0.f },
445 { 1u, 298u, 0.f, 0.f, 0.f, 0.f, 9.f, 0.f },
446 { 1u, 299u, 0.f, 0.f, 0.f, 0.f, 8.f, 0.f },
447 { 1u, 403u, 0.f, 0.f, 0.f, 0.f, 9.f, 0.f },
448 { 1u, 308u, 0.f, 0.f, 0.f, 0.f, 9.f, 0.f },
449 { 1u, 303u, 0.f, 0.f, 0.f, 0.f, 4.f, 0.f },
450 { 1u, 299u, 0.f, 0.f, 0.f, 0.f, 8.f, 0.f },
451 { 1u, 296u, 0.f, 0.f, 0.f, 0.f, 9.f, 0.f },
452 { 1u, 295u, 0.f, 0.f, 0.f, 0.f, 8.f, 0.f },
453 { 1u, 313u, 0.f, 0.f, 0.f, 0.f, 7.f, 0.f },
454 { 1u, 3u, 0.f, 0.f, 0.f, 0.f, 4.f, 0.f },
455 { 1u, 299u, 0.f, 0.f, 0.f, 0.f, 8.f, 0.f },
456 { 1u, 295u, 0.f, 0.f, 0.f, 0.f, 8.f, 0.f },
457 { 1u, 3u, 0.f, 0.f, 0.f, 0.f, 4.f, 0.f },
458 { 1u, 307u, 0.f, 0.f, 0.f, 0.f, 13.f, 0.f },
459 { 1u, 299u, 0.f, 0.f, 0.f, 0.f, 8.f, 0.f },
460 { 1u, 303u, 0.f, 0.f, 0.f, 0.f, 4.f, 0.f },
461 { 1u, 0u, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f },
462 { 1u, 310u, 0.f, 0.f, 0.f, 0.f, 9.f, 0.f },
463 { 1u, 309u, 0.f, 0.f, 0.f, 0.f, 9.f, 0.f },
464 { 1u, 313u, 0.f, 0.f, 0.f, 0.f, 7.f, 0.f },
465 { 1u, 313u, 0.f, 0.f, 0.f, 0.f, 7.f, 0.f },
466 { 1u, 299u, 0.f, 0.f, 0.f, 0.f, 8.f, 0.f },
467 { 1u, 3u, 0.f, 0.f, 0.f, 0.f, 4.f, 0.f },
468 { 1u, 303u, 0.f, 0.f, 0.f, 0.f, 4.f, 0.f },
469 { 1u, 312u, 0.f, 0.f, 0.f, 0.f, 5.f, 0.f },
470 { 1u, 295u, 0.f, 0.f, 0.f, 0.f, 8.f, 0.f },
471 { 1u, 297u, 0.f, 0.f, 0.f, 0.f, 7.f, 0.f },
472 { 1u, 315u, 0.f, 0.f, 0.f, 0.f, 8.f, 0.f },
473 { 1u, 308u, 0.f, 0.f, 0.f, 0.f, 9.f, 0.f },
474 { 1u, 298u, 0.f, 0.f, 0.f, 0.f, 9.f, 0.f },
475 { 1u, 303u, 0.f, 0.f, 0.f, 0.f, 4.f, 0.f },
476 { 1u, 295u, 0.f, 0.f, 0.f, 0.f, 8.f, 0.f },
477 { 1u, 3u, 0.f, 0.f, 0.f, 0.f, 4.f, 0.f },
478 { 1u, 308u, 0.f, 0.f, 0.f, 0.f, 9.f, 0.f },
479 { 1u, 299u, 0.f, 0.f, 0.f, 0.f, 8.f, 0.f },
480 { 1u, 3u, 0.f, 0.f, 0.f, 0.f, 4.f, 0.f },
481 { 1u, 297u, 0.f, 0.f, 0.f, 0.f, 7.f, 0.f },
482 { 1u, 315u, 0.f, 0.f, 0.f, 0.f, 8.f, 0.f },
483 { 1u, 307u, 0.f, 0.f, 0.f, 0.f, 13.f, 0.f },
484 { 1u, 4u, 0.f, 0.f, 0.f, 0.f, 3.f, 0.f },
485 { 1u, 0u, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f },
488 CharacterIndex characterIndices05[] = { 0u, 1u, 2u, 3u, 4u, 5u, 6u, 7u, 8u, 9u,
489 10u, 11u, 12u, 13u, 14u, 15u, 16u, 17u, 18u, 19u,
490 20u, 21u, 22u, 23u, 24u, 25u, 26u, 27u, 28u, 29u,
491 30u, 31u, 32u, 33u, 34u, 35u, 37u, 38u, 39u, 40u,
492 41u, 42u, 43u, 44u, 45u, 46u, 47u, 48u, 49u, 50u,
493 51u, 52u, 53u, 54u, 55u, 56u, 57u, 58u, 59u, 60u,
494 61u, 62u, 63u, 64u, 65u, 66u, 67u, 68u, 69u, 70u,
495 71u, 72u, 73u, 74u };
496 Length charactersPerGlyph05[] = { 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u,
497 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u,
498 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u,
499 1u, 1u, 1u, 1u, 1u, 2u, 1u, 1u, 1u, 1u,
500 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u,
501 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u,
502 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u,
504 CharacterIndex newParagraphGlyphs05[] = { 26u };
505 CharacterIndex newParagraphGlyphs06[] = { 49u };
506 CharacterIndex newParagraphGlyphs07[] = { 73u };
508 Vector<FontDescriptionRun> fontDescriptions01;
509 Vector<FontDescriptionRun> fontDescriptions02;
510 Vector<FontDescriptionRun> fontDescriptions03;
511 Vector<FontDescriptionRun> fontDescriptions04;
512 Vector<FontDescriptionRun> fontDescriptions05;
513 Vector<FontDescriptionRun> fontDescriptions06;
515 const std::string fontFamily( "TizenSans" );
516 const std::string fontFamilyMalayalam( "Noto Sans Malayalam" );
518 FontDescriptionRun fontDescriptionRun01 =
526 TextAbstraction::FontWeight::NONE,
527 TextAbstraction::FontWidth::NONE,
528 TextAbstraction::FontSlant::NONE,
529 TextAbstraction::FontClient::DEFAULT_POINT_SIZE,
536 fontDescriptionRun01.familyLength = fontFamily.size();
537 fontDescriptionRun01.familyName = new char[fontDescriptionRun01.familyLength];
538 memcpy( fontDescriptionRun01.familyName, fontFamily.c_str(), fontDescriptionRun01.familyLength );
540 fontDescriptions01.PushBack( fontDescriptionRun01 );
542 FontDescriptionRun fontDescriptionRun02 =
550 TextAbstraction::FontWeight::NONE,
551 TextAbstraction::FontWidth::NONE,
552 TextAbstraction::FontSlant::NONE,
553 TextAbstraction::FontClient::DEFAULT_POINT_SIZE,
560 fontDescriptionRun02.familyLength = fontFamily.size();
561 fontDescriptionRun02.familyName = new char[fontDescriptionRun02.familyLength];
562 memcpy( fontDescriptionRun02.familyName, fontFamily.c_str(), fontDescriptionRun02.familyLength );
564 fontDescriptions02.PushBack( fontDescriptionRun02 );
566 FontDescriptionRun fontDescriptionRun03 =
574 TextAbstraction::FontWeight::NONE,
575 TextAbstraction::FontWidth::NONE,
576 TextAbstraction::FontSlant::NONE,
577 TextAbstraction::FontClient::DEFAULT_POINT_SIZE,
584 fontDescriptionRun03.familyLength = fontFamilyMalayalam.size();
585 fontDescriptionRun03.familyName = new char[fontDescriptionRun03.familyLength];
586 memcpy( fontDescriptionRun03.familyName, fontFamilyMalayalam.c_str(), fontDescriptionRun03.familyLength );
588 fontDescriptions03.PushBack( fontDescriptionRun03 );
590 FontDescriptionRun fontDescriptionRun04 =
598 TextAbstraction::FontWeight::NONE,
599 TextAbstraction::FontWidth::NONE,
600 TextAbstraction::FontSlant::NONE,
601 TextAbstraction::FontClient::DEFAULT_POINT_SIZE,
608 fontDescriptionRun04.familyLength = fontFamily.size();
609 fontDescriptionRun04.familyName = new char[fontDescriptionRun04.familyLength];
610 memcpy( fontDescriptionRun04.familyName, fontFamily.c_str(), fontDescriptionRun04.familyLength );
612 fontDescriptions04.PushBack( fontDescriptionRun04 );
614 FontDescriptionRun fontDescriptionRun05 =
622 TextAbstraction::FontWeight::NONE,
623 TextAbstraction::FontWidth::NONE,
624 TextAbstraction::FontSlant::NONE,
625 TextAbstraction::FontClient::DEFAULT_POINT_SIZE,
632 fontDescriptionRun05.familyLength = fontFamily.size();
633 fontDescriptionRun05.familyName = new char[fontDescriptionRun05.familyLength];
634 memcpy( fontDescriptionRun05.familyName, fontFamily.c_str(), fontDescriptionRun05.familyLength );
636 fontDescriptions05.PushBack( fontDescriptionRun05 );
638 FontDescriptionRun fontDescriptionRun06 =
646 TextAbstraction::FontWeight::NONE,
647 TextAbstraction::FontWidth::NONE,
648 TextAbstraction::FontSlant::NONE,
649 TextAbstraction::FontClient::DEFAULT_POINT_SIZE,
656 fontDescriptionRun06.familyLength = fontFamily.size();
657 fontDescriptionRun06.familyName = new char[fontDescriptionRun06.familyLength];
658 memcpy( fontDescriptionRun06.familyName, fontFamily.c_str(), fontDescriptionRun06.familyLength );
660 fontDescriptions06.PushBack( fontDescriptionRun06 );
662 struct ShapeInfoData data[] =
684 charactersPerGlyph02,
690 "Latin script. Some paragraphs.",
691 "Hello world\ndemo\n",
697 charactersPerGlyph03,
699 newParagraphGlyphs03,
703 "Malayalam script. More glyphs than characters.",
704 "ജോസോഹോവോ",
710 charactersPerGlyph04,
716 "Latin script with some paragraphs. Update initial paragraph.",
717 "Lorem ipsum dolor sit amet\naeque definiebas ea mei\nposse iracundia ne cum.\n",
723 charactersPerGlyph05,
725 newParagraphGlyphs05,
729 "Latin script with some paragraphs. Update mid paragraph.",
730 "Lorem ipsum dolor sit amet\naeque definiebas ea mei\nposse iracundia ne cum.\n",
736 charactersPerGlyph05,
738 newParagraphGlyphs06,
742 "Latin script with some paragraphs. Update final paragraph.",
743 "Lorem ipsum dolor sit amet\naeque definiebas ea mei\nposse iracundia ne cum.\n",
749 charactersPerGlyph05,
751 newParagraphGlyphs07,
755 const unsigned int numberOfTests = 7u;
757 for( unsigned int index = 0u; index < numberOfTests; ++index )
759 ToolkitTestApplication application;
760 LoadTextShapeFonts();
762 if( !ShapeInfoTest( data[index] ) )
764 tet_result(TET_FAIL);
768 tet_result(TET_PASS);
772 int UtcDaliTextSoftwareStyling(void)
774 tet_infoline(" UtcDaliTextSoftwareStyling");
776 struct GlyphInfoData glyphs01[] =
778 { 4u, 38u, 0.f, 0.f, 0.f, 0.f, 10.f, 0.f, true, true },
779 { 4u, 39u, 0.f, 0.f, 0.f, 0.f, 9.f, 0.f, true, true },
780 { 4u, 40u, 0.f, 0.f, 0.f, 0.f, 10.f, 0.f, true, true },
781 { 4u, 41u, 0.f, 0.f, 0.f, 0.f, 10.f, 0.f, true, true },
783 struct GlyphInfoData glyphs02[] =
785 { 1u, 38u, 0.f, 0.f, 0.f, 0.f, 10.f, 0.f, false, false },
786 { 2u, 39u, 0.f, 0.f, 0.f, 0.f, 10.f, 0.f, false, true },
787 { 3u, 40u, 0.f, 0.f, 0.f, 0.f, 10.f, 0.f, true, false },
788 { 4u, 41u, 0.f, 0.f, 0.f, 0.f, 10.f, 0.f, true, true },
791 CharacterIndex characterIndices[] = { 0u, 1u, 2u, 3u };
792 Length charactersPerGlyph[] = { 1u, 1u, 1u, 1u };
794 Vector<FontDescriptionRun> fontDescriptions01;
795 Vector<FontDescriptionRun> fontDescriptions02;
797 const std::string fontFamily( "Roboto" );
799 FontDescriptionRun fontDescriptionRun01 =
807 TextAbstraction::FontWeight::BOLD,
808 TextAbstraction::FontWidth::NONE,
809 TextAbstraction::FontSlant::ITALIC,
810 TextAbstraction::FontClient::DEFAULT_POINT_SIZE,
817 fontDescriptionRun01.familyLength = fontFamily.size();
818 fontDescriptionRun01.familyName = new char[fontDescriptionRun01.familyLength];
819 memcpy( fontDescriptionRun01.familyName, fontFamily.c_str(), fontDescriptionRun01.familyLength );
821 fontDescriptions01.PushBack(fontDescriptionRun01);
823 FontDescriptionRun fontDescriptionRun02 =
831 TextAbstraction::FontWeight::NONE,
832 TextAbstraction::FontWidth::NONE,
833 TextAbstraction::FontSlant::NONE,
834 TextAbstraction::FontClient::DEFAULT_POINT_SIZE,
841 fontDescriptionRun02.familyLength = fontFamily.size();
842 fontDescriptionRun02.familyName = new char[fontDescriptionRun02.familyLength];
843 memcpy( fontDescriptionRun02.familyName, fontFamily.c_str(), fontDescriptionRun02.familyLength );
845 FontDescriptionRun fontDescriptionRun03 =
853 TextAbstraction::FontWeight::BOLD,
854 TextAbstraction::FontWidth::NONE,
855 TextAbstraction::FontSlant::NONE,
856 TextAbstraction::FontClient::DEFAULT_POINT_SIZE,
863 fontDescriptionRun03.familyLength = fontFamily.size();
864 fontDescriptionRun03.familyName = new char[fontDescriptionRun03.familyLength];
865 memcpy( fontDescriptionRun03.familyName, fontFamily.c_str(), fontDescriptionRun03.familyLength );
867 FontDescriptionRun fontDescriptionRun04 =
875 TextAbstraction::FontWeight::NONE,
876 TextAbstraction::FontWidth::NONE,
877 TextAbstraction::FontSlant::ITALIC,
878 TextAbstraction::FontClient::DEFAULT_POINT_SIZE,
885 fontDescriptionRun04.familyLength = fontFamily.size();
886 fontDescriptionRun04.familyName = new char[fontDescriptionRun04.familyLength];
887 memcpy( fontDescriptionRun04.familyName, fontFamily.c_str(), fontDescriptionRun04.familyLength );
889 FontDescriptionRun fontDescriptionRun05 =
897 TextAbstraction::FontWeight::BOLD,
898 TextAbstraction::FontWidth::NONE,
899 TextAbstraction::FontSlant::ITALIC,
900 TextAbstraction::FontClient::DEFAULT_POINT_SIZE,
907 fontDescriptionRun05.familyLength = fontFamily.size();
908 fontDescriptionRun05.familyName = new char[fontDescriptionRun05.familyLength];
909 memcpy( fontDescriptionRun05.familyName, fontFamily.c_str(), fontDescriptionRun05.familyLength );
911 fontDescriptions02.PushBack(fontDescriptionRun02);
912 fontDescriptions02.PushBack(fontDescriptionRun03);
913 fontDescriptions02.PushBack(fontDescriptionRun04);
914 fontDescriptions02.PushBack(fontDescriptionRun05);
917 struct ShapeInfoData data[] =
920 "Latin script. Characters have same font description",
933 "Latin script. Each character has different font description.",
947 const unsigned int numberOfTests = 2u;
949 for( unsigned int index = 0u; index < numberOfTests; ++index )
951 ToolkitTestApplication application;
952 LoadSoftwareStylingFonts();
954 if( !ShapeInfoTest( data[index] ) )
956 tet_result(TET_FAIL);
960 tet_result(TET_PASS);