Merge "FontClient - Add a method to get the raw data of a glyph." into devel/master
[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/devel-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::TextAbstraction::FontClient::Get()
55    */
56   static Dali::TextAbstraction::FontClient Get();
57
58   /**
59    * @copydoc Dali::TextAbstraction::FontClient::SetDpi()
60    */
61   void SetDpi( unsigned int horizontalDpi, unsigned int verticalDpi );
62
63   /**
64    * @copydoc Dali::TextAbstraction::FontClient::GetDpi()
65    */
66   void GetDpi( unsigned int& horizontalDpi, unsigned int& verticalDpi );
67
68   /**
69    * @copydoc Dali::TextAbstraction::FontClient::ResetSystemDefaults()
70    */
71   void ResetSystemDefaults();
72
73   /**
74    * @copydoc Dali::TextAbstraction::FontClient::GetDefaultFonts()
75    */
76   void GetDefaultFonts( FontList& defaultFonts );
77
78   /**
79    * @copydoc Dali::TextAbstraction::FontClient::GetDefaultPlatformFontDescription()
80    */
81   void GetDefaultPlatformFontDescription( FontDescription& fontDescription );
82
83   /**
84    * @copydoc Dali::TextAbstraction::FontClient::GetSystemFonts()
85    */
86   void GetSystemFonts( FontList& systemFonts );
87
88   /**
89    * @copydoc Dali::TextAbstraction::FontClient::GetDescription()
90    */
91   void GetDescription( FontId id, FontDescription& fontDescription );
92
93   /**
94    * @copydoc Dali::TextAbstraction::FontClient::GetPointSize()
95    */
96   PointSize26Dot6 GetPointSize( FontId id );
97
98   /**
99    * @copydoc Dali::TextAbstraction::FontClient::FindDefaultFont()
100    */
101   FontId FindDefaultFont( Character charcode,
102                           PointSize26Dot6 requestedPointSize,
103                           bool preferColor );
104
105   /**
106    * @copydoc Dali::TextAbstraction::FontClient::FindFallbackFont()
107    */
108   FontId FindFallbackFont( Character charcode,
109                            const FontDescription& preferredFontDescription,
110                            PointSize26Dot6 requestedPointSize,
111                            bool preferColor );
112
113   /**
114    * @copydoc Dali::TextAbstraction::FontClient::GetFontId( const FontPath& path, PointSize26Dot6 requestedPointSize, FaceIndex faceIndex )
115    */
116   FontId GetFontId( const FontPath& path, PointSize26Dot6 requestedPointSize, FaceIndex faceIndex );
117
118   /**
119    * @copydoc Dali::TextAbstraction::FontClient::GetFontId( const FontDescription& fontDescription, PointSize26Dot6 requestedPointSize, FaceIndex faceIndex )
120    */
121   FontId GetFontId( const FontDescription& fontDescription,
122                     PointSize26Dot6 requestedPointSize,
123                     FaceIndex faceIndex );
124
125   /**
126    * @copydoc Dali::TextAbstraction::FontClient::IsScalable( const FontPath& path )
127    */
128   bool IsScalable( const FontPath& path );
129
130   /**
131    * @copydoc Dali::TextAbstraction::FontClient::IsScalable( const FontDescription& fontDescription )
132    */
133   bool IsScalable( const FontDescription& fontDescription );
134
135   /**
136    * @copydoc Dali::TextAbstraction::FontClient::GetFixedSizes( const FontPath& path, Dali::Vector< PointSize26Dot6>& sizes )
137    */
138   void GetFixedSizes( const FontPath& path, Dali::Vector< PointSize26Dot6>& sizes );
139
140   /**
141    * @copydoc Dali::TextAbstraction::FontClient::GetFixedSizes()
142    */
143   void GetFixedSizes( const FontDescription& fontDescription,
144                       Dali::Vector< PointSize26Dot6 >& sizes );
145
146   /**
147    * @copydoc Dali::TextAbstraction::FontClient::GetFontMetrics()
148    */
149   void GetFontMetrics( FontId fontId, FontMetrics& metrics );
150
151   /**
152    * @copydoc Dali::TextAbstraction::FontClient::GetGlyphIndex()
153    */
154   GlyphIndex GetGlyphIndex( FontId fontId, Character charcode );
155
156   /**
157    * @copydoc Dali::TextAbstraction::FontClient::GetGlyphMetrics()
158    */
159   bool GetGlyphMetrics( GlyphInfo* array, uint32_t size, GlyphType type, bool horizontal );
160
161   /**
162    * @copydoc Dali::TextAbstraction::FontClient::CreateBitmap( FontId fontId, GlyphIndex glyphIndex, Dali::TextAbstraction::FontClient::GlyphBufferData& data )
163    */
164   void CreateBitmap( FontId fontId, GlyphIndex glyphIndex, Dali::TextAbstraction::FontClient::GlyphBufferData& data );
165
166   /**
167    * @copydoc Dali::TextAbstraction::FontClient::CreateBitmap( FontId fontId, GlyphIndex glyphIndex )
168    */
169   PixelData CreateBitmap( FontId fontId, GlyphIndex glyphIndex );
170
171   /**
172    * @copydoc Dali::TextAbstraction::FontClient::CreateVectorBlob()
173    */
174   void CreateVectorBlob( FontId fontId, GlyphIndex glyphIndex, VectorBlob*& blob, unsigned int& blobLength, unsigned int& nominalWidth, unsigned int& nominalHeight );
175
176   /**
177    * @copydoc Dali::TextAbstraction::FontClient::GetEllipsisGlyph()
178    */
179   const GlyphInfo& GetEllipsisGlyph( PointSize26Dot6 requestedPointSize );
180
181   /**
182    * @copydoc Dali::TextAbstraction::FontClient::IsColorGlyph()
183    */
184   bool IsColorGlyph( FontId fontId, GlyphIndex glyphIndex );
185
186 private:
187
188   /**
189    * Helper for lazy initialization.
190    */
191   void CreatePlugin();
192
193   // Undefined copy constructor.
194   FontClient( const FontClient& );
195
196   // Undefined assignment constructor.
197   FontClient& operator=( const FontClient& );
198
199 private:
200
201   struct Plugin;
202   Plugin* mPlugin;
203
204   // Allows DPI to be set without loading plugin
205   unsigned int mDpiHorizontal;
206   unsigned int mDpiVertical;
207
208 }; // class FontClient
209
210 } // namespace Internal
211
212 inline static Internal::FontClient& GetImplementation(FontClient& fontClient)
213 {
214   DALI_ASSERT_ALWAYS( fontClient && "fontClient handle is empty" );
215   BaseObject& handle = fontClient.GetBaseObject();
216   return static_cast<Internal::FontClient&>(handle);
217 }
218
219 inline static const Internal::FontClient& GetImplementation(const FontClient& fontClient)
220 {
221   DALI_ASSERT_ALWAYS( fontClient && "fontClient handle is empty" );
222   const BaseObject& handle = fontClient.GetBaseObject();
223   return static_cast<const Internal::FontClient&>(handle);
224 }
225
226 } // namespace TextAbstraction
227
228 } // namespace Dali
229
230 #endif // __DALI_INTERNAL_TEXT_ABSTRACTION_FONT_CLIENT_IMPL_H__