diff options
-rw-r--r-- | xfa/fgas/font/cfgas_gefont.cpp | 28 | ||||
-rw-r--r-- | xfa/fgas/font/cfgas_gefont.h | 5 | ||||
-rw-r--r-- | xfa/fgas/font/cfgas_pdffontmgr.cpp | 18 | ||||
-rw-r--r-- | xfa/fgas/font/cfgas_pdffontmgr.h | 3 | ||||
-rw-r--r-- | xfa/fxfa/cxfa_fontmgr.cpp | 5 |
5 files changed, 15 insertions, 44 deletions
diff --git a/xfa/fgas/font/cfgas_gefont.cpp b/xfa/fgas/font/cfgas_gefont.cpp index b6ec23a414..740504f088 100644 --- a/xfa/fgas/font/cfgas_gefont.cpp +++ b/xfa/fgas/font/cfgas_gefont.cpp @@ -164,23 +164,21 @@ bool CFGAS_GEFont::GetCharWidth(wchar_t wUnicode, int32_t* pWidth) { if (*pWidth > 0) return true; - if (!m_pProvider || !m_pProvider->GetCharWidth(RetainPtr<CFGAS_GEFont>(this), - wUnicode, pWidth)) { - RetainPtr<CFGAS_GEFont> pFont; - int32_t iGlyph; - std::tie(iGlyph, pFont) = GetGlyphIndexAndFont(wUnicode, true); - if (iGlyph != 0xFFFF && pFont) { - if (pFont.Get() == this) { - *pWidth = m_pFont->GetGlyphWidth(iGlyph); - if (*pWidth < 0) - *pWidth = -1; - } else if (pFont->GetCharWidth(wUnicode, pWidth)) { - return true; - } - } else { - *pWidth = -1; + RetainPtr<CFGAS_GEFont> pFont; + int32_t iGlyph; + std::tie(iGlyph, pFont) = GetGlyphIndexAndFont(wUnicode, true); + if (iGlyph != 0xFFFF && pFont) { + if (pFont.Get() == this) { + *pWidth = m_pFont->GetGlyphWidth(iGlyph); + if (*pWidth < 0) + *pWidth = -1; + } else if (pFont->GetCharWidth(wUnicode, pWidth)) { + return true; } + } else { + *pWidth = -1; } + m_CharWidthMap[wUnicode] = *pWidth; return *pWidth > 0; } diff --git a/xfa/fgas/font/cfgas_gefont.h b/xfa/fgas/font/cfgas_gefont.h index ab72f1356f..f4d729d3a5 100644 --- a/xfa/fgas/font/cfgas_gefont.h +++ b/xfa/fgas/font/cfgas_gefont.h @@ -49,10 +49,6 @@ class CFGAS_GEFont : public Retainable { RetainPtr<CFGAS_GEFont> GetSubstFont(int32_t iGlyphIndex); CFX_Font* GetDevFont() const { return m_pFont; } - void SetFontProvider(CFGAS_PDFFontMgr* pProvider) { - m_pProvider.Reset(pProvider); - } - void SetLogicalFontStyle(uint32_t dwLogFontStyle) { m_bUseLogFontStyle = true; m_dwLogFontStyle = dwLogFontStyle; @@ -82,7 +78,6 @@ class CFGAS_GEFont : public Retainable { bool m_bExternalFont; RetainPtr<CFGAS_GEFont> m_pSrcFont; // Only set by ctor, so no cycles. CFGAS_FontMgr::ObservedPtr m_pFontMgr; - CFGAS_PDFFontMgr::ObservedPtr m_pProvider; RetainPtr<IFX_SeekableReadStream> m_pFileRead; std::unique_ptr<CFX_UnicodeEncoding> m_pFontEncoding; std::map<wchar_t, int32_t> m_CharWidthMap; diff --git a/xfa/fgas/font/cfgas_pdffontmgr.cpp b/xfa/fgas/font/cfgas_pdffontmgr.cpp index e2fb905f66..ad28c9eaeb 100644 --- a/xfa/fgas/font/cfgas_pdffontmgr.cpp +++ b/xfa/fgas/font/cfgas_pdffontmgr.cpp @@ -183,24 +183,6 @@ bool CFGAS_PDFFontMgr::PsNameMatchDRFontName(const ByteStringView& bsPsName, return true; } -bool CFGAS_PDFFontMgr::GetCharWidth(const RetainPtr<CFGAS_GEFont>& pFont, - wchar_t wUnicode, - int32_t* pWidth) { - if (wUnicode != 0x20) - return false; - - auto it = m_FDE2PDFFont.find(pFont); - if (it == m_FDE2PDFFont.end()) - return false; - - CPDF_Font* pPDFFont = it->second; - // TODO(npm): CFGAS_GEFont::GetCharWidth currently uses -1 as a special value, - // so |pWidth| cannot be changed to unsigned until this behavior is changed. - *pWidth = static_cast<int32_t>( - pPDFFont->GetCharWidthF(pPDFFont->CharCodeFromUnicode(wUnicode))); - return true; -} - void CFGAS_PDFFontMgr::SetFont(const RetainPtr<CFGAS_GEFont>& pFont, CPDF_Font* pPDFFont) { m_FDE2PDFFont[pFont] = pPDFFont; diff --git a/xfa/fgas/font/cfgas_pdffontmgr.h b/xfa/fgas/font/cfgas_pdffontmgr.h index a019990dad..0cc647500b 100644 --- a/xfa/fgas/font/cfgas_pdffontmgr.h +++ b/xfa/fgas/font/cfgas_pdffontmgr.h @@ -30,9 +30,6 @@ class CFGAS_PDFFontMgr : public Observable<CFGAS_PDFFontMgr> { uint32_t dwFontStyles, CPDF_Font** pPDFFont, bool bStrictMatch); - bool GetCharWidth(const RetainPtr<CFGAS_GEFont>& pFont, - wchar_t wUnicode, - int32_t* pWidth); private: RetainPtr<CFGAS_GEFont> FindFont(const ByteString& strFamilyName, diff --git a/xfa/fxfa/cxfa_fontmgr.cpp b/xfa/fxfa/cxfa_fontmgr.cpp index c35b10c9bc..8bacf07742 100644 --- a/xfa/fxfa/cxfa_fontmgr.cpp +++ b/xfa/fxfa/cxfa_fontmgr.cpp @@ -74,10 +74,9 @@ RetainPtr<CFGAS_GEFont> CXFA_FontMgr::GetFont( } if (pFont) { - if (pPDFFont) { + if (pPDFFont) pMgr->SetFont(pFont, pPDFFont); - pFont->SetFontProvider(pMgr); - } + m_FontMap[bsKey] = pFont; } return pFont; |