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-abstraction/font-client-impl.h>
22 #ifndef DALI_PROFILE_UBUNTU
27 #include <singleton-service.h>
28 #include <dali/internal/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 FontId FontClient::GetFontId( const FontPath& path, PointSize26Dot6 requestedPointSize, FaceIndex faceIndex )
220 return mPlugin->GetFontId( path,
226 FontId FontClient::GetFontId( const FontDescription& fontDescription,
227 PointSize26Dot6 requestedPointSize,
228 FaceIndex faceIndex )
232 return mPlugin->GetFontId( fontDescription,
237 void FontClient::GetFontMetrics( FontId fontId, FontMetrics& metrics )
241 return mPlugin->GetFontMetrics( fontId, metrics );
244 GlyphIndex FontClient::GetGlyphIndex( FontId fontId, Character charcode )
248 return mPlugin->GetGlyphIndex( fontId, charcode );
251 bool FontClient::GetGlyphMetrics( GlyphInfo* array, uint32_t size, GlyphType type, bool horizontal )
255 return mPlugin->GetGlyphMetrics( array, size, type, horizontal );
258 void FontClient::CreateBitmap( FontId fontId, GlyphIndex glyphIndex, Dali::TextAbstraction::FontClient::GlyphBufferData& data, int outlineWidth )
262 mPlugin->CreateBitmap( fontId, glyphIndex, data, outlineWidth );
265 PixelData FontClient::CreateBitmap( FontId fontId, GlyphIndex glyphIndex, int outlineWidth )
269 return mPlugin->CreateBitmap( fontId, glyphIndex, outlineWidth );
272 void FontClient::CreateVectorBlob( FontId fontId, GlyphIndex glyphIndex, VectorBlob*& blob, unsigned int& blobLength, unsigned int& nominalWidth, unsigned int& nominalHeight )
276 return mPlugin->CreateVectorBlob( fontId, glyphIndex, blob, blobLength, nominalWidth, nominalHeight );
279 const GlyphInfo& FontClient::GetEllipsisGlyph( PointSize26Dot6 requestedPointSize )
283 return mPlugin->GetEllipsisGlyph( requestedPointSize );
286 bool FontClient::IsColorGlyph( FontId fontId, GlyphIndex glyphIndex )
290 return mPlugin->IsColorGlyph( fontId, glyphIndex );
293 bool FontClient::AddCustomFontDirectory( const FontPath& path )
297 return mPlugin->AddCustomFontDirectory( path );
300 void FontClient::CreatePlugin()
304 mPlugin = new Plugin( mDpiHorizontal, mDpiVertical );
308 } // namespace Internal
310 } // namespace TextAbstraction