/*
- * 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.
// 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