Merge "Change Application::ResizeSignal() deprecated version correctly" into devel...
[platform/core/uifw/dali-adaptor.git] / dali / internal / text / 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) 2019 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
28 struct FT_FaceRec_;
29
30 namespace Dali
31 {
32
33 namespace TextAbstraction
34 {
35
36 namespace Internal
37 {
38
39 /**
40  * Implementation of the FontClient
41  */
42 class FontClient : public BaseObject
43 {
44 public:
45
46   /**
47    * Constructor
48    */
49   FontClient();
50
51   /**
52    * Destructor
53    */
54   ~FontClient();
55
56   /**
57    * @copydoc Dali::TextAbstraction::FontClient::Get()
58    */
59   static Dali::TextAbstraction::FontClient Get();
60
61   /**
62    * @copydoc Dali::TextAbstraction::FontClient::ClearCache()
63    */
64   void ClearCache();
65
66   /**
67    * @copydoc Dali::TextAbstraction::FontClient::SetDpi()
68    */
69   void SetDpi( unsigned int horizontalDpi, unsigned int verticalDpi );
70
71   /**
72    * @copydoc Dali::TextAbstraction::FontClient::GetDpi()
73    */
74   void GetDpi( unsigned int& horizontalDpi, unsigned int& verticalDpi );
75
76   /**
77    * @copydoc Dali::TextAbstraction::FontClient::GetDefaultFontSize()
78    */
79   int GetDefaultFontSize();
80
81   /**
82    * @copydoc Dali::TextAbstraction::FontClient::ResetSystemDefaults()
83    */
84   void ResetSystemDefaults();
85
86   /**
87    * @copydoc Dali::TextAbstraction::FontClient::GetDefaultFonts()
88    */
89   void GetDefaultFonts( FontList& defaultFonts );
90
91   /**
92    * @copydoc Dali::TextAbstraction::FontClient::GetDefaultPlatformFontDescription()
93    */
94   void GetDefaultPlatformFontDescription( FontDescription& fontDescription );
95
96   /**
97    * @copydoc Dali::TextAbstraction::FontClient::GetSystemFonts()
98    */
99   void GetSystemFonts( FontList& systemFonts );
100
101   /**
102    * @copydoc Dali::TextAbstraction::FontClient::GetDescription()
103    */
104   void GetDescription( FontId id, FontDescription& fontDescription );
105
106   /**
107    * @copydoc Dali::TextAbstraction::FontClient::GetPointSize()
108    */
109   PointSize26Dot6 GetPointSize( FontId id );
110
111   /**
112    * @copydoc Dali::TextAbstraction::FontClient::IsCharacterSupportedByFont()
113    */
114   bool IsCharacterSupportedByFont( FontId fontId, Character character );
115
116   /**
117    * @copydoc Dali::TextAbstraction::FontClient::FindDefaultFont()
118    */
119   FontId FindDefaultFont( Character charcode,
120                           PointSize26Dot6 requestedPointSize,
121                           bool preferColor );
122
123   /**
124    * @copydoc Dali::TextAbstraction::FontClient::FindFallbackFont()
125    */
126   FontId FindFallbackFont( Character charcode,
127                            const FontDescription& preferredFontDescription,
128                            PointSize26Dot6 requestedPointSize,
129                            bool preferColor );
130
131   /**
132    * @copydoc Dali::TextAbstraction::FontClient::GetFontId( const FontPath& path, PointSize26Dot6 requestedPointSize, FaceIndex faceIndex )
133    */
134   FontId GetFontId( const FontPath& path, PointSize26Dot6 requestedPointSize, FaceIndex faceIndex );
135
136   /**
137    * @copydoc Dali::TextAbstraction::FontClient::GetFontId( const FontDescription& fontDescription, PointSize26Dot6 requestedPointSize, FaceIndex faceIndex )
138    */
139   FontId GetFontId( const FontDescription& fontDescription,
140                     PointSize26Dot6 requestedPointSize,
141                     FaceIndex faceIndex );
142
143   /**
144    * @copydoc Dali::TextAbstraction::FontClient::GetFontId( const BitmapFont& bitmapFont )
145    */
146   FontId GetFontId( const BitmapFont& bitmapFont );
147
148   /**
149    * @copydoc Dali::TextAbstraction::FontClient::IsScalable( const FontPath& path )
150    */
151   bool IsScalable( const FontPath& path );
152
153   /**
154    * @copydoc Dali::TextAbstraction::FontClient::IsScalable( const FontDescription& fontDescription )
155    */
156   bool IsScalable( const FontDescription& fontDescription );
157
158   /**
159    * @copydoc Dali::TextAbstraction::FontClient::GetFixedSizes( const FontPath& path, Dali::Vector< PointSize26Dot6>& sizes )
160    */
161   void GetFixedSizes( const FontPath& path, Dali::Vector< PointSize26Dot6>& sizes );
162
163   /**
164    * @copydoc Dali::TextAbstraction::FontClient::GetFixedSizes()
165    */
166   void GetFixedSizes( const FontDescription& fontDescription,
167                       Dali::Vector< PointSize26Dot6 >& sizes );
168
169   /**
170    * @copydoc Dali::TextAbstraction::FontClient::HasItalicStyle()
171    */
172   bool HasItalicStyle( FontId fontId ) const;
173
174   /**
175    * @copydoc Dali::TextAbstraction::FontClient::GetFontMetrics()
176    */
177   void GetFontMetrics( FontId fontId, FontMetrics& metrics );
178
179   /**
180    * @copydoc Dali::TextAbstraction::FontClient::GetGlyphIndex()
181    */
182   GlyphIndex GetGlyphIndex( FontId fontId, Character charcode );
183
184   /**
185    * @copydoc Dali::TextAbstraction::FontClient::GetGlyphMetrics()
186    */
187   bool GetGlyphMetrics( GlyphInfo* array, uint32_t size, GlyphType type, bool horizontal );
188
189   /**
190    * @copydoc Dali::TextAbstraction::FontClient::CreateBitmap( FontId fontId, GlyphIndex glyphIndex, bool isItalicRequired, bool isBoldRequired, Dali::TextAbstraction::FontClient::GlyphBufferData& data, int outlineWidth )
191    */
192   void CreateBitmap( FontId fontId, GlyphIndex glyphIndex, bool isItalicRequired, bool isBoldRequired, Dali::TextAbstraction::FontClient::GlyphBufferData& data, int outlineWidth );
193
194   /**
195    * @copydoc Dali::TextAbstraction::FontClient::CreateBitmap( FontId fontId, GlyphIndex glyphIndex, int outlineWidth )
196    */
197   PixelData CreateBitmap( FontId fontId, GlyphIndex glyphIndex, int outlineWidth );
198
199   /**
200    * @copydoc Dali::TextAbstraction::FontClient::CreateVectorBlob()
201    */
202   void CreateVectorBlob( FontId fontId, GlyphIndex glyphIndex, VectorBlob*& blob, unsigned int& blobLength, unsigned int& nominalWidth, unsigned int& nominalHeight );
203
204   /**
205    * @copydoc Dali::TextAbstraction::FontClient::GetEllipsisGlyph()
206    */
207   const GlyphInfo& GetEllipsisGlyph( PointSize26Dot6 requestedPointSize );
208
209   /**
210    * @copydoc Dali::TextAbstraction::FontClient::IsColorGlyph()
211    */
212   bool IsColorGlyph( FontId fontId, GlyphIndex glyphIndex );
213
214   /**
215    * @copydoc Dali::TextAbstraction::FontClient::CreateEmbeddedItem()
216    */
217   GlyphIndex CreateEmbeddedItem( const TextAbstraction::FontClient::EmbeddedItemDescription& description, Pixel::Format& pixelFormat );
218
219   /**
220    * @brief Retrieves the pointer to the FreeType Font Face for the given @p fontId.
221    *
222    * @param[in] fontId The font id.
223    *
224    * @return The pointer to the FreeType Font Face.
225    */
226   FT_FaceRec_* GetFreetypeFace( FontId fontId );
227
228   /**
229    * @brief Retrieves the type of font.
230    *
231    * @param[in] fontId The font id.
232    *
233    * @return FACE_FONT if the font has been loaded by FreeType, BITMAP_FONT if it's a font that has been loaded from images or INVALID if it's a non valid font.
234    */
235   FontDescription::Type GetFontType( FontId fontId );
236
237   /**
238    * @copydoc Dali::TextAbstraction::FontClient::AddCustomFontDirectory()
239    */
240   bool AddCustomFontDirectory( const FontPath& path );
241
242 private:
243
244   /**
245    * Helper for lazy initialization.
246    */
247   void CreatePlugin();
248
249   // Undefined copy constructor.
250   FontClient( const FontClient& );
251
252   // Undefined assignment constructor.
253   FontClient& operator=( const FontClient& );
254
255 private:
256
257   struct Plugin;
258   Plugin* mPlugin;
259
260   // Allows DPI to be set without loading plugin
261   unsigned int mDpiHorizontal;
262   unsigned int mDpiVertical;
263
264 }; // class FontClient
265
266 } // namespace Internal
267
268 inline static Internal::FontClient& GetImplementation(FontClient& fontClient)
269 {
270   DALI_ASSERT_ALWAYS( fontClient && "fontClient handle is empty" );
271   BaseObject& handle = fontClient.GetBaseObject();
272   return static_cast<Internal::FontClient&>(handle);
273 }
274
275 inline static const Internal::FontClient& GetImplementation(const FontClient& fontClient)
276 {
277   DALI_ASSERT_ALWAYS( fontClient && "fontClient handle is empty" );
278   const BaseObject& handle = fontClient.GetBaseObject();
279   return static_cast<const Internal::FontClient&>(handle);
280 }
281
282 } // namespace TextAbstraction
283
284 } // namespace Dali
285
286 #endif // DALI_INTERNAL_TEXT_ABSTRACTION_FONT_CLIENT_IMPL_H