2 * Copyright (c) 2015 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 #include <singleton-service.h>
23 #include <dali/internal/text-abstraction/font-client-plugin-impl.h>
28 namespace TextAbstraction
34 FontClient::FontClient()
41 FontClient::~FontClient()
46 Dali::TextAbstraction::FontClient FontClient::Get()
48 Dali::TextAbstraction::FontClient fontClientHandle;
50 Dali::SingletonService service( SingletonService::Get() );
53 // Check whether the singleton is already created
54 Dali::BaseHandle handle = service.GetSingleton( typeid( Dali::TextAbstraction::FontClient ) );
57 // If so, downcast the handle
58 FontClient* impl = dynamic_cast< Dali::TextAbstraction::Internal::FontClient* >( handle.GetObjectPtr() );
59 fontClientHandle = Dali::TextAbstraction::FontClient( impl );
61 else // create and register the object
63 fontClientHandle = Dali::TextAbstraction::FontClient( new FontClient );
64 service.Register( typeid( fontClientHandle ), fontClientHandle );
68 return fontClientHandle;
71 void FontClient::SetDpi( unsigned int horizontalDpi, unsigned int verticalDpi )
73 mDpiHorizontal = horizontalDpi;
74 mDpiVertical = verticalDpi;
76 // Allow DPI to be set without loading plugin
79 mPlugin->SetDpi( horizontalDpi, verticalDpi );
83 void FontClient::SetDefaultFontFamily( const std::string& fontFamilyName,
84 const std::string& fontStyle )
88 mPlugin->SetDefaultFontFamily( fontFamilyName, fontStyle );
91 void FontClient::GetDefaultFonts( FontList& defaultFonts )
95 mPlugin->GetDefaultFonts( defaultFonts );
98 void FontClient::GetDescription( FontId id, FontDescription& fontDescription )
102 mPlugin->GetDescription( id, fontDescription );
105 PointSize26Dot6 FontClient::GetPointSize( FontId id )
109 return mPlugin->GetPointSize( id );
112 void FontClient::GetSystemFonts( FontList& systemFonts )
116 mPlugin->GetSystemFonts( systemFonts );
119 FontId FontClient::FindDefaultFont( Character charcode, PointSize26Dot6 pointSize )
123 return mPlugin->FindDefaultFont( charcode, pointSize );
126 FontId FontClient::GetFontId( const FontPath& path, PointSize26Dot6 pointSize, FaceIndex faceIndex )
130 return mPlugin->GetFontId( path, pointSize, faceIndex );
133 FontId FontClient::GetFontId( const FontFamily& fontFamily,
134 const FontStyle& fontStyle,
135 PointSize26Dot6 pointSize,
136 FaceIndex faceIndex )
140 return mPlugin->GetFontId( fontFamily,
146 void FontClient::GetFontMetrics( FontId fontId, FontMetrics& metrics )
150 return mPlugin->GetFontMetrics( fontId, metrics );
153 GlyphIndex FontClient::GetGlyphIndex( FontId fontId, Character charcode )
157 return mPlugin->GetGlyphIndex( fontId, charcode );
160 bool FontClient::GetGlyphMetrics( GlyphInfo* array, uint32_t size, bool horizontal )
164 return mPlugin->GetGlyphMetrics( array, size, horizontal );
167 BitmapImage FontClient::CreateBitmap( FontId fontId, GlyphIndex glyphIndex )
171 return mPlugin->CreateBitmap( fontId, glyphIndex );
174 void FontClient::CreatePlugin()
178 mPlugin = new Plugin( mDpiHorizontal, mDpiVertical );
182 } // namespace Internal
184 } // namespace TextAbstraction