Tizen 2.1 base
[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 #include <FBaseString.h>
31 #include <FBaseDataType.h>
32 #include <FBaseColHashMapT.h>
33
34 #include "FGrp_FontMemoryManager.h"
35 #include "util/FGrp_UtilTemplate.h"
36
37
38 namespace Tizen { namespace Graphics
39 {
40
41 class _Font;
42 struct _FontResource;
43
44 class _FontRsrcManager
45         : public Tizen::Base::Object
46 {
47 public:
48         typedef std::tr1::shared_ptr<_IFont> SharedFontResource;
49
50         virtual ~_FontRsrcManager(void);
51
52         result GetFont(const Tizen::Base::String& fontPath, int style, int size, SharedFontResource& out);
53         result GetFont(const byte* pFontData, int fontDataSize, int style, int size, SharedFontResource& out);
54         result GetFont(int style, int size, SharedFontResource& out);
55
56         result GetSystemFont(const Tizen::Base::String& fontName, int style, int size, SharedFontResource& out);
57
58         result GetTempFont(const Tizen::Base::String& fontPath, int style, int size, SharedFontResource& out);
59         result AddFont(const Tizen::Base::String& fontPath, SharedFontResource& out);
60         bool SearchFont(const Tizen::Base::String& fontName);
61
62         bool ReloadDefaultSystemFont(void);
63         _FontMemoryManager& GetMemoryManager(void);
64         _Font& GetDefaultSystemFont(void);
65         bool RemoveMemory(unsigned long requestedSize);
66
67         Tizen::Base::String FindAppFontName(const Tizen::Base::String& fontName);
68
69         static _FontRsrcManager& GetInstance(void);
70
71 private:
72         _FontRsrcManager(void);
73         _FontRsrcManager(const _FontRsrcManager& obj);
74         _FontRsrcManager& operator =(const _FontRsrcManager& rhs);
75
76         bool __CreateFont(int fontEngine, const void* pBuffer, long bufSize, long face, _IFont** pOut);
77         bool __CreateFont(int fontEngine, const char* filePath, long face, _IFont** pOut);
78         bool __CreateStaticFont(int fontEngine, const void* pBuffer, long bufSize, long face, _IFont** pOut);
79         bool __SearchFont(const Tizen::Base::String& fontName, SharedFontResource& out) const;
80         bool __AddFont(const Tizen::Base::String& key, const SharedFontResource& font);
81         void __RemoveUnusedFont(void);
82         long __GetMaxFontEngine(void) const;
83         const Tizen::Base::String& __GetDefaultSystemFontPath(bool isBold);
84         Tizen::Base::String __GetFontPath(bool isBold);
85         bool __ReloadFont(Tizen::Base::String fontName, bool isBold);
86
87         static void __InitFontRsrcManager(void);
88
89 private:
90         Tizen::Base::Collection::HashMapT <Tizen::Base::String, SharedFontResource> __fontRsrcMap;
91         Tizen::Base::Collection::HashMapT <Tizen::Base::String, Tizen::Base::String> __appFontMap;
92
93         Tizen::Base::String __defaultSystemFontPath;
94         Tizen::Base::String __defaultSystemBoldFontPath;
95
96         _FontMemoryManager* __pFontMemoryManager;
97         _Font* __pDefaultSystemFont;
98
99         static _FontRsrcManager* __pTheInstance;
100         bool __isAppFontListInitialized;
101 }; // _FontRsrcManager
102
103 }} // Tizen::Graphics
104
105 #endif // _FGRP_INTERNAL_FONT_RSRC_MANAGER_H_