summaryrefslogtreecommitdiff
path: root/core/fxge/cfx_facecache.cpp
diff options
context:
space:
mode:
authorLei Zhang <thestig@chromium.org>2017-11-30 18:56:00 +0000
committerChromium commit bot <commit-bot@chromium.org>2017-11-30 18:56:00 +0000
commit247c0e05dacb3b958bb7aaf06f21b93e78c43e19 (patch)
treedbe1c1a7e36523124180b1f99ce7c58fe621d98d /core/fxge/cfx_facecache.cpp
parentfee910e6f81fd199bfe4fd62ea538d1bc33056a8 (diff)
downloadpdfium-247c0e05dacb3b958bb7aaf06f21b93e78c43e19.tar.xz
Relax checks in CFX_FaceCache::LoadGlyphPath().
The original fix to https://crbug.com/641333 was too strict. Relax the checks and use a std::tuple for the path map key, instead of trying to "hash" a key. BUG=chromium:788864 Change-Id: I6e6a96691bce2834c2e95baa16ebd39e6aa03140 Reviewed-on: https://pdfium-review.googlesource.com/19950 Reviewed-by: dsinclair <dsinclair@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org>
Diffstat (limited to 'core/fxge/cfx_facecache.cpp')
-rw-r--r--core/fxge/cfx_facecache.cpp22
1 files changed, 7 insertions, 15 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();