diff options
Diffstat (limited to 'core/fxge')
-rw-r--r-- | core/fxge/cfx_facecache.cpp | 22 | ||||
-rw-r--r-- | core/fxge/cfx_facecache.h | 5 |
2 files changed, 11 insertions, 16 deletions
diff --git a/core/fxge/cfx_facecache.cpp b/core/fxge/cfx_facecache.cpp index 3f037ac65a..bc29293c3a 100644 --- a/core/fxge/cfx_facecache.cpp +++ b/core/fxge/cfx_facecache.cpp @@ -194,23 +194,15 @@ std::unique_ptr<CFX_GlyphBitmap> CFX_FaceCache::RenderGlyph( const CFX_PathData* CFX_FaceCache::LoadGlyphPath(const CFX_Font* pFont, uint32_t glyph_index, int dest_width) { - if (!m_Face || glyph_index == kInvalidGlyphIndex || dest_width < 0) + if (!m_Face || glyph_index == kInvalidGlyphIndex) return nullptr; - uint32_t key = glyph_index; - auto* pSubstFont = pFont->GetSubstFont(); - if (pSubstFont) { - if (pSubstFont->m_Weight < 0 || pSubstFont->m_ItalicAngle < 0) - return nullptr; - uint32_t weight = static_cast<uint32_t>(pSubstFont->m_Weight); - uint32_t angle = static_cast<uint32_t>(pSubstFont->m_ItalicAngle); - uint32_t key_modifier = (weight / 16) << 15; - key_modifier += (angle / 2) << 21; - key_modifier += (static_cast<uint32_t>(dest_width) / 16) << 25; - if (pFont->IsVertical()) - key_modifier += 1U << 31; - key += key_modifier; - } + const auto* pSubstFont = pFont->GetSubstFont(); + int weight = pSubstFont ? pSubstFont->m_Weight : 0; + int angle = pSubstFont ? pSubstFont->m_ItalicAngle : 0; + bool vertical = pSubstFont ? pFont->IsVertical() : false; + const PathMapKey key = + std::make_tuple(glyph_index, dest_width, weight, angle, vertical); auto it = m_PathMap.find(key); if (it != m_PathMap.end()) return it->second.get(); diff --git a/core/fxge/cfx_facecache.h b/core/fxge/cfx_facecache.h index aa98161719..a39da88b01 100644 --- a/core/fxge/cfx_facecache.h +++ b/core/fxge/cfx_facecache.h @@ -9,6 +9,7 @@ #include <map> #include <memory> +#include <tuple> #include "core/fxcrt/unowned_ptr.h" #include "core/fxge/fx_font.h" @@ -42,6 +43,8 @@ class CFX_FaceCache { private: using SizeGlyphCache = std::map<uint32_t, std::unique_ptr<CFX_GlyphBitmap>>; + // <glyph_index, width, weight, angle, vertical> + using PathMapKey = std::tuple<uint32_t, int, int, int, bool>; std::unique_ptr<CFX_GlyphBitmap> RenderGlyph(const CFX_Font* pFont, uint32_t glyph_index, @@ -67,7 +70,7 @@ class CFX_FaceCache { FXFT_Face const m_Face; std::map<ByteString, SizeGlyphCache> m_SizeMap; - std::map<uint32_t, std::unique_ptr<CFX_PathData>> m_PathMap; + std::map<PathMapKey, std::unique_ptr<CFX_PathData>> m_PathMap; #if defined _SKIA_SUPPORT_ || _SKIA_SUPPORT_PATHS_ sk_sp<SkTypeface> m_pTypeface; #endif |