7fed0ab548dc11fd952ef8f3d06e0955bf37cb91
[platform/core/uifw/dali-adaptor.git] / dali / devel-api / text-abstraction / font-client.cpp
1 /*
2  * Copyright (c) 2019 Samsung Electronics Co., Ltd.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */
17
18 // CLASS HEADER
19 #include <dali/devel-api/text-abstraction/font-client.h>
20
21 // INTERNAL INCLUDES
22 #include <dali/internal/text/text-abstraction/font-client-impl.h>
23
24 namespace Dali
25 {
26
27 namespace TextAbstraction
28 {
29
30 const PointSize26Dot6 FontClient::DEFAULT_POINT_SIZE = 768u; // 12*64
31 const float FontClient::DEFAULT_ITALIC_ANGLE = 12.f * Dali::Math::PI_OVER_180; // FreeType documentation states the software italic is done by doing a horizontal shear of 12 degrees (file ftsynth.h).
32
33 FontClient::GlyphBufferData::GlyphBufferData()
34 : buffer{ nullptr },
35   width{ 0u },
36   height{ 0u },
37   outlineOffsetX{ 0 },
38   outlineOffsetY{ 0 },
39   format{ Pixel::A8 },
40   isColorEmoji{ false },
41   isColorBitmap{ false }
42 {
43 }
44
45 FontClient::GlyphBufferData::~GlyphBufferData()
46 {
47 }
48
49 FontClient FontClient::Get()
50 {
51   return Internal::FontClient::Get();
52 }
53
54 FontClient::FontClient()
55 {
56 }
57
58 FontClient::~FontClient()
59 {
60 }
61
62 FontClient::FontClient( const FontClient& handle )
63 : BaseHandle( handle )
64 {
65 }
66
67 FontClient& FontClient::operator=( const FontClient& handle )
68 {
69   BaseHandle::operator=( handle );
70   return *this;
71 }
72
73 void FontClient::ClearCache()
74 {
75   GetImplementation(*this).ClearCache();
76 }
77
78 void FontClient::SetDpi( unsigned int horizontalDpi, unsigned int verticalDpi  )
79 {
80   GetImplementation(*this).SetDpi( horizontalDpi, verticalDpi );
81 }
82
83 void FontClient::GetDpi( unsigned int& horizontalDpi, unsigned int& verticalDpi )
84 {
85   GetImplementation(*this).GetDpi( horizontalDpi, verticalDpi );
86 }
87
88 int FontClient::GetDefaultFontSize()
89 {
90   return GetImplementation(*this).GetDefaultFontSize();
91 }
92
93 void FontClient::ResetSystemDefaults()
94 {
95   GetImplementation(*this).ResetSystemDefaults();
96 }
97
98 void FontClient::GetDefaultFonts( FontList& defaultFonts )
99 {
100   GetImplementation(*this).GetDefaultFonts( defaultFonts );
101 }
102
103 void FontClient::GetDefaultPlatformFontDescription( FontDescription& fontDescription )
104 {
105   GetImplementation(*this).GetDefaultPlatformFontDescription( fontDescription );
106 }
107
108 void FontClient::GetSystemFonts( FontList& systemFonts )
109 {
110   GetImplementation(*this).GetSystemFonts( systemFonts );
111 }
112
113 void FontClient::GetDescription( FontId id, FontDescription& fontDescription )
114 {
115   GetImplementation(*this).GetDescription( id, fontDescription );
116 }
117
118 PointSize26Dot6 FontClient::GetPointSize( FontId id )
119 {
120   return GetImplementation(*this).GetPointSize( id );
121 }
122
123 bool FontClient::IsCharacterSupportedByFont( FontId fontId, Character character )
124 {
125   return GetImplementation(*this).IsCharacterSupportedByFont( fontId, character );
126 }
127
128 FontId FontClient::FindDefaultFont( Character charcode,
129                                     PointSize26Dot6 requestedPointSize,
130                                     bool preferColor )
131 {
132   return GetImplementation(*this).FindDefaultFont( charcode,
133                                                    requestedPointSize,
134                                                    preferColor );
135 }
136
137 FontId FontClient::FindFallbackFont( Character charcode,
138                                      const FontDescription& preferredFontDescription,
139                                      PointSize26Dot6 requestedPointSize,
140                                      bool preferColor )
141 {
142   return GetImplementation(*this).FindFallbackFont( charcode, preferredFontDescription, requestedPointSize, preferColor );
143 }
144
145 FontId FontClient::GetFontId( const FontPath& path, PointSize26Dot6 requestedPointSize, FaceIndex faceIndex )
146 {
147   return GetImplementation(*this).GetFontId( path, requestedPointSize, faceIndex );
148 }
149
150 FontId FontClient::GetFontId( const FontDescription& fontDescription,
151                               PointSize26Dot6 requestedPointSize,
152                               FaceIndex faceIndex )
153 {
154   return GetImplementation(*this).GetFontId( fontDescription,
155                                              requestedPointSize,
156                                              faceIndex );
157 }
158
159 FontId FontClient::GetFontId( const BitmapFont& bitmapFont )
160 {
161   return GetImplementation(*this).GetFontId( bitmapFont );
162 }
163
164 bool FontClient::IsScalable( const FontPath& path )
165 {
166   return GetImplementation(*this).IsScalable( path );
167 }
168
169 bool FontClient::IsScalable( const FontDescription& fontDescription )
170 {
171   return GetImplementation(*this).IsScalable( fontDescription );
172 }
173
174 void FontClient::GetFixedSizes( const FontPath& path, Dali::Vector< PointSize26Dot6>& sizes )
175 {
176   GetImplementation(*this).GetFixedSizes( path, sizes );
177 }
178
179 void FontClient::GetFixedSizes( const FontDescription& fontDescription,
180                                 Dali::Vector< PointSize26Dot6 >& sizes )
181 {
182   GetImplementation(*this).GetFixedSizes( fontDescription, sizes );
183 }
184
185 bool FontClient::HasItalicStyle( FontId fontId ) const
186 {
187   return GetImplementation(*this).HasItalicStyle( fontId );
188 }
189
190 void FontClient::GetFontMetrics( FontId fontId, FontMetrics& metrics )
191 {
192   GetImplementation(*this).GetFontMetrics( fontId, metrics );
193 }
194
195 GlyphIndex FontClient::GetGlyphIndex( FontId fontId, Character charcode )
196 {
197   return GetImplementation(*this).GetGlyphIndex( fontId, charcode );
198 }
199
200 bool FontClient::GetGlyphMetrics( GlyphInfo* array, uint32_t size, GlyphType type, bool horizontal )
201 {
202   return GetImplementation(*this).GetGlyphMetrics( array, size, type, horizontal );
203 }
204
205 void FontClient::CreateBitmap( FontId fontId, GlyphIndex glyphIndex, bool isItalicRequired, bool isBoldRequired, GlyphBufferData& data, int outlineWidth )
206 {
207   GetImplementation(*this).CreateBitmap( fontId, glyphIndex, isItalicRequired, isBoldRequired, data, outlineWidth );
208 }
209
210 PixelData FontClient::CreateBitmap( FontId fontId, GlyphIndex glyphIndex, int outlineWidth )
211 {
212   return GetImplementation(*this).CreateBitmap( fontId, glyphIndex, outlineWidth );
213 }
214
215 void FontClient::CreateVectorBlob( FontId fontId, GlyphIndex glyphIndex, VectorBlob*& blob, unsigned int& blobLength, unsigned int& nominalWidth, unsigned int& nominalHeight )
216 {
217   GetImplementation(*this).CreateVectorBlob( fontId, glyphIndex, blob, blobLength, nominalWidth, nominalHeight );
218 }
219
220 const GlyphInfo& FontClient::GetEllipsisGlyph( PointSize26Dot6 requestedPointSize )
221 {
222   return GetImplementation(*this).GetEllipsisGlyph( requestedPointSize );
223 }
224
225 bool FontClient::IsColorGlyph( FontId fontId, GlyphIndex glyphIndex )
226 {
227   return GetImplementation(*this).IsColorGlyph( fontId, glyphIndex );
228 }
229
230 bool FontClient::AddCustomFontDirectory( const FontPath& path )
231 {
232   return GetImplementation(*this).AddCustomFontDirectory( path );
233 }
234
235 GlyphIndex FontClient::CreateEmbeddedItem(const EmbeddedItemDescription& description, Pixel::Format& pixelFormat)
236 {
237   return GetImplementation(*this).CreateEmbeddedItem( description, pixelFormat);
238 }
239
240 FontClient::FontClient( Internal::FontClient* internal )
241 : BaseHandle( internal )
242 {
243 }
244
245 FontClient FontClientPreInitialize()
246 {
247   return Internal::FontClient::PreInitialize();
248 }
249
250 } // namespace TextAbstraction
251
252 } // namespace Dali