License conversion from Flora to Apache 2.0
[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 {
36 }
37
38 GlyphSet::~GlyphSet()
39 {
40   mCharacterList.clear();
41 }
42
43 void GlyphSet::AddCharacter(BitmapPtr bitmapData, const GlyphMetrics& glyphMetrics)
44 {
45   mCharacterList.push_back(Character(bitmapData, glyphMetrics));
46 }
47
48 void GlyphSet::AddCharacter(const Character& character)
49 {
50   mCharacterList.push_back(character);
51 }
52
53 const GlyphSet::CharacterList& GlyphSet::GetCharacterList() const
54 {
55   return mCharacterList;
56 }
57
58 bool GlyphSet::HasCharacter(const uint32_t charCode) const
59 {
60   for (CharacterConstIter iter = mCharacterList.begin(), endIter = mCharacterList.end(); iter != endIter; ++iter)
61   {
62     if (iter->second.code == charCode)
63     {
64       return true;
65     }
66   }
67   return false;
68 }
69
70 bool GlyphSet::HasCharacter(const Character& character) const
71 {
72   return HasCharacter(character.second.code);
73 }
74
75 ResourceId GlyphSet::GetAtlasResourceId() const
76 {
77   return mAtlasId;
78 }
79
80 void GlyphSet::SetAtlasResourceId(ResourceId resourceId)
81 {
82   mAtlasId = resourceId;
83 }
84
85 } //namespace Integration
86
87 } //namespace Dali