2 * Copyright (c) 2022 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/text-abstraction/plugin/font-client-plugin-impl.h>
22 #include <dali/devel-api/text-abstraction/font-list.h>
23 #include <dali/integration-api/debug.h>
24 #include <dali/integration-api/trace.h>
25 #include <dali/integration-api/platform-abstraction.h>
26 #include <dali/internal/adaptor/common/adaptor-impl.h>
27 #include <dali/internal/imaging/common/image-operations.h>
28 #include <dali/internal/text/text-abstraction/plugin/bitmap-font-cache-item.h>
29 #include <dali/internal/text/text-abstraction/plugin/embedded-item.h>
30 #include <dali/internal/text/text-abstraction/plugin/font-client-plugin-cache-handler.h>
31 #include <dali/internal/text/text-abstraction/plugin/font-client-utils.h>
32 #include <dali/internal/text/text-abstraction/plugin/font-face-cache-item.h>
33 #include <dali/public-api/common/dali-vector.h>
34 #include <dali/public-api/common/vector-wrapper.h>
37 #include <fontconfig/fontconfig.h>
41 #if defined(DEBUG_ENABLED)
43 // Note, to turn on trace and verbose logging, use "export LOG_FONT_CLIENT=3,true"
44 // Or re-define the following filter using Verbose,true instead of NoLogging,false,
45 // Or, add DALI_LOG_FILTER_ENABLE_TRACE(gFontClientLogFilter) in the code below.
47 Dali::Integration::Log::Filter* gFontClientLogFilter = Dali::Integration::Log::Filter::New(Debug::NoLogging, false, "LOG_FONT_CLIENT");
49 #define FONT_LOG_DESCRIPTION(fontDescription, prefix) \
50 DALI_LOG_INFO(gFontClientLogFilter, Debug::General, #prefix " description; family : [%s]\n", fontDescription.family.c_str()); \
51 DALI_LOG_INFO(gFontClientLogFilter, Debug::Verbose, \
55 " slant : [%s]\n\n", \
56 fontDescription.path.c_str(), \
57 FontWidth::Name[fontDescription.width], \
58 FontWeight::Name[fontDescription.weight], \
59 FontSlant::Name[fontDescription.slant])
61 #define FONT_LOG_REQUEST(charcode, requestedPointSize, preferColor) \
62 DALI_LOG_INFO(gFontClientLogFilter, Debug::General, \
64 " requestedPointSize : %d\n" \
65 " preferColor : %s\n", \
68 (preferColor ? "true" : "false"))
72 #define FONT_LOG_DESCRIPTION(fontDescription, prefix)
73 #define FONT_LOG_REQUEST(charcode, requestedPointSize, preferColor)
80 DALI_INIT_TRACE_FILTER(gTraceFilter, DALI_TRACE_FONT_PERFORMANCE_MARKER, false);
83 * Conversion from Fractional26.6 to float
85 const float FROM_266 = 1.0f / 64.0f;
86 const float POINTS_PER_INCH = 72.f;
88 const uint32_t ELLIPSIS_CHARACTER = 0x2026;
94 namespace Dali::TextAbstraction::Internal
99 * @brief Check if @p ftFace and @p requestedPointSize produces block that fit into atlas block
101 * @param[in/out] ftFace Face type object.
102 * @param[in] horizontalDpi The horizontal dpi.
103 * @param[in] verticalDpi The vertical dpi.
104 * @param[in] maxSizeFitInAtlas The maximum size of block to fit into atlas
105 * @param[in] requestedPointSize The requested point-size.
106 * @return whether the ftFace's block can fit into atlas
108 bool IsFitIntoAtlas(FT_Face& ftFace, int& error, const unsigned int& horizontalDpi, const unsigned int& verticalDpi, const Size& maxSizeFitInAtlas, const uint32_t& requestedPointSize)
112 error = FT_Set_Char_Size(ftFace,
118 if(error == FT_Err_Ok)
120 //Check width and height of block for requestedPointSize
121 //If the width or height is greater than the maximum-size then decrement by one unit of point-size.
122 if(static_cast<float>(ftFace->size->metrics.height) * FROM_266 <= maxSizeFitInAtlas.height && (static_cast<float>(ftFace->size->metrics.ascender) - static_cast<float>(ftFace->size->metrics.descender)) * FROM_266 <= maxSizeFitInAtlas.width)
132 * @brief Search on proper @p requestedPointSize that produces block that fit into atlas block considering on @p ftFace, @p horizontalDpi, and @p verticalDpi
134 * @param[in/out] ftFace Face type object.
135 * @param[in] horizontalDpi The horizontal dpi.
136 * @param[in] verticalDpi The vertical dpi.
137 * @param[in] maxSizeFitInAtlas The maximum size of block to fit into atlas
138 * @param[in/out] requestedPointSize The requested point-size.
139 * @return FreeType error code. 0 means success when requesting the nominal size (in points).
141 int SearchOnProperPointSize(FT_Face& ftFace, const unsigned int& horizontalDpi, const unsigned int& verticalDpi, const Size& maxSizeFitInAtlas, uint32_t& requestedPointSize)
143 //To improve performance of sequential search. This code is applying Exponential search then followed by Binary search.
144 const uint32_t& pointSizePerOneUnit = TextAbstraction::FontClient::NUMBER_OF_POINTS_PER_ONE_UNIT_OF_POINT_SIZE;
146 int error; // FreeType error code.
148 canFitInAtlas = IsFitIntoAtlas(ftFace, error, horizontalDpi, verticalDpi, maxSizeFitInAtlas, requestedPointSize);
149 if(FT_Err_Ok != error)
157 uint32_t exponentialDecrement = 1;
159 while(!canFitInAtlas && requestedPointSize > pointSizePerOneUnit * exponentialDecrement)
161 requestedPointSize -= (pointSizePerOneUnit * exponentialDecrement);
162 canFitInAtlas = IsFitIntoAtlas(ftFace, error, horizontalDpi, verticalDpi, maxSizeFitInAtlas, requestedPointSize);
163 if(FT_Err_Ok != error)
168 exponentialDecrement *= 2;
172 uint32_t minPointSize;
173 uint32_t maxPointSize;
177 exponentialDecrement /= 2;
178 minPointSize = requestedPointSize;
179 maxPointSize = requestedPointSize + (pointSizePerOneUnit * exponentialDecrement);
184 maxPointSize = requestedPointSize;
187 while(minPointSize < maxPointSize)
189 requestedPointSize = ((maxPointSize / pointSizePerOneUnit - minPointSize / pointSizePerOneUnit) / 2) * pointSizePerOneUnit + minPointSize;
190 canFitInAtlas = IsFitIntoAtlas(ftFace, error, horizontalDpi, verticalDpi, maxSizeFitInAtlas, requestedPointSize);
191 if(FT_Err_Ok != error)
198 if(minPointSize == requestedPointSize)
200 //Found targeted point-size
204 minPointSize = requestedPointSize;
208 maxPointSize = requestedPointSize;
218 FontClient::Plugin::Plugin(unsigned int horizontalDpi,
219 unsigned int verticalDpi)
220 : mFreeTypeLibrary(nullptr),
221 mDpiHorizontal(horizontalDpi),
222 mDpiVertical(verticalDpi),
223 mIsAtlasLimitationEnabled(TextAbstraction::FontClient::DEFAULT_ATLAS_LIMITATION_ENABLED),
224 mCurrentMaximumBlockSizeFitInAtlas(TextAbstraction::FontClient::MAX_SIZE_FIT_IN_ATLAS),
225 mVectorFontCache(nullptr),
226 mCacheHandler(new CacheHandler())
228 int error = FT_Init_FreeType(&mFreeTypeLibrary);
229 if(FT_Err_Ok != error)
231 DALI_LOG_INFO(gFontClientLogFilter, Debug::General, "FreeType Init error: %d\n", error);
234 #ifdef ENABLE_VECTOR_BASED_TEXT_RENDERING
235 mVectorFontCache = new VectorFontCache(mFreeTypeLibrary);
239 FontClient::Plugin::~Plugin()
241 // Delete cache hanlder before remove mFreeTypeLibrary
242 delete mCacheHandler;
244 #ifdef ENABLE_VECTOR_BASED_TEXT_RENDERING
245 delete mVectorFontCache;
248 FT_Done_FreeType(mFreeTypeLibrary);
251 void FontClient::Plugin::ClearCache() const
253 mCacheHandler->ClearCache();
256 void FontClient::Plugin::SetDpi(unsigned int horizontalDpi,
257 unsigned int verticalDpi)
259 mDpiHorizontal = horizontalDpi;
260 mDpiVertical = verticalDpi;
263 void FontClient::Plugin::ResetSystemDefaults() const
265 mCacheHandler->ResetSystemDefaults();
268 void FontClient::Plugin::FontPreCache(const FontFamilyList& fallbackFamilyList, const FontFamilyList& extraFamilyList, const FontFamily& localeFamily) const
270 mCacheHandler->InitDefaultFontDescription();
272 FontFamilyList familyList;
273 familyList.reserve(extraFamilyList.size() + 1);
275 for (const auto& fallbackFont : fallbackFamilyList)
277 FontList* fontList = nullptr;
278 CharacterSetList* characterSetList = nullptr;
279 FontDescriptionId fontDescriptionId = 0u;
280 FontDescription fontDescription;
281 fontDescription.family = FontFamily(fallbackFont);
282 fontDescription.weight = DefaultFontWeight();
283 fontDescription.width = DefaultFontWidth();
284 fontDescription.slant = DefaultFontSlant();
286 if(!mCacheHandler->FindFallbackFontList(fontDescription, fontList, characterSetList))
288 mCacheHandler->CacheFallbackFontList(std::move(fontDescription), fontList, characterSetList);
290 if(!mCacheHandler->FindValidatedFont(fontDescription, fontDescriptionId))
292 mCacheHandler->ValidateFont(fontDescription, fontDescriptionId);
295 if(extraFamilyList.empty() && localeFamily.empty())
301 familyList.insert(familyList.end(), extraFamilyList.begin(), extraFamilyList.end());
302 if(!localeFamily.empty())
304 familyList.push_back(localeFamily);
307 for(const auto& font : *fontList)
309 auto it = std::find(familyList.begin(), familyList.end(), font.family);
310 if(it != familyList.end())
312 if(!mCacheHandler->FindValidatedFont(font, fontDescriptionId))
314 mCacheHandler->ValidateFont(font, fontDescriptionId);
316 familyList.erase(it);
322 void FontClient::Plugin::GetDefaultPlatformFontDescription(FontDescription& fontDescription) const
324 DALI_LOG_TRACE_METHOD(gFontClientLogFilter);
326 mCacheHandler->InitDefaultFontDescription();
327 fontDescription = mCacheHandler->mDefaultFontDescription;
329 FONT_LOG_DESCRIPTION(fontDescription, "");
332 void FontClient::Plugin::GetDefaultFonts(FontList& defaultFonts) const
334 DALI_LOG_TRACE_METHOD(gFontClientLogFilter);
336 mCacheHandler->InitDefaultFonts();
337 defaultFonts = mCacheHandler->mDefaultFonts;
339 DALI_LOG_INFO(gFontClientLogFilter, Debug::General, " number of default fonts : [%d]\n", mCacheHandler->mDefaultFonts.size());
342 void FontClient::Plugin::GetSystemFonts(FontList& systemFonts) const
344 DALI_LOG_TRACE_METHOD(gFontClientLogFilter);
346 mCacheHandler->InitSystemFonts();
347 systemFonts = mCacheHandler->mSystemFonts;
349 DALI_LOG_INFO(gFontClientLogFilter, Debug::General, " number of system fonts : [%d]\n", mCacheHandler->mSystemFonts.size());
352 void FontClient::Plugin::GetDescription(FontId fontId,
353 FontDescription& fontDescription) const
355 DALI_LOG_TRACE_METHOD(gFontClientLogFilter);
356 DALI_LOG_INFO(gFontClientLogFilter, Debug::General, " font id : %d\n", fontId);
358 if((fontId > 0u) && (fontId - 1u < mCacheHandler->mFontIdCache.size()))
360 const auto& fontIdCacheItem = mCacheHandler->mFontIdCache[fontId - 1u];
361 switch(fontIdCacheItem.type)
363 case FontDescription::FACE_FONT:
365 for(const auto& item : mCacheHandler->mFontDescriptionSizeCache)
367 if(item.second == fontIdCacheItem.index)
369 fontDescription = *(mCacheHandler->mFontDescriptionCache.begin() + item.first.fontDescriptionId - 1u);
371 FONT_LOG_DESCRIPTION(fontDescription, "");
377 case FontDescription::BITMAP_FONT:
379 fontDescription.type = FontDescription::BITMAP_FONT;
380 fontDescription.family = mCacheHandler->mBitmapFontCache[fontIdCacheItem.index].font.name;
385 DALI_LOG_INFO(gFontClientLogFilter, Debug::General, " Invalid type of font\n");
386 fontDescription.type = FontDescription::INVALID;
387 fontDescription.family.clear();
392 DALI_LOG_INFO(gFontClientLogFilter, Debug::General, " No description found for the font id %d\n", fontId);
395 PointSize26Dot6 FontClient::Plugin::GetPointSize(FontId fontId) const
397 DALI_LOG_TRACE_METHOD(gFontClientLogFilter);
398 DALI_LOG_INFO(gFontClientLogFilter, Debug::General, " font id : %d\n", fontId);
400 PointSize26Dot6 pointSize = TextAbstraction::FontClient::DEFAULT_POINT_SIZE;
401 const FontCacheItemInterface* fontCacheItem = GetCachedFontItem(fontId);
402 if(fontCacheItem != nullptr)
404 pointSize = fontCacheItem->GetPointSize();
406 DALI_LOG_INFO(gFontClientLogFilter, Debug::General, " point size : %d\n", pointSize);
411 bool FontClient::Plugin::IsCharacterSupportedByFont(FontId fontId, Character character) const
413 DALI_LOG_TRACE_METHOD(gFontClientLogFilter);
414 DALI_LOG_INFO(gFontClientLogFilter, Debug::General, " font id : %d\n", fontId);
415 DALI_LOG_INFO(gFontClientLogFilter, Debug::General, " character : %p\n", character);
417 bool isSupported = false;
418 auto fontCacheItem = const_cast<FontCacheItemInterface*>(GetCachedFontItem(fontId));
419 if(fontCacheItem != nullptr)
421 isSupported = fontCacheItem->IsCharacterSupported(character); // May cache
424 DALI_LOG_INFO(gFontClientLogFilter, Debug::General, " is supported : %s\n", (isSupported ? "true" : "false"));
428 const FontCacheItemInterface* FontClient::Plugin::GetCachedFontItem(FontId fontId) const
430 if((fontId > 0u) && (fontId - 1u < mCacheHandler->mFontIdCache.size()))
432 const auto& fontIdCacheItem = mCacheHandler->mFontIdCache[fontId - 1u];
433 switch(fontIdCacheItem.type)
435 case FontDescription::FACE_FONT:
437 return &mCacheHandler->mFontFaceCache[fontIdCacheItem.index];
439 case FontDescription::BITMAP_FONT:
441 return &mCacheHandler->mBitmapFontCache[fontIdCacheItem.index];
445 DALI_LOG_INFO(gFontClientLogFilter, Debug::General, " Invalid type of font\n");
452 FontId FontClient::Plugin::FindFontForCharacter(const FontList& fontList,
453 const CharacterSetList& characterSetList,
455 PointSize26Dot6 requestedPointSize,
456 bool preferColor) const
458 DALI_ASSERT_DEBUG((fontList.size() == characterSetList.Count()) && "FontClient::Plugin::FindFontForCharacter. Different number of fonts and character sets.");
459 DALI_LOG_TRACE_METHOD(gFontClientLogFilter);
460 DALI_LOG_INFO(gFontClientLogFilter, Debug::General, " character : %p\n", character);
461 DALI_LOG_INFO(gFontClientLogFilter, Debug::General, " requestedPointSize : %d\n", requestedPointSize);
462 DALI_LOG_INFO(gFontClientLogFilter, Debug::General, " preferColor : %s\n", (preferColor ? "true" : "false"));
465 bool foundColor = false;
467 DALI_LOG_INFO(gFontClientLogFilter, Debug::General, " number of fonts : %d\n", fontList.size());
469 // Traverse the list of fonts.
470 // Check for each font if supports the character.
471 for(unsigned int index = 0u, numberOfFonts = fontList.size(); index < numberOfFonts; ++index)
473 const FontDescription& description = fontList[index];
474 const FcCharSet* const characterSet = characterSetList[index];
476 FONT_LOG_DESCRIPTION(description, "");
478 bool foundInRanges = false;
479 if(nullptr != characterSet)
481 foundInRanges = FcCharSetHasChar(characterSet, character);
486 fontId = GetFontId(description, requestedPointSize, 0u);
488 DALI_LOG_INFO(gFontClientLogFilter, Debug::Verbose, " font id : %d\n", fontId);
492 if((fontId > 0) && (fontId - 1u < mCacheHandler->mFontIdCache.size()))
494 const FontFaceCacheItem& item = mCacheHandler->mFontFaceCache[mCacheHandler->mFontIdCache[fontId - 1u].index];
496 foundColor = item.mHasColorTables;
499 DALI_LOG_INFO(gFontClientLogFilter, Debug::Verbose, " foundColor : %s\n", (foundColor ? "true" : "false"));
502 // Keep going unless we prefer a different (color) font.
503 if(!preferColor || foundColor)
510 DALI_LOG_INFO(gFontClientLogFilter, Debug::General, " font id : %d\n", fontId);
514 FontId FontClient::Plugin::FindDefaultFont(Character charcode,
515 PointSize26Dot6 requestedPointSize,
516 bool preferColor) const
518 DALI_LOG_TRACE_METHOD(gFontClientLogFilter);
519 FONT_LOG_REQUEST(charcode, requestedPointSize, preferColor);
523 // Create the list of default fonts if it has not been created.
524 mCacheHandler->InitDefaultFonts();
525 DALI_LOG_INFO(gFontClientLogFilter, Debug::Verbose, " number of default fonts : %d\n", mCacheHandler->mDefaultFonts.size());
527 // Traverse the list of default fonts.
528 // Check for each default font if supports the character.
529 fontId = FindFontForCharacter(mCacheHandler->mDefaultFonts, mCacheHandler->mDefaultFontCharacterSets, charcode, requestedPointSize, preferColor);
531 DALI_LOG_INFO(gFontClientLogFilter, Debug::General, " font id : %d\n", fontId);
535 FontId FontClient::Plugin::FindFallbackFont(Character charcode,
536 const FontDescription& preferredFontDescription,
537 PointSize26Dot6 requestedPointSize,
538 bool preferColor) const
540 DALI_LOG_TRACE_METHOD(gFontClientLogFilter);
541 FONT_LOG_REQUEST(charcode, requestedPointSize, preferColor);
543 DALI_TRACE_SCOPE(gTraceFilter, "DALI_TEXT_FIND_FALLBACKFONT");
545 // The font id to be returned.
548 FontDescription fontDescription;
550 // Fill the font description with the preferred font description and complete with the defaults.
551 fontDescription.family = preferredFontDescription.family.empty() ? DefaultFontFamily() : preferredFontDescription.family;
552 fontDescription.weight = ((FontWeight::NONE == preferredFontDescription.weight) ? DefaultFontWeight() : preferredFontDescription.weight);
553 fontDescription.width = ((FontWidth::NONE == preferredFontDescription.width) ? DefaultFontWidth() : preferredFontDescription.width);
554 fontDescription.slant = ((FontSlant::NONE == preferredFontDescription.slant) ? DefaultFontSlant() : preferredFontDescription.slant);
556 DALI_LOG_INFO(gFontClientLogFilter, Debug::General, " preferredFontDescription --> fontDescription\n");
557 DALI_LOG_INFO(gFontClientLogFilter, Debug::General, " [%s] --> [%s]\n", preferredFontDescription.family.c_str(), fontDescription.family.c_str());
558 DALI_LOG_INFO(gFontClientLogFilter, Debug::Verbose, " [%s] --> [%s]\n", FontWeight::Name[preferredFontDescription.weight], FontWeight::Name[fontDescription.weight]);
559 DALI_LOG_INFO(gFontClientLogFilter, Debug::Verbose, " [%s] --> [%s]\n", FontWidth::Name[preferredFontDescription.width], FontWidth::Name[fontDescription.width]);
560 DALI_LOG_INFO(gFontClientLogFilter, Debug::Verbose, " [%s] --> [%s]\n", FontSlant::Name[preferredFontDescription.slant], FontSlant::Name[fontDescription.slant]);
562 #if defined(TRACE_ENABLED)
563 if(gTraceFilter && gTraceFilter->IsTraceEnabled())
565 DALI_LOG_DEBUG_INFO("DALI_TEXT_FIND_FALLBACKFONT : %s -> %s\n", preferredFontDescription.family.c_str(), fontDescription.family.c_str());
569 // Check first if the font's description has been queried before.
570 FontList* fontList = nullptr;
571 CharacterSetList* characterSetList = nullptr;
573 if(!mCacheHandler->FindFallbackFontList(fontDescription, fontList, characterSetList))
575 mCacheHandler->CacheFallbackFontList(std::move(fontDescription), fontList, characterSetList);
578 if(fontList && characterSetList)
580 fontId = FindFontForCharacter(*fontList, *characterSetList, charcode, requestedPointSize, preferColor);
583 DALI_LOG_INFO(gFontClientLogFilter, Debug::General, " font id : %d\n", fontId);
587 FontId FontClient::Plugin::GetFontIdByPath(const FontPath& path,
588 PointSize26Dot6 requestedPointSize,
590 bool cacheDescription) const
592 DALI_LOG_TRACE_METHOD(gFontClientLogFilter);
593 DALI_LOG_INFO(gFontClientLogFilter, Debug::General, " path : [%s]\n", path.c_str());
594 DALI_LOG_INFO(gFontClientLogFilter, Debug::General, " requestedPointSize : %d\n", requestedPointSize);
598 if(nullptr != mFreeTypeLibrary)
601 if(mCacheHandler->FindFontByPath(path, requestedPointSize, faceIndex, foundId))
607 id = CreateFont(path, requestedPointSize, faceIndex, cacheDescription);
611 DALI_LOG_INFO(gFontClientLogFilter, Debug::General, " font id : %d\n", id);
615 FontId FontClient::Plugin::GetFontId(const FontDescription& fontDescription,
616 PointSize26Dot6 requestedPointSize,
617 FaceIndex faceIndex) const
619 DALI_LOG_TRACE_METHOD(gFontClientLogFilter);
620 FONT_LOG_DESCRIPTION(fontDescription, "");
622 // Special case when font Description don't have family information.
623 // In this case, we just use default description family and path.
624 const FontDescription& realFontDescription = fontDescription.family.empty() ? FontDescription(mCacheHandler->mDefaultFontDescription.path,
625 mCacheHandler->mDefaultFontDescription.family,
626 fontDescription.width,
627 fontDescription.weight,
628 fontDescription.slant,
629 fontDescription.type)
632 FONT_LOG_DESCRIPTION(realFontDescription, "");
633 DALI_LOG_INFO(gFontClientLogFilter, Debug::General, " requestedPointSize : %d\n", requestedPointSize);
635 // This method uses three vectors which caches:
636 // * The bitmap font cache
637 // * Pairs of non validated font descriptions and an index to a vector with paths to font file names.
638 // * The path to font file names.
639 // * The font ids of pairs 'font point size, index to the vector with paths to font file names'.
641 // 1) Checks if the font description matches with a previously loaded bitmap font.
642 // Returns if a font is found.
643 // 2) Checks in the cache if the font's description has been validated before.
644 // If it was it gets an index to the vector with paths to font file names. Otherwise,
645 // retrieves using font config a path to a font file name which matches with the
646 // font's description. The path is stored in the cache.
648 // 3) Checks in the cache if the pair 'font point size, index to the vector with paths to
649 // font file names' exists. If exists, it gets the font id. If it doesn't it calls
650 // the GetFontId() method with the path to the font file name and the point size to
653 // The font id to be returned.
656 // Check first if the font description matches with a previously loaded bitmap font.
657 if(mCacheHandler->FindBitmapFont(realFontDescription.family, fontId))
662 // Check if the font's description have been validated before.
663 FontDescriptionId fontDescriptionId = 0u;
665 if(!mCacheHandler->FindValidatedFont(realFontDescription, fontDescriptionId))
667 // Use font config to validate the font's description.
668 mCacheHandler->ValidateFont(realFontDescription, fontDescriptionId);
671 using FontCacheIndex = CacheHandler::FontCacheIndex;
672 FontCacheIndex fontCacheIndex = 0u;
673 // Check if exists a pair 'fontDescriptionId, requestedPointSize' in the cache.
674 if(!mCacheHandler->FindFont(fontDescriptionId, requestedPointSize, fontCacheIndex))
676 // Retrieve the font file name path.
677 const FontDescription& description = *(mCacheHandler->mFontDescriptionCache.begin() + fontDescriptionId - 1u);
679 // Retrieve the font id. Do not cache the description as it has been already cached.
680 // Note : CacheFontPath() API call ValidateFont() + setup CharacterSet + cache the font description.
681 // So set cacheDescription=false, that we don't call CacheFontPath().
682 fontId = GetFontIdByPath(description.path, requestedPointSize, faceIndex, false);
684 if((fontId > 0u) && (fontId - 1u < mCacheHandler->mFontIdCache.size()))
686 fontCacheIndex = mCacheHandler->mFontIdCache[fontId - 1u].index;
687 mCacheHandler->mFontFaceCache[fontCacheIndex].mCharacterSet = FcCharSetCopy(mCacheHandler->mCharacterSetCache[fontDescriptionId - 1u]);
689 // Cache the pair 'fontDescriptionId, requestedPointSize' to improve the following queries.
690 mCacheHandler->CacheFontDescriptionSize(fontDescriptionId, requestedPointSize, fontCacheIndex);
695 fontId = mCacheHandler->mFontFaceCache[fontCacheIndex].mFontId + 1u;
698 DALI_LOG_INFO(gFontClientLogFilter, Debug::General, " font id : %d\n", fontId);
702 FontId FontClient::Plugin::GetFontId(const BitmapFont& bitmapFont) const
704 // The font id to be returned.
706 if(!mCacheHandler->FindBitmapFont(bitmapFont.name, fontId))
708 BitmapFontCacheItem bitmapFontCacheItem(bitmapFont);
710 fontId = mCacheHandler->CacheBitmapFontCacheItem(std::move(bitmapFontCacheItem));
715 void FontClient::Plugin::GetFontMetrics(FontId fontId,
716 FontMetrics& metrics) const
718 const FontCacheItemInterface* fontCacheItem = GetCachedFontItem(fontId);
719 if(fontCacheItem != nullptr)
721 fontCacheItem->GetFontMetrics(metrics, mDpiVertical);
725 GlyphIndex FontClient::Plugin::GetGlyphIndex(FontId fontId,
726 Character charcode) const
728 const FontCacheItemInterface* fontCacheItem = GetCachedFontItem(fontId);
729 if(fontCacheItem != nullptr)
731 return fontCacheItem->GetGlyphIndex(charcode);
737 GlyphIndex FontClient::Plugin::GetGlyphIndex(FontId fontId,
739 Character variantSelector) const
741 const FontCacheItemInterface* fontCacheItem = GetCachedFontItem(fontId);
742 if(fontCacheItem != nullptr)
744 return fontCacheItem->GetGlyphIndex(charcode, variantSelector);
750 bool FontClient::Plugin::GetGlyphMetrics(GlyphInfo* array,
753 bool horizontal) const
755 if(VECTOR_GLYPH == type)
757 return GetVectorMetrics(array, size, horizontal);
760 return GetBitmapMetrics(array, size, horizontal);
763 bool FontClient::Plugin::GetBitmapMetrics(GlyphInfo* array,
765 bool horizontal) const
767 bool success(size > 0u);
769 for(unsigned int i = 0; i < size; ++i)
771 GlyphInfo& glyph = array[i];
773 const FontCacheItemInterface* fontCacheItem = GetCachedFontItem(glyph.fontId);
774 if(fontCacheItem != nullptr)
776 success &= fontCacheItem->GetGlyphMetrics(glyph, mDpiVertical, horizontal);
778 // Check if it's an embedded image.
779 else if((0u == glyph.fontId) && (0u != glyph.index) && (glyph.index <= mCacheHandler->mEmbeddedItemCache.size()))
781 mCacheHandler->mEmbeddedItemCache[glyph.index - 1u].GetGlyphMetrics(glyph);
792 bool FontClient::Plugin::GetVectorMetrics(GlyphInfo* array,
794 bool horizontal) const
796 #ifdef ENABLE_VECTOR_BASED_TEXT_RENDERING
799 for(unsigned int i = 0u; i < size; ++i)
801 FontId fontId = array[i].fontId;
804 (fontId - 1u) < mCacheHandler->mFontIdCache.size())
806 FontFaceCacheItem& font = mCacheHandler->mFontFaceCache[mCacheHandler->mFontIdCache[fontId - 1u].index];
808 if(!font.mVectorFontId)
810 font.mVectorFontId = mVectorFontCache->GetFontId(font.mPath);
813 mVectorFontCache->GetGlyphMetrics(font.mVectorFontId, array[i]);
815 // Vector metrics are in EMs, convert to pixels
816 const float scale = (static_cast<float>(font.mRequestedPointSize) * FROM_266) * static_cast<float>(mDpiVertical) / POINTS_PER_INCH;
817 array[i].width *= scale;
818 array[i].height *= scale;
819 array[i].xBearing *= scale;
820 array[i].yBearing *= scale;
821 array[i].advance *= scale;
835 void FontClient::Plugin::CreateBitmap(FontId fontId, GlyphIndex glyphIndex, bool isItalicRequired, bool isBoldRequired, Dali::TextAbstraction::FontClient::GlyphBufferData& data, int outlineWidth) const
837 data.isColorBitmap = false;
838 data.isColorEmoji = false;
839 const FontCacheItemInterface* fontCacheItem = GetCachedFontItem(fontId);
840 if(fontCacheItem != nullptr)
842 fontCacheItem->CreateBitmap(glyphIndex, data, outlineWidth, isItalicRequired, isBoldRequired);
844 else if((0u != glyphIndex) && (glyphIndex <= mCacheHandler->mEmbeddedItemCache.size()))
846 // It's an embedded item.
847 mCacheHandler->mEmbeddedItemCache[glyphIndex - 1u].CreateBitmap(mCacheHandler->mPixelBufferCache, data);
851 PixelData FontClient::Plugin::CreateBitmap(FontId fontId, GlyphIndex glyphIndex, int outlineWidth) const
853 TextAbstraction::FontClient::GlyphBufferData data;
855 CreateBitmap(fontId, glyphIndex, false, false, data, outlineWidth);
857 // If data is compressed or not owned buffer, copy this.
858 if(!data.isBufferOwned || data.compressionType != TextAbstraction::FontClient::GlyphBufferData::CompressionType::NO_COMPRESSION)
860 uint8_t* newBuffer = (uint8_t*)malloc(data.width * data.height * Pixel::GetBytesPerPixel(data.format));
861 TextAbstraction::FontClient::GlyphBufferData::Decompress(data, newBuffer);
862 if(data.isBufferOwned)
867 data.buffer = newBuffer;
868 data.isBufferOwned = true;
869 data.compressionType = TextAbstraction::FontClient::GlyphBufferData::CompressionType::NO_COMPRESSION;
872 return PixelData::New(data.buffer,
873 data.width * data.height * Pixel::GetBytesPerPixel(data.format),
880 void FontClient::Plugin::CreateVectorBlob(FontId fontId, GlyphIndex glyphIndex, VectorBlob*& blob, unsigned int& blobLength, unsigned int& nominalWidth, unsigned int& nominalHeight) const
885 #ifdef ENABLE_VECTOR_BASED_TEXT_RENDERING
887 (fontId - 1u < mCacheHandler->mFontIdCache.size()))
889 using FontCacheIndex = CacheHandler::FontCacheIndex;
890 const FontCacheIndex fontCacheIndex = mCacheHandler->mFontIdCache[fontId - 1u].index;
891 FontFaceCacheItem& font = mCacheHandler->mFontFaceCache[fontCacheIndex];
893 if(!font.mVectorFontId)
895 font.mVectorFontId = mVectorFontCache->GetFontId(font.mPath);
898 mVectorFontCache->GetVectorBlob(font.mVectorFontId, fontCacheIndex, glyphIndex, blob, blobLength, nominalWidth, nominalHeight);
903 const GlyphInfo& FontClient::Plugin::GetEllipsisGlyph(PointSize26Dot6 requestedPointSize) const
905 using EllipsisCacheIndex = CacheHandler::EllipsisCacheIndex;
906 using EllipsisItem = CacheHandler::EllipsisItem;
907 EllipsisCacheIndex ellipsisCacheIndex = 0u;
909 if(!mCacheHandler->FindEllipsis(requestedPointSize, ellipsisCacheIndex))
911 // No glyph has been found. Create one.
914 item.requestedPointSize = requestedPointSize;
915 item.index = ellipsisCacheIndex;
917 // Find a font for the ellipsis glyph.
918 item.glyph.fontId = FindDefaultFont(ELLIPSIS_CHARACTER,
922 // Set the character index to access the glyph inside the font.
923 item.glyph.index = GetGlyphIndex(item.glyph.fontId, ELLIPSIS_CHARACTER);
925 // Get glyph informations.
926 GetBitmapMetrics(&item.glyph, 1u, true);
928 DALI_LOG_INFO(gFontClientLogFilter, Debug::General, " glyph id %d found in the cache.\n", item.glyph.index);
929 DALI_LOG_INFO(gFontClientLogFilter, Debug::General, " font %d.\n", item.glyph.fontId);
931 ellipsisCacheIndex = mCacheHandler->CacheEllipsis(std::move(item));
933 return mCacheHandler->mEllipsisCache[ellipsisCacheIndex].glyph;
936 bool FontClient::Plugin::IsColorGlyph(FontId fontId, GlyphIndex glyphIndex) const
938 const FontCacheItemInterface* fontCacheItem = GetCachedFontItem(fontId);
939 return fontCacheItem && fontCacheItem->IsColorGlyph(glyphIndex);
942 FT_FaceRec_* FontClient::Plugin::GetFreetypeFace(FontId fontId) const
944 const FontCacheItemInterface* fontCacheItem = GetCachedFontItem(fontId);
945 if(fontCacheItem != nullptr)
947 return fontCacheItem->GetTypeface();
952 FontDescription::Type FontClient::Plugin::GetFontType(FontId fontId) const
954 const FontId index = fontId - 1u;
955 if((fontId > 0u) && (index < mCacheHandler->mFontIdCache.size()))
957 return mCacheHandler->mFontIdCache[index].type;
959 return FontDescription::INVALID;
962 bool FontClient::Plugin::AddCustomFontDirectory(const FontPath& path)
964 // nullptr as first parameter means the current configuration is used.
965 return FcConfigAppFontAddDir(nullptr, reinterpret_cast<const FcChar8*>(path.c_str()));
968 HarfBuzzFontHandle FontClient::Plugin::GetHarfBuzzFont(FontId fontId) const
970 FontCacheItemInterface* fontCacheItem = const_cast<FontCacheItemInterface*>(GetCachedFontItem(fontId));
971 if(fontCacheItem != nullptr)
973 return fontCacheItem->GetHarfBuzzFont(mDpiHorizontal, mDpiVertical); // May cache
978 GlyphIndex FontClient::Plugin::CreateEmbeddedItem(const TextAbstraction::FontClient::EmbeddedItemDescription& description, Pixel::Format& pixelFormat) const
980 EmbeddedItem embeddedItem;
982 embeddedItem.pixelBufferId = 0u;
983 embeddedItem.width = description.width;
984 embeddedItem.height = description.height;
986 pixelFormat = Pixel::A8;
988 if(!description.url.empty())
990 // Check if the url is in the cache.
991 Devel::PixelBuffer pixelBuffer;
992 if(!mCacheHandler->FindEmbeddedPixelBufferId(description.url, embeddedItem.pixelBufferId))
994 // The pixel buffer is not in the cache. Create one and cache it.
995 embeddedItem.pixelBufferId = mCacheHandler->CacheEmbeddedPixelBuffer(description.url);
998 if((embeddedItem.pixelBufferId > 0u) && (embeddedItem.pixelBufferId - 1u) < mCacheHandler->mPixelBufferCache.size())
1000 // Retrieve the pixel buffer from the cache to set the pixel format.
1001 pixelBuffer = mCacheHandler->mPixelBufferCache[embeddedItem.pixelBufferId - 1u].pixelBuffer;
1006 // Set the size of the embedded item if it has not been set.
1007 if(0u == embeddedItem.width)
1009 embeddedItem.width = static_cast<unsigned int>(pixelBuffer.GetWidth());
1012 if(0u == embeddedItem.height)
1014 embeddedItem.height = static_cast<unsigned int>(pixelBuffer.GetHeight());
1017 // Set the pixel format.
1018 pixelFormat = pixelBuffer.GetPixelFormat();
1022 // Find if the same embeddedItem has already been created.
1023 GlyphIndex index = 0u;
1024 if(!mCacheHandler->FindEmbeddedItem(embeddedItem.pixelBufferId, embeddedItem.width, embeddedItem.height, index))
1026 index = mCacheHandler->CacheEmbeddedItem(std::move(embeddedItem));
1031 void FontClient::Plugin::EnableAtlasLimitation(bool enabled)
1033 mIsAtlasLimitationEnabled = enabled;
1036 bool FontClient::Plugin::IsAtlasLimitationEnabled() const
1038 return mIsAtlasLimitationEnabled;
1041 Size FontClient::Plugin::GetMaximumTextAtlasSize() const
1043 return TextAbstraction::FontClient::MAX_TEXT_ATLAS_SIZE;
1046 Size FontClient::Plugin::GetDefaultTextAtlasSize() const
1048 return TextAbstraction::FontClient::DEFAULT_TEXT_ATLAS_SIZE;
1051 Size FontClient::Plugin::GetCurrentMaximumBlockSizeFitInAtlas() const
1053 return mCurrentMaximumBlockSizeFitInAtlas;
1056 bool FontClient::Plugin::SetCurrentMaximumBlockSizeFitInAtlas(const Size& currentMaximumBlockSizeFitInAtlas)
1058 bool isChanged = false;
1059 const Size& maxTextAtlasSize = TextAbstraction::FontClient::MAX_TEXT_ATLAS_SIZE;
1060 const uint16_t& padding = TextAbstraction::FontClient::PADDING_TEXT_ATLAS_BLOCK;
1062 if(currentMaximumBlockSizeFitInAtlas.width <= maxTextAtlasSize.width - padding && currentMaximumBlockSizeFitInAtlas.height <= maxTextAtlasSize.height - padding)
1064 mCurrentMaximumBlockSizeFitInAtlas = currentMaximumBlockSizeFitInAtlas;
1071 uint32_t FontClient::Plugin::GetNumberOfPointsPerOneUnitOfPointSize() const
1073 return TextAbstraction::FontClient::NUMBER_OF_POINTS_PER_ONE_UNIT_OF_POINT_SIZE;
1077 FontId FontClient::Plugin::CreateFont(const FontPath& path,
1078 PointSize26Dot6 requestedPointSize,
1079 FaceIndex faceIndex,
1080 bool cacheDescription) const
1082 DALI_LOG_TRACE_METHOD(gFontClientLogFilter);
1083 DALI_LOG_INFO(gFontClientLogFilter, Debug::General, " path : [%s]\n", path.c_str());
1084 DALI_LOG_INFO(gFontClientLogFilter, Debug::General, " requestedPointSize : %d\n", requestedPointSize);
1086 DALI_TRACE_SCOPE(gTraceFilter, "DALI_TEXT_CREATE_FONT");
1089 #if defined(TRACE_ENABLED)
1090 if(gTraceFilter && gTraceFilter->IsTraceEnabled())
1092 DALI_LOG_DEBUG_INFO("DALI_TEXT_CREATE_FONT : FT_New_Face : %s\n", path.c_str());
1096 // Create & cache new font face
1098 int error = FT_New_Face(mFreeTypeLibrary,
1103 if(FT_Err_Ok == error)
1105 // Check if a font is scalable.
1106 const bool isScalable = (0 != (ftFace->face_flags & FT_FACE_FLAG_SCALABLE));
1107 const bool hasFixedSizedBitmaps = (0 != (ftFace->face_flags & FT_FACE_FLAG_FIXED_SIZES)) && (0 != ftFace->num_fixed_sizes);
1108 const bool hasColorTables = (0 != (ftFace->face_flags & FT_FACE_FLAG_COLOR));
1110 DALI_LOG_INFO(gFontClientLogFilter, Debug::General, " isScalable : [%s]\n", (isScalable ? "true" : "false"));
1111 DALI_LOG_INFO(gFontClientLogFilter, Debug::General, " hasFixedSizedBitmaps : [%s]\n", (hasFixedSizedBitmaps ? "true" : "false"));
1112 DALI_LOG_INFO(gFontClientLogFilter, Debug::General, " hasColorTables : [%s]\n", (hasColorTables ? "true" : "false"));
1114 // Check to see if the font contains fixed sizes?
1115 if(!isScalable && hasFixedSizedBitmaps)
1117 PointSize26Dot6 actualPointSize = 0u;
1118 int fixedSizeIndex = 0;
1119 for(; fixedSizeIndex < ftFace->num_fixed_sizes; ++fixedSizeIndex)
1121 const PointSize26Dot6 fixedSize = static_cast<PointSize26Dot6>(ftFace->available_sizes[fixedSizeIndex].size);
1122 DALI_LOG_INFO(gFontClientLogFilter, Debug::Verbose, " size index : %d, size : %d\n", fixedSizeIndex, fixedSize);
1124 if(fixedSize >= requestedPointSize)
1126 actualPointSize = fixedSize;
1131 if(0u == actualPointSize)
1133 // The requested point size is bigger than the bigest fixed size.
1134 fixedSizeIndex = ftFace->num_fixed_sizes - 1;
1135 actualPointSize = static_cast<PointSize26Dot6>(ftFace->available_sizes[fixedSizeIndex].size);
1138 DALI_LOG_INFO(gFontClientLogFilter, Debug::Verbose, " size index : %d, actual size : %d\n", fixedSizeIndex, actualPointSize);
1140 // Tell Freetype to use this size
1141 error = FT_Select_Size(ftFace, fixedSizeIndex);
1142 if(FT_Err_Ok != error)
1144 DALI_LOG_INFO(gFontClientLogFilter, Debug::General, "FreeType Select_Size error: %d\n", error);
1148 FT_Size_Metrics& ftMetrics = ftFace->size->metrics;
1150 FontMetrics metrics(static_cast<float>(ftMetrics.ascender) * FROM_266,
1151 static_cast<float>(ftMetrics.descender) * FROM_266,
1152 static_cast<float>(ftMetrics.height) * FROM_266,
1153 static_cast<float>(ftFace->underline_position) * FROM_266,
1154 static_cast<float>(ftFace->underline_thickness) * FROM_266);
1156 const float fixedWidth = static_cast<float>(ftFace->available_sizes[fixedSizeIndex].width);
1157 const float fixedHeight = static_cast<float>(ftFace->available_sizes[fixedSizeIndex].height);
1159 // Create the FreeType font face item to cache.
1160 FontFaceCacheItem fontFaceCacheItem(mFreeTypeLibrary, ftFace, mCacheHandler->GetGlyphCacheManager(), path, requestedPointSize, faceIndex, metrics, fixedSizeIndex, fixedWidth, fixedHeight, hasColorTables);
1162 fontId = mCacheHandler->CacheFontFaceCacheItem(std::move(fontFaceCacheItem));
1167 if(mIsAtlasLimitationEnabled)
1169 //There is limitation on block size to fit in predefined atlas size.
1170 //If the block size cannot fit into atlas size, then the system cannot draw block.
1171 //This is workaround to avoid issue in advance
1172 //Decrementing point-size until arriving to maximum allowed block size.
1173 auto requestedPointSizeBackup = requestedPointSize;
1174 const Size& maxSizeFitInAtlas = GetCurrentMaximumBlockSizeFitInAtlas();
1175 error = SearchOnProperPointSize(ftFace, mDpiHorizontal, mDpiVertical, maxSizeFitInAtlas, requestedPointSize);
1177 if(requestedPointSize != requestedPointSizeBackup)
1179 DALI_LOG_WARNING(" The requested-point-size : %d, is reduced to point-size : %d\n", requestedPointSizeBackup, requestedPointSize);
1184 error = FT_Set_Char_Size(ftFace,
1191 if(FT_Err_Ok == error)
1193 FT_Size_Metrics& ftMetrics = ftFace->size->metrics;
1195 FontMetrics metrics(static_cast<float>(ftMetrics.ascender) * FROM_266,
1196 static_cast<float>(ftMetrics.descender) * FROM_266,
1197 static_cast<float>(ftMetrics.height) * FROM_266,
1198 static_cast<float>(ftFace->underline_position) * FROM_266,
1199 static_cast<float>(ftFace->underline_thickness) * FROM_266);
1201 // Create the FreeType font face item to cache.
1202 FontFaceCacheItem fontFaceCacheItem(mFreeTypeLibrary, ftFace, mCacheHandler->GetGlyphCacheManager(), path, requestedPointSize, faceIndex, metrics);
1204 fontId = mCacheHandler->CacheFontFaceCacheItem(std::move(fontFaceCacheItem));
1208 DALI_LOG_INFO(gFontClientLogFilter, Debug::General, " FreeType Set_Char_Size error: %d for pointSize %d\n", error, requestedPointSize);
1214 if(cacheDescription)
1216 DALI_LOG_INFO(gFontClientLogFilter, Debug::General, " Cache Font Path at font id : %d [%s]\n", fontId, path.c_str());
1217 mCacheHandler->CacheFontPath(ftFace, fontId, requestedPointSize, path);
1223 DALI_LOG_INFO(gFontClientLogFilter, Debug::General, " FreeType New_Face error: %d for [%s]\n", error, path.c_str());
1226 DALI_LOG_INFO(gFontClientLogFilter, Debug::General, " font id : %d\n", fontId);
1230 bool FontClient::Plugin::IsScalable(const FontPath& path) const
1232 bool isScalable = false;
1234 FT_Face ftFace = nullptr;
1235 int error = FT_New_Face(mFreeTypeLibrary,
1239 if(FT_Err_Ok != error)
1241 DALI_LOG_INFO(gFontClientLogFilter, Debug::General, "FontClient::Plugin::IsScalable. FreeType Cannot check font: %s\n", path.c_str());
1245 isScalable = ftFace->face_flags & FT_FACE_FLAG_SCALABLE;
1250 FT_Done_Face(ftFace);
1256 bool FontClient::Plugin::IsScalable(const FontDescription& fontDescription) const
1258 // Create a font pattern.
1259 FcPattern* fontFamilyPattern = CreateFontFamilyPattern(fontDescription); // Creates a font pattern that needs to be destroyed by calling FcPatternDestroy.
1261 FcResult result = FcResultMatch;
1263 // match the pattern
1264 FcPattern* match = FcFontMatch(nullptr /* use default configure */, fontFamilyPattern, &result); // Creates a font pattern that needs to be destroyed by calling FcPatternDestroy.
1265 bool isScalable = false;
1269 // Get the path to the font file name.
1271 GetFcString(match, FC_FILE, path);
1272 isScalable = IsScalable(path);
1276 DALI_LOG_INFO(gFontClientLogFilter, Debug::General, "FontClient::Plugin::IsScalable. FreeType Cannot check font: [%s]\n", fontDescription.family.c_str());
1279 // Destroys the created patterns.
1280 FcPatternDestroy(match);
1281 FcPatternDestroy(fontFamilyPattern);
1286 void FontClient::Plugin::GetFixedSizes(const FontPath& path, Vector<PointSize26Dot6>& sizes) const
1288 // Empty the caller container
1291 FT_Face ftFace = nullptr;
1292 int error = FT_New_Face(mFreeTypeLibrary,
1296 if(FT_Err_Ok != error)
1298 DALI_LOG_INFO(gFontClientLogFilter, Debug::General, "FontClient::Plugin::GetFixedSizes. FreeType Cannot check font path : [%s]\n", path.c_str());
1303 // Fetch the number of fixed sizes available
1304 if(ftFace->num_fixed_sizes && ftFace->available_sizes)
1306 for(int i = 0; i < ftFace->num_fixed_sizes; ++i)
1308 sizes.PushBack(ftFace->available_sizes[i].size);
1312 FT_Done_Face(ftFace);
1316 void FontClient::Plugin::GetFixedSizes(const FontDescription& fontDescription,
1317 Vector<PointSize26Dot6>& sizes) const
1319 // Create a font pattern.
1320 FcPattern* fontFamilyPattern = CreateFontFamilyPattern(fontDescription); // Creates a font pattern that needs to be destroyed by calling FcPatternDestroy.
1322 FcResult result = FcResultMatch;
1324 // match the pattern
1325 FcPattern* match = FcFontMatch(nullptr /* use default configure */, fontFamilyPattern, &result); // Creates a font pattern that needs to be destroyed by calling FcPatternDestroy.
1329 // Get the path to the font file name.
1331 GetFcString(match, FC_FILE, path);
1332 GetFixedSizes(path, sizes);
1336 DALI_LOG_INFO(gFontClientLogFilter, Debug::General, "FontClient::Plugin::GetFixedSizes. FreeType Cannot check font: [%s]\n", fontDescription.family.c_str());
1339 // Destroys the created patterns.
1340 FcPatternDestroy(match);
1341 FcPatternDestroy(fontFamilyPattern);
1344 bool FontClient::Plugin::HasItalicStyle(FontId fontId) const
1346 const FontCacheItemInterface* fontCacheItem = GetCachedFontItem(fontId);
1347 if(fontCacheItem != nullptr)
1349 return fontCacheItem->HasItalicStyle();
1354 } // namespace Dali::TextAbstraction::Internal