/*
- * Copyright (c) 2023 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2024 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
mCacheHandler->ClearCache();
}
+void FontClient::Plugin::ClearCacheOnLocaleChanged() const
+{
+ mCacheHandler->ClearCacheOnLocaleChanged();
+}
+
void FontClient::Plugin::SetDpi(unsigned int horizontalDpi,
unsigned int verticalDpi)
{
// Check if exists a pair 'fontDescriptionId, requestedPointSize' in the cache.
if(!mCacheHandler->FindFont(fontDescriptionId, requestedPointSize, fontCacheIndex))
{
- // Retrieve the font file name path.
- const FontDescription& description = *(mCacheHandler->mFontDescriptionCache.begin() + fontDescriptionId - 1u);
+ if(fontDescriptionId > 0u && fontDescriptionId <= mCacheHandler->mCharacterSetCache.Count())
+ {
+ // Retrieve the font file name path.
+ const FontDescription& description = *(mCacheHandler->mFontDescriptionCache.begin() + fontDescriptionId - 1u);
- // Retrieve the font id. Do not cache the description as it has been already cached.
- // Note : CacheFontPath() API call ValidateFont() + setup CharacterSet + cache the font description.
- // So set cacheDescription=false, that we don't call CacheFontPath().
- fontId = GetFontIdByPath(description.path, requestedPointSize, faceIndex, false);
+ // Retrieve the font id. Do not cache the description as it has been already cached.
+ // Note : CacheFontPath() API call ValidateFont() + setup CharacterSet + cache the font description.
+ // So set cacheDescription=false, that we don't call CacheFontPath().
+ fontId = GetFontIdByPath(description.path, requestedPointSize, faceIndex, false);
- if((fontId > 0u) && (fontId - 1u < mCacheHandler->mFontIdCache.size()))
- {
- fontCacheIndex = mCacheHandler->mFontIdCache[fontId - 1u].index;
- mCacheHandler->mFontFaceCache[fontCacheIndex].mCharacterSet = FcCharSetCopy(mCacheHandler->mCharacterSetCache[fontDescriptionId - 1u]);
+ if((fontId > 0u) && (fontId - 1u < mCacheHandler->mFontIdCache.size()))
+ {
+ fontCacheIndex = mCacheHandler->mFontIdCache[fontId - 1u].index;
+ mCacheHandler->mFontFaceCache[fontCacheIndex].mCharacterSet = FcCharSetCopy(mCacheHandler->mCharacterSetCache[fontDescriptionId - 1u]);
- // Cache the pair 'fontDescriptionId, requestedPointSize' to improve the following queries.
- mCacheHandler->CacheFontDescriptionSize(fontDescriptionId, requestedPointSize, fontCacheIndex);
+ // Cache the pair 'fontDescriptionId, requestedPointSize' to improve the following queries.
+ mCacheHandler->CacheFontDescriptionSize(fontDescriptionId, requestedPointSize, fontCacheIndex);
+ }
}
}
else
if(!data.isBufferOwned || data.compressionType != TextAbstraction::GlyphBufferData::CompressionType::NO_COMPRESSION)
{
uint8_t* newBuffer = (uint8_t*)malloc(data.width * data.height * Pixel::GetBytesPerPixel(data.format));
+ if(DALI_UNLIKELY(!newBuffer))
+ {
+ DALI_LOG_ERROR("malloc is failed. request malloc size : %u x %u x %u\n", data.width, data.height, Pixel::GetBytesPerPixel(data.format));
+ return Dali::PixelData();
+ }
+
TextAbstraction::GlyphBufferData::Decompress(data, newBuffer);
if(data.isBufferOwned)
{
EllipsisItem item;
item.requestedPointSize = requestedPointSize;
- item.index = ellipsisCacheIndex;
// Find a font for the ellipsis glyph.
item.glyph.fontId = FindDefaultFont(ELLIPSIS_CHARACTER,
DALI_LOG_INFO(gFontClientLogFilter, Debug::General, " glyph id %d found in the cache.\n", item.glyph.index);
DALI_LOG_INFO(gFontClientLogFilter, Debug::General, " font %d.\n", item.glyph.fontId);
+ // EllipsisCacheIndex is stored in item.index.
ellipsisCacheIndex = mCacheHandler->CacheEllipsis(std::move(item));
+ if(!mCacheHandler->mEllipsisCache.empty())
+ {
+ mCacheHandler->mEllipsisCache.back().index = ellipsisCacheIndex;
+ }
}
return mCacheHandler->mEllipsisCache[ellipsisCacheIndex].glyph;
}