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