Merge remote-tracking branch 'origin/tizen' into new_text
[platform/core/uifw/dali-adaptor.git] / text / dali / internal / text-abstraction / font-client-impl.h
1 #ifndef __DALI_INTERNAL_TEXT_ABSTRACTION_FONT_CLIENT_IMPL_H__
2 #define __DALI_INTERNAL_TEXT_ABSTRACTION_FONT_CLIENT_IMPL_H__
3
4 /*
5  * Copyright (c) 2015 Samsung Electronics Co., Ltd.
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  *
19  */
20
21 // EXTERNAL INCLUDES
22 #include <dali/public-api/object/base-object.h>
23
24 // INTERNAL INCLUDES
25 #include <dali/public-api/text-abstraction/font-client.h>
26
27 namespace Dali
28 {
29
30 namespace TextAbstraction
31 {
32
33 namespace Internal
34 {
35
36 /**
37  * Implementation of the FontClient
38  */
39 class FontClient : public BaseObject
40 {
41 public:
42
43   /**
44    * Constructor
45    */
46   FontClient();
47
48   /**
49    * Destructor
50    */
51   ~FontClient();
52
53   /**
54    * @copydoc Dali::FontClient::Get()
55    */
56   static Dali::TextAbstraction::FontClient Get();
57
58   /**
59    * @copydoc Dali::FontClient::SetDpi()
60    */
61   void SetDpi( unsigned int horizontalDpi, unsigned int verticalDpi );
62
63   /**
64    * @copydoc Dali::FontClient::SetDefaultFontFamily()
65    */
66   void SetDefaultFontFamily( const std::string& fontFamilyName,
67                              const std::string& fontStyle );
68
69   /**
70    * @copydoc Dali::FontClient::GetDefaultFonts()
71    */
72   void GetDefaultFonts( FontList& defaultFonts );
73
74   /**
75    * @copydoc Dali::FontClient::GetSystemFonts()
76    */
77   void GetSystemFonts( FontList& systemFonts );
78
79   /**
80    * @copydoc Dali::FontClient::GetDescription()
81    */
82   void GetDescription( FontId id, FontDescription& fontDescription );
83
84   /**
85    * @copydoc Dali::FontClient::GetPointSize()
86    */
87   PointSize26Dot6 GetPointSize( FontId id );
88
89   /**
90    * @copydoc Dali::FontClient::FindDefaultFont()
91    */
92   FontId FindDefaultFont( Character charcode, PointSize26Dot6 pointSize );
93
94   /**
95    * @copydoc Dali::FontClient::GetFontId( const FontPath& path, PointSize26Dot6 pointSize, FaceIndex faceIndex )
96    */
97   FontId GetFontId( const FontPath& path, PointSize26Dot6 pointSize, FaceIndex faceIndex );
98
99   /**
100    * @copydoc Dali::FontClient::GetFontId(const FontFamily& fontFamily, const FontStyle& fontStyle, PointSize26Dot6 pointSize, FaceIndex faceIndex )
101    */
102   FontId GetFontId( const FontFamily& fontFamily,
103                     const FontStyle& fontStyle,
104                     PointSize26Dot6 pointSize,
105                     FaceIndex faceIndex );
106
107   /**
108    * @copydoc Dali::FontClient::GetFontMetrics()
109    */
110   void GetFontMetrics( FontId fontId, FontMetrics& metrics );
111
112   /**
113    * @copydoc Dali::FontClient::GetGlyphIndex()
114    */
115   GlyphIndex GetGlyphIndex( FontId fontId, Character charcode );
116
117   /**
118    * @copydoc Dali::FontClient::CreateMetrics()
119    */
120   bool GetGlyphMetrics( GlyphInfo* array, uint32_t size, bool horizontal );
121
122   /**
123    * @copydoc Dali::FontClient::CreateBitmap()
124    */
125   BitmapImage CreateBitmap( FontId fontId, GlyphIndex glyphIndex );
126
127 private:
128
129   /**
130    * Helper for lazy initialization.
131    */
132   void CreatePlugin();
133
134   // Undefined copy constructor.
135   FontClient( const FontClient& );
136
137   // Undefined assignment constructor.
138   FontClient& operator=( FontClient& );
139
140 private:
141
142   struct Plugin;
143   Plugin* mPlugin;
144
145   // Allows DPI to be set without loading plugin
146   unsigned int mDpiHorizontal;
147   unsigned int mDpiVertical;
148
149 }; // class FontClient
150
151 } // namespace Internal
152
153 inline static Internal::FontClient& GetImplementation(FontClient& fontClient)
154 {
155   DALI_ASSERT_ALWAYS( fontClient && "fontClient handle is empty" );
156   BaseObject& handle = fontClient.GetBaseObject();
157   return static_cast<Internal::FontClient&>(handle);
158 }
159
160 inline static const Internal::FontClient& GetImplementation(const FontClient& fontClient)
161 {
162   DALI_ASSERT_ALWAYS( fontClient && "fontClient handle is empty" );
163   const BaseObject& handle = fontClient.GetBaseObject();
164   return static_cast<const Internal::FontClient&>(handle);
165 }
166
167 } // namespace TextAbstraction
168
169 } // namespace Dali
170
171 #endif // __DALI_INTERNAL_TEXT_ABSTRACTION_FONT_CLIENT_IMPL_H__