summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornpm <npm@chromium.org>2016-11-11 17:16:23 -0800
committerCommit bot <commit-bot@chromium.org>2016-11-11 17:16:23 -0800
commit8f3eb6051c0465923d6694bd0f0b6dc5bb51cbe3 (patch)
treedf8f721cdf86d0c0cd3a0780bb55ac9a7a58f4f1
parentc40697b24550182898b30de639790eaf82ebf158 (diff)
downloadpdfium-8f3eb6051c0465923d6694bd0f0b6dc5bb51cbe3.tar.xz
Remove IFGAS_FontMgr and clean up (the renamed) CFGAS_FontMgr a little.
IFGAS_FontMgr is an interface only for a class only defined on Windows, plus a class only defined for non-Windows. I'm removing the interface, renaming the class to have the same name in both cases, and cleaning up a bit of unused methods. Review-Url: https://codereview.chromium.org/2494883002
-rw-r--r--BUILD.gn5
-rw-r--r--xfa/fde/css/cfde_cssrulecollection.cpp4
-rw-r--r--xfa/fde/css/fde_css.h2
-rw-r--r--xfa/fde/css/fde_cssstyleselector.cpp2
-rw-r--r--xfa/fde/css/fde_cssstyleselector.h8
-rw-r--r--xfa/fde/fde_gedevice.cpp2
-rw-r--r--xfa/fde/fde_visualset.h2
-rw-r--r--xfa/fde/ifde_txtedtengine.h2
-rw-r--r--xfa/fde/tto/fde_textout.h2
-rw-r--r--xfa/fgas/font/cfgas_fontmgr.cpp (renamed from xfa/fgas/font/fgas_stdfontmgr.cpp)722
-rw-r--r--xfa/fgas/font/cfgas_fontmgr.h (renamed from xfa/fgas/font/fgas_stdfontmgr.h)178
-rw-r--r--xfa/fgas/font/fgas_font.h165
-rw-r--r--xfa/fgas/font/fgas_fontutils.cpp2
-rw-r--r--xfa/fgas/font/fgas_gefont.cpp12
-rw-r--r--xfa/fgas/font/fgas_gefont.h16
-rw-r--r--xfa/fgas/layout/fgas_unicode.h2
-rw-r--r--xfa/fwl/theme/cfwl_widgettp.cpp6
-rw-r--r--xfa/fwl/theme/cfwl_widgettp.h4
-rw-r--r--xfa/fxfa/app/xfa_ffapp.cpp8
-rw-r--r--xfa/fxfa/app/xfa_fontmgr.cpp6
-rw-r--r--xfa/fxfa/app/xfa_textlayout.cpp2
-rw-r--r--xfa/fxfa/xfa_ffapp.h6
-rw-r--r--xfa/fxfa/xfa_fontmgr.h2
23 files changed, 467 insertions, 693 deletions
diff --git a/BUILD.gn b/BUILD.gn
index 322c319ef4..c83854e2c1 100644
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -1145,13 +1145,12 @@ if (pdf_enable_xfa) {
"xfa/fgas/crt/fgas_stream.h",
"xfa/fgas/crt/fgas_utils.cpp",
"xfa/fgas/crt/fgas_utils.h",
- "xfa/fgas/font/fgas_font.h",
+ "xfa/fgas/font/cfgas_fontmgr.cpp",
+ "xfa/fgas/font/cfgas_fontmgr.h",
"xfa/fgas/font/fgas_fontutils.cpp",
"xfa/fgas/font/fgas_fontutils.h",
"xfa/fgas/font/fgas_gefont.cpp",
"xfa/fgas/font/fgas_gefont.h",
- "xfa/fgas/font/fgas_stdfontmgr.cpp",
- "xfa/fgas/font/fgas_stdfontmgr.h",
"xfa/fgas/layout/fgas_linebreak.cpp",
"xfa/fgas/layout/fgas_linebreak.h",
"xfa/fgas/layout/fgas_rtfbreak.cpp",
diff --git a/xfa/fde/css/cfde_cssrulecollection.cpp b/xfa/fde/css/cfde_cssrulecollection.cpp
index 70cc655a56..28a482b834 100644
--- a/xfa/fde/css/cfde_cssrulecollection.cpp
+++ b/xfa/fde/css/cfde_cssrulecollection.cpp
@@ -39,7 +39,7 @@ CFDE_CSSRuleCollection::~CFDE_CSSRuleCollection() {
void CFDE_CSSRuleCollection::AddRulesFrom(const CFDE_CSSStyleSheetArray& sheets,
uint32_t dwMediaList,
- IFGAS_FontMgr* pFontMgr) {
+ CFGAS_FontMgr* pFontMgr) {
int32_t iSheets = sheets.GetSize();
for (int32_t i = 0; i < iSheets; ++i) {
IFDE_CSSStyleSheet* pSheet = sheets.GetAt(i);
@@ -55,7 +55,7 @@ void CFDE_CSSRuleCollection::AddRulesFrom(const CFDE_CSSStyleSheetArray& sheets,
void CFDE_CSSRuleCollection::AddRulesFrom(IFDE_CSSStyleSheet* pStyleSheet,
IFDE_CSSRule* pRule,
uint32_t dwMediaList,
- IFGAS_FontMgr* pFontMgr) {
+ CFGAS_FontMgr* pFontMgr) {
switch (pRule->GetType()) {
case FDE_CSSRULETYPE_Style: {
IFDE_CSSStyleRule* pStyleRule = static_cast<IFDE_CSSStyleRule*>(pRule);
diff --git a/xfa/fde/css/fde_css.h b/xfa/fde/css/fde_css.h
index 1ee037537c..b9a0d2be5d 100644
--- a/xfa/fde/css/fde_css.h
+++ b/xfa/fde/css/fde_css.h
@@ -10,7 +10,7 @@
#include "core/fxge/fx_dib.h"
#include "xfa/fgas/crt/fgas_stream.h"
#include "xfa/fgas/crt/fgas_utils.h"
-#include "xfa/fgas/font/fgas_font.h"
+#include "xfa/fgas/font/cfgas_fontmgr.h"
class CFDE_CSSAccelerator;
class CFDE_CSSDeclaration;
diff --git a/xfa/fde/css/fde_cssstyleselector.cpp b/xfa/fde/css/fde_cssstyleselector.cpp
index 3eef4e4a4a..1bcd161f0c 100644
--- a/xfa/fde/css/fde_cssstyleselector.cpp
+++ b/xfa/fde/css/fde_cssstyleselector.cpp
@@ -106,7 +106,7 @@ FDE_CSSRuleData::FDE_CSSRuleData(CFDE_CSSSelector* pSel,
}
}
-CFDE_CSSStyleSelector::CFDE_CSSStyleSelector(IFGAS_FontMgr* pFontMgr)
+CFDE_CSSStyleSelector::CFDE_CSSStyleSelector(CFGAS_FontMgr* pFontMgr)
: m_pFontMgr(pFontMgr), m_fDefFontSize(12.0f) {
m_ePriorities[FDE_CSSSTYLESHEETPRIORITY_High] = FDE_CSSSTYLESHEETGROUP_Author;
m_ePriorities[FDE_CSSSTYLESHEETPRIORITY_Mid] = FDE_CSSSTYLESHEETGROUP_User;
diff --git a/xfa/fde/css/fde_cssstyleselector.h b/xfa/fde/css/fde_cssstyleselector.h
index d72c9bf0cd..8ef3885823 100644
--- a/xfa/fde/css/fde_cssstyleselector.h
+++ b/xfa/fde/css/fde_cssstyleselector.h
@@ -39,7 +39,7 @@ class CFDE_CSSRuleCollection : public CFX_Target {
void AddRulesFrom(const CFDE_CSSStyleSheetArray& sheets,
uint32_t dwMediaList,
- IFGAS_FontMgr* pFontMgr);
+ CFGAS_FontMgr* pFontMgr);
void Clear();
int32_t CountSelectors() const { return m_iSelectors; }
@@ -70,7 +70,7 @@ class CFDE_CSSRuleCollection : public CFX_Target {
void AddRulesFrom(IFDE_CSSStyleSheet* pStyleSheet,
IFDE_CSSRule* pRule,
uint32_t dwMediaList,
- IFGAS_FontMgr* pFontMgr);
+ CFGAS_FontMgr* pFontMgr);
void AddRuleTo(CFX_MapPtrToPtr& map,
uint32_t dwKey,
CFDE_CSSSelector* pSel,
@@ -88,7 +88,7 @@ class CFDE_CSSRuleCollection : public CFX_Target {
class CFDE_CSSStyleSelector : public CFX_Target {
public:
- explicit CFDE_CSSStyleSelector(IFGAS_FontMgr* pFontMgr);
+ explicit CFDE_CSSStyleSelector(CFGAS_FontMgr* pFontMgr);
~CFDE_CSSStyleSelector() override;
void SetDefFontSize(FX_FLOAT fFontSize);
@@ -172,7 +172,7 @@ class CFDE_CSSStyleSelector : public CFX_Target {
FDE_CSSRUBYPOSITION ToRubyPosition(FDE_CSSPROPERTYVALUE eValue);
FDE_CSSRUBYSPAN ToRubySpan(FDE_CSSPROPERTYVALUE eValue);
- IFGAS_FontMgr* const m_pFontMgr;
+ CFGAS_FontMgr* const m_pFontMgr;
FX_FLOAT m_fDefFontSize;
std::unique_ptr<IFX_MemoryAllocator> m_pRuleDataStore;
CFDE_CSSStyleSheetArray m_SheetGroups[FDE_CSSSTYLESHEETGROUP_MAX];
diff --git a/xfa/fde/fde_gedevice.cpp b/xfa/fde/fde_gedevice.cpp
index 314d17cdc1..4adfd54af4 100644
--- a/xfa/fde/fde_gedevice.cpp
+++ b/xfa/fde/fde_gedevice.cpp
@@ -14,7 +14,7 @@
#include "core/fxge/cfx_substfont.h"
#include "xfa/fde/cfde_path.h"
#include "xfa/fde/fde_object.h"
-#include "xfa/fgas/font/fgas_font.h"
+#include "xfa/fgas/font/cfgas_fontmgr.h"
#include "xfa/fgas/font/fgas_gefont.h"
CFDE_RenderDevice::CFDE_RenderDevice(CFX_RenderDevice* pDevice,
diff --git a/xfa/fde/fde_visualset.h b/xfa/fde/fde_visualset.h
index 58ac4b99e4..481f4a5cbb 100644
--- a/xfa/fde/fde_visualset.h
+++ b/xfa/fde/fde_visualset.h
@@ -13,7 +13,7 @@
#include "xfa/fde/cfde_path.h"
#include "xfa/fde/fde_object.h"
#include "xfa/fgas/crt/fgas_memory.h"
-#include "xfa/fgas/font/fgas_font.h"
+#include "xfa/fgas/font/cfgas_fontmgr.h"
struct FXTEXT_CHARPOS;
diff --git a/xfa/fde/ifde_txtedtengine.h b/xfa/fde/ifde_txtedtengine.h
index 960edd36b7..391449ce7a 100644
--- a/xfa/fde/ifde_txtedtengine.h
+++ b/xfa/fde/ifde_txtedtengine.h
@@ -8,7 +8,7 @@
#define XFA_FDE_IFDE_TXTEDTENGINE_H_
#include "core/fxge/fx_dib.h"
-#include "xfa/fgas/font/fgas_font.h"
+#include "xfa/fgas/font/cfgas_fontmgr.h"
class CFDE_TxtEdtEngine;
class IFDE_TxtEdtPage;
diff --git a/xfa/fde/tto/fde_textout.h b/xfa/fde/tto/fde_textout.h
index 3aba000db1..7e40f39dc7 100644
--- a/xfa/fde/tto/fde_textout.h
+++ b/xfa/fde/tto/fde_textout.h
@@ -15,7 +15,7 @@
#include "core/fxge/fx_dib.h"
#include "xfa/fde/fde_object.h"
#include "xfa/fgas/crt/fgas_utils.h"
-#include "xfa/fgas/font/fgas_font.h"
+#include "xfa/fgas/font/cfgas_fontmgr.h"
#define FDE_TTOSTYLE_Underline 0x0001
#define FDE_TTOSTYLE_Strikeout 0x0002
diff --git a/xfa/fgas/font/fgas_stdfontmgr.cpp b/xfa/fgas/font/cfgas_fontmgr.cpp
index d4907bb919..460acf801b 100644
--- a/xfa/fgas/font/fgas_stdfontmgr.cpp
+++ b/xfa/fgas/font/cfgas_fontmgr.cpp
@@ -4,25 +4,100 @@
// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-#include "xfa/fgas/font/fgas_stdfontmgr.h"
+#include "xfa/fgas/font/cfgas_fontmgr.h"
#include "core/fxcrt/fx_stream.h"
#include "core/fxge/cfx_fontmapper.h"
#include "core/fxge/cfx_fontmgr.h"
#include "core/fxge/cfx_gemodule.h"
#include "core/fxge/ifx_systemfontinfo.h"
+#include "third_party/base/ptr_util.h"
#include "xfa/fgas/crt/fgas_codepage.h"
#include "xfa/fgas/font/fgas_fontutils.h"
#include "xfa/fgas/font/fgas_gefont.h"
#if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_
-std::unique_ptr<IFGAS_FontMgr> IFGAS_FontMgr::Create(
+namespace {
+
+int32_t GetSimilarityScore(FX_FONTDESCRIPTOR const* pFont,
+ uint32_t dwFontStyles) {
+ int32_t iValue = 0;
+ if ((dwFontStyles & FX_FONTSTYLE_Symbolic) ==
+ (pFont->dwFontStyles & FX_FONTSTYLE_Symbolic)) {
+ iValue += 64;
+ }
+ if ((dwFontStyles & FX_FONTSTYLE_FixedPitch) ==
+ (pFont->dwFontStyles & FX_FONTSTYLE_FixedPitch)) {
+ iValue += 32;
+ }
+ if ((dwFontStyles & FX_FONTSTYLE_Serif) ==
+ (pFont->dwFontStyles & FX_FONTSTYLE_Serif)) {
+ iValue += 16;
+ }
+ if ((dwFontStyles & FX_FONTSTYLE_Script) ==
+ (pFont->dwFontStyles & FX_FONTSTYLE_Script)) {
+ iValue += 8;
+ }
+ return iValue;
+}
+
+FX_FONTDESCRIPTOR const* MatchDefaultFont(FX_LPFONTMATCHPARAMS pParams,
+ const CFX_FontDescriptors& fonts) {
+ FX_FONTDESCRIPTOR const* pBestFont = nullptr;
+ int32_t iBestSimilar = 0;
+ bool bMatchStyle = (pParams->dwMatchFlags & FX_FONTMATCHPARA_MatchStyle) > 0;
+ for (int32_t i = 0; i < fonts.GetSize(); ++i) {
+ FX_FONTDESCRIPTOR const* pFont = fonts.GetPtrAt(i);
+ if ((pFont->dwFontStyles & FX_FONTSTYLE_BoldItalic) ==
+ FX_FONTSTYLE_BoldItalic) {
+ continue;
+ }
+ if (pParams->pwsFamily) {
+ if (FXSYS_wcsicmp(pParams->pwsFamily, pFont->wsFontFace))
+ continue;
+ if (pFont->uCharSet == FX_CHARSET_Symbol)
+ return pFont;
+ }
+ if (pFont->uCharSet == FX_CHARSET_Symbol)
+ continue;
+ if (pParams->wCodePage != 0xFFFF) {
+ if (FX_GetCodePageFromCharset(pFont->uCharSet) != pParams->wCodePage)
+ continue;
+ } else {
+ if (pParams->dwUSB < 128) {
+ uint32_t dwByte = pParams->dwUSB / 32;
+ uint32_t dwUSB = 1 << (pParams->dwUSB % 32);
+ if ((pFont->FontSignature.fsUsb[dwByte] & dwUSB) == 0)
+ continue;
+ }
+ }
+ if (bMatchStyle) {
+ if ((pFont->dwFontStyles & 0x0F) == (pParams->dwFontStyles & 0x0F))
+ return pFont;
+ continue;
+ }
+ if (pParams->pwsFamily) {
+ if (FXSYS_wcsicmp(pParams->pwsFamily, pFont->wsFontFace) == 0)
+ return pFont;
+ }
+ int32_t iSimilarValue = GetSimilarityScore(pFont, pParams->dwFontStyles);
+ if (iBestSimilar < iSimilarValue) {
+ iBestSimilar = iSimilarValue;
+ pBestFont = pFont;
+ }
+ }
+ return iBestSimilar < 1 ? nullptr : pBestFont;
+}
+
+} // namespace
+
+std::unique_ptr<CFGAS_FontMgr> CFGAS_FontMgr::Create(
FX_LPEnumAllFonts pEnumerator) {
- return std::unique_ptr<IFGAS_FontMgr>(new CFGAS_StdFontMgrImp(pEnumerator));
+ return pdfium::MakeUnique<CFGAS_FontMgr>(pEnumerator);
}
-CFGAS_StdFontMgrImp::CFGAS_StdFontMgrImp(FX_LPEnumAllFonts pEnumerator)
+CFGAS_FontMgr::CFGAS_FontMgr(FX_LPEnumAllFonts pEnumerator)
: m_pEnumerator(pEnumerator),
m_FontFaces(100),
m_CPFonts(8),
@@ -31,12 +106,11 @@ CFGAS_StdFontMgrImp::CFGAS_StdFontMgrImp(FX_LPEnumAllFonts pEnumerator)
m_BufferFonts(4),
m_StreamFonts(4),
m_DeriveFonts(4) {
- if (m_pEnumerator) {
+ if (m_pEnumerator)
m_pEnumerator(m_FontFaces, nullptr, 0xFEFF);
- }
}
-CFGAS_StdFontMgrImp::~CFGAS_StdFontMgrImp() {
+CFGAS_FontMgr::~CFGAS_FontMgr() {
m_FontFaces.RemoveAll(false);
m_CPFonts.RemoveAll();
m_FamilyFonts.RemoveAll();
@@ -48,15 +122,14 @@ CFGAS_StdFontMgrImp::~CFGAS_StdFontMgrImp() {
m_Fonts[i]->Release();
}
-CFGAS_GEFont* CFGAS_StdFontMgrImp::GetDefFontByCodePage(
+CFGAS_GEFont* CFGAS_FontMgr::GetDefFontByCodePage(
uint16_t wCodePage,
uint32_t dwFontStyles,
const FX_WCHAR* pszFontFamily) {
uint32_t dwHash = FGAS_GetFontHashCode(wCodePage, dwFontStyles);
CFGAS_GEFont* pFont = nullptr;
- if (m_CPFonts.Lookup((void*)(uintptr_t)dwHash, (void*&)pFont)) {
+ if (m_CPFonts.Lookup((void*)(uintptr_t)dwHash, (void*&)pFont))
return pFont ? LoadFont(pFont, dwFontStyles, wCodePage) : nullptr;
- }
FX_FONTDESCRIPTOR const* pFD =
FindFont(pszFontFamily, dwFontStyles, true, wCodePage);
if (!pFD)
@@ -78,15 +151,7 @@ CFGAS_GEFont* CFGAS_StdFontMgrImp::GetDefFontByCodePage(
return nullptr;
}
-CFGAS_GEFont* CFGAS_StdFontMgrImp::GetDefFontByCharset(
- uint8_t nCharset,
- uint32_t dwFontStyles,
- const FX_WCHAR* pszFontFamily) {
- return GetDefFontByCodePage(FX_GetCodePageFromCharset(nCharset), dwFontStyles,
- pszFontFamily);
-}
-
-CFGAS_GEFont* CFGAS_StdFontMgrImp::GetDefFontByUnicode(
+CFGAS_GEFont* CFGAS_FontMgr::GetDefFontByUnicode(
FX_WCHAR wUnicode,
uint32_t dwFontStyles,
const FX_WCHAR* pszFontFamily) {
@@ -125,23 +190,14 @@ CFGAS_GEFont* CFGAS_StdFontMgrImp::GetDefFontByUnicode(
return nullptr;
}
-CFGAS_GEFont* CFGAS_StdFontMgrImp::GetDefFontByLanguage(
- uint16_t wLanguage,
- uint32_t dwFontStyles,
- const FX_WCHAR* pszFontFamily) {
- return GetDefFontByCodePage(FX_GetDefCodePageByLanguage(wLanguage),
- dwFontStyles, pszFontFamily);
-}
-
-CFGAS_GEFont* CFGAS_StdFontMgrImp::LoadFont(const FX_WCHAR* pszFontFamily,
- uint32_t dwFontStyles,
- uint16_t wCodePage) {
+CFGAS_GEFont* CFGAS_FontMgr::LoadFont(const FX_WCHAR* pszFontFamily,
+ uint32_t dwFontStyles,
+ uint16_t wCodePage) {
uint32_t dwHash =
FGAS_GetFontFamilyHash(pszFontFamily, dwFontStyles, wCodePage);
CFGAS_GEFont* pFont = nullptr;
- if (m_FamilyFonts.Lookup((void*)(uintptr_t)dwHash, (void*&)pFont)) {
+ if (m_FamilyFonts.Lookup((void*)(uintptr_t)dwHash, (void*&)pFont))
return pFont ? LoadFont(pFont, dwFontStyles, wCodePage) : nullptr;
- }
FX_FONTDESCRIPTOR const* pFD =
FindFont(pszFontFamily, dwFontStyles, true, wCodePage);
if (!pFD)
@@ -149,9 +205,8 @@ CFGAS_GEFont* CFGAS_StdFontMgrImp::LoadFont(const FX_WCHAR* pszFontFamily,
if (!pFD)
return nullptr;
- if (wCodePage == 0xFFFF) {
+ if (wCodePage == 0xFFFF)
wCodePage = FX_GetCodePageFromCharset(pFD->uCharSet);
- }
pFont =
CFGAS_GEFont::LoadFont(pFD->wsFontFace, dwFontStyles, wCodePage, this);
if (pFont) {
@@ -164,14 +219,12 @@ CFGAS_GEFont* CFGAS_StdFontMgrImp::LoadFont(const FX_WCHAR* pszFontFamily,
return nullptr;
}
-CFGAS_GEFont* CFGAS_StdFontMgrImp::LoadFont(const uint8_t* pBuffer,
- int32_t iLength) {
+CFGAS_GEFont* CFGAS_FontMgr::LoadFont(const uint8_t* pBuffer, int32_t iLength) {
ASSERT(pBuffer && iLength > 0);
CFGAS_GEFont* pFont = nullptr;
if (m_BufferFonts.Lookup((void*)pBuffer, (void*&)pFont)) {
- if (pFont) {
+ if (pFont)
return pFont->Retain();
- }
}
pFont = CFGAS_GEFont::LoadFont(pBuffer, iLength, this);
if (pFont) {
@@ -182,11 +235,11 @@ CFGAS_GEFont* CFGAS_StdFontMgrImp::LoadFont(const uint8_t* pBuffer,
return nullptr;
}
-CFGAS_GEFont* CFGAS_StdFontMgrImp::LoadFont(IFX_Stream* pFontStream,
- const FX_WCHAR* pszFontAlias,
- uint32_t dwFontStyles,
- uint16_t wCodePage,
- bool bSaveStream) {
+CFGAS_GEFont* CFGAS_FontMgr::LoadFont(IFX_Stream* pFontStream,
+ const FX_WCHAR* pszFontAlias,
+ uint32_t dwFontStyles,
+ uint16_t wCodePage,
+ bool bSaveStream) {
ASSERT(pFontStream && pFontStream->GetLength() > 0);
CFGAS_GEFont* pFont = nullptr;
if (m_StreamFonts.Lookup((void*)pFontStream, (void*&)pFont)) {
@@ -213,13 +266,12 @@ CFGAS_GEFont* CFGAS_StdFontMgrImp::LoadFont(IFX_Stream* pFontStream,
return nullptr;
}
-CFGAS_GEFont* CFGAS_StdFontMgrImp::LoadFont(CFGAS_GEFont* pSrcFont,
- uint32_t dwFontStyles,
- uint16_t wCodePage) {
+CFGAS_GEFont* CFGAS_FontMgr::LoadFont(CFGAS_GEFont* pSrcFont,
+ uint32_t dwFontStyles,
+ uint16_t wCodePage) {
ASSERT(pSrcFont);
- if (pSrcFont->GetFontStyles() == dwFontStyles) {
+ if (pSrcFont->GetFontStyles() == dwFontStyles)
return pSrcFont->Retain();
- }
void* buffer[3] = {pSrcFont, (void*)(uintptr_t)dwFontStyles,
(void*)(uintptr_t)wCodePage};
uint32_t dwHash = FX_HashCode_GetA(
@@ -227,9 +279,8 @@ CFGAS_GEFont* CFGAS_StdFontMgrImp::LoadFont(CFGAS_GEFont* pSrcFont,
CFGAS_GEFont* pFont = nullptr;
if (m_DeriveFonts.GetCount() > 0) {
m_DeriveFonts.Lookup((void*)(uintptr_t)dwHash, (void*&)pFont);
- if (pFont) {
+ if (pFont)
return pFont->Retain();
- }
}
pFont = pSrcFont->Derive(dwFontStyles, wCodePage);
if (pFont) {
@@ -244,28 +295,26 @@ CFGAS_GEFont* CFGAS_StdFontMgrImp::LoadFont(CFGAS_GEFont* pSrcFont,
return nullptr;
}
-void CFGAS_StdFontMgrImp::ClearFontCache() {
+void CFGAS_FontMgr::ClearFontCache() {
for (int32_t i = 0; i < m_Fonts.GetSize(); i++)
m_Fonts[i]->Reset();
}
-void CFGAS_StdFontMgrImp::RemoveFont(CFX_MapPtrToPtr& fontMap,
- CFGAS_GEFont* pFont) {
+void CFGAS_FontMgr::RemoveFont(CFX_MapPtrToPtr& fontMap, CFGAS_GEFont* pFont) {
FX_POSITION pos = fontMap.GetStartPosition();
void* pKey;
void* pFind;
while (pos) {
pFind = nullptr;
fontMap.GetNextAssoc(pos, pKey, pFind);
- if (pFind != (void*)pFont) {
+ if (pFind != (void*)pFont)
continue;
- }
fontMap.RemoveKey(pKey);
break;
}
}
-void CFGAS_StdFontMgrImp::RemoveFont(CFGAS_GEFont* pFont) {
+void CFGAS_FontMgr::RemoveFont(CFGAS_GEFont* pFont) {
RemoveFont(m_CPFonts, pFont);
RemoveFont(m_FamilyFonts, pFont);
RemoveFont(m_UnicodeFonts, pFont);
@@ -273,18 +322,16 @@ void CFGAS_StdFontMgrImp::RemoveFont(CFGAS_GEFont* pFont) {
RemoveFont(m_StreamFonts, pFont);
RemoveFont(m_DeriveFonts, pFont);
int32_t iFind = m_Fonts.Find(pFont);
- if (iFind > -1) {
+ if (iFind > -1)
m_Fonts.RemoveAt(iFind, 1);
- }
}
-FX_FONTDESCRIPTOR const* CFGAS_StdFontMgrImp::FindFont(
- const FX_WCHAR* pszFontFamily,
- uint32_t dwFontStyles,
- uint32_t dwMatchFlags,
- uint16_t wCodePage,
- uint32_t dwUSB,
- FX_WCHAR wUnicode) {
+FX_FONTDESCRIPTOR const* CFGAS_FontMgr::FindFont(const FX_WCHAR* pszFontFamily,
+ uint32_t dwFontStyles,
+ uint32_t dwMatchFlags,
+ uint16_t wCodePage,
+ uint32_t dwUSB,
+ FX_WCHAR wUnicode) {
FX_FONTMATCHPARAMS params;
FXSYS_memset(&params, 0, sizeof(params));
params.dwUSB = dwUSB;
@@ -293,23 +340,20 @@ FX_FONTDESCRIPTOR const* CFGAS_StdFontMgrImp::FindFont(
params.pwsFamily = pszFontFamily;
params.dwFontStyles = dwFontStyles;
params.dwMatchFlags = dwMatchFlags;
- FX_FONTDESCRIPTOR const* pDesc = FX_DefFontMatcher(&params, m_FontFaces);
- if (pDesc) {
+ FX_FONTDESCRIPTOR const* pDesc = MatchDefaultFont(&params, m_FontFaces);
+ if (pDesc)
return pDesc;
- }
if (pszFontFamily && m_pEnumerator) {
CFX_FontDescriptors namedFonts(100);
m_pEnumerator(namedFonts, pszFontFamily, wUnicode);
params.pwsFamily = nullptr;
- pDesc = FX_DefFontMatcher(&params, namedFonts);
- if (!pDesc) {
+ pDesc = MatchDefaultFont(&params, namedFonts);
+ if (!pDesc)
return nullptr;
- }
for (int32_t i = m_FontFaces.GetSize() - 1; i >= 0; i--) {
FX_FONTDESCRIPTOR const* pMatch = m_FontFaces.GetPtrAt(i);
- if (*pMatch == *pDesc) {
+ if (*pMatch == *pDesc)
return pMatch;
- }
}
int index = m_FontFaces.Add(*pDesc);
return m_FontFaces.GetPtrAt(index);
@@ -317,102 +361,17 @@ FX_FONTDESCRIPTOR const* CFGAS_StdFontMgrImp::FindFont(
return nullptr;
}
-FX_FONTDESCRIPTOR const* FX_DefFontMatcher(FX_LPFONTMATCHPARAMS pParams,
- const CFX_FontDescriptors& fonts) {
- FX_FONTDESCRIPTOR const* pBestFont = nullptr;
- int32_t iBestSimilar = 0;
- bool bMatchStyle = (pParams->dwMatchFlags & FX_FONTMATCHPARA_MacthStyle) > 0;
- int32_t iCount = fonts.GetSize();
- for (int32_t i = 0; i < iCount; ++i) {
- FX_FONTDESCRIPTOR const* pFont = fonts.GetPtrAt(i);
- if ((pFont->dwFontStyles & FX_FONTSTYLE_BoldItalic) ==
- FX_FONTSTYLE_BoldItalic) {
- continue;
- }
- if (pParams->pwsFamily) {
- if (FXSYS_wcsicmp(pParams->pwsFamily, pFont->wsFontFace)) {
- continue;
- }
- if (pFont->uCharSet == FX_CHARSET_Symbol) {
- return pFont;
- }
- }
- if (pFont->uCharSet == FX_CHARSET_Symbol) {
- continue;
- }
- if (pParams->wCodePage != 0xFFFF) {
- if (FX_GetCodePageFromCharset(pFont->uCharSet) != pParams->wCodePage) {
- continue;
- }
- } else {
- if (pParams->dwUSB < 128) {
- uint32_t dwByte = pParams->dwUSB / 32;
- uint32_t dwUSB = 1 << (pParams->dwUSB % 32);
- if ((pFont->FontSignature.fsUsb[dwByte] & dwUSB) == 0) {
- continue;
- }
- }
- }
- if (bMatchStyle) {
- if ((pFont->dwFontStyles & 0x0F) == (pParams->dwFontStyles & 0x0F))
- return pFont;
- continue;
- }
- if (pParams->pwsFamily) {
- if (FXSYS_wcsicmp(pParams->pwsFamily, pFont->wsFontFace) == 0) {
- return pFont;
- }
- }
- int32_t iSimilarValue = FX_GetSimilarValue(pFont, pParams->dwFontStyles);
- if (iBestSimilar < iSimilarValue) {
- iBestSimilar = iSimilarValue;
- pBestFont = pFont;
- }
- }
- return iBestSimilar < 1 ? nullptr : pBestFont;
-}
-
-int32_t FX_GetSimilarValue(FX_FONTDESCRIPTOR const* pFont,
- uint32_t dwFontStyles) {
- int32_t iValue = 0;
- if ((dwFontStyles & FX_FONTSTYLE_Symbolic) ==
- (pFont->dwFontStyles & FX_FONTSTYLE_Symbolic)) {
- iValue += 64;
- }
- if ((dwFontStyles & FX_FONTSTYLE_FixedPitch) ==
- (pFont->dwFontStyles & FX_FONTSTYLE_FixedPitch)) {
- iValue += 32;
- }
- if ((dwFontStyles & FX_FONTSTYLE_Serif) ==
- (pFont->dwFontStyles & FX_FONTSTYLE_Serif)) {
- iValue += 16;
- }
- if ((dwFontStyles & FX_FONTSTYLE_Script) ==
- (pFont->dwFontStyles & FX_FONTSTYLE_Script)) {
- iValue += 8;
- }
- return iValue;
-}
-
-FX_LPMatchFont FX_GetDefFontMatchor() {
- return FX_DefFontMatcher;
-}
-
uint32_t FX_GetGdiFontStyles(const LOGFONTW& lf) {
uint32_t dwStyles = 0;
- if ((lf.lfPitchAndFamily & 0x03) == FIXED_PITCH) {
+ if ((lf.lfPitchAndFamily & 0x03) == FIXED_PITCH)
dwStyles |= FX_FONTSTYLE_FixedPitch;
- }
uint8_t nFamilies = lf.lfPitchAndFamily & 0xF0;
- if (nFamilies == FF_ROMAN) {
+ if (nFamilies == FF_ROMAN)
dwStyles |= FX_FONTSTYLE_Serif;
- }
- if (nFamilies == FF_SCRIPT) {
+ if (nFamilies == FF_SCRIPT)
dwStyles |= FX_FONTSTYLE_Script;
- }
- if (lf.lfCharSet == SYMBOL_CHARSET) {
+ if (lf.lfCharSet == SYMBOL_CHARSET)
dwStyles |= FX_FONTSTYLE_Symbolic;
- }
return dwStyles;
}
@@ -420,13 +379,11 @@ static int32_t CALLBACK FX_GdiFontEnumProc(ENUMLOGFONTEX* lpelfe,
NEWTEXTMETRICEX* lpntme,
DWORD dwFontType,
LPARAM lParam) {
- if (dwFontType != TRUETYPE_FONTTYPE) {
+ if (dwFontType != TRUETYPE_FONTTYPE)
return 1;
- }
const LOGFONTW& lf = ((LPENUMLOGFONTEXW)lpelfe)->elfLogFont;
- if (lf.lfFaceName[0] == L'@') {
+ if (lf.lfFaceName[0] == L'@')
return 1;
- }
FX_FONTDESCRIPTOR* pFont = FX_Alloc(FX_FONTDESCRIPTOR, 1);
FXSYS_memset(pFont, 0, sizeof(FX_FONTDESCRIPTOR));
pFont->uCharSet = lf.lfCharSet;
@@ -460,7 +417,10 @@ FX_LPEnumAllFonts FX_GetDefFontEnumerator() {
return FX_EnumGdiFonts;
}
-#else
+#else // _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_
+
+namespace {
+
const FX_CHAR* g_FontFolders[] = {
#if _FXM_PLATFORM_ == _FXM_PLATFORM_LINUX_
"/usr/share/fonts", "/usr/share/X11/fonts/Type1",
@@ -472,6 +432,113 @@ const FX_CHAR* g_FontFolders[] = {
#endif
};
+struct FX_BitCodePage {
+ uint16_t wBit;
+ uint16_t wCodePage;
+};
+
+const FX_BitCodePage g_Bit2CodePage[] = {
+ {0, 1252}, {1, 1250}, {2, 1251}, {3, 1253}, {4, 1254}, {5, 1255},
+ {6, 1256}, {7, 1257}, {8, 1258}, {9, 0}, {10, 0}, {11, 0},
+ {12, 0}, {13, 0}, {14, 0}, {15, 0}, {16, 874}, {17, 932},
+ {18, 936}, {19, 949}, {20, 950}, {21, 1361}, {22, 0}, {23, 0},
+ {24, 0}, {25, 0}, {26, 0}, {27, 0}, {28, 0}, {29, 0},
+ {30, 0}, {31, 0}, {32, 0}, {33, 0}, {34, 0}, {35, 0},
+ {36, 0}, {37, 0}, {38, 0}, {39, 0}, {40, 0}, {41, 0},
+ {42, 0}, {43, 0}, {44, 0}, {45, 0}, {46, 0}, {47, 0},
+ {48, 869}, {49, 866}, {50, 865}, {51, 864}, {52, 863}, {53, 862},
+ {54, 861}, {55, 860}, {56, 857}, {57, 855}, {58, 852}, {59, 775},
+ {60, 737}, {61, 708}, {62, 850}, {63, 437},
+};
+
+uint16_t FX_GetCodePageBit(uint16_t wCodePage) {
+ for (size_t i = 0; i < FX_ArraySize(g_Bit2CodePage); ++i) {
+ if (g_Bit2CodePage[i].wCodePage == wCodePage)
+ return g_Bit2CodePage[i].wBit;
+ }
+ return (uint16_t)-1;
+}
+
+uint16_t FX_GetUnicodeBit(FX_WCHAR wcUnicode) {
+ const FGAS_FONTUSB* x = FGAS_GetUnicodeBitField(wcUnicode);
+ return x ? x->wBitField : 999;
+}
+
+inline uint8_t GetUInt8(const uint8_t* p) {
+ return (uint8_t)(p[0]);
+}
+
+inline uint16_t GetUInt16(const uint8_t* p) {
+ return (uint16_t)(p[0] << 8 | p[1]);
+}
+
+struct FX_BIT2CHARSET {
+ uint16_t wBit;
+ uint16_t wCharset;
+};
+
+const FX_BIT2CHARSET g_FX_Bit2Charset1[16] = {
+ {1 << 0, FX_CHARSET_ANSI},
+ {1 << 1, FX_CHARSET_MSWin_EasterEuropean},
+ {1 << 2, FX_CHARSET_MSWin_Cyrillic},
+ {1 << 3, FX_CHARSET_MSWin_Greek},
+ {1 << 4, FX_CHARSET_MSWin_Turkish},
+ {1 << 5, FX_CHARSET_MSWin_Hebrew},
+ {1 << 6, FX_CHARSET_MSWin_Arabic},
+ {1 << 7, FX_CHARSET_MSWin_Baltic},
+ {1 << 8, FX_CHARSET_MSWin_Vietnamese},
+ {1 << 9, FX_CHARSET_Default},
+ {1 << 10, FX_CHARSET_Default},
+ {1 << 11, FX_CHARSET_Default},
+ {1 << 12, FX_CHARSET_Default},
+ {1 << 13, FX_CHARSET_Default},
+ {1 << 14, FX_CHARSET_Default},
+ {1 << 15, FX_CHARSET_Default},
+};
+
+const FX_BIT2CHARSET g_FX_Bit2Charset2[16] = {
+ {1 << 0, FX_CHARSET_Thai},
+ {1 << 1, FX_CHARSET_ShiftJIS},
+ {1 << 2, FX_CHARSET_ChineseSimplified},
+ {1 << 3, FX_CHARSET_Korean},
+ {1 << 4, FX_CHARSET_ChineseTriditional},
+ {1 << 5, FX_CHARSET_Johab},
+ {1 << 6, FX_CHARSET_Default},
+ {1 << 7, FX_CHARSET_Default},
+ {1 << 8, FX_CHARSET_Default},
+ {1 << 9, FX_CHARSET_Default},
+ {1 << 10, FX_CHARSET_Default},
+ {1 << 11, FX_CHARSET_Default},
+ {1 << 12, FX_CHARSET_Default},
+ {1 << 13, FX_CHARSET_Default},
+ {1 << 14, FX_CHARSET_OEM},
+ {1 << 15, FX_CHARSET_Symbol},
+};
+
+const FX_BIT2CHARSET g_FX_Bit2Charset3[16] = {
+ {1 << 0, FX_CHARSET_Default}, {1 << 1, FX_CHARSET_Default},
+ {1 << 2, FX_CHARSET_Default}, {1 << 3, FX_CHARSET_Default},
+ {1 << 4, FX_CHARSET_Default}, {1 << 5, FX_CHARSET_Default},
+ {1 << 6, FX_CHARSET_Default}, {1 << 7, FX_CHARSET_Default},
+ {1 << 8, FX_CHARSET_Default}, {1 << 9, FX_CHARSET_Default},
+ {1 << 10, FX_CHARSET_Default}, {1 << 11, FX_CHARSET_Default},
+ {1 << 12, FX_CHARSET_Default}, {1 << 13, FX_CHARSET_Default},
+ {1 << 14, FX_CHARSET_Default}, {1 << 15, FX_CHARSET_Default},
+};
+
+const FX_BIT2CHARSET g_FX_Bit2Charset4[16] = {
+ {1 << 0, FX_CHARSET_Default}, {1 << 1, FX_CHARSET_Default},
+ {1 << 2, FX_CHARSET_Default}, {1 << 3, FX_CHARSET_Default},
+ {1 << 4, FX_CHARSET_Default}, {1 << 5, FX_CHARSET_Default},
+ {1 << 6, FX_CHARSET_Default}, {1 << 7, FX_CHARSET_Default},
+ {1 << 8, FX_CHARSET_Default}, {1 << 9, FX_CHARSET_Default},
+ {1 << 10, FX_CHARSET_Default}, {1 << 11, FX_CHARSET_Default},
+ {1 << 12, FX_CHARSET_Default}, {1 << 13, FX_CHARSET_Default},
+ {1 << 14, FX_CHARSET_Default}, {1 << 15, FX_CHARSET_US},
+};
+
+} // namespace
+
CFX_FontDescriptor::CFX_FontDescriptor()
: m_nFaceIndex(0), m_dwFontStyles(0), m_dwUsb(), m_dwCsb() {}
@@ -539,9 +606,8 @@ CFX_ByteString CFX_FontSourceEnum_File::GetNextFile() {
FX_POSITION CFX_FontSourceEnum_File::GetStartPosition() {
m_wsNext = GetNextFile().UTF8Decode();
- if (m_wsNext.GetLength() == 0) {
+ if (m_wsNext.GetLength() == 0)
return (FX_POSITION)0;
- }
return (FX_POSITION)-1;
}
@@ -552,24 +618,23 @@ IFX_FileAccess* CFX_FontSourceEnum_File::GetNext(FX_POSITION& pos) {
return pAccess;
}
-std::unique_ptr<IFGAS_FontMgr> IFGAS_FontMgr::Create(
+std::unique_ptr<CFGAS_FontMgr> CFGAS_FontMgr::Create(
CFX_FontSourceEnum_File* pFontEnum) {
if (!pFontEnum)
return nullptr;
- std::unique_ptr<CFGAS_FontMgrImp> pFontMgr(new CFGAS_FontMgrImp(pFontEnum));
+ auto pFontMgr = pdfium::MakeUnique<CFGAS_FontMgr>(pFontEnum);
if (!pFontMgr->EnumFonts())
return nullptr;
- return std::move(pFontMgr);
+ return pFontMgr;
}
-CFGAS_FontMgrImp::CFGAS_FontMgrImp(CFX_FontSourceEnum_File* pFontEnum)
+CFGAS_FontMgr::CFGAS_FontMgr(CFX_FontSourceEnum_File* pFontEnum)
: m_pFontSource(pFontEnum) {}
-CFGAS_FontMgrImp::~CFGAS_FontMgrImp() {
- for (int32_t i = 0; i < m_InstalledFonts.GetSize(); i++) {
+CFGAS_FontMgr::~CFGAS_FontMgr() {
+ for (int32_t i = 0; i < m_InstalledFonts.GetSize(); i++)
delete m_InstalledFonts[i];
- }
FX_POSITION pos = m_Hash2CandidateList.GetStartPosition();
while (pos) {
uint32_t dwHash;
@@ -596,7 +661,7 @@ CFGAS_FontMgrImp::~CFGAS_FontMgrImp() {
}
}
-bool CFGAS_FontMgrImp::EnumFontsFromFontMapper() {
+bool CFGAS_FontMgr::EnumFontsFromFontMapper() {
CFX_FontMapper* pFontMapper =
CFX_GEModule::Get()->GetFontMgr()->GetBuiltinMapper();
if (!pFontMapper)
@@ -624,7 +689,7 @@ bool CFGAS_FontMgrImp::EnumFontsFromFontMapper() {
return true;
}
-bool CFGAS_FontMgrImp::EnumFontsFromFiles() {
+bool CFGAS_FontMgr::EnumFontsFromFiles() {
CFX_GEModule::Get()->GetFontMgr()->InitFTLibrary();
FX_POSITION pos = m_pFontSource->GetStartPosition();
IFX_FileAccess* pFontSource = nullptr;
@@ -645,44 +710,15 @@ bool CFGAS_FontMgrImp::EnumFontsFromFiles() {
return true;
}
-bool CFGAS_FontMgrImp::EnumFonts() {
+bool CFGAS_FontMgr::EnumFonts() {
if (EnumFontsFromFontMapper())
return true;
return EnumFontsFromFiles();
}
-CFGAS_GEFont* CFGAS_FontMgrImp::GetDefFontByCodePage(
- uint16_t wCodePage,
- uint32_t dwFontStyles,
- const FX_WCHAR* pszFontFamily) {
- return nullptr;
-}
-
-CFGAS_GEFont* CFGAS_FontMgrImp::GetDefFontByCharset(
- uint8_t nCharset,
- uint32_t dwFontStyles,
- const FX_WCHAR* pszFontFamily) {
- return nullptr;
-}
-
-CFGAS_GEFont* CFGAS_FontMgrImp::GetDefFontByUnicode(
- FX_WCHAR wUnicode,
- uint32_t dwFontStyles,
- const FX_WCHAR* pszFontFamily) {
- return nullptr;
-}
-
-CFGAS_GEFont* CFGAS_FontMgrImp::GetDefFontByLanguage(
- uint16_t wLanguage,
- uint32_t dwFontStyles,
- const FX_WCHAR* pszFontFamily) {
- return nullptr;
-}
-
-CFGAS_GEFont* CFGAS_FontMgrImp::GetFontByCodePage(
- uint16_t wCodePage,
- uint32_t dwFontStyles,
- const FX_WCHAR* pszFontFamily) {
+CFGAS_GEFont* CFGAS_FontMgr::GetFontByCodePage(uint16_t wCodePage,
+ uint32_t dwFontStyles,
+ const FX_WCHAR* pszFontFamily) {
CFX_ByteString bsHash;
bsHash.Format("%d, %d", wCodePage, dwFontStyles);
bsHash += CFX_WideString(pszFontFamily).UTF8Encode();
@@ -720,18 +756,9 @@ CFGAS_GEFont* CFGAS_FontMgrImp::GetFontByCodePage(
return pFont;
}
-CFGAS_GEFont* CFGAS_FontMgrImp::GetFontByCharset(
- uint8_t nCharset,
- uint32_t dwFontStyles,
- const FX_WCHAR* pszFontFamily) {
- return GetFontByCodePage(FX_GetCodePageFromCharset(nCharset), dwFontStyles,
- pszFontFamily);
-}
-
-CFGAS_GEFont* CFGAS_FontMgrImp::GetFontByUnicode(
- FX_WCHAR wUnicode,
- uint32_t dwFontStyles,
- const FX_WCHAR* pszFontFamily) {
+CFGAS_GEFont* CFGAS_FontMgr::GetFontByUnicode(FX_WCHAR wUnicode,
+ uint32_t dwFontStyles,
+ const FX_WCHAR* pszFontFamily) {
CFGAS_GEFont* pFont = nullptr;
if (m_FailedUnicodes2Nullptr.Lookup(wUnicode, pFont))
return nullptr;
@@ -780,8 +807,8 @@ CFGAS_GEFont* CFGAS_FontMgrImp::GetFontByUnicode(
return nullptr;
}
-bool CFGAS_FontMgrImp::VerifyUnicode(CFX_FontDescriptor* pDesc,
- FX_WCHAR wcUnicode) {
+bool CFGAS_FontMgr::VerifyUnicode(CFX_FontDescriptor* pDesc,
+ FX_WCHAR wcUnicode) {
IFX_SeekableReadStream* pFileRead =
CreateFontStream(pDesc->m_wsFaceName.UTF8Encode());
if (!pFileRead)
@@ -798,7 +825,7 @@ bool CFGAS_FontMgrImp::VerifyUnicode(CFX_FontDescriptor* pDesc,
return !retCharmap && retIndex;
}
-bool CFGAS_FontMgrImp::VerifyUnicode(CFGAS_GEFont* pFont, FX_WCHAR wcUnicode) {
+bool CFGAS_FontMgr::VerifyUnicode(CFGAS_GEFont* pFont, FX_WCHAR wcUnicode) {
if (!pFont)
return false;
@@ -814,17 +841,9 @@ bool CFGAS_FontMgrImp::VerifyUnicode(CFGAS_GEFont* pFont, FX_WCHAR wcUnicode) {
return true;
}
-CFGAS_GEFont* CFGAS_FontMgrImp::GetFontByLanguage(
- uint16_t wLanguage,
- uint32_t dwFontStyles,
- const FX_WCHAR* pszFontFamily) {
- return GetFontByCodePage(FX_GetDefCodePageByLanguage(wLanguage), dwFontStyles,
- pszFontFamily);
-}
-
-CFGAS_GEFont* CFGAS_FontMgrImp::LoadFont(const CFX_WideString& wsFaceName,
- int32_t iFaceIndex,
- int32_t* pFaceCount) {
+CFGAS_GEFont* CFGAS_FontMgr::LoadFont(const CFX_WideString& wsFaceName,
+ int32_t iFaceIndex,
+ int32_t* pFaceCount) {
CFX_FontMgr* pFontMgr = CFX_GEModule::Get()->GetFontMgr();
CFX_FontMapper* pFontMapper = pFontMgr->GetBuiltinMapper();
if (!pFontMapper)
@@ -879,8 +898,8 @@ void _ftStreamClose(FXFT_Stream stream) {}
}; // extern "C"
-FXFT_Face CFGAS_FontMgrImp::LoadFace(IFX_SeekableReadStream* pFontStream,
- int32_t iFaceIndex) {
+FXFT_Face CFGAS_FontMgr::LoadFace(IFX_SeekableReadStream* pFontStream,
+ int32_t iFaceIndex) {
if (!pFontStream)
return nullptr;
@@ -914,7 +933,7 @@ FXFT_Face CFGAS_FontMgrImp::LoadFace(IFX_SeekableReadStream* pFontStream,
return pFace;
}
-IFX_SeekableReadStream* CFGAS_FontMgrImp::CreateFontStream(
+IFX_SeekableReadStream* CFGAS_FontMgr::CreateFontStream(
CFX_FontMapper* pFontMapper,
IFX_SystemFontInfo* pSystemFontInfo,
uint32_t index) {
@@ -935,7 +954,7 @@ IFX_SeekableReadStream* CFGAS_FontMgrImp::CreateFontStream(
return FX_CreateMemoryStream(pBuffer, dwFileSize, true);
}
-IFX_SeekableReadStream* CFGAS_FontMgrImp::CreateFontStream(
+IFX_SeekableReadStream* CFGAS_FontMgr::CreateFontStream(
const CFX_ByteString& bsFaceName) {
CFX_FontMgr* pFontMgr = CFX_GEModule::Get()->GetFontMgr();
CFX_FontMapper* pFontMapper = pFontMgr->GetBuiltinMapper();
@@ -955,11 +974,11 @@ IFX_SeekableReadStream* CFGAS_FontMgrImp::CreateFontStream(
return nullptr;
}
-int32_t CFGAS_FontMgrImp::MatchFonts(CFX_FontDescriptorInfos& MatchedFonts,
- uint16_t wCodePage,
- uint32_t dwFontStyles,
- const CFX_WideString& FontName,
- FX_WCHAR wcUnicode) {
+int32_t CFGAS_FontMgr::MatchFonts(CFX_FontDescriptorInfos& MatchedFonts,
+ uint16_t wCodePage,
+ uint32_t dwFontStyles,
+ const CFX_WideString& FontName,
+ FX_WCHAR wcUnicode) {
MatchedFonts.RemoveAll();
CFX_WideString wsNormalizedFontName = FontName;
@@ -987,56 +1006,23 @@ int32_t CFGAS_FontMgrImp::MatchFonts(CFX_FontDescriptorInfos& MatchedFonts,
return MatchedFonts.GetSize();
}
-struct FX_BitCodePage {
- uint16_t wBit;
- uint16_t wCodePage;
-};
-static const FX_BitCodePage g_Bit2CodePage[] = {
- {0, 1252}, {1, 1250}, {2, 1251}, {3, 1253}, {4, 1254}, {5, 1255},
- {6, 1256}, {7, 1257}, {8, 1258}, {9, 0}, {10, 0}, {11, 0},
- {12, 0}, {13, 0}, {14, 0}, {15, 0}, {16, 874}, {17, 932},
- {18, 936}, {19, 949}, {20, 950}, {21, 1361}, {22, 0}, {23, 0},
- {24, 0}, {25, 0}, {26, 0}, {27, 0}, {28, 0}, {29, 0},
- {30, 0}, {31, 0}, {32, 0}, {33, 0}, {34, 0}, {35, 0},
- {36, 0}, {37, 0}, {38, 0}, {39, 0}, {40, 0}, {41, 0},
- {42, 0}, {43, 0}, {44, 0}, {45, 0}, {46, 0}, {47, 0},
- {48, 869}, {49, 866}, {50, 865}, {51, 864}, {52, 863}, {53, 862},
- {54, 861}, {55, 860}, {56, 857}, {57, 855}, {58, 852}, {59, 775},
- {60, 737}, {61, 708}, {62, 850}, {63, 437},
-};
-
-uint16_t FX_GetCodePageBit(uint16_t wCodePage) {
- for (size_t i = 0; i < FX_ArraySize(g_Bit2CodePage); ++i) {
- if (g_Bit2CodePage[i].wCodePage == wCodePage)
- return g_Bit2CodePage[i].wBit;
- }
- return (uint16_t)-1;
-}
-
-uint16_t FX_GetUnicodeBit(FX_WCHAR wcUnicode) {
- const FGAS_FONTUSB* x = FGAS_GetUnicodeBitField(wcUnicode);
- return x ? x->wBitField : 999;
-}
-
-int32_t CFGAS_FontMgrImp::CalcPenalty(CFX_FontDescriptor* pInstalled,
- uint16_t wCodePage,
- uint32_t dwFontStyles,
- const CFX_WideString& FontName,
- FX_WCHAR wcUnicode) {
+int32_t CFGAS_FontMgr::CalcPenalty(CFX_FontDescriptor* pInstalled,
+ uint16_t wCodePage,
+ uint32_t dwFontStyles,
+ const CFX_WideString& FontName,
+ FX_WCHAR wcUnicode) {
int32_t nPenalty = 30000;
if (0 != FontName.GetLength()) {
if (FontName != pInstalled->m_wsFaceName) {
int32_t i;
for (i = 0; i < pInstalled->m_wsFamilyNames.GetSize(); i++) {
- if (pInstalled->m_wsFamilyNames[i] == FontName) {
+ if (pInstalled->m_wsFamilyNames[i] == FontName)
break;
- }
}
- if (i == pInstalled->m_wsFamilyNames.GetSize()) {
+ if (i == pInstalled->m_wsFamilyNames.GetSize())
nPenalty += 0xFFFF;
- } else {
+ else
nPenalty -= 28000;
- }
} else {
nPenalty -= 30000;
}
@@ -1044,64 +1030,54 @@ int32_t CFGAS_FontMgrImp::CalcPenalty(CFX_FontDescriptor* pInstalled,
0 == IsPartName(pInstalled->m_wsFaceName, FontName)) {
int32_t i;
for (i = 0; i < pInstalled->m_wsFamilyNames.GetSize(); i++) {
- if (0 != IsPartName(pInstalled->m_wsFamilyNames[i], FontName)) {
+ if (0 != IsPartName(pInstalled->m_wsFamilyNames[i], FontName))
break;
- }
}
- if (i == pInstalled->m_wsFamilyNames.GetSize()) {
+ if (i == pInstalled->m_wsFamilyNames.GetSize())
nPenalty += 0xFFFF;
- } else {
+ else
nPenalty -= 26000;
- }
} else {
nPenalty -= 27000;
}
}
uint32_t dwStyleMask = pInstalled->m_dwFontStyles ^ dwFontStyles;
- if (dwStyleMask & FX_FONTSTYLE_Bold) {
+ if (dwStyleMask & FX_FONTSTYLE_Bold)
nPenalty += 4500;
- }
- if (dwStyleMask & FX_FONTSTYLE_FixedPitch) {
+ if (dwStyleMask & FX_FONTSTYLE_FixedPitch)
nPenalty += 10000;
- }
- if (dwStyleMask & FX_FONTSTYLE_Italic) {
+ if (dwStyleMask & FX_FONTSTYLE_Italic)
nPenalty += 10000;
- }
- if (dwStyleMask & FX_FONTSTYLE_Serif) {
+ if (dwStyleMask & FX_FONTSTYLE_Serif)
nPenalty += 500;
- }
- if (dwStyleMask & FX_FONTSTYLE_Symbolic) {
+ if (dwStyleMask & FX_FONTSTYLE_Symbolic)
nPenalty += 0xFFFF;
- }
- if (nPenalty >= 0xFFFF) {
+ if (nPenalty >= 0xFFFF)
return 0xFFFF;
- }
uint16_t wBit =
((0 == wCodePage || 0xFFFF == wCodePage) ? (uint16_t)-1
: FX_GetCodePageBit(wCodePage));
if (wBit != (uint16_t)-1) {
ASSERT(wBit < 64);
- if (0 == (pInstalled->m_dwCsb[wBit / 32] & (1 << (wBit % 32)))) {
+ if (0 == (pInstalled->m_dwCsb[wBit / 32] & (1 << (wBit % 32))))
nPenalty += 0xFFFF;
- } else {
+ else
nPenalty -= 60000;
- }
}
wBit =
((0 == wcUnicode || 0xFFFE == wcUnicode) ? (uint16_t)999
: FX_GetUnicodeBit(wcUnicode));
if (wBit != (uint16_t)999) {
ASSERT(wBit < 128);
- if (0 == (pInstalled->m_dwUsb[wBit / 32] & (1 << (wBit % 32)))) {
+ if (0 == (pInstalled->m_dwUsb[wBit / 32] & (1 << (wBit % 32))))
nPenalty += 0xFFFF;
- } else {
+ else
nPenalty -= 60000;
- }
}
return nPenalty;
}
-void CFGAS_FontMgrImp::ClearFontCache() {
+void CFGAS_FontMgr::ClearFontCache() {
FX_POSITION pos = m_Hash2CandidateList.GetStartPosition();
while (pos) {
uint32_t dwHash;
@@ -1118,10 +1094,10 @@ void CFGAS_FontMgrImp::ClearFontCache() {
}
}
-void CFGAS_FontMgrImp::RemoveFont(CFGAS_GEFont* pEFont) {
- if (!pEFont) {
+void CFGAS_FontMgr::RemoveFont(CFGAS_GEFont* pEFont) {
+ if (!pEFont)
return;
- }
+
IFX_SeekableReadStream* pFileRead;
if (m_IFXFont2FileRead.Lookup(pEFont, pFileRead)) {
pFileRead->Release();
@@ -1135,9 +1111,8 @@ void CFGAS_FontMgrImp::RemoveFont(CFGAS_GEFont* pEFont) {
m_Hash2Fonts.GetNextAssoc(pos, dwHash, pFonts);
if (pFonts) {
for (int32_t i = 0; i < pFonts->GetSize(); i++) {
- if (pFonts->GetAt(i) == pEFont) {
+ if (pFonts->GetAt(i) == pEFont)
pFonts->SetAt(i, nullptr);
- }
}
} else {
m_Hash2Fonts.RemoveKey(dwHash);
@@ -1145,8 +1120,8 @@ void CFGAS_FontMgrImp::RemoveFont(CFGAS_GEFont* pEFont) {
}
}
-void CFGAS_FontMgrImp::RegisterFace(FXFT_Face pFace,
- const CFX_WideString* pFaceName) {
+void CFGAS_FontMgr::RegisterFace(FXFT_Face pFace,
+ const CFX_WideString* pFaceName) {
if ((pFace->face_flags & FT_FACE_FLAG_SCALABLE) == 0)
return;
@@ -1180,8 +1155,8 @@ void CFGAS_FontMgrImp::RegisterFace(FXFT_Face pFace,
m_InstalledFonts.Add(pFont.release());
}
-void CFGAS_FontMgrImp::RegisterFaces(IFX_SeekableReadStream* pFontStream,
- const CFX_WideString* pFaceName) {
+void CFGAS_FontMgr::RegisterFaces(IFX_SeekableReadStream* pFontStream,
+ const CFX_WideString* pFaceName) {
int32_t index = 0;
int32_t num_faces = 0;
do {
@@ -1198,34 +1173,25 @@ void CFGAS_FontMgrImp::RegisterFaces(IFX_SeekableReadStream* pFontStream,
} while (index < num_faces);
}
-uint32_t CFGAS_FontMgrImp::GetFlags(FXFT_Face pFace) {
+uint32_t CFGAS_FontMgr::GetFlags(FXFT_Face pFace) {
uint32_t flag = 0;
- if (FT_IS_FIXED_WIDTH(pFace)) {
+ if (FT_IS_FIXED_WIDTH(pFace))
flag |= FX_FONTSTYLE_FixedPitch;
- }
TT_OS2* pOS2 = (TT_OS2*)FT_Get_Sfnt_Table(pFace, ft_sfnt_os2);
- if (!pOS2) {
+ if (!pOS2)
return flag;
- }
- if (pOS2->ulCodePageRange1 & (1 << 31)) {
+ if (pOS2->ulCodePageRange1 & (1 << 31))
flag |= FX_FONTSTYLE_Symbolic;
- }
if (pOS2->panose[0] == 2) {
uint8_t uSerif = pOS2->panose[1];
- if ((uSerif > 1 && uSerif < 10) || uSerif > 13) {
+ if ((uSerif > 1 && uSerif < 10) || uSerif > 13)
flag |= FX_FONTSTYLE_Serif;
- }
}
return flag;
}
-#define GetUInt8(p) ((uint8_t)((p)[0]))
-#define GetUInt16(p) ((uint16_t)((p)[0] << 8 | (p)[1]))
-#define GetUInt32(p) \
- ((uint32_t)((p)[0] << 24 | (p)[1] << 16 | (p)[2] << 8 | (p)[3]))
-
-void CFGAS_FontMgrImp::GetNames(const uint8_t* name_table,
- CFX_WideStringArray& Names) {
+void CFGAS_FontMgr::GetNames(const uint8_t* name_table,
+ CFX_WideStringArray& Names) {
if (!name_table) {
return;
}
@@ -1259,81 +1225,15 @@ void CFGAS_FontMgrImp::GetNames(const uint8_t* name_table,
}
}
}
-#undef GetUInt8
-#undef GetUInt16
-#undef GetUInt32
-struct FX_BIT2CHARSET {
- uint16_t wBit;
- uint16_t wCharset;
-};
-
-FX_BIT2CHARSET g_FX_Bit2Charset1[16] = {
- {1 << 0, FX_CHARSET_ANSI},
- {1 << 1, FX_CHARSET_MSWin_EasterEuropean},
- {1 << 2, FX_CHARSET_MSWin_Cyrillic},
- {1 << 3, FX_CHARSET_MSWin_Greek},
- {1 << 4, FX_CHARSET_MSWin_Turkish},
- {1 << 5, FX_CHARSET_MSWin_Hebrew},
- {1 << 6, FX_CHARSET_MSWin_Arabic},
- {1 << 7, FX_CHARSET_MSWin_Baltic},
- {1 << 8, FX_CHARSET_MSWin_Vietnamese},
- {1 << 9, FX_CHARSET_Default},
- {1 << 10, FX_CHARSET_Default},
- {1 << 11, FX_CHARSET_Default},
- {1 << 12, FX_CHARSET_Default},
- {1 << 13, FX_CHARSET_Default},
- {1 << 14, FX_CHARSET_Default},
- {1 << 15, FX_CHARSET_Default},
-};
-
-FX_BIT2CHARSET g_FX_Bit2Charset2[16] = {
- {1 << 0, FX_CHARSET_Thai},
- {1 << 1, FX_CHARSET_ShiftJIS},
- {1 << 2, FX_CHARSET_ChineseSimplified},
- {1 << 3, FX_CHARSET_Korean},
- {1 << 4, FX_CHARSET_ChineseTriditional},
- {1 << 5, FX_CHARSET_Johab},
- {1 << 6, FX_CHARSET_Default},
- {1 << 7, FX_CHARSET_Default},
- {1 << 8, FX_CHARSET_Default},
- {1 << 9, FX_CHARSET_Default},
- {1 << 10, FX_CHARSET_Default},
- {1 << 11, FX_CHARSET_Default},
- {1 << 12, FX_CHARSET_Default},
- {1 << 13, FX_CHARSET_Default},
- {1 << 14, FX_CHARSET_OEM},
- {1 << 15, FX_CHARSET_Symbol},
-};
-
-FX_BIT2CHARSET g_FX_Bit2Charset3[16] = {
- {1 << 0, FX_CHARSET_Default}, {1 << 1, FX_CHARSET_Default},
- {1 << 2, FX_CHARSET_Default}, {1 << 3, FX_CHARSET_Default},
- {1 << 4, FX_CHARSET_Default}, {1 << 5, FX_CHARSET_Default},
- {1 << 6, FX_CHARSET_Default}, {1 << 7, FX_CHARSET_Default},
- {1 << 8, FX_CHARSET_Default}, {1 << 9, FX_CHARSET_Default},
- {1 << 10, FX_CHARSET_Default}, {1 << 11, FX_CHARSET_Default},
- {1 << 12, FX_CHARSET_Default}, {1 << 13, FX_CHARSET_Default},
- {1 << 14, FX_CHARSET_Default}, {1 << 15, FX_CHARSET_Default},
-};
-
-FX_BIT2CHARSET g_FX_Bit2Charset4[16] = {
- {1 << 0, FX_CHARSET_Default}, {1 << 1, FX_CHARSET_Default},
- {1 << 2, FX_CHARSET_Default}, {1 << 3, FX_CHARSET_Default},
- {1 << 4, FX_CHARSET_Default}, {1 << 5, FX_CHARSET_Default},
- {1 << 6, FX_CHARSET_Default}, {1 << 7, FX_CHARSET_Default},
- {1 << 8, FX_CHARSET_Default}, {1 << 9, FX_CHARSET_Default},
- {1 << 10, FX_CHARSET_Default}, {1 << 11, FX_CHARSET_Default},
- {1 << 12, FX_CHARSET_Default}, {1 << 13, FX_CHARSET_Default},
- {1 << 14, FX_CHARSET_Default}, {1 << 15, FX_CHARSET_US},
-};
+// TODO(npm): Get rid of this #define
#define CODEPAGERANGE_IMPLEMENT(n) \
for (int32_t i = 0; i < 16; i++) { \
if ((a##n & g_FX_Bit2Charset##n[i].wBit) != 0) \
charsets.push_back(g_FX_Bit2Charset##n[i].wCharset); \
}
-std::vector<uint16_t> CFGAS_FontMgrImp::GetCharsets(FXFT_Face pFace) const {
+std::vector<uint16_t> CFGAS_FontMgr::GetCharsets(FXFT_Face pFace) const {
std::vector<uint16_t> charsets;
TT_OS2* pOS2 = (TT_OS2*)FT_Get_Sfnt_Table(pFace, ft_sfnt_os2);
if (pOS2) {
@@ -1352,9 +1252,8 @@ std::vector<uint16_t> CFGAS_FontMgrImp::GetCharsets(FXFT_Face pFace) const {
}
#undef CODEPAGERANGE_IMPLEMENT
-void CFGAS_FontMgrImp::GetUSBCSB(FXFT_Face pFace,
- uint32_t* USB,
- uint32_t* CSB) {
+
+void CFGAS_FontMgr::GetUSBCSB(FXFT_Face pFace, uint32_t* USB, uint32_t* CSB) {
TT_OS2* pOS2 = (TT_OS2*)FT_Get_Sfnt_Table(pFace, ft_sfnt_os2);
if (pOS2) {
USB[0] = pOS2->ulUnicodeRange1;
@@ -1373,12 +1272,11 @@ void CFGAS_FontMgrImp::GetUSBCSB(FXFT_Face pFace,
}
}
-int32_t CFGAS_FontMgrImp::IsPartName(const CFX_WideString& Name1,
- const CFX_WideString& Name2) {
- if (Name1.Find(Name2.c_str()) != -1) {
+int32_t CFGAS_FontMgr::IsPartName(const CFX_WideString& Name1,
+ const CFX_WideString& Name2) {
+ if (Name1.Find(Name2.c_str()) != -1)
return 1;
- }
return 0;
}
-#endif
+#endif // _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_
diff --git a/xfa/fgas/font/fgas_stdfontmgr.h b/xfa/fgas/font/cfgas_fontmgr.h
index 2c7a1a2fdd..572be382a8 100644
--- a/xfa/fgas/font/fgas_stdfontmgr.h
+++ b/xfa/fgas/font/cfgas_fontmgr.h
@@ -4,8 +4,8 @@
// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-#ifndef XFA_FGAS_FONT_FGAS_STDFONTMGR_H_
-#define XFA_FGAS_FONT_FGAS_STDFONTMGR_H_
+#ifndef XFA_FGAS_FONT_CFGAS_FONTMGR_H_
+#define XFA_FGAS_FONT_CFGAS_FONTMGR_H_
#include <vector>
@@ -14,53 +14,110 @@
#include "core/fxge/fx_freetype.h"
#include "core/fxge/ifx_systemfontinfo.h"
#include "third_party/freetype/include/freetype/fttypes.h"
-#include "xfa/fgas/font/fgas_font.h"
+#include "xfa/fgas/crt/fgas_stream.h"
+#include "xfa/fgas/font/cfgas_fontmgr.h"
#if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_
-int32_t FX_GetSimilarValue(FX_FONTDESCRIPTOR const* pFont,
- uint32_t dwFontStyles);
-FX_FONTDESCRIPTOR const* FX_DefFontMatcher(FX_LPFONTMATCHPARAMS pParams,
- const CFX_FontDescriptors& fonts);
+#include "xfa/fgas/crt/fgas_memory.h"
+#include "xfa/fgas/crt/fgas_utils.h"
+#endif // _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_
-class CFGAS_StdFontMgrImp : public IFGAS_FontMgr {
+#define FX_FONTSTYLE_Normal 0x00
+#define FX_FONTSTYLE_FixedPitch 0x01
+#define FX_FONTSTYLE_Serif 0x02
+#define FX_FONTSTYLE_Symbolic 0x04
+#define FX_FONTSTYLE_Script 0x08
+#define FX_FONTSTYLE_Italic 0x40
+#define FX_FONTSTYLE_Bold 0x40000
+#define FX_FONTSTYLE_BoldItalic (FX_FONTSTYLE_Bold | FX_FONTSTYLE_Italic)
+#define FX_FONTSTYLE_ExactMatch 0x80000000
+
+class CFX_FontSourceEnum_File;
+class CFGAS_GEFont;
+class CXFA_PDFFontMgr;
+class CFGAS_FontMgr;
+
+#if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_
+#define FX_FONTMATCHPARA_MatchStyle 0x01
+
+struct FX_FONTMATCHPARAMS {
+ const FX_WCHAR* pwsFamily;
+ uint32_t dwFontStyles;
+ uint32_t dwUSB;
+ uint32_t dwMatchFlags;
+ FX_WCHAR wUnicode;
+ uint16_t wCodePage;
+};
+
+typedef FX_FONTMATCHPARAMS* FX_LPFONTMATCHPARAMS;
+
+struct FX_FONTSIGNATURE {
+ uint32_t fsUsb[4];
+ uint32_t fsCsb[2];
+};
+
+inline bool operator==(const FX_FONTSIGNATURE& left,
+ const FX_FONTSIGNATURE& right) {
+ return left.fsUsb[0] == right.fsUsb[0] && left.fsUsb[1] == right.fsUsb[1] &&
+ left.fsUsb[2] == right.fsUsb[2] && left.fsUsb[3] == right.fsUsb[3] &&
+ left.fsCsb[0] == right.fsCsb[0] && left.fsCsb[1] == right.fsCsb[1];
+}
+
+struct FX_FONTDESCRIPTOR {
+ FX_WCHAR wsFontFace[32];
+ uint32_t dwFontStyles;
+ uint8_t uCharSet;
+ FX_FONTSIGNATURE FontSignature;
+};
+
+typedef CFX_MassArrayTemplate<FX_FONTDESCRIPTOR> CFX_FontDescriptors;
+
+inline bool operator==(const FX_FONTDESCRIPTOR& left,
+ const FX_FONTDESCRIPTOR& right) {
+ return left.uCharSet == right.uCharSet &&
+ left.dwFontStyles == right.dwFontStyles &&
+ left.FontSignature == right.FontSignature &&
+ FXSYS_wcscmp(left.wsFontFace, right.wsFontFace) == 0;
+}
+
+typedef void (*FX_LPEnumAllFonts)(CFX_FontDescriptors& fonts,
+ const FX_WCHAR* pwsFaceName,
+ FX_WCHAR wUnicode);
+
+FX_LPEnumAllFonts FX_GetDefFontEnumerator();
+
+class CFGAS_FontMgr {
public:
- explicit CFGAS_StdFontMgrImp(FX_LPEnumAllFonts pEnumerator);
- ~CFGAS_StdFontMgrImp() override;
-
- // IFGAS_FontMgr:
- CFGAS_GEFont* GetDefFontByCodePage(
- uint16_t wCodePage,
- uint32_t dwFontStyles,
- const FX_WCHAR* pszFontFamily = nullptr) override;
- CFGAS_GEFont* GetDefFontByCharset(
- uint8_t nCharset,
- uint32_t dwFontStyles,
- const FX_WCHAR* pszFontFamily = nullptr) override;
- CFGAS_GEFont* GetDefFontByUnicode(
- FX_WCHAR wUnicode,
- uint32_t dwFontStyles,
- const FX_WCHAR* pszFontFamily = nullptr) override;
- CFGAS_GEFont* GetDefFontByLanguage(
- uint16_t wLanguage,
- uint32_t dwFontStyles,
- const FX_WCHAR* pszFontFamily = nullptr) override;
+ explicit CFGAS_FontMgr(FX_LPEnumAllFonts pEnumerator);
+ ~CFGAS_FontMgr();
+
+ static std::unique_ptr<CFGAS_FontMgr> Create(FX_LPEnumAllFonts pEnumerator);
+
+ CFGAS_GEFont* GetDefFontByCodePage(uint16_t wCodePage,
+ uint32_t dwFontStyles,
+ const FX_WCHAR* pszFontFamily = nullptr);
+ CFGAS_GEFont* GetDefFontByUnicode(FX_WCHAR wUnicode,
+ uint32_t dwFontStyles,
+ const FX_WCHAR* pszFontFamily = nullptr);
CFGAS_GEFont* LoadFont(const FX_WCHAR* pszFontFamily,
uint32_t dwFontStyles,
- uint16_t wCodePage = 0xFFFF) override;
- CFGAS_GEFont* LoadFont(const uint8_t* pBuffer, int32_t iLength) override;
+ uint16_t wCodePage = 0xFFFF);
+ CFGAS_GEFont* LoadFont(const uint8_t* pBuffer, int32_t iLength);
CFGAS_GEFont* LoadFont(IFX_Stream* pFontStream,
const FX_WCHAR* pszFontAlias = nullptr,
uint32_t dwFontStyles = 0,
uint16_t wCodePage = 0,
- bool bSaveStream = false) override;
+ bool bSaveStream = false);
CFGAS_GEFont* LoadFont(CFGAS_GEFont* pSrcFont,
uint32_t dwFontStyles,
- uint16_t wCodePage = 0xFFFF) override;
+ uint16_t wCodePage = 0xFFFF);
- void ClearFontCache() override;
- void RemoveFont(CFGAS_GEFont* pFont) override;
+ // TODO(npm): This method is not being used, but probably should be in
+ // destructor
+ void ClearFontCache();
+ void RemoveFont(CFGAS_GEFont* pFont);
- protected:
+ private:
void RemoveFont(CFX_MapPtrToPtr& fontMap, CFGAS_GEFont* pFont);
FX_FONTDESCRIPTOR const* FindFont(const FX_WCHAR* pszFontFamily,
uint32_t dwFontStyles,
@@ -79,10 +136,8 @@ class CFGAS_StdFontMgrImp : public IFGAS_FontMgr {
CFX_MapPtrToPtr m_StreamFonts;
CFX_MapPtrToPtr m_DeriveFonts;
};
-uint32_t FX_GetGdiFontStyles(const LOGFONTW& lf);
-
-#else
+#else // _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_
class CFX_FontDescriptor {
public:
CFX_FontDescriptor();
@@ -142,49 +197,36 @@ class CFX_FontSourceEnum_File {
CFX_ByteStringArray m_FolderPaths;
};
-class CFGAS_FontMgrImp : public IFGAS_FontMgr {
+class CFGAS_FontMgr {
public:
- explicit CFGAS_FontMgrImp(CFX_FontSourceEnum_File* pFontEnum);
- ~CFGAS_FontMgrImp() override;
+ explicit CFGAS_FontMgr(CFX_FontSourceEnum_File* pFontEnum);
+ ~CFGAS_FontMgr();
+ static std::unique_ptr<CFGAS_FontMgr> Create(
+ CFX_FontSourceEnum_File* pFontEnum);
- // IFGAS_FontMgr:
- CFGAS_GEFont* GetDefFontByCodePage(uint16_t wCodePage,
- uint32_t dwFontStyles,
- const FX_WCHAR* pszFontFamily) override;
- CFGAS_GEFont* GetDefFontByCharset(uint8_t nCharset,
- uint32_t dwFontStyles,
- const FX_WCHAR* pszFontFamily) override;
- CFGAS_GEFont* GetDefFontByUnicode(FX_WCHAR wUnicode,
- uint32_t dwFontStyles,
- const FX_WCHAR* pszFontFamily) override;
- CFGAS_GEFont* GetDefFontByLanguage(uint16_t wLanguage,
- uint32_t dwFontStyles,
- const FX_WCHAR* pszFontFamily) override;
CFGAS_GEFont* GetFontByCodePage(uint16_t wCodePage,
uint32_t dwFontStyles,
- const FX_WCHAR* pszFontFamily) override;
- CFGAS_GEFont* GetFontByCharset(uint8_t nCharset,
- uint32_t dwFontStyles,
- const FX_WCHAR* pszFontFamily) override;
+ const FX_WCHAR* pszFontFamily);
CFGAS_GEFont* GetFontByUnicode(FX_WCHAR wUnicode,
uint32_t dwFontStyles,
- const FX_WCHAR* pszFontFamily) override;
- CFGAS_GEFont* GetFontByLanguage(uint16_t wLanguage,
- uint32_t dwFontStyles,
- const FX_WCHAR* pszFontFamily) override;
- void ClearFontCache() override;
- void RemoveFont(CFGAS_GEFont* pFont) override;
+ const FX_WCHAR* pszFontFamily);
+ void ClearFontCache();
+ void RemoveFont(CFGAS_GEFont* pFont);
CFGAS_GEFont* LoadFont(const CFX_WideString& wsFaceName,
int32_t iFaceIndex,
int32_t* pFaceCount);
+ inline CFGAS_GEFont* LoadFont(const FX_WCHAR* pszFontFamily,
+ uint32_t dwFontStyles,
+ uint16_t wCodePage) {
+ return GetFontByCodePage(wCodePage, dwFontStyles, pszFontFamily);
+ }
bool EnumFonts();
bool EnumFontsFromFontMapper();
bool EnumFontsFromFiles();
- protected:
- void RegisterFace(FXFT_Face pFace,
- const CFX_WideString* pFaceName);
+ private:
+ void RegisterFace(FXFT_Face pFace, const CFX_WideString* pFaceName);
void RegisterFaces(IFX_SeekableReadStream* pFontStream,
const CFX_WideString* pFaceName);
void GetNames(const uint8_t* name_table, CFX_WideStringArray& Names);
@@ -219,4 +261,4 @@ class CFGAS_FontMgrImp : public IFGAS_FontMgr {
};
#endif
-#endif // XFA_FGAS_FONT_FGAS_STDFONTMGR_H_
+#endif // XFA_FGAS_FONT_CFGAS_FONTMGR_H_
diff --git a/xfa/fgas/font/fgas_font.h b/xfa/fgas/font/fgas_font.h
deleted file mode 100644
index dbc4ec2f3b..0000000000
--- a/xfa/fgas/font/fgas_font.h
+++ /dev/null
@@ -1,165 +0,0 @@
-// Copyright 2014 PDFium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-
-#ifndef XFA_FGAS_FONT_FGAS_FONT_H_
-#define XFA_FGAS_FONT_FGAS_FONT_H_
-
-#include "core/fxge/fx_font.h"
-#include "xfa/fgas/crt/fgas_stream.h"
-
-#if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_
-#include "xfa/fgas/crt/fgas_memory.h"
-#include "xfa/fgas/crt/fgas_utils.h"
-#endif // _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_
-
-class CFX_FontSourceEnum_File;
-class CFGAS_GEFont;
-class CXFA_PDFFontMgr;
-class IFGAS_FontMgr;
-
-#define FX_FONTSTYLE_Normal 0x00
-#define FX_FONTSTYLE_FixedPitch 0x01
-#define FX_FONTSTYLE_Serif 0x02
-#define FX_FONTSTYLE_Symbolic 0x04
-#define FX_FONTSTYLE_Script 0x08
-#define FX_FONTSTYLE_Italic 0x40
-#define FX_FONTSTYLE_Bold 0x40000
-#define FX_FONTSTYLE_BoldItalic (FX_FONTSTYLE_Bold | FX_FONTSTYLE_Italic)
-#define FX_FONTSTYLE_ExactMatch 0x80000000
-
-#if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_
-struct FX_FONTMATCHPARAMS {
- const FX_WCHAR* pwsFamily;
- uint32_t dwFontStyles;
- uint32_t dwUSB;
- uint32_t dwMatchFlags;
- FX_WCHAR wUnicode;
- uint16_t wCodePage;
-};
-typedef FX_FONTMATCHPARAMS* FX_LPFONTMATCHPARAMS;
-typedef FX_FONTMATCHPARAMS const* FX_LPCFONTMATCHPARAMS;
-
-struct FX_FONTSIGNATURE {
- uint32_t fsUsb[4];
- uint32_t fsCsb[2];
-};
-inline bool operator==(const FX_FONTSIGNATURE& left,
- const FX_FONTSIGNATURE& right) {
- return left.fsUsb[0] == right.fsUsb[0] && left.fsUsb[1] == right.fsUsb[1] &&
- left.fsUsb[2] == right.fsUsb[2] && left.fsUsb[3] == right.fsUsb[3] &&
- left.fsCsb[0] == right.fsCsb[0] && left.fsCsb[1] == right.fsCsb[1];
-}
-
-struct FX_FONTDESCRIPTOR {
- FX_WCHAR wsFontFace[32];
- uint32_t dwFontStyles;
- uint8_t uCharSet;
- FX_FONTSIGNATURE FontSignature;
-};
-
-typedef CFX_MassArrayTemplate<FX_FONTDESCRIPTOR> CFX_FontDescriptors;
-inline bool operator==(const FX_FONTDESCRIPTOR& left,
- const FX_FONTDESCRIPTOR& right) {
- return left.uCharSet == right.uCharSet &&
- left.dwFontStyles == right.dwFontStyles &&
- left.FontSignature == right.FontSignature &&
- FXSYS_wcscmp(left.wsFontFace, right.wsFontFace) == 0;
-}
-
-#define FX_FONTMATCHPARA_MacthStyle 0x01
-#define FX_FONTMATCHPARA_MacthFamily 0x02
-#define FX_FONTMATCHPARA_MacthUnicode 0x04
-typedef void (*FX_LPEnumAllFonts)(CFX_FontDescriptors& fonts,
- const FX_WCHAR* pwsFaceName,
- FX_WCHAR wUnicode);
-FX_LPEnumAllFonts FX_GetDefFontEnumerator();
-typedef FX_FONTDESCRIPTOR const* (*FX_LPMatchFont)(
- FX_LPFONTMATCHPARAMS pParams,
- const CFX_FontDescriptors& fonts);
-FX_LPMatchFont FX_GetDefFontMatchor();
-
-class IFGAS_FontMgr {
- public:
- virtual ~IFGAS_FontMgr() {}
-
- static std::unique_ptr<IFGAS_FontMgr> Create(FX_LPEnumAllFonts pEnumerator);
-
- virtual CFGAS_GEFont* GetDefFontByCodePage(
- uint16_t wCodePage,
- uint32_t dwFontStyles,
- const FX_WCHAR* pszFontFamily = nullptr) = 0;
- virtual CFGAS_GEFont* GetDefFontByCharset(
- uint8_t nCharset,
- uint32_t dwFontStyles,
- const FX_WCHAR* pszFontFamily = nullptr) = 0;
- virtual CFGAS_GEFont* GetDefFontByUnicode(
- FX_WCHAR wUnicode,
- uint32_t dwFontStyles,
- const FX_WCHAR* pszFontFamily = nullptr) = 0;
- virtual CFGAS_GEFont* GetDefFontByLanguage(
- uint16_t wLanguage,
- uint32_t dwFontStyles,
- const FX_WCHAR* pszFontFamily = nullptr) = 0;
- virtual CFGAS_GEFont* LoadFont(const FX_WCHAR* pszFontFamily,
- uint32_t dwFontStyles,
- uint16_t wCodePage = 0xFFFF) = 0;
- virtual CFGAS_GEFont* LoadFont(const uint8_t* pBuffer, int32_t iLength) = 0;
- virtual CFGAS_GEFont* LoadFont(IFX_Stream* pFontStream,
- const FX_WCHAR* pszFontAlias = nullptr,
- uint32_t dwFontStyles = 0,
- uint16_t wCodePage = 0,
- bool bSaveStream = false) = 0;
- virtual CFGAS_GEFont* LoadFont(CFGAS_GEFont* pSrcFont,
- uint32_t dwFontStyles,
- uint16_t wCodePage = 0xFFFF) = 0;
- virtual void ClearFontCache() = 0;
- virtual void RemoveFont(CFGAS_GEFont* pFont) = 0;
-};
-
-#else // _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_
-
-class IFGAS_FontMgr {
- public:
- virtual ~IFGAS_FontMgr() {}
-
- static std::unique_ptr<IFGAS_FontMgr> Create(
- CFX_FontSourceEnum_File* pFontEnum);
-
- virtual CFGAS_GEFont* GetDefFontByCodePage(uint16_t wCodePage,
- uint32_t dwFontStyles,
- const FX_WCHAR* pszFontFamily) = 0;
- virtual CFGAS_GEFont* GetDefFontByCharset(uint8_t nCharset,
- uint32_t dwFontStyles,
- const FX_WCHAR* pszFontFamily) = 0;
- virtual CFGAS_GEFont* GetDefFontByUnicode(FX_WCHAR wUnicode,
- uint32_t dwFontStyles,
- const FX_WCHAR* pszFontFamily) = 0;
- virtual CFGAS_GEFont* GetDefFontByLanguage(uint16_t wLanguage,
- uint32_t dwFontStyles,
- const FX_WCHAR* pszFontFamily) = 0;
- virtual CFGAS_GEFont* GetFontByCodePage(uint16_t wCodePage,
- uint32_t dwFontStyles,
- const FX_WCHAR* pszFontFamily) = 0;
- inline CFGAS_GEFont* LoadFont(const FX_WCHAR* pszFontFamily,
- uint32_t dwFontStyles,
- uint16_t wCodePage) {
- return GetFontByCodePage(wCodePage, dwFontStyles, pszFontFamily);
- }
- virtual CFGAS_GEFont* GetFontByCharset(uint8_t nCharset,
- uint32_t dwFontStyles,
- const FX_WCHAR* pszFontFamily) = 0;
- virtual CFGAS_GEFont* GetFontByUnicode(FX_WCHAR wUnicode,
- uint32_t dwFontStyles,
- const FX_WCHAR* pszFontFamily) = 0;
- virtual CFGAS_GEFont* GetFontByLanguage(uint16_t wLanguage,
- uint32_t dwFontStyles,
- const FX_WCHAR* pszFontFamily) = 0;
- virtual void ClearFontCache() = 0;
- virtual void RemoveFont(CFGAS_GEFont* pFont) = 0;
-};
-#endif // _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_
-
-#endif // XFA_FGAS_FONT_FGAS_FONT_H_
diff --git a/xfa/fgas/font/fgas_fontutils.cpp b/xfa/fgas/font/fgas_fontutils.cpp
index 8e923c1209..e74056b53e 100644
--- a/xfa/fgas/font/fgas_fontutils.cpp
+++ b/xfa/fgas/font/fgas_fontutils.cpp
@@ -7,7 +7,7 @@
#include "xfa/fgas/font/fgas_fontutils.h"
#include "core/fxcrt/fx_ext.h"
-#include "xfa/fgas/font/fgas_font.h"
+#include "xfa/fgas/font/cfgas_fontmgr.h"
uint32_t FGAS_GetFontHashCode(uint16_t wCodePage, uint32_t dwFontStyles) {
uint32_t dwHash = wCodePage;
diff --git a/xfa/fgas/font/fgas_gefont.cpp b/xfa/fgas/font/fgas_gefont.cpp
index b78cfe516a..8a6ff28b43 100644
--- a/xfa/fgas/font/fgas_gefont.cpp
+++ b/xfa/fgas/font/fgas_gefont.cpp
@@ -20,7 +20,7 @@
CFGAS_GEFont* CFGAS_GEFont::LoadFont(const FX_WCHAR* pszFontFamily,
uint32_t dwFontStyles,
uint16_t wCodePage,
- IFGAS_FontMgr* pFontMgr) {
+ CFGAS_FontMgr* pFontMgr) {
#if _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_
if (pFontMgr)
return pFontMgr->GetFontByCodePage(wCodePage, dwFontStyles, pszFontFamily);
@@ -37,7 +37,7 @@ CFGAS_GEFont* CFGAS_GEFont::LoadFont(const FX_WCHAR* pszFontFamily,
// static
CFGAS_GEFont* CFGAS_GEFont::LoadFont(CFX_Font* pExternalFont,
- IFGAS_FontMgr* pFontMgr) {
+ CFGAS_FontMgr* pFontMgr) {
CFGAS_GEFont* pFont = new CFGAS_GEFont(pFontMgr);
if (!pFont->LoadFontInternal(pExternalFont)) {
pFont->Release();
@@ -48,7 +48,7 @@ CFGAS_GEFont* CFGAS_GEFont::LoadFont(CFX_Font* pExternalFont,
// static
CFGAS_GEFont* CFGAS_GEFont::LoadFont(std::unique_ptr<CFX_Font> pInternalFont,
- IFGAS_FontMgr* pFontMgr) {
+ CFGAS_FontMgr* pFontMgr) {
CFGAS_GEFont* pFont = new CFGAS_GEFont(pFontMgr);
if (!pFont->LoadFontInternal(std::move(pInternalFont))) {
pFont->Release();
@@ -61,7 +61,7 @@ CFGAS_GEFont* CFGAS_GEFont::LoadFont(std::unique_ptr<CFX_Font> pInternalFont,
// static
CFGAS_GEFont* CFGAS_GEFont::LoadFont(const uint8_t* pBuffer,
int32_t iLength,
- IFGAS_FontMgr* pFontMgr) {
+ CFGAS_FontMgr* pFontMgr) {
CFGAS_GEFont* pFont = new CFGAS_GEFont(pFontMgr);
if (!pFont->LoadFontInternal(pBuffer, iLength)) {
pFont->Release();
@@ -72,7 +72,7 @@ CFGAS_GEFont* CFGAS_GEFont::LoadFont(const uint8_t* pBuffer,
// static
CFGAS_GEFont* CFGAS_GEFont::LoadFont(IFX_Stream* pFontStream,
- IFGAS_FontMgr* pFontMgr,
+ CFGAS_FontMgr* pFontMgr,
bool bSaveStream) {
CFGAS_GEFont* pFont = new CFGAS_GEFont(pFontMgr);
if (!pFont->LoadFontInternal(pFontStream, bSaveStream)) {
@@ -83,7 +83,7 @@ CFGAS_GEFont* CFGAS_GEFont::LoadFont(IFX_Stream* pFontStream,
}
#endif // _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_
-CFGAS_GEFont::CFGAS_GEFont(IFGAS_FontMgr* pFontMgr)
+CFGAS_GEFont::CFGAS_GEFont(CFGAS_FontMgr* pFontMgr)
:
#if _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_
m_bUseLogFontStyle(false),
diff --git a/xfa/fgas/font/fgas_gefont.h b/xfa/fgas/font/fgas_gefont.h
index 4ce61f3989..7baafefc7e 100644
--- a/xfa/fgas/font/fgas_gefont.h
+++ b/xfa/fgas/font/fgas_gefont.h
@@ -11,7 +11,7 @@
#include "core/fxcrt/fx_memory.h"
#include "xfa/fgas/crt/fgas_utils.h"
-#include "xfa/fgas/font/fgas_font.h"
+#include "xfa/fgas/font/cfgas_fontmgr.h"
#define FXFONT_SUBST_ITALIC 0x02
@@ -23,17 +23,17 @@ class CFGAS_GEFont {
static CFGAS_GEFont* LoadFont(const FX_WCHAR* pszFontFamily,
uint32_t dwFontStyles,
uint16_t wCodePage,
- IFGAS_FontMgr* pFontMgr);
+ CFGAS_FontMgr* pFontMgr);
static CFGAS_GEFont* LoadFont(CFX_Font* pExternalFont,
- IFGAS_FontMgr* pFontMgr);
+ CFGAS_FontMgr* pFontMgr);
static CFGAS_GEFont* LoadFont(std::unique_ptr<CFX_Font> pInternalFont,
- IFGAS_FontMgr* pFontMgr);
+ CFGAS_FontMgr* pFontMgr);
#if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_
static CFGAS_GEFont* LoadFont(const uint8_t* pBuffer,
int32_t iLength,
- IFGAS_FontMgr* pFontMgr);
+ CFGAS_FontMgr* pFontMgr);
static CFGAS_GEFont* LoadFont(IFX_Stream* pFontStream,
- IFGAS_FontMgr* pFontMgr,
+ CFGAS_FontMgr* pFontMgr,
bool bSaveStream);
#endif
@@ -63,7 +63,7 @@ class CFGAS_GEFont {
#endif
protected:
- explicit CFGAS_GEFont(IFGAS_FontMgr* pFontMgr);
+ explicit CFGAS_GEFont(CFGAS_FontMgr* pFontMgr);
CFGAS_GEFont(CFGAS_GEFont* src, uint32_t dwFontStyles);
#if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_
@@ -95,7 +95,7 @@ class CFGAS_GEFont {
#endif
CFX_Font* m_pFont;
CFGAS_GEFont* const m_pSrcFont;
- IFGAS_FontMgr* const m_pFontMgr;
+ CFGAS_FontMgr* const m_pFontMgr;
int32_t m_iRefCount;
bool m_bExternalFont;
std::unique_ptr<IFX_Stream, ReleaseDeleter<IFX_Stream>> m_pStream;
diff --git a/xfa/fgas/layout/fgas_unicode.h b/xfa/fgas/layout/fgas_unicode.h
index 12614a1299..f7a0d201d9 100644
--- a/xfa/fgas/layout/fgas_unicode.h
+++ b/xfa/fgas/layout/fgas_unicode.h
@@ -8,7 +8,7 @@
#define XFA_FGAS_LAYOUT_FGAS_UNICODE_H_
#include "xfa/fgas/crt/fgas_utils.h"
-#include "xfa/fgas/font/fgas_font.h"
+#include "xfa/fgas/font/cfgas_fontmgr.h"
struct FX_TPO {
int32_t index;
diff --git a/xfa/fwl/theme/cfwl_widgettp.cpp b/xfa/fwl/theme/cfwl_widgettp.cpp
index bbcbabbb54..80a7b8fe4a 100644
--- a/xfa/fwl/theme/cfwl_widgettp.cpp
+++ b/xfa/fwl/theme/cfwl_widgettp.cpp
@@ -10,7 +10,7 @@
#include "xfa/fde/tto/fde_textout.h"
#include "xfa/fgas/font/fgas_gefont.h"
-#include "xfa/fgas/font/fgas_stdfontmgr.h"
+#include "xfa/fgas/font/cfgas_fontmgr.h"
#include "xfa/fwl/core/cfwl_themebackground.h"
#include "xfa/fwl/core/cfwl_themepart.h"
#include "xfa/fwl/core/cfwl_themetext.h"
@@ -664,10 +664,10 @@ bool CFWL_FontData::LoadFont(const CFX_WideStringC& wsFontFamily,
m_dwCodePage = dwCodePage;
if (!m_pFontMgr) {
#if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_
- m_pFontMgr = IFGAS_FontMgr::Create(FX_GetDefFontEnumerator());
+ m_pFontMgr = CFGAS_FontMgr::Create(FX_GetDefFontEnumerator());
#else
m_pFontSource.reset(new CFX_FontSourceEnum_File);
- m_pFontMgr = IFGAS_FontMgr::Create(m_pFontSource.get());
+ m_pFontMgr = CFGAS_FontMgr::Create(m_pFontSource.get());
#endif
}
m_pFont.reset(CFGAS_GEFont::LoadFont(wsFontFamily.c_str(), dwFontStyles,
diff --git a/xfa/fwl/theme/cfwl_widgettp.h b/xfa/fwl/theme/cfwl_widgettp.h
index 73625d05d8..4a9ef1347b 100644
--- a/xfa/fwl/theme/cfwl_widgettp.h
+++ b/xfa/fwl/theme/cfwl_widgettp.h
@@ -96,7 +96,7 @@ class CFGAS_GEFont;
class CFWL_ThemeBackground;
class CFWL_ThemePart;
class CFWL_ThemeText;
-class IFGAS_FontMgr;
+class CFGAS_FontMgr;
class IFWL_Widget;
#if _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_
@@ -245,7 +245,7 @@ class CFWL_FontData {
#if _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_
std::unique_ptr<CFX_FontSourceEnum_File> m_pFontSource;
#endif
- std::unique_ptr<IFGAS_FontMgr> m_pFontMgr;
+ std::unique_ptr<CFGAS_FontMgr> m_pFontMgr;
std::unique_ptr<CFGAS_GEFont> m_pFont;
};
diff --git a/xfa/fxfa/app/xfa_ffapp.cpp b/xfa/fxfa/app/xfa_ffapp.cpp
index c5dcad848c..bfb9822ecc 100644
--- a/xfa/fxfa/app/xfa_ffapp.cpp
+++ b/xfa/fxfa/app/xfa_ffapp.cpp
@@ -9,7 +9,7 @@
#include <algorithm>
#include <utility>
-#include "xfa/fgas/font/fgas_stdfontmgr.h"
+#include "xfa/fgas/font/cfgas_fontmgr.h"
#include "xfa/fwl/core/cfwl_widgetmgr.h"
#include "xfa/fwl/core/fwl_noteimp.h"
#include "xfa/fxfa/app/xfa_fwladapter.h"
@@ -115,13 +115,13 @@ CXFA_FontMgr* CXFA_FFApp::GetXFAFontMgr() const {
return m_pFontMgr.get();
}
-IFGAS_FontMgr* CXFA_FFApp::GetFDEFontMgr() {
+CFGAS_FontMgr* CXFA_FFApp::GetFDEFontMgr() {
if (!m_pFDEFontMgr) {
#if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_
- m_pFDEFontMgr = IFGAS_FontMgr::Create(FX_GetDefFontEnumerator());
+ m_pFDEFontMgr = CFGAS_FontMgr::Create(FX_GetDefFontEnumerator());
#else
m_pFontSource.reset(new CFX_FontSourceEnum_File);
- m_pFDEFontMgr = IFGAS_FontMgr::Create(m_pFontSource.get());
+ m_pFDEFontMgr = CFGAS_FontMgr::Create(m_pFontSource.get());
#endif
}
return m_pFDEFontMgr.get();
diff --git a/xfa/fxfa/app/xfa_fontmgr.cpp b/xfa/fxfa/app/xfa_fontmgr.cpp
index 589dcd42f2..ddac27d533 100644
--- a/xfa/fxfa/app/xfa_fontmgr.cpp
+++ b/xfa/fxfa/app/xfa_fontmgr.cpp
@@ -1749,7 +1749,7 @@ CFGAS_GEFont* CXFA_DefFontMgr::GetFont(CXFA_FFDoc* hDoc,
uint32_t dwFontStyles,
uint16_t wCodePage) {
CFX_WideString wsFontName(wsFontFamily);
- IFGAS_FontMgr* pFDEFontMgr = hDoc->GetApp()->GetFDEFontMgr();
+ CFGAS_FontMgr* pFDEFontMgr = hDoc->GetApp()->GetFDEFontMgr();
CFGAS_GEFont* pFont =
pFDEFontMgr->LoadFont(wsFontName.c_str(), dwFontStyles, wCodePage);
if (!pFont) {
@@ -1793,7 +1793,7 @@ CFGAS_GEFont* CXFA_DefFontMgr::GetDefaultFont(
const CFX_WideStringC& wsFontFamily,
uint32_t dwFontStyles,
uint16_t wCodePage) {
- IFGAS_FontMgr* pFDEFontMgr = hDoc->GetApp()->GetFDEFontMgr();
+ CFGAS_FontMgr* pFDEFontMgr = hDoc->GetApp()->GetFDEFontMgr();
CFGAS_GEFont* pFont =
pFDEFontMgr->LoadFont(L"Arial Narrow", dwFontStyles, wCodePage);
if (!pFont) {
@@ -1836,7 +1836,7 @@ CFGAS_GEFont* CXFA_PDFFontMgr::FindFont(const CFX_ByteString& strPsName,
}
CFX_ByteString name = strPsName;
name.Remove(' ');
- IFGAS_FontMgr* pFDEFontMgr = m_pDoc->GetApp()->GetFDEFontMgr();
+ CFGAS_FontMgr* pFDEFontMgr = m_pDoc->GetApp()->GetFDEFontMgr();
for (const auto& it : *pFontSetDict) {
const CFX_ByteString& key = it.first;
CPDF_Object* pObj = it.second;
diff --git a/xfa/fxfa/app/xfa_textlayout.cpp b/xfa/fxfa/app/xfa_textlayout.cpp
index 291cc5133a..345fc272e3 100644
--- a/xfa/fxfa/app/xfa_textlayout.cpp
+++ b/xfa/fxfa/app/xfa_textlayout.cpp
@@ -94,7 +94,7 @@ void CXFA_TextParser::InitCSSData(CXFA_TextProvider* pTextProvider) {
if (!m_pSelector) {
CXFA_FFDoc* pDoc = pTextProvider->GetDocNode();
- IFGAS_FontMgr* pFontMgr = pDoc->GetApp()->GetFDEFontMgr();
+ CFGAS_FontMgr* pFontMgr = pDoc->GetApp()->GetFDEFontMgr();
ASSERT(pFontMgr);
m_pSelector.reset(new CFDE_CSSStyleSelector(pFontMgr));
FX_FLOAT fFontSize = 10;
diff --git a/xfa/fxfa/xfa_ffapp.h b/xfa/fxfa/xfa_ffapp.h
index 359f8ffa3c..e7475de889 100644
--- a/xfa/fxfa/xfa_ffapp.h
+++ b/xfa/fxfa/xfa_ffapp.h
@@ -12,7 +12,7 @@
#include "core/fpdfapi/parser/cpdf_stream.h"
#include "core/fpdfapi/parser/cpdf_stream_acc.h"
-#include "xfa/fgas/font/fgas_font.h"
+#include "xfa/fgas/font/cfgas_fontmgr.h"
#include "xfa/fwl/core/ifwl_app.h"
#include "xfa/fxfa/fxfa.h"
@@ -52,7 +52,7 @@ class CXFA_FFApp {
CXFA_FFDocHandler* GetDocHandler();
CXFA_FWLAdapterWidgetMgr* GetWidgetMgr(CFWL_WidgetMgrDelegate* pDelegate);
- IFGAS_FontMgr* GetFDEFontMgr();
+ CFGAS_FontMgr* GetFDEFontMgr();
CXFA_FWLTheme* GetFWLTheme();
IXFA_AppProvider* GetAppProvider() const { return m_pProvider; }
@@ -79,7 +79,7 @@ class CXFA_FFApp {
//
// TODO(dsinclair): The GEFont should have the FontMgr as the pointer instead
// of the DEFFontMgr so this goes away. Bug 561.
- std::unique_ptr<IFGAS_FontMgr> m_pFDEFontMgr;
+ std::unique_ptr<CFGAS_FontMgr> m_pFDEFontMgr;
std::unique_ptr<CXFA_FontMgr> m_pFontMgr;
#if _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_
diff --git a/xfa/fxfa/xfa_fontmgr.h b/xfa/fxfa/xfa_fontmgr.h
index 8838bbcd0c..a6a5822e0d 100644
--- a/xfa/fxfa/xfa_fontmgr.h
+++ b/xfa/fxfa/xfa_fontmgr.h
@@ -12,7 +12,7 @@
#include "core/fxcrt/fx_ext.h"
#include "core/fxcrt/fx_system.h"
-#include "xfa/fgas/font/fgas_font.h"
+#include "xfa/fgas/font/cfgas_fontmgr.h"
#include "xfa/fxfa/fxfa.h"
class CPDF_Font;