Revert " modify license, permission and remove ^M char"
[framework/osp/uifw.git] / src / graphics / FGrp_FontRsrcManager.h
1 //
2 // Open Service Platform
3 // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
4 //
5 // Licensed under the Flora License, Version 1.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
8 //
9 //     http://floralicense.org/license/
10 //
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an AS IS BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
16 //
17
18 /*
19  * @file        FGrp_FontRsrcManager.h
20  * @brief       This is the header file for FGrp_FontRsrcManager class.
21  *
22  */
23
24 #ifndef _FGRP_INTERNAL_FONT_RSRC_MANAGER_H_
25 #define _FGRP_INTERNAL_FONT_RSRC_MANAGER_H_
26
27 #include <memory>
28 #include <tr1/memory>
29
30
31 #ifdef USE_HASHMAP_FOR_FONT
32         #include <FBaseColHashMapT.h>
33 #else
34         #include <list>
35         #include <algorithm>
36 #endif
37
38 #include <FBaseString.h>
39 #include <FBaseDataType.h>
40 #include <FBaseColArrayListT.h>
41
42 #include "FGrp_FontMemoryManager.h"
43 #include "util/FGrp_UtilTemplate.h"
44
45 namespace Tizen { namespace Graphics
46 {
47
48 class _Font;
49 struct _FontResource;
50
51 class _FontRsrcManager
52         : public Tizen::Base::Object
53 {
54 public:
55         typedef std::tr1::shared_ptr<_IFont> SharedFontResource;
56 #ifdef USE_HASHMAP_FOR_FONT
57         typedef Tizen::Base::Collection::HashMapT <_Util::WString, SharedFontResource> FontMapT;
58         typedef Tizen::Base::Collection::HashMapT <_Util::WString, _Util::WString> AppFontMapT;
59 #else
60         typedef std::list<std::pair<_Util::WString, SharedFontResource> > FontMapT;
61         typedef std::list<std::pair<_Util::WString, _Util::WString> > AppFontMapT;
62 #endif
63
64         virtual ~_FontRsrcManager(void);
65
66         result GetFont(const Tizen::Base::String& fontPath, int style, _Util::FixedPoint26_6 size, SharedFontResource& out);
67         result GetFont(const byte* pFontData, int fontDataSize, int style, _Util::FixedPoint26_6 size, SharedFontResource& out);
68         result GetFont(int style, _Util::FixedPoint26_6 size, SharedFontResource& out);
69
70         result GetSystemFont(const Tizen::Base::String& fontName, int style, _Util::FixedPoint26_6 size, SharedFontResource& out);
71
72         result GetTempFont(const Tizen::Base::String& fontPath, int style, _Util::FixedPoint26_6 size, SharedFontResource& out);
73         result AddFont(const _Util::WString& fontPath, SharedFontResource& out);
74         bool SearchFont(const _Util::WString& fontName);
75
76         bool ReloadDefaultSystemFont(void);
77         _FontMemoryManager& GetMemoryManager(void);
78         _Font& GetDefaultSystemFont(void);
79         bool RemoveMemory(unsigned long requestedSize);
80
81         _Util::WString FindAppFontName(const _Util::WString& fontName);
82
83         static _FontRsrcManager& GetInstance(void);
84
85 private:
86         _FontRsrcManager(void);
87         _FontRsrcManager(const _FontRsrcManager& obj);
88         _FontRsrcManager& operator =(const _FontRsrcManager& rhs);
89
90         bool __CreateFont(int fontEngine, const void* pBuffer, long bufSize, long face, _IFont** pOut);
91         bool __CreateFont(int fontEngine, const char* filePath, long face, _IFont** pOut);
92         bool __CreateStaticFont(int fontEngine, const void* pBuffer, long bufSize, long face, _IFont** pOut);
93         bool __SearchFont(const _Util::WString& fontName, SharedFontResource& out) const;
94         bool __AddFont(const _Util::WString& key, const SharedFontResource& font);
95         void __RemoveUnusedFont(void);
96         long __GetMaxFontEngine(void) const;
97         const Tizen::Base::String& __GetDefaultSystemFontPath(bool isBold);
98         Tizen::Base::String __GetFontPath(bool isBold);
99         bool __ReloadFont(Tizen::Base::String fontName, bool isBold);
100
101         static void __InitFontRsrcManager(void);
102
103 private:
104         FontMapT __fontRsrcMap;
105         AppFontMapT __appFontMap;
106
107         Tizen::Base::String __defaultSystemFontPath;
108         Tizen::Base::String __defaultSystemBoldFontPath;
109
110         _FontMemoryManager* __pFontMemoryManager;
111         _Font* __pDefaultSystemFont;
112
113         static _FontRsrcManager* __pTheInstance;
114         bool __isAppFontListInitialized;
115 }; // _FontRsrcManager
116
117 }} // Tizen::Graphics
118
119 #endif // _FGRP_INTERNAL_FONT_RSRC_MANAGER_H_