New size negotiation
[platform/core/uifw/dali-core.git] / dali / integration-api / glyph-set.cpp
1 /*
2  * Copyright (c) 2014 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 // CLASS HEADER
19 #include <dali/integration-api/glyph-set.h>
20
21 namespace Dali
22 {
23
24 namespace Integration
25 {
26
27 GlyphSet::GlyphSet()
28 : mFontHash(0),
29   mLineHeight(0.0f),
30   mAscender(0.0f),
31   mUnitsPerEM(0.0f),
32   mUnderlinePosition(0.0f),
33   mUnderlineThickness(0.0f),
34   mPadAdjust(0.0f),
35   mAtlasId( 0 )
36 {
37 }
38
39 GlyphSet::~GlyphSet()
40 {
41   mCharacterList.clear();
42 }
43
44 void GlyphSet::AddCharacter(BitmapPtr bitmapData, const GlyphMetrics& glyphMetrics)
45 {
46   mCharacterList.push_back(Character(bitmapData, glyphMetrics));
47 }
48
49 void GlyphSet::AddCharacter(const Character& character)
50 {
51   mCharacterList.push_back(character);
52 }
53
54 const GlyphSet::CharacterList& GlyphSet::GetCharacterList() const
55 {
56   return mCharacterList;
57 }
58
59 bool GlyphSet::HasCharacter(const uint32_t charCode) const
60 {
61   for (CharacterConstIter iter = mCharacterList.begin(), endIter = mCharacterList.end(); iter != endIter; ++iter)
62   {
63     if (iter->second.code == charCode)
64     {
65       return true;
66     }
67   }
68   return false;
69 }
70
71 bool GlyphSet::HasCharacter(const Character& character) const
72 {
73   return HasCharacter(character.second.code);
74 }
75
76 ResourceId GlyphSet::GetAtlasResourceId() const
77 {
78   return mAtlasId;
79 }
80
81 void GlyphSet::SetAtlasResourceId(ResourceId resourceId)
82 {
83   mAtlasId = resourceId;
84 }
85
86 } //namespace Integration
87
88 } //namespace Dali