2 * Copyright (c) 2014 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.
19 #include <dali/internal/event/text/atlas/atlas-rank-generator.h>
27 namespace // un-named namespace
31 * Given a text string, and the number of characters matched, return the match status
32 * @param textSize, size of the text
33 * @param charMissing number of characters that don't exist in the Atlas
34 * @return the character match status
36 AtlasRanking::CharacterMatch GetTextMatchStatus( std::size_t textSize, std::size_t charsMissing )
38 if( charsMissing == 0 )
40 return AtlasRanking::ALL_CHARACTERS_MATCHED;
42 else if ( charsMissing == textSize )
44 return AtlasRanking::NO_CHARACTERS_MATCHED;
48 return AtlasRanking::SOME_CHARACTERS_MATCHED;
53 * Returns the space status of the atlas based on whether the text will
54 * fit in it and if it can be resized
55 * @param canFit whether the text can fit in the atlas
56 * @param atlasResizable whether the atlas is resizable.
57 * @return the space status
59 AtlasRanking::SpaceStatus GetAtlasSpaceStatus( bool canFit, bool atlasResizable)
63 return AtlasRanking::HAS_SPACE;
65 else if( atlasResizable )
67 return AtlasRanking::FULL_CAN_BE_RESIZED;
71 return AtlasRanking::FULL_CANNOT_BE_RESIZED;
75 } // un-named namespace
77 AtlasRanking GetAtlasRanking( const TextArray& text,
79 const GlyphStatusContainer& container,
83 unsigned int charsNotLoaded(0);
85 // find if the text will fit or not, and how many characters are missing
86 container.GetTextStatus( text, fontId, charsNotLoaded, canFit);
88 AtlasRanking::CharacterMatch charMatchStatus = GetTextMatchStatus( text.size(), charsNotLoaded );
90 AtlasRanking::SpaceStatus spaceStatus = GetAtlasSpaceStatus( canFit, atlasResizable);
92 AtlasRanking ranking( charMatchStatus,
93 AtlasRanking::FONT_MATCHED, // @todo hard coded for now, until atlas splitting supported
99 } // namespace Internal