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