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