Merge "Add to set and get Input Panel language" into devel/master
[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   format{ Pixel::A8 },
38   isColorEmoji{ false },
39   isColorBitmap{ false }
40 {
41 }
42
43 FontClient::GlyphBufferData::~GlyphBufferData()
44 {
45 }
46
47 FontClient FontClient::Get()
48 {
49   return Internal::FontClient::Get();
50 }
51
52 FontClient::FontClient()
53 {
54 }
55
56 FontClient::~FontClient()
57 {
58 }
59
60 FontClient::FontClient( const FontClient& handle )
61 : BaseHandle( handle )
62 {
63 }
64
65 FontClient& FontClient::operator=( const FontClient& handle )
66 {
67   BaseHandle::operator=( handle );
68   return *this;
69 }
70
71 void FontClient::ClearCache()
72 {
73   GetImplementation(*this).ClearCache();
74 }
75
76 void FontClient::SetDpi( unsigned int horizontalDpi, unsigned int verticalDpi  )
77 {
78   GetImplementation(*this).SetDpi( horizontalDpi, verticalDpi );
79 }
80
81 void FontClient::GetDpi( unsigned int& horizontalDpi, unsigned int& verticalDpi )
82 {
83   GetImplementation(*this).GetDpi( horizontalDpi, verticalDpi );
84 }
85
86 int FontClient::GetDefaultFontSize()
87 {
88   return GetImplementation(*this).GetDefaultFontSize();
89 }
90
91 void FontClient::ResetSystemDefaults()
92 {
93   GetImplementation(*this).ResetSystemDefaults();
94 }
95
96 void FontClient::GetDefaultFonts( FontList& defaultFonts )
97 {
98   GetImplementation(*this).GetDefaultFonts( defaultFonts );
99 }
100
101 void FontClient::GetDefaultPlatformFontDescription( FontDescription& fontDescription )
102 {
103   GetImplementation(*this).GetDefaultPlatformFontDescription( fontDescription );
104 }
105
106 void FontClient::GetSystemFonts( FontList& systemFonts )
107 {
108   GetImplementation(*this).GetSystemFonts( systemFonts );
109 }
110
111 void FontClient::GetDescription( FontId id, FontDescription& fontDescription )
112 {
113   GetImplementation(*this).GetDescription( id, fontDescription );
114 }
115
116 PointSize26Dot6 FontClient::GetPointSize( FontId id )
117 {
118   return GetImplementation(*this).GetPointSize( id );
119 }
120
121 bool FontClient::IsCharacterSupportedByFont( FontId fontId, Character character )
122 {
123   return GetImplementation(*this).IsCharacterSupportedByFont( fontId, character );
124 }
125
126 FontId FontClient::FindDefaultFont( Character charcode,
127                                     PointSize26Dot6 requestedPointSize,
128                                     bool preferColor )
129 {
130   return GetImplementation(*this).FindDefaultFont( charcode,
131                                                    requestedPointSize,
132                                                    preferColor );
133 }
134
135 FontId FontClient::FindFallbackFont( Character charcode,
136                                      const FontDescription& preferredFontDescription,
137                                      PointSize26Dot6 requestedPointSize,
138                                      bool preferColor )
139 {
140   return GetImplementation(*this).FindFallbackFont( charcode, preferredFontDescription, requestedPointSize, preferColor );
141 }
142
143 FontId FontClient::GetFontId( const FontPath& path, PointSize26Dot6 requestedPointSize, FaceIndex faceIndex )
144 {
145   return GetImplementation(*this).GetFontId( path, requestedPointSize, faceIndex );
146 }
147
148 FontId FontClient::GetFontId( const FontDescription& fontDescription,
149                               PointSize26Dot6 requestedPointSize,
150                               FaceIndex faceIndex )
151 {
152   return GetImplementation(*this).GetFontId( fontDescription,
153                                              requestedPointSize,
154                                              faceIndex );
155 }
156
157 FontId FontClient::GetFontId( const BitmapFont& bitmapFont )
158 {
159   return GetImplementation(*this).GetFontId( bitmapFont );
160 }
161
162 bool FontClient::IsScalable( const FontPath& path )
163 {
164   return GetImplementation(*this).IsScalable( path );
165 }
166
167 bool FontClient::IsScalable( const FontDescription& fontDescription )
168 {
169   return GetImplementation(*this).IsScalable( fontDescription );
170 }
171
172 void FontClient::GetFixedSizes( const FontPath& path, Dali::Vector< PointSize26Dot6>& sizes )
173 {
174   GetImplementation(*this).GetFixedSizes( path, sizes );
175 }
176
177 void FontClient::GetFixedSizes( const FontDescription& fontDescription,
178                                 Dali::Vector< PointSize26Dot6 >& sizes )
179 {
180   GetImplementation(*this).GetFixedSizes( fontDescription, sizes );
181 }
182
183 bool FontClient::HasItalicStyle( FontId fontId ) const
184 {
185   return GetImplementation(*this).HasItalicStyle( fontId );
186 }
187
188 void FontClient::GetFontMetrics( FontId fontId, FontMetrics& metrics )
189 {
190   GetImplementation(*this).GetFontMetrics( fontId, metrics );
191 }
192
193 GlyphIndex FontClient::GetGlyphIndex( FontId fontId, Character charcode )
194 {
195   return GetImplementation(*this).GetGlyphIndex( fontId, charcode );
196 }
197
198 bool FontClient::GetGlyphMetrics( GlyphInfo* array, uint32_t size, GlyphType type, bool horizontal )
199 {
200   return GetImplementation(*this).GetGlyphMetrics( array, size, type, horizontal );
201 }
202
203 void FontClient::CreateBitmap( FontId fontId, GlyphIndex glyphIndex, bool isItalicRequired, bool isBoldRequired, GlyphBufferData& data, int outlineWidth )
204 {
205   GetImplementation(*this).CreateBitmap( fontId, glyphIndex, isItalicRequired, isBoldRequired, data, outlineWidth );
206 }
207
208 PixelData FontClient::CreateBitmap( FontId fontId, GlyphIndex glyphIndex, int outlineWidth )
209 {
210   return GetImplementation(*this).CreateBitmap( fontId, glyphIndex, outlineWidth );
211 }
212
213 void FontClient::CreateVectorBlob( FontId fontId, GlyphIndex glyphIndex, VectorBlob*& blob, unsigned int& blobLength, unsigned int& nominalWidth, unsigned int& nominalHeight )
214 {
215   GetImplementation(*this).CreateVectorBlob( fontId, glyphIndex, blob, blobLength, nominalWidth, nominalHeight );
216 }
217
218 const GlyphInfo& FontClient::GetEllipsisGlyph( PointSize26Dot6 requestedPointSize )
219 {
220   return GetImplementation(*this).GetEllipsisGlyph( requestedPointSize );
221 }
222
223 bool FontClient::IsColorGlyph( FontId fontId, GlyphIndex glyphIndex )
224 {
225   return GetImplementation(*this).IsColorGlyph( fontId, glyphIndex );
226 }
227
228 bool FontClient::AddCustomFontDirectory( const FontPath& path )
229 {
230   return GetImplementation(*this).AddCustomFontDirectory( path );
231 }
232
233 GlyphIndex FontClient::CreateEmbeddedItem(const EmbeddedItemDescription& description, Pixel::Format& pixelFormat)
234 {
235   return GetImplementation(*this).CreateEmbeddedItem( description, pixelFormat);
236 }
237
238 FontClient::FontClient( Internal::FontClient* internal )
239 : BaseHandle( internal )
240 {
241 }
242
243 } // namespace TextAbstraction
244
245 } // namespace Dali