diff options
author | Nicolas Pena <npm@chromium.org> | 2017-11-07 16:32:20 +0000 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2017-11-07 16:32:20 +0000 |
commit | 979e916fde750e47f262c59dc75f4ca2dc19ed39 (patch) | |
tree | 5e767486014c58e384f827f3fd7dc11efe658865 | |
parent | f2f12b32b601f022b5c10fddd8c4d19d00072630 (diff) | |
download | pdfium-979e916fde750e47f262c59dc75f4ca2dc19ed39.tar.xz |
Remove m_bFlagExact from CFX_SubstFont
This CL removes the single use case from |m_bFlagExact|. This flag
allows the PDF viewer to treat a substitute font with a matching name as
if it was actually an embedded font, which is wrong. For all substitute
fonts, it is important to follow the longer process of first obtaining
the unicode from the charcode to then obtain the glyph in the substitute
font that corresponds to that unicode.
Bug: chromium:781785
Change-Id: Ie5958b43914e0e46334b89b7c2c55c02d0da0c11
Reviewed-on: https://pdfium-review.googlesource.com/17859
Reviewed-by: Lei Zhang <thestig@chromium.org>
Commit-Queue: Nicolás Peña Moreno <npm@chromium.org>
-rw-r--r-- | core/fpdfapi/font/cpdf_cidfont.cpp | 2 | ||||
-rw-r--r-- | core/fxge/android/cfx_androidfontinfo.cpp | 3 | ||||
-rw-r--r-- | core/fxge/android/cfx_androidfontinfo.h | 3 | ||||
-rw-r--r-- | core/fxge/apple/fx_mac_imp.cpp | 7 | ||||
-rw-r--r-- | core/fxge/cfx_folderfontinfo.cpp | 3 | ||||
-rw-r--r-- | core/fxge/cfx_folderfontinfo.h | 3 | ||||
-rw-r--r-- | core/fxge/cfx_font.cpp | 1 | ||||
-rw-r--r-- | core/fxge/cfx_fontmapper.cpp | 10 | ||||
-rw-r--r-- | core/fxge/cfx_substfont.cpp | 3 | ||||
-rw-r--r-- | core/fxge/cfx_substfont.h | 1 | ||||
-rw-r--r-- | core/fxge/fx_ge_linux.cpp | 11 | ||||
-rw-r--r-- | core/fxge/ifx_systemfontinfo.h | 3 | ||||
-rw-r--r-- | core/fxge/win32/fx_win32_device.cpp | 21 | ||||
-rw-r--r-- | fpdfsdk/fpdf_sysfontinfo.cpp | 7 | ||||
-rw-r--r-- | public/fpdf_sysfontinfo.h | 5 | ||||
-rw-r--r-- | xfa/fgas/font/cfgas_fontmgr.cpp | 6 |
16 files changed, 30 insertions, 59 deletions
diff --git a/core/fpdfapi/font/cpdf_cidfont.cpp b/core/fpdfapi/font/cpdf_cidfont.cpp index 4eedf7db69..082b5039e3 100644 --- a/core/fpdfapi/font/cpdf_cidfont.cpp +++ b/core/fpdfapi/font/cpdf_cidfont.cpp @@ -407,7 +407,7 @@ bool CPDF_CIDFont::Load() { if (!IsEmbedded()) LoadSubstFont(); - if (m_pFontFile || GetSubstFont()->m_bFlagExact) { + if (m_pFontFile) { CPDF_Object* pmap = pCIDFontDict->GetDirectObjectFor("CIDToGIDMap"); if (pmap) { if (CPDF_Stream* pStream = pmap->AsStream()) { diff --git a/core/fxge/android/cfx_androidfontinfo.cpp b/core/fxge/android/cfx_androidfontinfo.cpp index 15ac8c29b2..61d213edd6 100644 --- a/core/fxge/android/cfx_androidfontinfo.cpp +++ b/core/fxge/android/cfx_androidfontinfo.cpp @@ -30,8 +30,7 @@ void* CFX_AndroidFontInfo::MapFont(int weight, bool bItalic, int charset, int pitch_family, - const char* face, - int& iExact) { + const char* face) { if (!m_pFontMgr) return nullptr; diff --git a/core/fxge/android/cfx_androidfontinfo.h b/core/fxge/android/cfx_androidfontinfo.h index 653770f095..bf5fae59df 100644 --- a/core/fxge/android/cfx_androidfontinfo.h +++ b/core/fxge/android/cfx_androidfontinfo.h @@ -28,8 +28,7 @@ class CFX_AndroidFontInfo : public IFX_SystemFontInfo { bool bItalic, int charset, int pitch_family, - const char* face, - int& bExact) override; + const char* face) override; void* GetFont(const char* face) override; uint32_t GetFontData(void* hFont, uint32_t table, diff --git a/core/fxge/apple/fx_mac_imp.cpp b/core/fxge/apple/fx_mac_imp.cpp index 324f0200b9..edd36bf2bc 100644 --- a/core/fxge/apple/fx_mac_imp.cpp +++ b/core/fxge/apple/fx_mac_imp.cpp @@ -44,8 +44,7 @@ class CFX_MacFontInfo : public CFX_FolderFontInfo { bool bItalic, int charset, int pitch_family, - const char* family, - int& iExact) override; + const char* family) override; }; const char JAPAN_GOTHIC[] = "Hiragino Kaku Gothic Pro W6"; @@ -64,13 +63,11 @@ void* CFX_MacFontInfo::MapFont(int weight, bool bItalic, int charset, int pitch_family, - const char* cstr_face, - int& iExact) { + const char* cstr_face) { ByteString face = cstr_face; for (size_t i = 0; i < FX_ArraySize(g_Base14Substs); ++i) { if (face == ByteStringView(g_Base14Substs[i].m_pName)) { face = g_Base14Substs[i].m_pSubstName; - iExact = true; return GetFont(face.c_str()); } } diff --git a/core/fxge/cfx_folderfontinfo.cpp b/core/fxge/cfx_folderfontinfo.cpp index 6b564f80c6..532824d248 100644 --- a/core/fxge/cfx_folderfontinfo.cpp +++ b/core/fxge/cfx_folderfontinfo.cpp @@ -313,8 +313,7 @@ void* CFX_FolderFontInfo::MapFont(int weight, bool bItalic, int charset, int pitch_family, - const char* family, - int& iExact) { + const char* family) { return nullptr; } diff --git a/core/fxge/cfx_folderfontinfo.h b/core/fxge/cfx_folderfontinfo.h index 23c20d52d2..79faa01838 100644 --- a/core/fxge/cfx_folderfontinfo.h +++ b/core/fxge/cfx_folderfontinfo.h @@ -29,8 +29,7 @@ class CFX_FolderFontInfo : public IFX_SystemFontInfo { bool bItalic, int charset, int pitch_family, - const char* face, - int& bExact) override; + const char* face) override; #ifdef PDF_ENABLE_XFA void* MapFontByUnicode(uint32_t dwUnicode, int weight, diff --git a/core/fxge/cfx_font.cpp b/core/fxge/cfx_font.cpp index da6b0e0fe3..3f4f1356f8 100644 --- a/core/fxge/cfx_font.cpp +++ b/core/fxge/cfx_font.cpp @@ -237,7 +237,6 @@ bool CFX_Font::LoadClone(const CFX_Font* pFont) { m_pSubstFont = pdfium::MakeUnique<CFX_SubstFont>(); m_pSubstFont->m_Charset = pFont->m_pSubstFont->m_Charset; m_pSubstFont->m_bFlagMM = pFont->m_pSubstFont->m_bFlagMM; - m_pSubstFont->m_bFlagExact = pFont->m_pSubstFont->m_bFlagExact; #ifdef PDF_ENABLE_XFA m_pSubstFont->m_bFlagItalic = pFont->m_pSubstFont->m_bFlagItalic; #endif // PDF_ENABLE_XFA diff --git a/core/fxge/cfx_fontmapper.cpp b/core/fxge/cfx_fontmapper.cpp index 00372885f6..0511b0a76a 100644 --- a/core/fxge/cfx_fontmapper.cpp +++ b/core/fxge/cfx_fontmapper.cpp @@ -337,9 +337,7 @@ void CFX_FontMapper::AddInstalledFont(const ByteString& name, int charset) { if (bLocalized) { void* hFont = m_pFontInfo->GetFont(name.c_str()); if (!hFont) { - int iExact; - hFont = m_pFontInfo->MapFont(0, 0, FX_CHARSET_Default, 0, name.c_str(), - iExact); + hFont = m_pFontInfo->MapFont(0, 0, FX_CHARSET_Default, 0, name.c_str()); if (!hFont) return; } @@ -554,7 +552,6 @@ FXFT_Face CFX_FontMapper::FindSubstFont(const ByteString& name, if (FontStyleIsItalic(nStyle)) bItalic = true; - int iExact = 0; int Charset = FX_CHARSET_ANSI; if (WindowCP) Charset = GetCharsetFromCodePage(WindowCP); @@ -622,11 +619,8 @@ FXFT_Face CFX_FontMapper::FindSubstFont(const ByteString& name, } else if (FontStyleIsItalic(flags)) { bItalic = true; } - iExact = !match.IsEmpty(); void* hFont = m_pFontInfo->MapFont(weight, bItalic, Charset, PitchFamily, - family.c_str(), iExact); - if (iExact) - pSubstFont->m_bFlagExact = true; + family.c_str()); if (!hFont) { #ifdef PDF_ENABLE_XFA if (flags & FXFONT_EXACTMATCH) diff --git a/core/fxge/cfx_substfont.cpp b/core/fxge/cfx_substfont.cpp index 9058ab3d3c..6c5459ede6 100644 --- a/core/fxge/cfx_substfont.cpp +++ b/core/fxge/cfx_substfont.cpp @@ -19,6 +19,5 @@ CFX_SubstFont::CFX_SubstFont() #ifdef PDF_ENABLE_XFA m_bFlagItalic(false), #endif // PDF_ENABLE_XFA - m_bFlagMM(false), - m_bFlagExact(false) { + m_bFlagMM(false) { } diff --git a/core/fxge/cfx_substfont.h b/core/fxge/cfx_substfont.h index 2076a09093..e6d93a80a4 100644 --- a/core/fxge/cfx_substfont.h +++ b/core/fxge/cfx_substfont.h @@ -25,7 +25,6 @@ class CFX_SubstFont { bool m_bFlagItalic; #endif // PDF_ENABLE_XFA bool m_bFlagMM; - bool m_bFlagExact; }; #endif // CORE_FXGE_CFX_SUBSTFONT_H_ diff --git a/core/fxge/fx_ge_linux.cpp b/core/fxge/fx_ge_linux.cpp index c9d1dd128b..22a3c4cd1b 100644 --- a/core/fxge/fx_ge_linux.cpp +++ b/core/fxge/fx_ge_linux.cpp @@ -74,8 +74,7 @@ class CFX_LinuxFontInfo : public CFX_FolderFontInfo { bool bItalic, int charset, int pitch_family, - const char* family, - int& iExact) override; + const char* family) override; bool ParseFontCfg(const char** pUserPaths); }; @@ -83,13 +82,11 @@ void* CFX_LinuxFontInfo::MapFont(int weight, bool bItalic, int charset, int pitch_family, - const char* cstr_face, - int& iExact) { + const char* cstr_face) { void* font = GetSubstFont(cstr_face); - if (font) { - iExact = 1; + if (font) return font; - } + bool bCJK = true; switch (charset) { case FX_CHARSET_ShiftJIS: { diff --git a/core/fxge/ifx_systemfontinfo.h b/core/fxge/ifx_systemfontinfo.h index cb85f7fde4..b6d6626552 100644 --- a/core/fxge/ifx_systemfontinfo.h +++ b/core/fxge/ifx_systemfontinfo.h @@ -27,8 +27,7 @@ class IFX_SystemFontInfo { bool bItalic, int charset, int pitch_family, - const char* face, - int& iExact) = 0; + const char* face) = 0; #ifdef PDF_ENABLE_XFA virtual void* MapFontByUnicode(uint32_t dwUnicode, diff --git a/core/fxge/win32/fx_win32_device.cpp b/core/fxge/win32/fx_win32_device.cpp index 35f9a5fce5..77e988cc42 100644 --- a/core/fxge/win32/fx_win32_device.cpp +++ b/core/fxge/win32/fx_win32_device.cpp @@ -325,8 +325,7 @@ class CFX_Win32FallbackFontInfo final : public CFX_FolderFontInfo { bool bItalic, int charset, int pitch_family, - const char* family, - int& iExact) override; + const char* family) override; }; class CFX_Win32FontInfo final : public IFX_SystemFontInfo { @@ -340,8 +339,7 @@ class CFX_Win32FontInfo final : public IFX_SystemFontInfo { bool bItalic, int charset, int pitch_family, - const char* face, - int& iExact) override; + const char* face) override; void* GetFont(const char* face) override { return nullptr; } uint32_t GetFontData(void* hFont, uint32_t table, @@ -475,13 +473,11 @@ void* CFX_Win32FallbackFontInfo::MapFont(int weight, bool bItalic, int charset, int pitch_family, - const char* cstr_face, - int& iExact) { + const char* cstr_face) { void* font = GetSubstFont(cstr_face); - if (font) { - iExact = 1; + if (font) return font; - } + bool bCJK = true; switch (charset) { case FX_CHARSET_ShiftJIS: @@ -567,18 +563,17 @@ void* CFX_Win32FontInfo::MapFont(int weight, bool bItalic, int charset, int pitch_family, - const char* cstr_face, - int& iExact) { + const char* cstr_face) { ByteString face = cstr_face; int iBaseFont; - for (iBaseFont = 0; iBaseFont < 12; iBaseFont++) + for (iBaseFont = 0; iBaseFont < 12; iBaseFont++) { if (face == ByteStringView(g_Base14Substs[iBaseFont].m_pName)) { face = g_Base14Substs[iBaseFont].m_pWinName; weight = g_Base14Substs[iBaseFont].m_bBold ? FW_BOLD : FW_NORMAL; bItalic = g_Base14Substs[iBaseFont].m_bItalic; - iExact = true; break; } + } if (charset == FX_CHARSET_ANSI || charset == FX_CHARSET_Symbol) charset = FX_CHARSET_Default; diff --git a/fpdfsdk/fpdf_sysfontinfo.cpp b/fpdfsdk/fpdf_sysfontinfo.cpp index f1f165afcb..9d5270c1f0 100644 --- a/fpdfsdk/fpdf_sysfontinfo.cpp +++ b/fpdfsdk/fpdf_sysfontinfo.cpp @@ -50,10 +50,11 @@ class CFX_ExternalFontInfo final : public IFX_SystemFontInfo { bool bItalic, int charset, int pitch_family, - const char* family, - int& iExact) override { + const char* family) override { if (!m_pInfo->MapFont) return nullptr; + + int iExact; return m_pInfo->MapFont(m_pInfo, weight, bItalic, charset, pitch_family, family, &iExact); } @@ -146,7 +147,7 @@ static void* DefaultMapFont(struct _FPDF_SYSFONTINFO* pThis, int* bExact) { auto* pDefault = static_cast<FPDF_SYSFONTINFO_DEFAULT*>(pThis); return pDefault->m_pFontInfo->MapFont(weight, !!bItalic, charset, - pitch_family, family, *bExact); + pitch_family, family); } void* DefaultGetFont(struct _FPDF_SYSFONTINFO* pThis, const char* family) { diff --git a/public/fpdf_sysfontinfo.h b/public/fpdf_sysfontinfo.h index c9aa33856d..49302c892f 100644 --- a/public/fpdf_sysfontinfo.h +++ b/public/fpdf_sysfontinfo.h @@ -106,10 +106,7 @@ typedef struct _FPDF_SYSFONTINFO { *constants. * face - Typeface name. Currently use system local encoding *only. - * bExact - Pointer to a boolean value receiving the indicator - *whether mapper found the exact match. - * If mapper is not sure whether it's exact match, - *ignore this paramter. + * bExact - Obsolete: this parameter is now ignored. * Return Value: * An opaque pointer for font handle, or NULL if system mapping is *not supported. diff --git a/xfa/fgas/font/cfgas_fontmgr.cpp b/xfa/fgas/font/cfgas_fontmgr.cpp index 7beba120fa..3838434a51 100644 --- a/xfa/fgas/font/cfgas_fontmgr.cpp +++ b/xfa/fgas/font/cfgas_fontmgr.cpp @@ -957,10 +957,8 @@ RetainPtr<IFX_SeekableReadStream> CFGAS_FontMgr::CreateFontStream( CFX_FontMapper* pFontMapper, IFX_SystemFontInfo* pSystemFontInfo, uint32_t index) { - int iExact = 0; - void* hFont = - pSystemFontInfo->MapFont(0, 0, FX_CHARSET_Default, 0, - pFontMapper->GetFaceName(index).c_str(), iExact); + void* hFont = pSystemFontInfo->MapFont( + 0, 0, FX_CHARSET_Default, 0, pFontMapper->GetFaceName(index).c_str()); if (!hFont) return nullptr; |