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, bool preferColor )
123 return mPlugin->FindDefaultFont( charcode, pointSize, preferColor );
126 bool FontClient::IsScalable( const FontPath& path )
130 return mPlugin->IsScalable( path );
133 bool FontClient::IsScalable( const FontFamily& fontFamily, const FontStyle& style )
137 return mPlugin->IsScalable( fontFamily, style );
140 void FontClient::GetFixedSizes( const FontPath& path, Dali::Vector< PointSize26Dot6>& sizes )
144 mPlugin->GetFixedSizes( path, sizes );
147 void FontClient::GetFixedSizes( const FontFamily& fontFamily,
148 const FontStyle& style,
149 Dali::Vector< PointSize26Dot6 >& sizes )
153 mPlugin->GetFixedSizes( fontFamily, style, sizes );
156 FontId FontClient::GetFontId( const FontPath& path, PointSize26Dot6 pointSize, FaceIndex faceIndex )
160 return mPlugin->GetFontId( path, pointSize, faceIndex );
163 FontId FontClient::GetFontId( const FontFamily& fontFamily,
164 const FontStyle& fontStyle,
165 PointSize26Dot6 pointSize,
166 FaceIndex faceIndex )
170 return mPlugin->GetFontId( fontFamily,
176 void FontClient::GetFontMetrics( FontId fontId, FontMetrics& metrics )
180 return mPlugin->GetFontMetrics( fontId, metrics );
183 GlyphIndex FontClient::GetGlyphIndex( FontId fontId, Character charcode )
187 return mPlugin->GetGlyphIndex( fontId, charcode );
190 bool FontClient::GetGlyphMetrics( GlyphInfo* array, uint32_t size, bool horizontal )
194 return mPlugin->GetGlyphMetrics( array, size, horizontal );
197 BufferImage FontClient::CreateBitmap( FontId fontId, GlyphIndex glyphIndex )
201 return mPlugin->CreateBitmap( fontId, glyphIndex );
204 void FontClient::CreatePlugin()
208 mPlugin = new Plugin( mDpiHorizontal, mDpiVertical );
212 } // namespace Internal
214 } // namespace TextAbstraction