summaryrefslogtreecommitdiff
path: root/xfa/fgas
diff options
context:
space:
mode:
Diffstat (limited to 'xfa/fgas')
-rw-r--r--xfa/fgas/font/cfgas_gefont.cpp41
-rw-r--r--xfa/fgas/font/cfgas_gefont.h3
2 files changed, 18 insertions, 26 deletions
diff --git a/xfa/fgas/font/cfgas_gefont.cpp b/xfa/fgas/font/cfgas_gefont.cpp
index a175202e7d..a57962d084 100644
--- a/xfa/fgas/font/cfgas_gefont.cpp
+++ b/xfa/fgas/font/cfgas_gefont.cpp
@@ -220,8 +220,6 @@ bool CFGAS_GEFont::InitFont() {
m_pCharWidthMap =
pdfium::MakeUnique<CFX_DiscreteArrayTemplate<uint16_t>>(1024);
}
- if (!m_pRectArray)
- m_pRectArray = pdfium::MakeUnique<CFX_MassArrayTemplate<CFX_Rect>>(16);
return true;
}
@@ -315,32 +313,27 @@ bool CFGAS_GEFont::GetCharBBoxInternal(FX_WCHAR wUnicode,
CFX_Rect* bbox,
bool bRecursive,
bool bCharCode) {
- ASSERT(m_pRectArray);
- CFX_Rect* pRect = nullptr;
auto it = m_BBoxMap.find(wUnicode);
- if (it == m_BBoxMap.end()) {
- CFX_RetainPtr<CFGAS_GEFont> pFont;
- int32_t iGlyph = GetGlyphIndex(wUnicode, true, &pFont, bCharCode);
- if (iGlyph != 0xFFFF && pFont) {
- if (pFont.Get() == this) {
- FX_RECT rtBBox;
- if (m_pFont->GetGlyphBBox(iGlyph, rtBBox)) {
- CFX_Rect rt(rtBBox.left, rtBBox.top, rtBBox.Width(), rtBBox.Height());
- int32_t index = m_pRectArray->Add(rt);
- pRect = m_pRectArray->GetPtrAt(index);
- m_BBoxMap[wUnicode] = pRect;
- }
- } else if (pFont->GetCharBBoxInternal(wUnicode, bbox, false, bCharCode)) {
- return true;
- }
- }
- } else {
- pRect = it->second;
+ if (it != m_BBoxMap.end()) {
+ *bbox = it->second;
+ return true;
}
- if (!pRect)
+
+ CFX_RetainPtr<CFGAS_GEFont> pFont;
+ int32_t iGlyph = GetGlyphIndex(wUnicode, true, &pFont, bCharCode);
+ if (!pFont || iGlyph == 0xFFFF)
+ return false;
+
+ if (pFont.Get() != this)
+ return pFont->GetCharBBoxInternal(wUnicode, bbox, false, bCharCode);
+
+ FX_RECT rtBBox;
+ if (!m_pFont->GetGlyphBBox(iGlyph, rtBBox))
return false;
- *bbox = *pRect;
+ CFX_Rect rt(rtBBox.left, rtBBox.top, rtBBox.Width(), rtBBox.Height());
+ m_BBoxMap[wUnicode] = rt;
+ *bbox = rt;
return true;
}
diff --git a/xfa/fgas/font/cfgas_gefont.h b/xfa/fgas/font/cfgas_gefont.h
index 6c9d890df4..2201721a93 100644
--- a/xfa/fgas/font/cfgas_gefont.h
+++ b/xfa/fgas/font/cfgas_gefont.h
@@ -109,8 +109,7 @@ class CFGAS_GEFont : public CFX_Retainable {
CFX_RetainPtr<IFX_SeekableReadStream> m_pFileRead;
std::unique_ptr<CFX_UnicodeEncoding> m_pFontEncoding;
std::unique_ptr<CFX_DiscreteArrayTemplate<uint16_t>> m_pCharWidthMap;
- std::unique_ptr<CFX_MassArrayTemplate<CFX_Rect>> m_pRectArray;
- std::map<FX_WCHAR, CFX_Rect*> m_BBoxMap; // Rect owned by m_pRectArray.
+ std::map<FX_WCHAR, CFX_Rect> m_BBoxMap;
CXFA_PDFFontMgr* m_pProvider; // not owned.
std::vector<CFX_RetainPtr<CFGAS_GEFont>> m_SubstFonts;
std::map<FX_WCHAR, CFX_RetainPtr<CFGAS_GEFont>> m_FontMapper;