2 * Copyright (c) 2019 Samsung Electronics Co., Ltd.
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
19 #include <dali/internal/text/text-abstraction/font-client-impl.h>
22 #ifndef DALI_PROFILE_UBUNTU
27 #include <dali/devel-api/adaptor-framework/singleton-service.h>
28 #include <dali/internal/text/text-abstraction/font-client-plugin-impl.h>
33 namespace TextAbstraction
39 FontClient::FontClient()
46 FontClient::~FontClient()
51 Dali::TextAbstraction::FontClient FontClient::Get()
53 Dali::TextAbstraction::FontClient fontClientHandle;
55 Dali::SingletonService service( SingletonService::Get() );
58 // Check whether the singleton is already created
59 Dali::BaseHandle handle = service.GetSingleton( typeid( Dali::TextAbstraction::FontClient ) );
62 // If so, downcast the handle
63 FontClient* impl = dynamic_cast< Dali::TextAbstraction::Internal::FontClient* >( handle.GetObjectPtr() );
64 fontClientHandle = Dali::TextAbstraction::FontClient( impl );
66 else // create and register the object
68 fontClientHandle = Dali::TextAbstraction::FontClient( new FontClient );
69 service.Register( typeid( fontClientHandle ), fontClientHandle );
73 return fontClientHandle;
76 void FontClient::ClearCache()
80 mPlugin->ClearCache();
85 void FontClient::SetDpi( unsigned int horizontalDpi, unsigned int verticalDpi )
87 mDpiHorizontal = horizontalDpi;
88 mDpiVertical = verticalDpi;
90 // Allow DPI to be set without loading plugin
93 mPlugin->SetDpi( horizontalDpi, verticalDpi );
97 void FontClient::GetDpi( unsigned int& horizontalDpi, unsigned int& verticalDpi )
99 horizontalDpi = mDpiHorizontal;
100 verticalDpi = mDpiVertical;
103 int FontClient::GetDefaultFontSize()
107 #ifndef DALI_PROFILE_UBUNTU
108 vconf_get_int( VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_SIZE, &fontSize );
109 #endif // DALI_PROFILE_UBUNTU
114 void FontClient::ResetSystemDefaults()
118 mPlugin->ResetSystemDefaults();
121 void FontClient::GetDefaultFonts( FontList& defaultFonts )
125 mPlugin->GetDefaultFonts( defaultFonts );
128 void FontClient::GetDefaultPlatformFontDescription( FontDescription& fontDescription )
132 mPlugin->GetDefaultPlatformFontDescription( fontDescription );
135 void FontClient::GetDescription( FontId id, FontDescription& fontDescription )
139 mPlugin->GetDescription( id, fontDescription );
142 PointSize26Dot6 FontClient::GetPointSize( FontId id )
146 return mPlugin->GetPointSize( id );
149 bool FontClient::IsCharacterSupportedByFont( FontId fontId, Character character )
153 return mPlugin->IsCharacterSupportedByFont( fontId, character );
156 void FontClient::GetSystemFonts( FontList& systemFonts )
160 mPlugin->GetSystemFonts( systemFonts );
163 FontId FontClient::FindDefaultFont( Character charcode,
164 PointSize26Dot6 requestedPointSize,
169 return mPlugin->FindDefaultFont( charcode,
174 FontId FontClient::FindFallbackFont( Character charcode,
175 const FontDescription& preferredFontDescription,
176 PointSize26Dot6 requestedPointSize,
181 return mPlugin->FindFallbackFont( charcode,
182 preferredFontDescription,
187 bool FontClient::IsScalable( const FontPath& path )
191 return mPlugin->IsScalable( path );
194 bool FontClient::IsScalable( const FontDescription& fontDescription )
198 return mPlugin->IsScalable( fontDescription );
201 void FontClient::GetFixedSizes( const FontPath& path, Dali::Vector< PointSize26Dot6>& sizes )
205 mPlugin->GetFixedSizes( path, sizes );
208 void FontClient::GetFixedSizes( const FontDescription& fontDescription,
209 Dali::Vector< PointSize26Dot6 >& sizes )
213 mPlugin->GetFixedSizes( fontDescription, sizes );
216 bool FontClient::HasItalicStyle( FontId fontId ) const
223 return mPlugin->HasItalicStyle( fontId );
226 FontId FontClient::GetFontId( const FontPath& path, PointSize26Dot6 requestedPointSize, FaceIndex faceIndex )
230 return mPlugin->GetFontId( path,
236 FontId FontClient::GetFontId( const FontDescription& fontDescription,
237 PointSize26Dot6 requestedPointSize,
238 FaceIndex faceIndex )
242 return mPlugin->GetFontId( fontDescription,
247 FontId FontClient::GetFontId( const BitmapFont& bitmapFont )
251 return mPlugin->GetFontId( bitmapFont );
254 void FontClient::GetFontMetrics( FontId fontId, FontMetrics& metrics )
258 mPlugin->GetFontMetrics( fontId, metrics );
261 GlyphIndex FontClient::GetGlyphIndex( FontId fontId, Character charcode )
265 return mPlugin->GetGlyphIndex( fontId, charcode );
268 bool FontClient::GetGlyphMetrics( GlyphInfo* array, uint32_t size, GlyphType type, bool horizontal )
272 return mPlugin->GetGlyphMetrics( array, size, type, horizontal );
275 void FontClient::CreateBitmap( FontId fontId, GlyphIndex glyphIndex, bool isItalicRequired, bool isBoldRequired, Dali::TextAbstraction::FontClient::GlyphBufferData& data, int outlineWidth )
279 mPlugin->CreateBitmap( fontId, glyphIndex, isItalicRequired, isBoldRequired, data, outlineWidth );
282 PixelData FontClient::CreateBitmap( FontId fontId, GlyphIndex glyphIndex, int outlineWidth )
286 return mPlugin->CreateBitmap( fontId, glyphIndex, outlineWidth );
289 void FontClient::CreateVectorBlob( FontId fontId, GlyphIndex glyphIndex, VectorBlob*& blob, unsigned int& blobLength, unsigned int& nominalWidth, unsigned int& nominalHeight )
293 mPlugin->CreateVectorBlob( fontId, glyphIndex, blob, blobLength, nominalWidth, nominalHeight );
296 const GlyphInfo& FontClient::GetEllipsisGlyph( PointSize26Dot6 requestedPointSize )
300 return mPlugin->GetEllipsisGlyph( requestedPointSize );
303 bool FontClient::IsColorGlyph( FontId fontId, GlyphIndex glyphIndex )
307 return mPlugin->IsColorGlyph( fontId, glyphIndex );
310 GlyphIndex FontClient::CreateEmbeddedItem(const TextAbstraction::FontClient::EmbeddedItemDescription& description, Pixel::Format& pixelFormat)
314 return mPlugin->CreateEmbeddedItem( description, pixelFormat );
317 FT_FaceRec_* FontClient::GetFreetypeFace( FontId fontId )
321 return mPlugin->GetFreetypeFace( fontId );
324 FontDescription::Type FontClient::GetFontType( FontId fontId )
328 return mPlugin->GetFontType( fontId );
331 bool FontClient::AddCustomFontDirectory( const FontPath& path )
335 return mPlugin->AddCustomFontDirectory( path );
338 void FontClient::CreatePlugin()
342 mPlugin = new Plugin( mDpiHorizontal, mDpiVertical );
346 } // namespace Internal
348 } // namespace TextAbstraction