2 * Copyright (c) 2017 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::SetDpi( unsigned int horizontalDpi, unsigned int verticalDpi )
78 mDpiHorizontal = horizontalDpi;
79 mDpiVertical = verticalDpi;
81 // Allow DPI to be set without loading plugin
84 mPlugin->SetDpi( horizontalDpi, verticalDpi );
88 void FontClient::GetDpi( unsigned int& horizontalDpi, unsigned int& verticalDpi )
90 horizontalDpi = mDpiHorizontal;
91 verticalDpi = mDpiVertical;
94 int FontClient::GetDefaultFontSize()
98 #ifndef DALI_PROFILE_UBUNTU
99 vconf_get_int( VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_SIZE, &fontSize );
100 #endif // DALI_PROFILE_UBUNTU
105 void FontClient::ResetSystemDefaults()
109 mPlugin->ResetSystemDefaults();
112 void FontClient::GetDefaultFonts( FontList& defaultFonts )
116 mPlugin->GetDefaultFonts( defaultFonts );
119 void FontClient::GetDefaultPlatformFontDescription( FontDescription& fontDescription )
123 mPlugin->GetDefaultPlatformFontDescription( fontDescription );
126 void FontClient::GetDescription( FontId id, FontDescription& fontDescription )
130 mPlugin->GetDescription( id, fontDescription );
133 PointSize26Dot6 FontClient::GetPointSize( FontId id )
137 return mPlugin->GetPointSize( id );
140 bool FontClient::IsCharacterSupportedByFont( FontId fontId, Character character )
144 return mPlugin->IsCharacterSupportedByFont( fontId, character );
147 void FontClient::GetSystemFonts( FontList& systemFonts )
151 mPlugin->GetSystemFonts( systemFonts );
154 FontId FontClient::FindDefaultFont( Character charcode,
155 PointSize26Dot6 requestedPointSize,
160 return mPlugin->FindDefaultFont( charcode,
165 FontId FontClient::FindFallbackFont( Character charcode,
166 const FontDescription& preferredFontDescription,
167 PointSize26Dot6 requestedPointSize,
172 return mPlugin->FindFallbackFont( charcode,
173 preferredFontDescription,
178 bool FontClient::IsScalable( const FontPath& path )
182 return mPlugin->IsScalable( path );
185 bool FontClient::IsScalable( const FontDescription& fontDescription )
189 return mPlugin->IsScalable( fontDescription );
192 void FontClient::GetFixedSizes( const FontPath& path, Dali::Vector< PointSize26Dot6>& sizes )
196 mPlugin->GetFixedSizes( path, sizes );
199 void FontClient::GetFixedSizes( const FontDescription& fontDescription,
200 Dali::Vector< PointSize26Dot6 >& sizes )
204 mPlugin->GetFixedSizes( fontDescription, sizes );
207 FontId FontClient::GetFontId( const FontPath& path, PointSize26Dot6 requestedPointSize, FaceIndex faceIndex )
211 return mPlugin->GetFontId( path,
217 FontId FontClient::GetFontId( const FontDescription& fontDescription,
218 PointSize26Dot6 requestedPointSize,
219 FaceIndex faceIndex )
223 return mPlugin->GetFontId( fontDescription,
228 void FontClient::GetFontMetrics( FontId fontId, FontMetrics& metrics )
232 return mPlugin->GetFontMetrics( fontId, metrics );
235 GlyphIndex FontClient::GetGlyphIndex( FontId fontId, Character charcode )
239 return mPlugin->GetGlyphIndex( fontId, charcode );
242 bool FontClient::GetGlyphMetrics( GlyphInfo* array, uint32_t size, GlyphType type, bool horizontal )
246 return mPlugin->GetGlyphMetrics( array, size, type, horizontal );
249 void FontClient::CreateBitmap( FontId fontId, GlyphIndex glyphIndex, bool softwareItalic, bool softwareBold, Dali::TextAbstraction::FontClient::GlyphBufferData& data, int outlineWidth )
253 mPlugin->CreateBitmap( fontId, glyphIndex, softwareItalic, softwareBold, data, outlineWidth );
256 PixelData FontClient::CreateBitmap( FontId fontId, GlyphIndex glyphIndex, int outlineWidth )
260 return mPlugin->CreateBitmap( fontId, glyphIndex, outlineWidth );
263 void FontClient::CreateVectorBlob( FontId fontId, GlyphIndex glyphIndex, VectorBlob*& blob, unsigned int& blobLength, unsigned int& nominalWidth, unsigned int& nominalHeight )
267 return mPlugin->CreateVectorBlob( fontId, glyphIndex, blob, blobLength, nominalWidth, nominalHeight );
270 const GlyphInfo& FontClient::GetEllipsisGlyph( PointSize26Dot6 requestedPointSize )
274 return mPlugin->GetEllipsisGlyph( requestedPointSize );
277 bool FontClient::IsColorGlyph( FontId fontId, GlyphIndex glyphIndex )
281 return mPlugin->IsColorGlyph( fontId, glyphIndex );
284 FT_FaceRec_* FontClient::GetFreetypeFace( FontId fontId )
288 return mPlugin->GetFreetypeFace( fontId );
291 bool FontClient::AddCustomFontDirectory( const FontPath& path )
295 return mPlugin->AddCustomFontDirectory( path );
298 void FontClient::CreatePlugin()
302 mPlugin = new Plugin( mDpiHorizontal, mDpiVertical );
306 } // namespace Internal
308 } // namespace TextAbstraction