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::GetDescription( FontId id, FontDescription& fontDescription )
88 PointSize26Dot6 FontClient::GetPointSize( FontId id )
92 return mPlugin->GetPointSize( id );
95 void FontClient::GetSystemFonts( FontList& systemFonts )
99 mPlugin->GetSystemFonts( systemFonts );
102 FontId FontClient::FindDefaultFont( Character charcode, PointSize26Dot6 pointSize )
106 return mPlugin->FindDefaultFont( charcode, pointSize );
109 FontId FontClient::GetFontId( const FontPath& path, PointSize26Dot6 pointSize, FaceIndex faceIndex )
113 return mPlugin->GetFontId( path, pointSize, faceIndex );
116 FontId FontClient::GetFontId( const FontFamily& fontFamily,
117 const FontStyle& fontStyle,
118 PointSize26Dot6 pointSize,
119 FaceIndex faceIndex )
123 return mPlugin->GetFontId( fontFamily,
129 void FontClient::GetFontMetrics( FontId fontId, FontMetrics& metrics )
133 return mPlugin->GetFontMetrics( fontId, metrics );
136 GlyphIndex FontClient::GetGlyphIndex( FontId fontId, Character charcode )
140 return mPlugin->GetGlyphIndex( fontId, charcode );
143 bool FontClient::GetGlyphMetrics( GlyphInfo* array, uint32_t size, bool horizontal )
147 return mPlugin->GetGlyphMetrics( array, size, horizontal );
150 BitmapImage FontClient::CreateBitmap( FontId fontId, GlyphIndex glyphIndex )
154 return mPlugin->CreateBitmap( fontId, glyphIndex );
157 void FontClient::CreatePlugin()
161 mPlugin = new Plugin( mDpiHorizontal, mDpiVertical );
162 mPlugin->Initialize();
166 } // namespace Internal
168 } // namespace TextAbstraction