[drape] nit

Signed-off-by: x7z4w <x7z4w@noreply.codeberg.org>
This commit is contained in:
x7z4w
2025-11-27 12:24:22 +00:00
parent 3b0b4520a1
commit 07fb3c0055

View File

@@ -56,6 +56,8 @@ FreetypeError constexpr g_FT_Errors[] =
namespace dp namespace dp
{ {
int constexpr kInvalidFont = -1; int constexpr kInvalidFont = -1;
// Empirically measured, may need more tuning.
size_t constexpr kMaxCacheSize = 50000;
template <typename ToDo> template <typename ToDo>
void ParseUniBlocks(std::string const & uniBlocksFile, ToDo toDo) void ParseUniBlocks(std::string const & uniBlocksFile, ToDo toDo)
@@ -360,6 +362,8 @@ FreetypeError constexpr g_FT_Errors[] =
m_impl->m_fonts.reserve(params.m_fonts.size()); m_impl->m_fonts.reserve(params.m_fonts.size());
m_impl->m_textMetricsCache.reserve(kMaxCacheSize);
FREETYPE_CHECK(FT_Init_FreeType(&m_impl->m_library)); FREETYPE_CHECK(FT_Init_FreeType(&m_impl->m_library));
// Default Freetype spread/sdf border is 8. // Default Freetype spread/sdf border is 8.
@@ -370,11 +374,9 @@ FreetypeError constexpr g_FT_Errors[] =
for (auto const & fontName : params.m_fonts) for (auto const & fontName : params.m_fonts)
{ {
bool ignoreFont = false; bool ignoreFont = false;
std::for_each(blacklst.begin(), blacklst.end(), [&ignoreFont, &fontName](TFontAndBlockName const & p) for (TFontAndBlockName const & p : blacklst)
{
if (p.first == fontName && p.second == "*") if (p.first == fontName && p.second == "*")
ignoreFont = true; ignoreFont = true;
});
if (ignoreFont) if (ignoreFont)
continue; continue;
@@ -633,8 +635,6 @@ FreetypeError constexpr g_FT_Errors[] =
if (allGlyphs.m_glyphs.empty()) if (allGlyphs.m_glyphs.empty())
LOG(LWARNING, ("No glyphs were found in all fonts for string with characters in warnings above" /*, utf8*/)); LOG(LWARNING, ("No glyphs were found in all fonts for string with characters in warnings above" /*, utf8*/));
// Empirically measured, may need more tuning.
size_t constexpr kMaxCacheSize = 50000;
if (m_impl->m_textMetricsCache.size() > kMaxCacheSize) if (m_impl->m_textMetricsCache.size() > kMaxCacheSize)
{ {
LOG(LINFO, ("Clearing text metrics cache")); LOG(LINFO, ("Clearing text metrics cache"));