X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=blobdiff_plain;f=automated-tests%2Fsrc%2Fdali-toolkit-internal%2Futc-Dali-Text-Shaping.cpp;h=272db3182f0ac90a916637f5a81cdd59ac289cc6;hp=9dd7d57650264aeccbbcda264ae74c102d60c6fa;hb=fbd8d4da2506b57b46a71c5d113f4cb86f23c731;hpb=4cc02f3e2045755c2c65e64a6f5e126a4c6208ea diff --git a/automated-tests/src/dali-toolkit-internal/utc-Dali-Text-Shaping.cpp b/automated-tests/src/dali-toolkit-internal/utc-Dali-Text-Shaping.cpp index 9dd7d57..272db31 100755 --- a/automated-tests/src/dali-toolkit-internal/utc-Dali-Text-Shaping.cpp +++ b/automated-tests/src/dali-toolkit-internal/utc-Dali-Text-Shaping.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019 Samsung Electronics Co., Ltd. + * Copyright (c) 2021 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -87,7 +87,7 @@ bool IsEqualGlyph ( const GlyphInfoData& glyphData, const GlyphInfo& glyph ) { return false; } - if( fabsf( glyphData.advance - glyph.advance ) > Math::MACHINE_EPSILON_1000 ) + if( fabsf( glyphData.advance - floor(glyph.advance) ) > Math::MACHINE_EPSILON_1000 ) { return false; } @@ -119,6 +119,7 @@ struct ShapeInfoData Length* charactersPerGlyph; ///< The characters per glyph. uint32_t expectedNumberOfNewParagraphGlyphs; ///< The expected number of glyphs. GlyphIndex* newParagraphGlyphs; ///< Indices to the new paragraphs glyphs. + bool markupProcessorEnabled; //< Enable markup processor to use markup text. Vector fontDescriptions; ///< Fonts which is used for text. }; @@ -140,7 +141,10 @@ bool ShapeInfoTest( const ShapeInfoData& data ) layoutSize, textModel, metrics, - false ); + data.markupProcessorEnabled, + LineWrap::WORD, + false, + Toolkit::DevelText::EllipsisPosition::END ); LogicalModelPtr logicalModel = textModel->mLogicalModel; VisualModelPtr visualModel = textModel->mVisualModel; @@ -247,7 +251,7 @@ bool ShapeInfoTest( const ShapeInfoData& data ) std::cout << " height : " << glyphInfo.height << std::endl; std::cout << " xBearing : " << glyphInfo.xBearing << std::endl; std::cout << " yBearing : " << glyphInfo.yBearing << std::endl; - std::cout << " advance : " << glyphInfo.advance << std::endl; + std::cout << " advance : " << floor(glyphInfo.advance) << std::endl; std::cout << " scaleFactor : " << glyphInfo.scaleFactor << std::endl; std::cout << " isItalicRequired : " << glyphInfo.isItalicRequired << std::endl; std::cout << " isBoldRequired : " << glyphInfo.isBoldRequired << std::endl; @@ -334,6 +338,34 @@ void LoadSoftwareStylingFonts() fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/roboto/Roboto-BoldItalic.ttf" ); } +void LoadEmojiFonts() +{ + TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get(); + fontClient.ClearCache(); + fontClient.SetDpi( 96u, 96u ); + + char* pathNamePtr = get_current_dir_name(); + const std::string pathName( pathNamePtr ); + free( pathNamePtr ); + + + TextAbstraction::FontDescription fontDescriptionText; + fontDescriptionText.path = ""; + fontDescriptionText.family = "DejaVuSans"; + fontDescriptionText.width = TextAbstraction::FontWidth::NONE; + fontDescriptionText.weight = TextAbstraction::FontWeight::NORMAL; + fontDescriptionText.slant = TextAbstraction::FontSlant::NONE; + fontClient.GetFontId(fontDescriptionText, TextAbstraction::FontClient::DEFAULT_POINT_SIZE); + + TextAbstraction::FontDescription fontDescriptionEmoji; + fontDescriptionEmoji.path = ""; + fontDescriptionEmoji.family = "NotoColorEmoji"; + fontDescriptionEmoji.width = TextAbstraction::FontWidth::NONE; + fontDescriptionEmoji.weight = TextAbstraction::FontWeight::NORMAL; + fontDescriptionEmoji.slant = TextAbstraction::FontSlant::NONE; + fontClient.GetFontId(fontDescriptionEmoji, TextAbstraction::FontClient::DEFAULT_POINT_SIZE); +} + } // namespace ////////////////////////////////////////////////////////// @@ -668,7 +700,8 @@ int UtcDaliTextShape(void) nullptr, nullptr, 0u, - nullptr + nullptr, + false, }, { "Latin script", @@ -681,6 +714,7 @@ int UtcDaliTextShape(void) charactersPerGlyph02, 0u, nullptr, + false, fontDescriptions01 }, { @@ -694,6 +728,7 @@ int UtcDaliTextShape(void) charactersPerGlyph03, 2u, newParagraphGlyphs03, + false, fontDescriptions02 }, { @@ -707,6 +742,7 @@ int UtcDaliTextShape(void) charactersPerGlyph04, 0u, nullptr, + false, fontDescriptions03 }, { @@ -720,7 +756,8 @@ int UtcDaliTextShape(void) charactersPerGlyph05, 1u, newParagraphGlyphs05, - fontDescriptions04 + false, + fontDescriptions04, }, { "Latin script with some paragraphs. Update mid paragraph.", @@ -733,6 +770,7 @@ int UtcDaliTextShape(void) charactersPerGlyph05, 1u, newParagraphGlyphs06, + false, fontDescriptions05 }, { @@ -746,6 +784,7 @@ int UtcDaliTextShape(void) charactersPerGlyph05, 1u, newParagraphGlyphs07, + false, fontDescriptions06 }, }; @@ -924,6 +963,7 @@ int UtcDaliTextSoftwareStyling(void) charactersPerGlyph, 0u, nullptr, + false, fontDescriptions01 }, { @@ -937,6 +977,7 @@ int UtcDaliTextSoftwareStyling(void) charactersPerGlyph, 0u, nullptr, + false, fontDescriptions02 } }; @@ -957,3 +998,142 @@ int UtcDaliTextSoftwareStyling(void) tet_result(TET_PASS); END_TEST; } + + +int UtcDaliTextShapeEmojiSequences(void) +{ + + ToolkitTestApplication application; + + tet_infoline(" UtcDaliTextShapeEmojiSequences"); + + const std::string colorFontFamily( "NotoColorEmoji" ); + const std::string textFontFamily( "DejaVuSans" ); + + LoadEmojiFonts(); + + //Common attributes for font Descriptions + CharacterRun characterRun = {0u, 2u}; + FontWeight weight = TextAbstraction::FontWeight::NORMAL; + FontWidth width = TextAbstraction::FontWidth::NORMAL; + FontSlant slant = TextAbstraction::FontSlant::ITALIC; + PointSize26Dot6 size = TextAbstraction::FontClient::DEFAULT_POINT_SIZE; + + bool familyDefined = true; + bool weightDefined = false; + bool widthDefined = false; + bool slantDefined = false; + bool sizeDefined = false; + + + // variation selector 16 (Emoji) + struct GlyphInfoData glyphsVS16[] = + { + { 2u, 74u, 0.f, 0.f, 0.f, 0.f, 39.0f, 0.f, false, false }, + }; + CharacterIndex characterIndicesVS16[] = { 0u, 1u}; + Length charactersPerGlyphVS16[] = { 2u }; + + + + // variation selector 15 (Text) + struct GlyphInfoData glyphsVS15[] = + { + { 1u, 3842u, 0.f, 0.f, 0.f, 0.f, 14.0f, 0.f, false, false }, + { 1u, 8203u, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, false, false }, + }; + CharacterIndex characterIndicesVS15[] = { 0u, 0u}; + Length charactersPerGlyphVS15[] = { 0u, 2u }; + + //Font Descriptions + Vector fontDescriptionsColorVS16 = + CreateSingleFontDescription (characterRun, colorFontFamily, weight, width, + slant, size, familyDefined, weightDefined, widthDefined, slantDefined, sizeDefined); + + Vector fontDescriptionsColorVS15 = + CreateSingleFontDescription (characterRun, colorFontFamily, weight, width, + slant, size, familyDefined, weightDefined, widthDefined, slantDefined, sizeDefined); + + Vector fontDescriptionsTextVS16 = + CreateSingleFontDescription (characterRun, textFontFamily, weight, width, + slant, size, familyDefined, weightDefined, widthDefined, slantDefined, sizeDefined); + + Vector fontDescriptionsTextVS15 = + CreateSingleFontDescription (characterRun, textFontFamily, weight, width, + slant, size, familyDefined, weightDefined, widthDefined, slantDefined, sizeDefined); + + + struct ShapeInfoData data[] = + { + { + "EMOJI Sequence: Color Font with VS16", + "☪️", + 0u, + 2u, + 1u, + glyphsVS16, + characterIndicesVS16, + charactersPerGlyphVS16, + 0u, + nullptr, + true, + fontDescriptionsColorVS16 + }, + { + "EMOJI Sequence: Color Font with VS15", + "☪︎", + 0u, + 2u, + 2u, + glyphsVS15, + characterIndicesVS15, + charactersPerGlyphVS15, + 0u, + nullptr, + true, + fontDescriptionsColorVS15 + }, + { + "EMOJI Sequence: Text Font with VS16", + "☪️", + 0u, + 2u, + 1u, + glyphsVS16, + characterIndicesVS16, + charactersPerGlyphVS16, + 0u, + nullptr, + true, + fontDescriptionsTextVS16 + }, + { + "EMOJI Sequence: Text Font with VS15", + "☪︎", + 0u, + 2u, + 2u, + glyphsVS15, + characterIndicesVS15, + charactersPerGlyphVS15, + 0u, + nullptr, + true, + fontDescriptionsTextVS15 + }, + }; + + const unsigned int numberOfTests = 4u; + + for( unsigned int index = 0u; index < numberOfTests; ++index ) + { + tet_infoline( data[index].description.c_str()); + if( !ShapeInfoTest( data[index] ) ) + { + tet_result(TET_FAIL); + } + } + + tet_result(TET_PASS); + END_TEST; +}