2 * Copyright (c) 2019 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/devel-api/text-abstraction/font-client.h>
22 #include <dali/internal/text/text-abstraction/font-client-impl.h>
27 namespace TextAbstraction
30 const PointSize26Dot6 FontClient::DEFAULT_POINT_SIZE = 768u; // 12*64
31 const float FontClient::DEFAULT_ITALIC_ANGLE = 12.f * Dali::Math::PI_OVER_180; // FreeType documentation states the software italic is done by doing a horizontal shear of 12 degrees (file ftsynth.h).
33 FontClient::GlyphBufferData::GlyphBufferData()
38 isColorEmoji{ false },
39 isColorBitmap{ false }
43 FontClient::GlyphBufferData::~GlyphBufferData()
47 FontClient FontClient::Get()
49 return Internal::FontClient::Get();
52 FontClient::FontClient()
56 FontClient::~FontClient()
60 FontClient::FontClient( const FontClient& handle )
61 : BaseHandle( handle )
65 FontClient& FontClient::operator=( const FontClient& handle )
67 BaseHandle::operator=( handle );
71 void FontClient::ClearCache()
73 GetImplementation(*this).ClearCache();
76 void FontClient::SetDpi( unsigned int horizontalDpi, unsigned int verticalDpi )
78 GetImplementation(*this).SetDpi( horizontalDpi, verticalDpi );
81 void FontClient::GetDpi( unsigned int& horizontalDpi, unsigned int& verticalDpi )
83 GetImplementation(*this).GetDpi( horizontalDpi, verticalDpi );
86 int FontClient::GetDefaultFontSize()
88 return GetImplementation(*this).GetDefaultFontSize();
91 void FontClient::ResetSystemDefaults()
93 GetImplementation(*this).ResetSystemDefaults();
96 void FontClient::GetDefaultFonts( FontList& defaultFonts )
98 GetImplementation(*this).GetDefaultFonts( defaultFonts );
101 void FontClient::GetDefaultPlatformFontDescription( FontDescription& fontDescription )
103 GetImplementation(*this).GetDefaultPlatformFontDescription( fontDescription );
106 void FontClient::GetSystemFonts( FontList& systemFonts )
108 GetImplementation(*this).GetSystemFonts( systemFonts );
111 void FontClient::GetDescription( FontId id, FontDescription& fontDescription )
113 GetImplementation(*this).GetDescription( id, fontDescription );
116 PointSize26Dot6 FontClient::GetPointSize( FontId id )
118 return GetImplementation(*this).GetPointSize( id );
121 bool FontClient::IsCharacterSupportedByFont( FontId fontId, Character character )
123 return GetImplementation(*this).IsCharacterSupportedByFont( fontId, character );
126 FontId FontClient::FindDefaultFont( Character charcode,
127 PointSize26Dot6 requestedPointSize,
130 return GetImplementation(*this).FindDefaultFont( charcode,
135 FontId FontClient::FindFallbackFont( Character charcode,
136 const FontDescription& preferredFontDescription,
137 PointSize26Dot6 requestedPointSize,
140 return GetImplementation(*this).FindFallbackFont( charcode, preferredFontDescription, requestedPointSize, preferColor );
143 FontId FontClient::GetFontId( const FontPath& path, PointSize26Dot6 requestedPointSize, FaceIndex faceIndex )
145 return GetImplementation(*this).GetFontId( path, requestedPointSize, faceIndex );
148 FontId FontClient::GetFontId( const FontDescription& fontDescription,
149 PointSize26Dot6 requestedPointSize,
150 FaceIndex faceIndex )
152 return GetImplementation(*this).GetFontId( fontDescription,
157 FontId FontClient::GetFontId( const BitmapFont& bitmapFont )
159 return GetImplementation(*this).GetFontId( bitmapFont );
162 bool FontClient::IsScalable( const FontPath& path )
164 return GetImplementation(*this).IsScalable( path );
167 bool FontClient::IsScalable( const FontDescription& fontDescription )
169 return GetImplementation(*this).IsScalable( fontDescription );
172 void FontClient::GetFixedSizes( const FontPath& path, Dali::Vector< PointSize26Dot6>& sizes )
174 GetImplementation(*this).GetFixedSizes( path, sizes );
177 void FontClient::GetFixedSizes( const FontDescription& fontDescription,
178 Dali::Vector< PointSize26Dot6 >& sizes )
180 GetImplementation(*this).GetFixedSizes( fontDescription, sizes );
183 bool FontClient::HasItalicStyle( FontId fontId ) const
185 return GetImplementation(*this).HasItalicStyle( fontId );
188 void FontClient::GetFontMetrics( FontId fontId, FontMetrics& metrics )
190 GetImplementation(*this).GetFontMetrics( fontId, metrics );
193 GlyphIndex FontClient::GetGlyphIndex( FontId fontId, Character charcode )
195 return GetImplementation(*this).GetGlyphIndex( fontId, charcode );
198 bool FontClient::GetGlyphMetrics( GlyphInfo* array, uint32_t size, GlyphType type, bool horizontal )
200 return GetImplementation(*this).GetGlyphMetrics( array, size, type, horizontal );
203 void FontClient::CreateBitmap( FontId fontId, GlyphIndex glyphIndex, bool isItalicRequired, bool isBoldRequired, GlyphBufferData& data, int outlineWidth )
205 GetImplementation(*this).CreateBitmap( fontId, glyphIndex, isItalicRequired, isBoldRequired, data, outlineWidth );
208 PixelData FontClient::CreateBitmap( FontId fontId, GlyphIndex glyphIndex, int outlineWidth )
210 return GetImplementation(*this).CreateBitmap( fontId, glyphIndex, outlineWidth );
213 void FontClient::CreateVectorBlob( FontId fontId, GlyphIndex glyphIndex, VectorBlob*& blob, unsigned int& blobLength, unsigned int& nominalWidth, unsigned int& nominalHeight )
215 GetImplementation(*this).CreateVectorBlob( fontId, glyphIndex, blob, blobLength, nominalWidth, nominalHeight );
218 const GlyphInfo& FontClient::GetEllipsisGlyph( PointSize26Dot6 requestedPointSize )
220 return GetImplementation(*this).GetEllipsisGlyph( requestedPointSize );
223 bool FontClient::IsColorGlyph( FontId fontId, GlyphIndex glyphIndex )
225 return GetImplementation(*this).IsColorGlyph( fontId, glyphIndex );
228 bool FontClient::AddCustomFontDirectory( const FontPath& path )
230 return GetImplementation(*this).AddCustomFontDirectory( path );
233 GlyphIndex FontClient::CreateEmbeddedItem(const EmbeddedItemDescription& description, Pixel::Format& pixelFormat)
235 return GetImplementation(*this).CreateEmbeddedItem( description, pixelFormat);
238 FontClient::FontClient( Internal::FontClient* internal )
239 : BaseHandle( internal )
243 } // namespace TextAbstraction