summaryrefslogtreecommitdiff
path: root/xfa/fgas
diff options
context:
space:
mode:
authorthestig <thestig@chromium.org>2016-06-07 17:33:37 -0700
committerCommit bot <commit-bot@chromium.org>2016-06-07 17:33:37 -0700
commita4fdfc5ed0e8d2e6acc52cc34eac42c6072f0ccc (patch)
tree255d0e11679bd1f54f94dd717e74db5827f967e9 /xfa/fgas
parent759de3828419522e8ecd7cdaee469e55061a7c08 (diff)
downloadpdfium-a4fdfc5ed0e8d2e6acc52cc34eac42c6072f0ccc.tar.xz
Replace IFGAS_Font with underlying concrete type
Review-Url: https://codereview.chromium.org/2037563002
Diffstat (limited to 'xfa/fgas')
-rw-r--r--xfa/fgas/font/fgas_font.h149
-rw-r--r--xfa/fgas/font/fgas_gefont.cpp155
-rw-r--r--xfa/fgas/font/fgas_gefont.h116
-rw-r--r--xfa/fgas/font/fgas_stdfontmgr.cpp180
-rw-r--r--xfa/fgas/font/fgas_stdfontmgr.h124
-rw-r--r--xfa/fgas/layout/fgas_rtfbreak.cpp7
-rw-r--r--xfa/fgas/layout/fgas_rtfbreak.h8
-rw-r--r--xfa/fgas/layout/fgas_textbreak.cpp7
-rw-r--r--xfa/fgas/layout/fgas_textbreak.h8
-rw-r--r--xfa/fgas/layout/fgas_unicode.h2
10 files changed, 356 insertions, 400 deletions
diff --git a/xfa/fgas/font/fgas_font.h b/xfa/fgas/font/fgas_font.h
index 5d3a44092d..049c5a06ff 100644
--- a/xfa/fgas/font/fgas_font.h
+++ b/xfa/fgas/font/fgas_font.h
@@ -16,8 +16,8 @@
#endif // _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_
class CFX_FontSourceEnum_File;
+class CFGAS_GEFont;
class CXFA_PDFFontMgr;
-class IFGAS_Font;
class IFGAS_FontMgr;
#define FX_FONTSTYLE_Normal 0x00
@@ -29,71 +29,6 @@ class IFGAS_FontMgr;
#define FX_FONTSTYLE_Bold 0x40000
#define FX_FONTSTYLE_BoldItalic (FX_FONTSTYLE_Bold | FX_FONTSTYLE_Italic)
#define FX_FONTSTYLE_ExactMatch 0x80000000
-#define FX_FONTDECORATION_Underline 0x00000001
-#define FX_FONTDECORATION_Strikeout 0x00000002
-#define FX_FONTDECORATION_Overline 0x00000004
-#define FX_FONTDECORATION_Emphasis 0x00000008
-#define FX_FONTDECORATION_Superscript 0x00000010
-#define FX_FONTDECORATION_Subscript 0x00000020
-#define FX_FONTDECORATION_SmallCapital 0x00000040
-#define FX_FONTDECORATION_Capital 0x00000080
-#define FX_FONTDECORATION_Lowercase 0x000000C0
-#define FX_FONTDECORATION_Raised 0x00000100
-#define FX_FONTDECORATION_Sunken 0x00000200
-#define FX_FONTDECORATION_Shadow 0x00000400
-#define FX_FONTDECORATION_BoundingShape 0x20000000
-#define FX_FONTDECORATION_Hide 0x40000000
-#define FX_FONTDECORATION_StrokeFill 0x80000000
-#define FX_BOUNDINGSHAPE_None 0
-#define FX_BOUNDINGSHAPE_Circle 1
-#define FX_BOUNDINGSHAPE_Square 2
-#define FX_BOUNDINGSHAPE_Triangle 3
-#define FX_BOUNDINGSHAPE_Diamond 4
-
-class IFGAS_Font {
- public:
- static IFGAS_Font* LoadFont(const FX_WCHAR* pszFontFamily,
- uint32_t dwFontStyles,
- uint16_t wCodePage,
- IFGAS_FontMgr* pFontMgr);
- static IFGAS_Font* LoadFont(const uint8_t* pBuffer,
- int32_t iLength,
- IFGAS_FontMgr* pFontMgr);
- static IFGAS_Font* LoadFont(const FX_WCHAR* pszFileName,
- IFGAS_FontMgr* pFontMgr);
- static IFGAS_Font* LoadFont(IFX_Stream* pFontStream,
- IFGAS_FontMgr* pFontMgr,
- FX_BOOL bSaveStream = FALSE);
- static IFGAS_Font* LoadFont(CFX_Font* pExtFont,
- IFGAS_FontMgr* pFontMgr,
- FX_BOOL bTakeOver = FALSE);
- virtual ~IFGAS_Font() {}
- virtual void Release() = 0;
- virtual IFGAS_Font* Retain() = 0;
- virtual IFGAS_Font* Derive(uint32_t dwFontStyles, uint16_t wCodePage = 0) = 0;
- virtual void GetFamilyName(CFX_WideString& wsFamily) const = 0;
- virtual uint32_t GetFontStyles() const = 0;
- virtual uint8_t GetCharSet() const = 0;
- virtual FX_BOOL GetCharWidth(FX_WCHAR wUnicode,
- int32_t& iWidth,
- FX_BOOL bCharCode = FALSE) = 0;
- virtual int32_t GetGlyphIndex(FX_WCHAR wUnicode,
- FX_BOOL bCharCode = FALSE) = 0;
- virtual int32_t GetAscent() const = 0;
- virtual int32_t GetDescent() const = 0;
- virtual FX_BOOL GetCharBBox(FX_WCHAR wUnicode,
- CFX_Rect& bbox,
- FX_BOOL bCharCode = FALSE) = 0;
- virtual FX_BOOL GetBBox(CFX_Rect& bbox) = 0;
- virtual int32_t GetItalicAngle() const = 0;
- virtual void Reset() = 0;
- virtual IFGAS_Font* GetSubstFont(int32_t iGlyphIndex) const = 0;
- virtual CFX_Font* GetDevFont() const = 0;
- virtual void SetFontProvider(CXFA_PDFFontMgr* pProvider) = 0;
-#if _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_
- virtual void SetLogicalFontStyle(uint32_t dwLogFontStyle) = 0;
-#endif
-};
#if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_
struct FX_FONTMATCHPARAMS {
@@ -150,37 +85,37 @@ class IFGAS_FontMgr {
static IFGAS_FontMgr* Create(FX_LPEnumAllFonts pEnumerator);
virtual ~IFGAS_FontMgr() {}
virtual void Release() = 0;
- virtual IFGAS_Font* GetDefFontByCodePage(
+ virtual CFGAS_GEFont* GetDefFontByCodePage(
uint16_t wCodePage,
uint32_t dwFontStyles,
const FX_WCHAR* pszFontFamily = NULL) = 0;
- virtual IFGAS_Font* GetDefFontByCharset(
+ virtual CFGAS_GEFont* GetDefFontByCharset(
uint8_t nCharset,
uint32_t dwFontStyles,
const FX_WCHAR* pszFontFamily = NULL) = 0;
- virtual IFGAS_Font* GetDefFontByUnicode(
+ virtual CFGAS_GEFont* GetDefFontByUnicode(
FX_WCHAR wUnicode,
uint32_t dwFontStyles,
const FX_WCHAR* pszFontFamily = NULL) = 0;
- virtual IFGAS_Font* GetDefFontByLanguage(
+ virtual CFGAS_GEFont* GetDefFontByLanguage(
uint16_t wLanguage,
uint32_t dwFontStyles,
const FX_WCHAR* pszFontFamily = NULL) = 0;
- virtual IFGAS_Font* LoadFont(const FX_WCHAR* pszFontFamily,
- uint32_t dwFontStyles,
- uint16_t wCodePage = 0xFFFF) = 0;
- virtual IFGAS_Font* LoadFont(const uint8_t* pBuffer, int32_t iLength) = 0;
- virtual IFGAS_Font* LoadFont(const FX_WCHAR* pszFileName) = 0;
- virtual IFGAS_Font* LoadFont(IFX_Stream* pFontStream,
- const FX_WCHAR* pszFontAlias = NULL,
- uint32_t dwFontStyles = 0,
- uint16_t wCodePage = 0,
- FX_BOOL bSaveStream = FALSE) = 0;
- virtual IFGAS_Font* LoadFont(IFGAS_Font* pSrcFont,
- uint32_t dwFontStyles,
- uint16_t wCodePage = 0xFFFF) = 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(const FX_WCHAR* pszFileName) = 0;
+ virtual CFGAS_GEFont* LoadFont(IFX_Stream* pFontStream,
+ const FX_WCHAR* pszFontAlias = NULL,
+ uint32_t dwFontStyles = 0,
+ uint16_t wCodePage = 0,
+ FX_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(IFGAS_Font* pFont) = 0;
+ virtual void RemoveFont(CFGAS_GEFont* pFont) = 0;
};
#else // _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_
@@ -190,57 +125,57 @@ class IFGAS_FontMgr {
static IFGAS_FontMgr* Create(CFX_FontSourceEnum_File* pFontEnum);
virtual ~IFGAS_FontMgr() {}
virtual void Release() = 0;
- virtual IFGAS_Font* GetDefFontByCodePage(
+ virtual CFGAS_GEFont* GetDefFontByCodePage(
uint16_t wCodePage,
uint32_t dwFontStyles,
const FX_WCHAR* pszFontFamily = NULL) = 0;
- virtual IFGAS_Font* GetDefFontByCharset(
+ virtual CFGAS_GEFont* GetDefFontByCharset(
uint8_t nCharset,
uint32_t dwFontStyles,
const FX_WCHAR* pszFontFamily = NULL) = 0;
- virtual IFGAS_Font* GetDefFontByUnicode(
+ virtual CFGAS_GEFont* GetDefFontByUnicode(
FX_WCHAR wUnicode,
uint32_t dwFontStyles,
const FX_WCHAR* pszFontFamily = NULL) = 0;
- virtual IFGAS_Font* GetDefFontByLanguage(
+ virtual CFGAS_GEFont* GetDefFontByLanguage(
uint16_t wLanguage,
uint32_t dwFontStyles,
const FX_WCHAR* pszFontFamily = NULL) = 0;
- virtual IFGAS_Font* GetFontByCodePage(
+ virtual CFGAS_GEFont* GetFontByCodePage(
uint16_t wCodePage,
uint32_t dwFontStyles,
const FX_WCHAR* pszFontFamily = NULL) = 0;
- inline IFGAS_Font* LoadFont(const FX_WCHAR* pszFontFamily,
- uint32_t dwFontStyles,
- uint16_t wCodePage) {
+ inline CFGAS_GEFont* LoadFont(const FX_WCHAR* pszFontFamily,
+ uint32_t dwFontStyles,
+ uint16_t wCodePage) {
return GetFontByCodePage(wCodePage, dwFontStyles, pszFontFamily);
}
- virtual IFGAS_Font* GetFontByCharset(
+ virtual CFGAS_GEFont* GetFontByCharset(
uint8_t nCharset,
uint32_t dwFontStyles,
const FX_WCHAR* pszFontFamily = NULL) = 0;
- virtual IFGAS_Font* GetFontByUnicode(
+ virtual CFGAS_GEFont* GetFontByUnicode(
FX_WCHAR wUnicode,
uint32_t dwFontStyles,
const FX_WCHAR* pszFontFamily = NULL) = 0;
- virtual IFGAS_Font* GetFontByLanguage(
+ virtual CFGAS_GEFont* GetFontByLanguage(
uint16_t wLanguage,
uint32_t dwFontStyles,
const FX_WCHAR* pszFontFamily = NULL) = 0;
- virtual IFGAS_Font* LoadFont(const uint8_t* pBuffer,
- int32_t iLength,
- int32_t iFaceIndex,
- int32_t* pFaceCount = NULL) = 0;
- virtual IFGAS_Font* LoadFont(const FX_WCHAR* pszFileName,
- int32_t iFaceIndex,
- int32_t* pFaceCount = NULL) = 0;
- virtual IFGAS_Font* LoadFont(IFX_Stream* pFontStream,
- int32_t iFaceIndex,
- int32_t* pFaceCount = NULL,
- FX_BOOL bSaveStream = FALSE) = 0;
+ virtual CFGAS_GEFont* LoadFont(const uint8_t* pBuffer,
+ int32_t iLength,
+ int32_t iFaceIndex,
+ int32_t* pFaceCount = NULL) = 0;
+ virtual CFGAS_GEFont* LoadFont(const FX_WCHAR* pszFileName,
+ int32_t iFaceIndex,
+ int32_t* pFaceCount = NULL) = 0;
+ virtual CFGAS_GEFont* LoadFont(IFX_Stream* pFontStream,
+ int32_t iFaceIndex,
+ int32_t* pFaceCount = NULL,
+ FX_BOOL bSaveStream = FALSE) = 0;
virtual void ClearFontCache() = 0;
- virtual void RemoveFont(IFGAS_Font* pFont) = 0;
+ virtual void RemoveFont(CFGAS_GEFont* pFont) = 0;
};
#endif // _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_
diff --git a/xfa/fgas/font/fgas_gefont.cpp b/xfa/fgas/font/fgas_gefont.cpp
index ae6465c13f..c26ad15c66 100644
--- a/xfa/fgas/font/fgas_gefont.cpp
+++ b/xfa/fgas/font/fgas_gefont.cpp
@@ -10,10 +10,11 @@
#include "xfa/fgas/font/fgas_fontutils.h"
#include "xfa/fxfa/include/xfa_fontmgr.h"
-IFGAS_Font* IFGAS_Font::LoadFont(const FX_WCHAR* pszFontFamily,
- uint32_t dwFontStyles,
- uint16_t wCodePage,
- IFGAS_FontMgr* pFontMgr) {
+// static
+CFGAS_GEFont* CFGAS_GEFont::LoadFont(const FX_WCHAR* pszFontFamily,
+ uint32_t dwFontStyles,
+ uint16_t wCodePage,
+ IFGAS_FontMgr* pFontMgr) {
#if _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_
if (NULL != pFontMgr) {
return pFontMgr->GetFontByCodePage(wCodePage, dwFontStyles, pszFontFamily);
@@ -28,66 +29,54 @@ IFGAS_Font* IFGAS_Font::LoadFont(const FX_WCHAR* pszFontFamily,
return pFont;
#endif
}
-IFGAS_Font* IFGAS_Font::LoadFont(const uint8_t* pBuffer,
- int32_t iLength,
- IFGAS_FontMgr* pFontMgr) {
-#if _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_
- if (NULL != pFontMgr) {
- return pFontMgr->LoadFont(pBuffer, iLength, 0, NULL);
- }
- return NULL;
-#else
+
+// static
+CFGAS_GEFont* CFGAS_GEFont::LoadFont(CFX_Font* pExtFont,
+ IFGAS_FontMgr* pFontMgr,
+ FX_BOOL bTakeOver) {
CFGAS_GEFont* pFont = new CFGAS_GEFont(pFontMgr);
- if (!pFont->LoadFont(pBuffer, iLength)) {
+ if (!pFont->LoadFont(pExtFont, bTakeOver)) {
pFont->Release();
return NULL;
}
return pFont;
-#endif
}
-IFGAS_Font* IFGAS_Font::LoadFont(const FX_WCHAR* pszFileName,
- IFGAS_FontMgr* pFontMgr) {
-#if _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_
- if (NULL != pFontMgr) {
- return pFontMgr->LoadFont(pszFileName, 0, NULL);
- }
- return NULL;
-#else
+
+#if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_
+// static
+CFGAS_GEFont* CFGAS_GEFont::LoadFont(const uint8_t* pBuffer,
+ int32_t iLength,
+ IFGAS_FontMgr* pFontMgr) {
CFGAS_GEFont* pFont = new CFGAS_GEFont(pFontMgr);
- if (!pFont->LoadFont(pszFileName)) {
+ if (!pFont->LoadFont(pBuffer, iLength)) {
pFont->Release();
- return NULL;
+ return nullptr;
}
return pFont;
-#endif
}
-IFGAS_Font* IFGAS_Font::LoadFont(IFX_Stream* pFontStream,
- IFGAS_FontMgr* pFontMgr,
- FX_BOOL bSaveStream) {
-#if _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_
- if (NULL != pFontMgr) {
- return pFontMgr->LoadFont(pFontStream, 0, NULL);
- }
- return NULL;
-#else
- CFGAS_GEFont* pFont = new CFGAS_GEFont(pFontMgr);
- if (!pFont->LoadFont(pFontStream, bSaveStream)) {
+
+// static
+CFGAS_GEFont* CFGAS_GEFont::LoadFont(const FX_WCHAR* pszFileName) {
+ CFGAS_GEFont* pFont = new CFGAS_GEFont(nullptr);
+ if (!pFont->LoadFontInternal(pszFileName)) {
pFont->Release();
- return NULL;
+ return nullptr;
}
return pFont;
-#endif
}
-IFGAS_Font* IFGAS_Font::LoadFont(CFX_Font* pExtFont,
- IFGAS_FontMgr* pFontMgr,
- FX_BOOL bTakeOver) {
+
+// static
+CFGAS_GEFont* CFGAS_GEFont::LoadFont(IFX_Stream* pFontStream,
+ IFGAS_FontMgr* pFontMgr,
+ FX_BOOL bSaveStream) {
CFGAS_GEFont* pFont = new CFGAS_GEFont(pFontMgr);
- if (!pFont->LoadFont(pExtFont, bTakeOver)) {
+ if (!pFont->LoadFont(pFontStream, bSaveStream)) {
pFont->Release();
- return NULL;
+ return nullptr;
}
return pFont;
}
+#endif // _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_
CFGAS_GEFont::CFGAS_GEFont(IFGAS_FontMgr* pFontMgr)
:
@@ -171,10 +160,12 @@ void CFGAS_GEFont::Release() {
delete this;
}
}
-IFGAS_Font* CFGAS_GEFont::Retain() {
+CFGAS_GEFont* CFGAS_GEFont::Retain() {
++m_iRefCount;
return this;
}
+
+#if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_
FX_BOOL CFGAS_GEFont::LoadFont(const FX_WCHAR* pszFontFamily,
uint32_t dwFontStyles,
uint16_t wCodePage) {
@@ -229,6 +220,7 @@ FX_BOOL CFGAS_GEFont::LoadFont(const FX_WCHAR* pszFontFamily,
}
return bRet;
}
+
FX_BOOL CFGAS_GEFont::LoadFont(const uint8_t* pBuffer, int32_t length) {
if (m_pFont) {
return FALSE;
@@ -241,7 +233,8 @@ FX_BOOL CFGAS_GEFont::LoadFont(const uint8_t* pBuffer, int32_t length) {
m_wCharSet = 0xFFFF;
return bRet;
}
-FX_BOOL CFGAS_GEFont::LoadFont(const FX_WCHAR* pszFileName) {
+
+FX_BOOL CFGAS_GEFont::LoadFontInternal(const FX_WCHAR* pszFileName) {
if (m_pFont || m_pStream || m_pFileRead) {
return FALSE;
}
@@ -262,6 +255,7 @@ FX_BOOL CFGAS_GEFont::LoadFont(const FX_WCHAR* pszFileName) {
m_wCharSet = 0xFFFF;
return bRet;
}
+
FX_BOOL CFGAS_GEFont::LoadFont(IFX_Stream* pFontStream, FX_BOOL bSaveStream) {
if (m_pFont || m_pFileRead || !pFontStream || pFontStream->GetLength() < 1) {
return FALSE;
@@ -281,6 +275,8 @@ FX_BOOL CFGAS_GEFont::LoadFont(IFX_Stream* pFontStream, FX_BOOL bSaveStream) {
m_wCharSet = 0xFFFF;
return bRet;
}
+#endif // _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_
+
FX_BOOL CFGAS_GEFont::LoadFont(CFX_Font* pExtFont, FX_BOOL bTakeOver) {
if (m_pFont || !pExtFont) {
return FALSE;
@@ -296,6 +292,7 @@ FX_BOOL CFGAS_GEFont::LoadFont(CFX_Font* pExtFont, FX_BOOL bTakeOver) {
m_wCharSet = 0xFFFF;
return bRet;
}
+
FX_BOOL CFGAS_GEFont::InitFont() {
if (!m_pFont)
return FALSE;
@@ -313,7 +310,7 @@ FX_BOOL CFGAS_GEFont::InitFont() {
return TRUE;
}
-IFGAS_Font* CFGAS_GEFont::Derive(uint32_t dwFontStyles, uint16_t wCodePage) {
+CFGAS_GEFont* CFGAS_GEFont::Derive(uint32_t dwFontStyles, uint16_t wCodePage) {
if (GetFontStyles() == dwFontStyles) {
return Retain();
}
@@ -366,27 +363,27 @@ uint32_t CFGAS_GEFont::GetFontStyles() const {
FX_BOOL CFGAS_GEFont::GetCharWidth(FX_WCHAR wUnicode,
int32_t& iWidth,
FX_BOOL bCharCode) {
- return GetCharWidth(wUnicode, iWidth, TRUE, bCharCode);
+ return GetCharWidthInternal(wUnicode, iWidth, TRUE, bCharCode);
}
-FX_BOOL CFGAS_GEFont::GetCharWidth(FX_WCHAR wUnicode,
- int32_t& iWidth,
- FX_BOOL bRecursive,
- FX_BOOL bCharCode) {
+FX_BOOL CFGAS_GEFont::GetCharWidthInternal(FX_WCHAR wUnicode,
+ int32_t& iWidth,
+ FX_BOOL bRecursive,
+ FX_BOOL bCharCode) {
ASSERT(m_pCharWidthMap != NULL);
iWidth = m_pCharWidthMap->GetAt(wUnicode, 0);
if (iWidth < 1) {
if (!m_pProvider ||
!m_pProvider->GetCharWidth(this, wUnicode, iWidth, bCharCode)) {
- IFGAS_Font* pFont = NULL;
+ CFGAS_GEFont* pFont = NULL;
int32_t iGlyph = GetGlyphIndex(wUnicode, TRUE, &pFont, bCharCode);
if (iGlyph != 0xFFFF && pFont != NULL) {
- if (pFont == (IFGAS_Font*)this) {
+ if (pFont == this) {
iWidth = m_pFont->GetGlyphWidth(iGlyph);
if (iWidth < 0) {
iWidth = -1;
}
- } else if (((CFGAS_GEFont*)pFont)
- ->GetCharWidth(wUnicode, iWidth, FALSE, bCharCode)) {
+ } else if (pFont->GetCharWidthInternal(wUnicode, iWidth, FALSE,
+ bCharCode)) {
return TRUE;
}
} else {
@@ -402,20 +399,20 @@ FX_BOOL CFGAS_GEFont::GetCharWidth(FX_WCHAR wUnicode,
FX_BOOL CFGAS_GEFont::GetCharBBox(FX_WCHAR wUnicode,
CFX_Rect& bbox,
FX_BOOL bCharCode) {
- return GetCharBBox(wUnicode, bbox, TRUE, bCharCode);
+ return GetCharBBoxInternal(wUnicode, bbox, TRUE, bCharCode);
}
-FX_BOOL CFGAS_GEFont::GetCharBBox(FX_WCHAR wUnicode,
- CFX_Rect& bbox,
- FX_BOOL bRecursive,
- FX_BOOL bCharCode) {
+FX_BOOL CFGAS_GEFont::GetCharBBoxInternal(FX_WCHAR wUnicode,
+ CFX_Rect& bbox,
+ FX_BOOL bRecursive,
+ FX_BOOL bCharCode) {
ASSERT(m_pRectArray != NULL);
ASSERT(m_pBBoxMap != NULL);
void* pRect = NULL;
if (!m_pBBoxMap->Lookup((void*)(uintptr_t)wUnicode, pRect)) {
- IFGAS_Font* pFont = NULL;
+ CFGAS_GEFont* pFont = NULL;
int32_t iGlyph = GetGlyphIndex(wUnicode, TRUE, &pFont, bCharCode);
if (iGlyph != 0xFFFF && pFont != NULL) {
- if (pFont == (IFGAS_Font*)this) {
+ if (pFont == this) {
FX_RECT rtBBox;
if (m_pFont->GetGlyphBBox(iGlyph, rtBBox)) {
CFX_Rect rt;
@@ -424,8 +421,7 @@ FX_BOOL CFGAS_GEFont::GetCharBBox(FX_WCHAR wUnicode,
pRect = m_pRectArray->GetPtrAt(index);
m_pBBoxMap->SetAt((void*)(uintptr_t)wUnicode, pRect);
}
- } else if (((CFGAS_GEFont*)pFont)
- ->GetCharBBox(wUnicode, bbox, FALSE, bCharCode)) {
+ } else if (pFont->GetCharBBoxInternal(wUnicode, bbox, FALSE, bCharCode)) {
return TRUE;
}
}
@@ -458,13 +454,13 @@ int32_t CFGAS_GEFont::GetGlyphIndex(FX_WCHAR wUnicode, FX_BOOL bCharCode) {
}
int32_t CFGAS_GEFont::GetGlyphIndex(FX_WCHAR wUnicode,
FX_BOOL bRecursive,
- IFGAS_Font** ppFont,
+ CFGAS_GEFont** ppFont,
FX_BOOL bCharCode) {
ASSERT(m_pFontEncoding != NULL);
int32_t iGlyphIndex = m_pFontEncoding->GlyphFromCharCode(wUnicode);
if (iGlyphIndex > 0) {
if (ppFont != NULL) {
- *ppFont = (IFGAS_Font*)this;
+ *ppFont = this;
}
return iGlyphIndex;
}
@@ -477,10 +473,9 @@ int32_t CFGAS_GEFont::GetGlyphIndex(FX_WCHAR wUnicode,
return 0xFFFF;
}
auto it = m_FontMapper.find(wUnicode);
- IFGAS_Font* pFont = it != m_FontMapper.end() ? it->second : nullptr;
+ CFGAS_GEFont* pFont = it != m_FontMapper.end() ? it->second : nullptr;
if (pFont && pFont != this) {
- iGlyphIndex =
- ((CFGAS_GEFont*)pFont)->GetGlyphIndex(wUnicode, FALSE, NULL, bCharCode);
+ iGlyphIndex = pFont->GetGlyphIndex(wUnicode, FALSE, NULL, bCharCode);
if (iGlyphIndex != 0xFFFF) {
int32_t i = m_SubstFonts.Find(pFont);
if (i > -1) {
@@ -495,11 +490,11 @@ int32_t CFGAS_GEFont::GetGlyphIndex(FX_WCHAR wUnicode,
CFX_WideString wsFamily;
GetFamilyName(wsFamily);
#if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_
- pFont = m_pFontMgr->GetDefFontByUnicode(wUnicode, GetFontStyles(),
- wsFamily.c_str());
+ CFGAS_GEFont* pFont = m_pFontMgr->GetDefFontByUnicode(
+ wUnicode, GetFontStyles(), wsFamily.c_str());
#else
- pFont = m_pFontMgr->GetFontByUnicode(wUnicode, GetFontStyles(),
- wsFamily.c_str());
+ CFGAS_GEFont* pFont = m_pFontMgr->GetFontByUnicode(
+ wUnicode, GetFontStyles(), wsFamily.c_str());
if (!pFont)
pFont = m_pFontMgr->GetFontByUnicode(wUnicode, GetFontStyles(), NULL);
#endif
@@ -511,8 +506,7 @@ int32_t CFGAS_GEFont::GetGlyphIndex(FX_WCHAR wUnicode,
m_FontMapper[wUnicode] = pFont;
int32_t i = m_SubstFonts.GetSize();
m_SubstFonts.Add(pFont);
- iGlyphIndex = ((CFGAS_GEFont*)pFont)
- ->GetGlyphIndex(wUnicode, FALSE, NULL, bCharCode);
+ iGlyphIndex = pFont->GetGlyphIndex(wUnicode, FALSE, NULL, bCharCode);
if (iGlyphIndex != 0xFFFF) {
iGlyphIndex |= ((i + 1) << 24);
if (ppFont)
@@ -530,11 +524,8 @@ int32_t CFGAS_GEFont::GetDescent() const {
return m_pFont->GetDescent();
}
void CFGAS_GEFont::Reset() {
- int32_t iCount = m_SubstFonts.GetSize();
- for (int32_t i = 0; i < iCount; i++) {
- IFGAS_Font* pFont = m_SubstFonts[i];
- ((CFGAS_GEFont*)pFont)->Reset();
- }
+ for (int32_t i = 0; i < m_SubstFonts.GetSize(); i++)
+ m_SubstFonts[i]->Reset();
if (m_pCharWidthMap != NULL) {
m_pCharWidthMap->RemoveAll();
}
@@ -545,7 +536,7 @@ void CFGAS_GEFont::Reset() {
m_pRectArray->RemoveAll();
}
}
-IFGAS_Font* CFGAS_GEFont::GetSubstFont(int32_t iGlyphIndex) const {
+CFGAS_GEFont* CFGAS_GEFont::GetSubstFont(int32_t iGlyphIndex) const {
iGlyphIndex = ((uint32_t)iGlyphIndex) >> 24;
return iGlyphIndex == 0 ? const_cast<CFGAS_GEFont*>(this)
: m_SubstFonts[iGlyphIndex - 1];
diff --git a/xfa/fgas/font/fgas_gefont.h b/xfa/fgas/font/fgas_gefont.h
index c818b6286d..877d292890 100644
--- a/xfa/fgas/font/fgas_gefont.h
+++ b/xfa/fgas/font/fgas_gefont.h
@@ -16,51 +16,82 @@
class CXFA_PDFFontMgr;
-class CFGAS_GEFont : public IFGAS_Font {
+class CFGAS_GEFont {
public:
- CFGAS_GEFont(const CFGAS_GEFont& src, uint32_t dwFontStyles);
- explicit CFGAS_GEFont(IFGAS_FontMgr* pFontMgr);
+ static CFGAS_GEFont* LoadFont(const FX_WCHAR* pszFontFamily,
+ uint32_t dwFontStyles,
+ uint16_t wCodePage,
+ IFGAS_FontMgr* pFontMgr);
+ static CFGAS_GEFont* LoadFont(CFX_Font* pExtFont,
+ IFGAS_FontMgr* pFontMgr,
+ FX_BOOL bTakeOver);
+#if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_
+ static CFGAS_GEFont* LoadFont(const uint8_t* pBuffer,
+ int32_t iLength,
+ IFGAS_FontMgr* pFontMgr);
+ static CFGAS_GEFont* LoadFont(const FX_WCHAR* pszFileName);
+ static CFGAS_GEFont* LoadFont(IFX_Stream* pFontStream,
+ IFGAS_FontMgr* pFontMgr,
+ FX_BOOL bSaveStream);
+#endif
+
~CFGAS_GEFont();
- // IFGAS_Font:
- virtual void Release();
- virtual IFGAS_Font* Retain();
+ void Release();
+ CFGAS_GEFont* Retain();
+ CFGAS_GEFont* Derive(uint32_t dwFontStyles, uint16_t wCodePage = 0);
+ void GetFamilyName(CFX_WideString& wsFamily) const;
+ uint32_t GetFontStyles() const;
+ uint8_t GetCharSet() const;
+ FX_BOOL GetCharWidth(FX_WCHAR wUnicode,
+ int32_t& iWidth,
+ FX_BOOL bCharCode = FALSE);
+ int32_t GetGlyphIndex(FX_WCHAR wUnicode, FX_BOOL bCharCode = FALSE);
+ int32_t GetAscent() const;
+ int32_t GetDescent() const;
+ FX_BOOL GetCharBBox(FX_WCHAR wUnicode,
+ CFX_Rect& bbox,
+ FX_BOOL bCharCode = FALSE);
+ FX_BOOL GetBBox(CFX_Rect& bbox);
+ int32_t GetItalicAngle() const;
+ void Reset();
+ CFGAS_GEFont* GetSubstFont(int32_t iGlyphIndex) const;
+ CFX_Font* GetDevFont() const { return m_pFont; }
+ void SetFontProvider(CXFA_PDFFontMgr* pProvider) { m_pProvider = pProvider; }
+#if _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_
+ void SetLogicalFontStyle(uint32_t dwLogFontStyle) {
+ m_bUseLogFontStyle = TRUE;
+ m_dwLogFontStyle = dwLogFontStyle;
+ }
+#endif
+
+ protected:
+ explicit CFGAS_GEFont(IFGAS_FontMgr* pFontMgr);
+ CFGAS_GEFont(const CFGAS_GEFont& src, uint32_t dwFontStyles);
+
+#if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_
FX_BOOL LoadFont(const FX_WCHAR* pszFontFamily,
uint32_t dwFontStyles,
uint16_t wCodePage);
FX_BOOL LoadFont(const uint8_t* pBuffer, int32_t length);
- FX_BOOL LoadFont(const FX_WCHAR* pszFileName);
+ FX_BOOL LoadFontInternal(const FX_WCHAR* pszFileName);
FX_BOOL LoadFont(IFX_Stream* pFontStream, FX_BOOL bSaveStream);
- FX_BOOL LoadFont(CFX_Font* pExtFont, FX_BOOL bTakeOver = FALSE);
- virtual IFGAS_Font* Derive(uint32_t dwFontStyles, uint16_t wCodePage = 0);
- virtual void GetFamilyName(CFX_WideString& wsFamily) const;
- virtual uint32_t GetFontStyles() const;
- virtual uint8_t GetCharSet() const;
- virtual FX_BOOL GetCharWidth(FX_WCHAR wUnicode,
- int32_t& iWidth,
- FX_BOOL bCharCode = FALSE);
- virtual int32_t GetGlyphIndex(FX_WCHAR wUnicode, FX_BOOL bCharCode = FALSE);
- virtual int32_t GetAscent() const;
- virtual int32_t GetDescent() const;
- virtual FX_BOOL GetCharBBox(FX_WCHAR wUnicode,
+#endif
+ FX_BOOL LoadFont(CFX_Font* pExtFont, FX_BOOL bTakeOver);
+ FX_BOOL InitFont();
+ FX_BOOL GetCharBBoxInternal(FX_WCHAR wUnicode,
CFX_Rect& bbox,
+ FX_BOOL bRecursive,
FX_BOOL bCharCode = FALSE);
- virtual FX_BOOL GetBBox(CFX_Rect& bbox);
- virtual int32_t GetItalicAngle() const;
- virtual void Reset();
- virtual IFGAS_Font* GetSubstFont(int32_t iGlyphIndex) const;
- virtual CFX_Font* GetDevFont() const { return m_pFont; }
- virtual void SetFontProvider(CXFA_PDFFontMgr* pProvider) {
- m_pProvider = pProvider;
- }
-#if _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_
- virtual void SetLogicalFontStyle(uint32_t dwLogFontStyle) {
- m_bUseLogFontStyle = TRUE;
- m_dwLogFontStyle = dwLogFontStyle;
- }
-#endif
+ FX_BOOL GetCharWidthInternal(FX_WCHAR wUnicode,
+ int32_t& iWidth,
+ FX_BOOL bRecursive,
+ FX_BOOL bCharCode = FALSE);
+ int32_t GetGlyphIndex(FX_WCHAR wUnicode,
+ FX_BOOL bRecursive,
+ CFGAS_GEFont** ppFont,
+ FX_BOOL bCharCode = FALSE);
- protected:
#if _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_
FX_BOOL m_bUseLogFontStyle;
uint32_t m_dwLogFontStyle;
@@ -77,21 +108,8 @@ class CFGAS_GEFont : public IFGAS_Font {
CFX_MapPtrToPtr* m_pBBoxMap;
CXFA_PDFFontMgr* m_pProvider;
uint16_t m_wCharSet;
- CFX_ArrayTemplate<IFGAS_Font*> m_SubstFonts;
- std::map<FX_WCHAR, IFGAS_Font*> m_FontMapper;
- FX_BOOL InitFont();
- FX_BOOL GetCharBBox(FX_WCHAR wUnicode,
- CFX_Rect& bbox,
- FX_BOOL bRecursive,
- FX_BOOL bCharCode = FALSE);
- FX_BOOL GetCharWidth(FX_WCHAR wUnicode,
- int32_t& iWidth,
- FX_BOOL bRecursive,
- FX_BOOL bCharCode = FALSE);
- int32_t GetGlyphIndex(FX_WCHAR wUnicode,
- FX_BOOL bRecursive,
- IFGAS_Font** ppFont,
- FX_BOOL bCharCode = FALSE);
+ CFX_ArrayTemplate<CFGAS_GEFont*> m_SubstFonts;
+ std::map<FX_WCHAR, CFGAS_GEFont*> m_FontMapper;
};
#endif // XFA_FGAS_FONT_FGAS_GEFONT_H_
diff --git a/xfa/fgas/font/fgas_stdfontmgr.cpp b/xfa/fgas/font/fgas_stdfontmgr.cpp
index 9ea37cf32b..17bd204889 100644
--- a/xfa/fgas/font/fgas_stdfontmgr.cpp
+++ b/xfa/fgas/font/fgas_stdfontmgr.cpp
@@ -1,4 +1,4 @@
-// Copyright 2014 PDFium Authors. All rights reserved.
+// Copyright 2015 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.
@@ -10,6 +10,7 @@
#include "core/fxge/include/fx_ge.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_
IFGAS_FontMgr* IFGAS_FontMgr::Create(FX_LPEnumAllFonts pEnumerator) {
@@ -43,12 +44,12 @@ CFGAS_StdFontMgrImp::~CFGAS_StdFontMgrImp() {
m_Fonts[i]->Release();
}
-IFGAS_Font* CFGAS_StdFontMgrImp::GetDefFontByCodePage(
+CFGAS_GEFont* CFGAS_StdFontMgrImp::GetDefFontByCodePage(
uint16_t wCodePage,
uint32_t dwFontStyles,
const FX_WCHAR* pszFontFamily) {
uint32_t dwHash = FGAS_GetFontHashCode(wCodePage, dwFontStyles);
- IFGAS_Font* pFont = NULL;
+ CFGAS_GEFont* pFont = NULL;
if (m_CPFonts.Lookup((void*)(uintptr_t)dwHash, (void*&)pFont)) {
return pFont ? LoadFont(pFont, dwFontStyles, wCodePage) : NULL;
}
@@ -60,7 +61,8 @@ IFGAS_Font* CFGAS_StdFontMgrImp::GetDefFontByCodePage(
}
}
ASSERT(pFD);
- pFont = IFGAS_Font::LoadFont(pFD->wsFontFace, dwFontStyles, wCodePage, this);
+ pFont =
+ CFGAS_GEFont::LoadFont(pFD->wsFontFace, dwFontStyles, wCodePage, this);
if (pFont) {
m_Fonts.Add(pFont);
m_CPFonts.SetAt((void*)(uintptr_t)dwHash, (void*)pFont);
@@ -70,7 +72,7 @@ IFGAS_Font* CFGAS_StdFontMgrImp::GetDefFontByCodePage(
}
return NULL;
}
-IFGAS_Font* CFGAS_StdFontMgrImp::GetDefFontByCharset(
+CFGAS_GEFont* CFGAS_StdFontMgrImp::GetDefFontByCharset(
uint8_t nCharset,
uint32_t dwFontStyles,
const FX_WCHAR* pszFontFamily) {
@@ -78,7 +80,7 @@ IFGAS_Font* CFGAS_StdFontMgrImp::GetDefFontByCharset(
pszFontFamily);
}
-IFGAS_Font* CFGAS_StdFontMgrImp::GetDefFontByUnicode(
+CFGAS_GEFont* CFGAS_StdFontMgrImp::GetDefFontByUnicode(
FX_WCHAR wUnicode,
uint32_t dwFontStyles,
const FX_WCHAR* pszFontFamily) {
@@ -88,7 +90,7 @@ IFGAS_Font* CFGAS_StdFontMgrImp::GetDefFontByUnicode(
uint32_t dwHash =
FGAS_GetFontFamilyHash(pszFontFamily, dwFontStyles, pRet->wBitField);
- IFGAS_Font* pFont = nullptr;
+ CFGAS_GEFont* pFont = nullptr;
if (m_UnicodeFonts.Lookup((void*)(uintptr_t)dwHash, (void*&)pFont))
return pFont ? LoadFont(pFont, dwFontStyles, pRet->wCodePage) : nullptr;
@@ -104,7 +106,7 @@ IFGAS_Font* CFGAS_StdFontMgrImp::GetDefFontByUnicode(
uint16_t wCodePage = FX_GetCodePageFromCharset(pFD->uCharSet);
const FX_WCHAR* pFontFace = pFD->wsFontFace;
- pFont = IFGAS_Font::LoadFont(pFontFace, dwFontStyles, wCodePage, this);
+ pFont = CFGAS_GEFont::LoadFont(pFontFace, dwFontStyles, wCodePage, this);
if (pFont) {
m_Fonts.Add(pFont);
m_UnicodeFonts.SetAt((void*)(uintptr_t)dwHash, (void*)pFont);
@@ -117,19 +119,19 @@ IFGAS_Font* CFGAS_StdFontMgrImp::GetDefFontByUnicode(
return nullptr;
}
-IFGAS_Font* CFGAS_StdFontMgrImp::GetDefFontByLanguage(
+CFGAS_GEFont* CFGAS_StdFontMgrImp::GetDefFontByLanguage(
uint16_t wLanguage,
uint32_t dwFontStyles,
const FX_WCHAR* pszFontFamily) {
return GetDefFontByCodePage(FX_GetDefCodePageByLanguage(wLanguage),
dwFontStyles, pszFontFamily);
}
-IFGAS_Font* CFGAS_StdFontMgrImp::LoadFont(const FX_WCHAR* pszFontFamily,
- uint32_t dwFontStyles,
- uint16_t wCodePage) {
+CFGAS_GEFont* CFGAS_StdFontMgrImp::LoadFont(const FX_WCHAR* pszFontFamily,
+ uint32_t dwFontStyles,
+ uint16_t wCodePage) {
uint32_t dwHash =
FGAS_GetFontFamilyHash(pszFontFamily, dwFontStyles, wCodePage);
- IFGAS_Font* pFont = NULL;
+ CFGAS_GEFont* pFont = NULL;
if (m_FamilyFonts.Lookup((void*)(uintptr_t)dwHash, (void*&)pFont)) {
return pFont ? LoadFont(pFont, dwFontStyles, wCodePage) : NULL;
}
@@ -144,7 +146,8 @@ IFGAS_Font* CFGAS_StdFontMgrImp::LoadFont(const FX_WCHAR* pszFontFamily,
if (wCodePage == 0xFFFF) {
wCodePage = FX_GetCodePageFromCharset(pFD->uCharSet);
}
- pFont = IFGAS_Font::LoadFont(pFD->wsFontFace, dwFontStyles, wCodePage, this);
+ pFont =
+ CFGAS_GEFont::LoadFont(pFD->wsFontFace, dwFontStyles, wCodePage, this);
if (pFont) {
m_Fonts.Add(pFont);
m_FamilyFonts.SetAt((void*)(uintptr_t)dwHash, (void*)pFont);
@@ -154,16 +157,16 @@ IFGAS_Font* CFGAS_StdFontMgrImp::LoadFont(const FX_WCHAR* pszFontFamily,
}
return NULL;
}
-IFGAS_Font* CFGAS_StdFontMgrImp::LoadFont(const uint8_t* pBuffer,
- int32_t iLength) {
+CFGAS_GEFont* CFGAS_StdFontMgrImp::LoadFont(const uint8_t* pBuffer,
+ int32_t iLength) {
ASSERT(pBuffer && iLength > 0);
- IFGAS_Font* pFont = NULL;
+ CFGAS_GEFont* pFont = NULL;
if (m_BufferFonts.Lookup((void*)pBuffer, (void*&)pFont)) {
if (pFont) {
return pFont->Retain();
}
}
- pFont = IFGAS_Font::LoadFont(pBuffer, iLength, this);
+ pFont = CFGAS_GEFont::LoadFont(pBuffer, iLength, this);
if (pFont) {
m_Fonts.Add(pFont);
m_BufferFonts.SetAt((void*)pBuffer, pFont);
@@ -171,16 +174,16 @@ IFGAS_Font* CFGAS_StdFontMgrImp::LoadFont(const uint8_t* pBuffer,
}
return NULL;
}
-IFGAS_Font* CFGAS_StdFontMgrImp::LoadFont(const FX_WCHAR* pszFileName) {
+CFGAS_GEFont* CFGAS_StdFontMgrImp::LoadFont(const FX_WCHAR* pszFileName) {
ASSERT(pszFileName);
uint32_t dwHash = FX_HashCode_GetW(pszFileName, false);
- IFGAS_Font* pFont = NULL;
+ CFGAS_GEFont* pFont = NULL;
if (m_FileFonts.Lookup((void*)(uintptr_t)dwHash, (void*&)pFont)) {
if (pFont) {
return pFont->Retain();
}
}
- pFont = IFGAS_Font::LoadFont(pszFileName, NULL);
+ pFont = CFGAS_GEFont::LoadFont(pszFileName);
if (pFont) {
m_Fonts.Add(pFont);
m_FileFonts.SetAt((void*)(uintptr_t)dwHash, (void*)pFont);
@@ -188,13 +191,13 @@ IFGAS_Font* CFGAS_StdFontMgrImp::LoadFont(const FX_WCHAR* pszFileName) {
}
return NULL;
}
-IFGAS_Font* CFGAS_StdFontMgrImp::LoadFont(IFX_Stream* pFontStream,
- const FX_WCHAR* pszFontAlias,
- uint32_t dwFontStyles,
- uint16_t wCodePage,
- FX_BOOL bSaveStream) {
+CFGAS_GEFont* CFGAS_StdFontMgrImp::LoadFont(IFX_Stream* pFontStream,
+ const FX_WCHAR* pszFontAlias,
+ uint32_t dwFontStyles,
+ uint16_t wCodePage,
+ FX_BOOL bSaveStream) {
ASSERT(pFontStream && pFontStream->GetLength() > 0);
- IFGAS_Font* pFont = NULL;
+ CFGAS_GEFont* pFont = NULL;
if (m_StreamFonts.Lookup((void*)pFontStream, (void*&)pFont)) {
if (pFont) {
if (pszFontAlias) {
@@ -205,7 +208,7 @@ IFGAS_Font* CFGAS_StdFontMgrImp::LoadFont(IFX_Stream* pFontStream,
return LoadFont(pFont, dwFontStyles, wCodePage);
}
}
- pFont = IFGAS_Font::LoadFont(pFontStream, this, bSaveStream);
+ pFont = CFGAS_GEFont::LoadFont(pFontStream, this, bSaveStream);
if (pFont) {
m_Fonts.Add(pFont);
m_StreamFonts.SetAt((void*)pFontStream, (void*)pFont);
@@ -218,9 +221,9 @@ IFGAS_Font* CFGAS_StdFontMgrImp::LoadFont(IFX_Stream* pFontStream,
}
return NULL;
}
-IFGAS_Font* CFGAS_StdFontMgrImp::LoadFont(IFGAS_Font* pSrcFont,
- uint32_t dwFontStyles,
- uint16_t wCodePage) {
+CFGAS_GEFont* CFGAS_StdFontMgrImp::LoadFont(CFGAS_GEFont* pSrcFont,
+ uint32_t dwFontStyles,
+ uint16_t wCodePage) {
ASSERT(pSrcFont);
if (pSrcFont->GetFontStyles() == dwFontStyles) {
return pSrcFont->Retain();
@@ -229,7 +232,7 @@ IFGAS_Font* CFGAS_StdFontMgrImp::LoadFont(IFGAS_Font* pSrcFont,
(void*)(uintptr_t)wCodePage};
uint32_t dwHash = FX_HashCode_GetA(
CFX_ByteStringC((uint8_t*)buffer, sizeof(buffer)), false);
- IFGAS_Font* pFont = NULL;
+ CFGAS_GEFont* pFont = NULL;
if (m_DeriveFonts.GetCount() > 0) {
m_DeriveFonts.Lookup((void*)(uintptr_t)dwHash, (void*&)pFont);
if (pFont) {
@@ -255,7 +258,7 @@ void CFGAS_StdFontMgrImp::ClearFontCache() {
}
void CFGAS_StdFontMgrImp::RemoveFont(CFX_MapPtrToPtr& fontMap,
- IFGAS_Font* pFont) {
+ CFGAS_GEFont* pFont) {
FX_POSITION pos = fontMap.GetStartPosition();
void* pKey;
void* pFind;
@@ -269,7 +272,7 @@ void CFGAS_StdFontMgrImp::RemoveFont(CFX_MapPtrToPtr& fontMap,
break;
}
}
-void CFGAS_StdFontMgrImp::RemoveFont(IFGAS_Font* pFont) {
+void CFGAS_StdFontMgrImp::RemoveFont(CFGAS_GEFont* pFont) {
RemoveFont(m_CPFonts, pFont);
RemoveFont(m_FamilyFonts, pFont);
RemoveFont(m_UnicodeFonts, pFont);
@@ -631,7 +634,7 @@ void CFGAS_FontMgrImp::Release() {
pos = m_Hash2Fonts.GetStartPosition();
while (pos) {
uint32_t dwHash;
- CFX_ArrayTemplate<IFGAS_Font*>* pFonts;
+ CFX_ArrayTemplate<CFGAS_GEFont*>* pFonts;
m_Hash2Fonts.GetNextAssoc(pos, dwHash, pFonts);
delete pFonts;
}
@@ -648,7 +651,7 @@ void CFGAS_FontMgrImp::Release() {
pos = m_FileAccess2IFXFont.GetStartPosition();
while (pos) {
uint32_t dwHash;
- IFGAS_Font* pFont;
+ CFGAS_GEFont* pFont;
m_FileAccess2IFXFont.GetNextAssoc(pos, dwHash, pFont);
if (NULL != pFont) {
pFont->Release();
@@ -656,46 +659,47 @@ void CFGAS_FontMgrImp::Release() {
}
pos = m_IFXFont2FileRead.GetStartPosition();
while (pos) {
- IFGAS_Font* pFont;
+ CFGAS_GEFont* pFont;
IFX_FileRead* pFileRead;
m_IFXFont2FileRead.GetNextAssoc(pos, pFont, pFileRead);
pFileRead->Release();
}
delete this;
}
-IFGAS_Font* CFGAS_FontMgrImp::GetDefFontByCodePage(
+CFGAS_GEFont* CFGAS_FontMgrImp::GetDefFontByCodePage(
uint16_t wCodePage,
uint32_t dwFontStyles,
const FX_WCHAR* pszFontFamily) {
return nullptr;
}
-IFGAS_Font* CFGAS_FontMgrImp::GetDefFontByCharset(
+CFGAS_GEFont* CFGAS_FontMgrImp::GetDefFontByCharset(
uint8_t nCharset,
uint32_t dwFontStyles,
const FX_WCHAR* pszFontFamily) {
return nullptr;
}
-IFGAS_Font* CFGAS_FontMgrImp::GetDefFontByUnicode(
+CFGAS_GEFont* CFGAS_FontMgrImp::GetDefFontByUnicode(
FX_WCHAR wUnicode,
uint32_t dwFontStyles,
const FX_WCHAR* pszFontFamily) {
return nullptr;
}
-IFGAS_Font* CFGAS_FontMgrImp::GetDefFontByLanguage(
+CFGAS_GEFont* CFGAS_FontMgrImp::GetDefFontByLanguage(
uint16_t wLanguage,
uint32_t dwFontStyles,
const FX_WCHAR* pszFontFamily) {
return nullptr;
}
-IFGAS_Font* CFGAS_FontMgrImp::GetFontByCodePage(uint16_t wCodePage,
- uint32_t dwFontStyles,
- const FX_WCHAR* pszFontFamily) {
+CFGAS_GEFont* CFGAS_FontMgrImp::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();
uint32_t dwHash = FX_HashCode_GetA(bsHash.AsStringC(), false);
- CFX_ArrayTemplate<IFGAS_Font*>* pFonts = nullptr;
+ CFX_ArrayTemplate<CFGAS_GEFont*>* pFonts = nullptr;
if (m_Hash2Fonts.Lookup(dwHash, pFonts)) {
if (!pFonts)
return nullptr;
@@ -705,7 +709,7 @@ IFGAS_Font* CFGAS_FontMgrImp::GetFontByCodePage(uint16_t wCodePage,
}
if (!pFonts)
- pFonts = new CFX_ArrayTemplate<IFGAS_Font*>;
+ pFonts = new CFX_ArrayTemplate<CFGAS_GEFont*>;
m_Hash2Fonts.SetAt(dwHash, pFonts);
CFX_FontDescriptorInfos* sortedFonts = nullptr;
@@ -719,7 +723,7 @@ IFGAS_Font* CFGAS_FontMgrImp::GetFontByCodePage(uint16_t wCodePage,
return nullptr;
CFX_FontDescriptor* pDesc = sortedFonts->GetAt(0).pFont;
- IFGAS_Font* pFont =
+ CFGAS_GEFont* pFont =
pDesc->m_pFileAccess
? LoadFont(pDesc->m_pFileAccess, pDesc->m_nFaceIndex, nullptr)
: LoadFont(pDesc->m_wsFaceName, pDesc->m_nFaceIndex, nullptr);
@@ -729,16 +733,18 @@ IFGAS_Font* CFGAS_FontMgrImp::GetFontByCodePage(uint16_t wCodePage,
pFonts->Add(pFont);
return pFont;
}
-IFGAS_Font* CFGAS_FontMgrImp::GetFontByCharset(uint8_t nCharset,
- uint32_t dwFontStyles,
- const FX_WCHAR* pszFontFamily) {
+CFGAS_GEFont* CFGAS_FontMgrImp::GetFontByCharset(
+ uint8_t nCharset,
+ uint32_t dwFontStyles,
+ const FX_WCHAR* pszFontFamily) {
return GetFontByCodePage(FX_GetCodePageFromCharset(nCharset), dwFontStyles,
pszFontFamily);
}
-IFGAS_Font* CFGAS_FontMgrImp::GetFontByUnicode(FX_WCHAR wUnicode,
- uint32_t dwFontStyles,
- const FX_WCHAR* pszFontFamily) {
- IFGAS_Font* pFont = nullptr;
+CFGAS_GEFont* CFGAS_FontMgrImp::GetFontByUnicode(
+ FX_WCHAR wUnicode,
+ uint32_t dwFontStyles,
+ const FX_WCHAR* pszFontFamily) {
+ CFGAS_GEFont* pFont = nullptr;
if (m_FailedUnicodes2NULL.Lookup(wUnicode, pFont))
return nullptr;
const FGAS_FONTUSB* x = FGAS_GetUnicodeBitField(wUnicode);
@@ -751,7 +757,7 @@ IFGAS_Font* CFGAS_FontMgrImp::GetFontByUnicode(FX_WCHAR wUnicode,
bsHash.Format("%d, %d", wCodePage, dwFontStyles);
bsHash += CFX_WideString(pszFontFamily).UTF8Encode();
uint32_t dwHash = FX_HashCode_GetA(bsHash.AsStringC(), false);
- CFX_ArrayTemplate<IFGAS_Font*>* pFonts = nullptr;
+ CFX_ArrayTemplate<CFGAS_GEFont*>* pFonts = nullptr;
if (m_Hash2Fonts.Lookup(dwHash, pFonts)) {
if (!pFonts)
return nullptr;
@@ -761,7 +767,7 @@ IFGAS_Font* CFGAS_FontMgrImp::GetFontByUnicode(FX_WCHAR wUnicode,
}
}
if (!pFonts)
- pFonts = new CFX_ArrayTemplate<IFGAS_Font*>;
+ pFonts = new CFX_ArrayTemplate<CFGAS_GEFont*>;
m_Hash2Fonts.SetAt(dwHash, pFonts);
CFX_FontDescriptorInfos* sortedFonts = nullptr;
if (!m_Hash2CandidateList.Lookup(dwHash, sortedFonts)) {
@@ -809,7 +815,8 @@ FX_BOOL CFGAS_FontMgrImp::VerifyUnicode(CFX_FontDescriptor* pDesc,
return !retCharmap && retIndex;
}
-FX_BOOL CFGAS_FontMgrImp::VerifyUnicode(IFGAS_Font* pFont, FX_WCHAR wcUnicode) {
+FX_BOOL CFGAS_FontMgrImp::VerifyUnicode(CFGAS_GEFont* pFont,
+ FX_WCHAR wcUnicode) {
if (!pFont)
return FALSE;
@@ -825,17 +832,18 @@ FX_BOOL CFGAS_FontMgrImp::VerifyUnicode(IFGAS_Font* pFont, FX_WCHAR wcUnicode) {
return TRUE;
}
-IFGAS_Font* CFGAS_FontMgrImp::GetFontByLanguage(uint16_t wLanguage,
- uint32_t dwFontStyles,
- const FX_WCHAR* pszFontFamily) {
+CFGAS_GEFont* CFGAS_FontMgrImp::GetFontByLanguage(
+ uint16_t wLanguage,
+ uint32_t dwFontStyles,
+ const FX_WCHAR* pszFontFamily) {
return GetFontByCodePage(FX_GetDefCodePageByLanguage(wLanguage), dwFontStyles,
pszFontFamily);
}
-IFGAS_Font* CFGAS_FontMgrImp::LoadFont(const uint8_t* pBuffer,
- int32_t iLength,
- int32_t iFaceIndex,
- int32_t* pFaceCount) {
+CFGAS_GEFont* CFGAS_FontMgrImp::LoadFont(const uint8_t* pBuffer,
+ int32_t iLength,
+ int32_t iFaceIndex,
+ int32_t* pFaceCount) {
void* Hash[2] = {(void*)(uintptr_t)pBuffer, (void*)(uintptr_t)iLength};
uint32_t dwHash =
FX_HashCode_GetA(CFX_ByteStringC((uint8_t*)Hash, sizeof(Hash)), false);
@@ -845,9 +853,9 @@ IFGAS_Font* CFGAS_FontMgrImp::LoadFont(const uint8_t* pBuffer,
: nullptr;
}
-IFGAS_Font* CFGAS_FontMgrImp::LoadFont(const FX_WCHAR* pszFileName,
- int32_t iFaceIndex,
- int32_t* pFaceCount) {
+CFGAS_GEFont* CFGAS_FontMgrImp::LoadFont(const FX_WCHAR* pszFileName,
+ int32_t iFaceIndex,
+ int32_t* pFaceCount) {
CFX_ByteString bsHash;
bsHash += CFX_WideString(pszFileName).UTF8Encode();
@@ -862,10 +870,10 @@ IFGAS_Font* CFGAS_FontMgrImp::LoadFont(const FX_WCHAR* pszFileName,
: nullptr;
}
-IFGAS_Font* CFGAS_FontMgrImp::LoadFont(IFX_Stream* pFontStream,
- int32_t iFaceIndex,
- int32_t* pFaceCount,
- FX_BOOL bSaveStream) {
+CFGAS_GEFont* CFGAS_FontMgrImp::LoadFont(IFX_Stream* pFontStream,
+ int32_t iFaceIndex,
+ int32_t* pFaceCount,
+ FX_BOOL bSaveStream) {
void* Hash[1] = {(void*)(uintptr_t)pFontStream};
uint32_t dwHash =
FX_HashCode_GetA(CFX_ByteStringC((uint8_t*)Hash, sizeof(Hash)), false);
@@ -876,12 +884,12 @@ IFGAS_Font* CFGAS_FontMgrImp::LoadFont(IFX_Stream* pFontStream,
: nullptr;
}
-IFGAS_Font* CFGAS_FontMgrImp::LoadFont(IFX_FileAccess* pFontAccess,
- int32_t iFaceIndex,
- int32_t* pFaceCount,
- FX_BOOL bWantCache) {
+CFGAS_GEFont* CFGAS_FontMgrImp::LoadFont(IFX_FileAccess* pFontAccess,
+ int32_t iFaceIndex,
+ int32_t* pFaceCount,
+ FX_BOOL bWantCache) {
uint32_t dwHash = 0;
- IFGAS_Font* pFont = nullptr;
+ CFGAS_GEFont* pFont = nullptr;
if (bWantCache) {
CFX_ByteString bsHash;
bsHash.Format("%d, %d", (uintptr_t)pFontAccess, iFaceIndex);
@@ -907,7 +915,7 @@ IFGAS_Font* CFGAS_FontMgrImp::LoadFont(IFX_FileAccess* pFontAccess,
pFontStream->Release();
return nullptr;
}
- pFont = IFGAS_Font::LoadFont(pInternalFont, this, TRUE);
+ pFont = CFGAS_GEFont::LoadFont(pInternalFont, this, TRUE);
if (!pFont) {
delete pInternalFont;
pFontStream->Release();
@@ -923,9 +931,9 @@ IFGAS_Font* CFGAS_FontMgrImp::LoadFont(IFX_FileAccess* pFontAccess,
return pFont;
}
-IFGAS_Font* CFGAS_FontMgrImp::LoadFont(const CFX_WideString& wsFaceName,
- int32_t iFaceIndex,
- int32_t* pFaceCount) {
+CFGAS_GEFont* CFGAS_FontMgrImp::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)
@@ -950,7 +958,7 @@ IFGAS_Font* CFGAS_FontMgrImp::LoadFont(const CFX_WideString& wsFaceName,
return nullptr;
}
- IFGAS_Font* pFont = IFGAS_Font::LoadFont(pInternalFont, this, FALSE);
+ CFGAS_GEFont* pFont = CFGAS_GEFont::LoadFont(pInternalFont, this, FALSE);
if (!pFont) {
pFontStream->Release();
return nullptr;
@@ -1214,7 +1222,7 @@ void CFGAS_FontMgrImp::ClearFontCache() {
pos = m_FileAccess2IFXFont.GetStartPosition();
while (pos) {
uint32_t dwHash;
- IFGAS_Font* pFont;
+ CFGAS_GEFont* pFont;
m_FileAccess2IFXFont.GetNextAssoc(pos, dwHash, pFont);
if (NULL != pFont) {
pFont->Release();
@@ -1222,13 +1230,13 @@ void CFGAS_FontMgrImp::ClearFontCache() {
}
pos = m_IFXFont2FileRead.GetStartPosition();
while (pos) {
- IFGAS_Font* pFont;
+ CFGAS_GEFont* pFont;
IFX_FileRead* pFileRead;
m_IFXFont2FileRead.GetNextAssoc(pos, pFont, pFileRead);
pFileRead->Release();
}
}
-void CFGAS_FontMgrImp::RemoveFont(IFGAS_Font* pEFont) {
+void CFGAS_FontMgrImp::RemoveFont(CFGAS_GEFont* pEFont) {
if (NULL == pEFont) {
return;
}
@@ -1241,7 +1249,7 @@ void CFGAS_FontMgrImp::RemoveFont(IFGAS_Font* pEFont) {
pos = m_FileAccess2IFXFont.GetStartPosition();
while (pos) {
uint32_t dwHash;
- IFGAS_Font* pCFont;
+ CFGAS_GEFont* pCFont;
m_FileAccess2IFXFont.GetNextAssoc(pos, dwHash, pCFont);
if (pCFont == pEFont) {
m_FileAccess2IFXFont.RemoveKey(dwHash);
@@ -1251,7 +1259,7 @@ void CFGAS_FontMgrImp::RemoveFont(IFGAS_Font* pEFont) {
pos = m_Hash2Fonts.GetStartPosition();
while (pos) {
uint32_t dwHash;
- CFX_ArrayTemplate<IFGAS_Font*>* pFonts;
+ CFX_ArrayTemplate<CFGAS_GEFont*>* pFonts;
m_Hash2Fonts.GetNextAssoc(pos, dwHash, pFonts);
if (NULL != pFonts) {
for (int32_t i = 0; i < pFonts->GetSize(); i++) {
diff --git a/xfa/fgas/font/fgas_stdfontmgr.h b/xfa/fgas/font/fgas_stdfontmgr.h
index 2aea2078aa..cbc10584ec 100644
--- a/xfa/fgas/font/fgas_stdfontmgr.h
+++ b/xfa/fgas/font/fgas_stdfontmgr.h
@@ -25,52 +25,52 @@ class CFGAS_StdFontMgrImp : public IFGAS_FontMgr {
// IFGAS_FontMgr:
void Release() override { delete this; }
- IFGAS_Font* GetDefFontByCodePage(
+ CFGAS_GEFont* GetDefFontByCodePage(
uint16_t wCodePage,
uint32_t dwFontStyles,
const FX_WCHAR* pszFontFamily = NULL) override;
- IFGAS_Font* GetDefFontByCharset(
+ CFGAS_GEFont* GetDefFontByCharset(
uint8_t nCharset,
uint32_t dwFontStyles,
const FX_WCHAR* pszFontFamily = NULL) override;
- IFGAS_Font* GetDefFontByUnicode(
+ CFGAS_GEFont* GetDefFontByUnicode(
FX_WCHAR wUnicode,
uint32_t dwFontStyles,
const FX_WCHAR* pszFontFamily = NULL) override;
- IFGAS_Font* GetDefFontByLanguage(
+ CFGAS_GEFont* GetDefFontByLanguage(
uint16_t wLanguage,
uint32_t dwFontStyles,
const FX_WCHAR* pszFontFamily = NULL) override;
- IFGAS_Font* LoadFont(const FX_WCHAR* pszFontFamily,
- uint32_t dwFontStyles,
- uint16_t wCodePage = 0xFFFF) override;
- IFGAS_Font* LoadFont(const uint8_t* pBuffer, int32_t iLength) override;
- IFGAS_Font* LoadFont(const FX_WCHAR* pszFileName) override;
- IFGAS_Font* LoadFont(IFX_Stream* pFontStream,
- const FX_WCHAR* pszFontAlias = NULL,
- uint32_t dwFontStyles = 0,
- uint16_t wCodePage = 0,
- FX_BOOL bSaveStream = FALSE) override;
- IFGAS_Font* LoadFont(IFGAS_Font* pSrcFont,
- uint32_t dwFontStyles,
- uint16_t wCodePage = 0xFFFF) override;
+ 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;
+ CFGAS_GEFont* LoadFont(const FX_WCHAR* pszFileName) override;
+ CFGAS_GEFont* LoadFont(IFX_Stream* pFontStream,
+ const FX_WCHAR* pszFontAlias = NULL,
+ uint32_t dwFontStyles = 0,
+ uint16_t wCodePage = 0,
+ FX_BOOL bSaveStream = FALSE) override;
+ CFGAS_GEFont* LoadFont(CFGAS_GEFont* pSrcFont,
+ uint32_t dwFontStyles,
+ uint16_t wCodePage = 0xFFFF) override;
void ClearFontCache() override;
- void RemoveFont(IFGAS_Font* pFont) override;
+ void RemoveFont(CFGAS_GEFont* pFont) override;
protected:
- void RemoveFont(CFX_MapPtrToPtr& fontMap, IFGAS_Font* pFont);
+ void RemoveFont(CFX_MapPtrToPtr& fontMap, CFGAS_GEFont* pFont);
FX_FONTDESCRIPTOR const* FindFont(const FX_WCHAR* pszFontFamily,
uint32_t dwFontStyles,
uint32_t dwMatchFlags,
uint16_t wCodePage,
uint32_t dwUSB = 999,
FX_WCHAR wUnicode = 0);
- IFGAS_Font* GetFont(FX_FONTDESCRIPTOR const* pFD, uint32_t dwFontStyles);
+ CFGAS_GEFont* GetFont(FX_FONTDESCRIPTOR const* pFD, uint32_t dwFontStyles);
FX_LPEnumAllFonts m_pEnumerator;
CFX_FontDescriptors m_FontFaces;
- CFX_ArrayTemplate<IFGAS_Font*> m_Fonts;
+ CFX_ArrayTemplate<CFGAS_GEFont*> m_Fonts;
CFX_MapPtrToPtr m_CPFonts;
CFX_MapPtrToPtr m_FamilyFonts;
CFX_MapPtrToPtr m_UnicodeFonts;
@@ -155,51 +155,53 @@ class CFGAS_FontMgrImp : public IFGAS_FontMgr {
// IFGAS_FontMgr:
void Release() override;
- IFGAS_Font* GetDefFontByCodePage(
+ CFGAS_GEFont* GetDefFontByCodePage(
uint16_t wCodePage,
uint32_t dwFontStyles,
const FX_WCHAR* pszFontFamily = NULL) override;
- IFGAS_Font* GetDefFontByCharset(
+ CFGAS_GEFont* GetDefFontByCharset(
uint8_t nCharset,
uint32_t dwFontStyles,
const FX_WCHAR* pszFontFamily = NULL) override;
- IFGAS_Font* GetDefFontByUnicode(
+ CFGAS_GEFont* GetDefFontByUnicode(
FX_WCHAR wUnicode,
uint32_t dwFontStyles,
const FX_WCHAR* pszFontFamily = NULL) override;
- IFGAS_Font* GetDefFontByLanguage(
+ CFGAS_GEFont* GetDefFontByLanguage(
uint16_t wLanguage,
uint32_t dwFontStyles,
const FX_WCHAR* pszFontFamily = NULL) override;
- IFGAS_Font* GetFontByCodePage(uint16_t wCodePage,
- uint32_t dwFontStyles,
- const FX_WCHAR* pszFontFamily = NULL) override;
- IFGAS_Font* GetFontByCharset(uint8_t nCharset,
- uint32_t dwFontStyles,
- const FX_WCHAR* pszFontFamily = NULL) override;
- IFGAS_Font* GetFontByUnicode(FX_WCHAR wUnicode,
- uint32_t dwFontStyles,
- const FX_WCHAR* pszFontFamily = NULL) override;
- IFGAS_Font* GetFontByLanguage(uint16_t wLanguage,
- uint32_t dwFontStyles,
- const FX_WCHAR* pszFontFamily = NULL) override;
- IFGAS_Font* LoadFont(const uint8_t* pBuffer,
- int32_t iLength,
- int32_t iFaceIndex,
- int32_t* pFaceCount) override;
- IFGAS_Font* LoadFont(const FX_WCHAR* pszFileName,
- int32_t iFaceIndex,
- int32_t* pFaceCount) override;
- IFGAS_Font* LoadFont(IFX_Stream* pFontStream,
- int32_t iFaceIndex,
- int32_t* pFaceCount,
- FX_BOOL bSaveStream = FALSE) override;
+ CFGAS_GEFont* GetFontByCodePage(
+ uint16_t wCodePage,
+ uint32_t dwFontStyles,
+ const FX_WCHAR* pszFontFamily = NULL) override;
+ CFGAS_GEFont* GetFontByCharset(uint8_t nCharset,
+ uint32_t dwFontStyles,
+ const FX_WCHAR* pszFontFamily = NULL) override;
+ CFGAS_GEFont* GetFontByUnicode(FX_WCHAR wUnicode,
+ uint32_t dwFontStyles,
+ const FX_WCHAR* pszFontFamily = NULL) override;
+ CFGAS_GEFont* GetFontByLanguage(
+ uint16_t wLanguage,
+ uint32_t dwFontStyles,
+ const FX_WCHAR* pszFontFamily = NULL) override;
+ CFGAS_GEFont* LoadFont(const uint8_t* pBuffer,
+ int32_t iLength,
+ int32_t iFaceIndex,
+ int32_t* pFaceCount) override;
+ CFGAS_GEFont* LoadFont(const FX_WCHAR* pszFileName,
+ int32_t iFaceIndex,
+ int32_t* pFaceCount) override;
+ CFGAS_GEFont* LoadFont(IFX_Stream* pFontStream,
+ int32_t iFaceIndex,
+ int32_t* pFaceCount,
+ FX_BOOL bSaveStream = FALSE) override;
void ClearFontCache() override;
- void RemoveFont(IFGAS_Font* pFont) override;
+ void RemoveFont(CFGAS_GEFont* pFont) override;
- IFGAS_Font* LoadFont(const CFX_WideString& wsFaceName,
- int32_t iFaceIndex,
- int32_t* pFaceCount);
+ CFGAS_GEFont* LoadFont(const CFX_WideString& wsFaceName,
+ int32_t iFaceIndex,
+ int32_t* pFaceCount);
FX_BOOL EnumFonts();
FX_BOOL EnumFontsFromFontMapper();
FX_BOOL EnumFontsFromFiles();
@@ -217,7 +219,7 @@ class CFGAS_FontMgrImp : public IFGAS_FontMgr {
uint32_t GetFlags(FXFT_Face pFace);
CFX_FontDescriptors m_InstalledFonts;
FX_BOOL VerifyUnicode(CFX_FontDescriptor* pDesc, FX_WCHAR wcUnicode);
- FX_BOOL VerifyUnicode(IFGAS_Font* pFont, FX_WCHAR wcUnicode);
+ FX_BOOL VerifyUnicode(CFGAS_GEFont* pFont, FX_WCHAR wcUnicode);
int32_t IsPartName(const CFX_WideString& Name1, const CFX_WideString& Name2);
int32_t MatchFonts(CFX_FontDescriptorInfos& MatchedFonts,
uint16_t wCodePage,
@@ -229,10 +231,10 @@ class CFGAS_FontMgrImp : public IFGAS_FontMgr {
uint32_t dwFontStyles,
const CFX_WideString& FontName,
FX_WCHAR wcUnicode = 0xFFFE);
- IFGAS_Font* LoadFont(IFX_FileAccess* pFontAccess,
- int32_t iFaceIndex,
- int32_t* pFaceCount,
- FX_BOOL bWantCache = FALSE);
+ CFGAS_GEFont* LoadFont(IFX_FileAccess* pFontAccess,
+ int32_t iFaceIndex,
+ int32_t* pFaceCount,
+ FX_BOOL bWantCache = FALSE);
FXFT_Face LoadFace(IFX_FileRead* pFontStream, int32_t iFaceIndex);
IFX_FileRead* CreateFontStream(CFX_FontMapper* pFontMapper,
IFX_SystemFontInfo* pSystemFontInfo,
@@ -240,11 +242,11 @@ class CFGAS_FontMgrImp : public IFGAS_FontMgr {
IFX_FileRead* CreateFontStream(const CFX_ByteString& bsFaceName);
CFX_MapPtrTemplate<uint32_t, CFX_FontDescriptorInfos*> m_Hash2CandidateList;
- CFX_MapPtrTemplate<uint32_t, CFX_ArrayTemplate<IFGAS_Font*>*> m_Hash2Fonts;
+ CFX_MapPtrTemplate<uint32_t, CFX_ArrayTemplate<CFGAS_GEFont*>*> m_Hash2Fonts;
CFX_MapPtrTemplate<uint32_t, IFX_FileAccess*> m_Hash2FileAccess;
- CFX_MapPtrTemplate<uint32_t, IFGAS_Font*> m_FileAccess2IFXFont;
- CFX_MapPtrTemplate<IFGAS_Font*, IFX_FileRead*> m_IFXFont2FileRead;
- CFX_MapPtrTemplate<FX_WCHAR, IFGAS_Font*> m_FailedUnicodes2NULL;
+ CFX_MapPtrTemplate<uint32_t, CFGAS_GEFont*> m_FileAccess2IFXFont;
+ CFX_MapPtrTemplate<CFGAS_GEFont*, IFX_FileRead*> m_IFXFont2FileRead;
+ CFX_MapPtrTemplate<FX_WCHAR, CFGAS_GEFont*> m_FailedUnicodes2NULL;
CFX_FontSourceEnum_File* const m_pFontSource;
};
#endif
diff --git a/xfa/fgas/layout/fgas_rtfbreak.cpp b/xfa/fgas/layout/fgas_rtfbreak.cpp
index 514c9f0925..388a3be6f9 100644
--- a/xfa/fgas/layout/fgas_rtfbreak.cpp
+++ b/xfa/fgas/layout/fgas_rtfbreak.cpp
@@ -10,6 +10,7 @@
#include "core/fxcrt/include/fx_arabic.h"
#include "core/fxcrt/include/fx_arb.h"
+#include "xfa/fgas/font/fgas_gefont.h"
#include "xfa/fgas/layout/fgas_linebreak.h"
#include "xfa/fgas/layout/fgas_unicode.h"
@@ -86,7 +87,7 @@ void CFX_RTFBreak::SetLayoutStyles(uint32_t dwLayoutStyles) {
m_iRotation = m_iLineRotation + m_iCharRotation;
m_iRotation %= 4;
}
-void CFX_RTFBreak::SetFont(IFGAS_Font* pFont) {
+void CFX_RTFBreak::SetFont(CFGAS_GEFont* pFont) {
if (pFont == NULL) {
return;
}
@@ -1184,7 +1185,7 @@ int32_t CFX_RTFBreak::GetDisplayPos(const FX_RTFTEXTOBJ* pText,
const FX_WCHAR* pStr = pText->pStr;
int32_t* pWidths = pText->pWidths;
int32_t iLength = pText->iLength - 1;
- IFGAS_Font* pFont = pText->pFont;
+ CFGAS_GEFont* pFont = pText->pFont;
uint32_t dwStyles = pText->dwLayoutStyles;
CFX_RectF rtText(*pText->pRect);
FX_BOOL bRTLPiece = FX_IsOdd(pText->iBidiLevel);
@@ -1430,7 +1431,7 @@ int32_t CFX_RTFBreak::GetCharRects(const FX_RTFTEXTOBJ* pText,
FX_FLOAT fFontSize = pText->fFontSize;
int32_t iFontSize = FXSYS_round(fFontSize * 20.0f);
FX_FLOAT fScale = fFontSize / 1000.0f;
- IFGAS_Font* pFont = pText->pFont;
+ CFGAS_GEFont* pFont = pText->pFont;
if (pFont == NULL) {
bCharBBox = FALSE;
}
diff --git a/xfa/fgas/layout/fgas_rtfbreak.h b/xfa/fgas/layout/fgas_rtfbreak.h
index d2041615d0..83d83a6c45 100644
--- a/xfa/fgas/layout/fgas_rtfbreak.h
+++ b/xfa/fgas/layout/fgas_rtfbreak.h
@@ -14,7 +14,7 @@
#include "xfa/fgas/layout/fgas_textbreak.h"
#include "xfa/fgas/layout/fgas_unicode.h"
-class IFGAS_Font;
+class CFGAS_GEFont;
#define FX_RTFBREAKPOLICY_None 0x00
#define FX_RTFBREAKPOLICY_SpaceBreak 0x01
@@ -82,7 +82,7 @@ struct FX_RTFTEXTOBJ {
const FX_WCHAR* pStr;
int32_t* pWidths;
int32_t iLength;
- IFGAS_Font* pFont;
+ CFGAS_GEFont* pFont;
FX_FLOAT fFontSize;
uint32_t dwLayoutStyles;
int32_t iCharRotation;
@@ -250,7 +250,7 @@ class CFX_RTFBreak {
void SetLineStartPos(FX_FLOAT fLinePos);
uint32_t GetLayoutStyles() const { return m_dwLayoutStyles; }
void SetLayoutStyles(uint32_t dwLayoutStyles);
- void SetFont(IFGAS_Font* pFont);
+ void SetFont(CFGAS_GEFont* pFont);
void SetFontSize(FX_FLOAT fFontSize);
void SetTabWidth(FX_FLOAT fTabWidth);
void AddPositionedTab(FX_FLOAT fTabPos);
@@ -298,7 +298,7 @@ class CFX_RTFBreak {
FX_BOOL m_bVertical;
FX_BOOL m_bSingleLine;
FX_BOOL m_bCharCode;
- IFGAS_Font* m_pFont;
+ CFGAS_GEFont* m_pFont;
int32_t m_iFontHeight;
int32_t m_iFontSize;
int32_t m_iTabWidth;
diff --git a/xfa/fgas/layout/fgas_textbreak.cpp b/xfa/fgas/layout/fgas_textbreak.cpp
index 85cff44349..8ba3ae818d 100644
--- a/xfa/fgas/layout/fgas_textbreak.cpp
+++ b/xfa/fgas/layout/fgas_textbreak.cpp
@@ -11,6 +11,7 @@
#include "core/fxcrt/include/fx_arabic.h"
#include "core/fxcrt/include/fx_arb.h"
#include "core/fxcrt/include/fx_memory.h"
+#include "xfa/fgas/font/fgas_gefont.h"
#include "xfa/fgas/layout/fgas_linebreak.h"
#include "xfa/fgas/layout/fgas_unicode.h"
@@ -93,7 +94,7 @@ void CFX_TxtBreak::SetLayoutStyles(uint32_t dwLayoutStyles) {
m_iRotation = m_iLineRotation + m_iCharRotation;
m_iRotation %= 4;
}
-void CFX_TxtBreak::SetFont(IFGAS_Font* pFont) {
+void CFX_TxtBreak::SetFont(CFGAS_GEFont* pFont) {
if (pFont == NULL) {
return;
}
@@ -1174,7 +1175,7 @@ int32_t CFX_TxtBreak::GetDisplayPos(const FX_TXTRUN* pTxtRun,
const FX_WCHAR* pStr = pTxtRun->wsStr.c_str();
int32_t* pWidths = pTxtRun->pWidths;
int32_t iLength = pTxtRun->iLength - 1;
- IFGAS_Font* pFont = pTxtRun->pFont;
+ CFGAS_GEFont* pFont = pTxtRun->pFont;
uint32_t dwStyles = pTxtRun->dwStyles;
CFX_RectF rtText(*pTxtRun->pRect);
FX_BOOL bRTLPiece =
@@ -1565,7 +1566,7 @@ int32_t CFX_TxtBreak::GetCharRects(const FX_TXTRUN* pTxtRun,
FX_FLOAT fFontSize = pTxtRun->fFontSize;
int32_t iFontSize = FXSYS_round(fFontSize * 20.0f);
FX_FLOAT fScale = fFontSize / 1000.0f;
- IFGAS_Font* pFont = pTxtRun->pFont;
+ CFGAS_GEFont* pFont = pTxtRun->pFont;
if (pFont == NULL) {
bCharBBox = FALSE;
}
diff --git a/xfa/fgas/layout/fgas_textbreak.h b/xfa/fgas/layout/fgas_textbreak.h
index db0b7f604e..9943eab2c7 100644
--- a/xfa/fgas/layout/fgas_textbreak.h
+++ b/xfa/fgas/layout/fgas_textbreak.h
@@ -13,9 +13,9 @@
#include "xfa/fgas/layout/fgas_unicode.h"
class CFX_Char;
+class CFGAS_GEFont;
class CFX_TxtChar;
class CFX_TxtPiece;
-class IFGAS_Font;
class IFX_TxtAccess;
#define FX_TXTBREAKPOLICY_None 0x00
@@ -103,7 +103,7 @@ struct FX_TXTRUN {
CFX_WideString wsStr;
int32_t* pWidths;
int32_t iLength;
- IFGAS_Font* pFont;
+ CFGAS_GEFont* pFont;
FX_FLOAT fFontSize;
uint32_t dwStyles;
int32_t iHorizontalScale;
@@ -232,7 +232,7 @@ class CFX_TxtBreak {
void SetLinePos(FX_FLOAT fLinePos);
uint32_t GetLayoutStyles() const { return m_dwLayoutStyles; }
void SetLayoutStyles(uint32_t dwLayoutStyles);
- void SetFont(IFGAS_Font* pFont);
+ void SetFont(CFGAS_GEFont* pFont);
void SetFontSize(FX_FLOAT fFontSize);
void SetTabWidth(FX_FLOAT fTabWidth, FX_BOOL bEquidistant);
void SetDefaultChar(FX_WCHAR wch);
@@ -306,7 +306,7 @@ class CFX_TxtBreak {
FX_BOOL m_bCombText;
int32_t m_iArabicContext;
int32_t m_iCurArabicContext;
- IFGAS_Font* m_pFont;
+ CFGAS_GEFont* m_pFont;
int32_t m_iFontSize;
FX_BOOL m_bEquidistant;
int32_t m_iTabWidth;
diff --git a/xfa/fgas/layout/fgas_unicode.h b/xfa/fgas/layout/fgas_unicode.h
index 463cb33bc6..650943a72f 100644
--- a/xfa/fgas/layout/fgas_unicode.h
+++ b/xfa/fgas/layout/fgas_unicode.h
@@ -20,7 +20,7 @@ void FX_TEXTLAYOUT_PieceSort(CFX_TPOArray& tpos, int32_t iStart, int32_t iEnd);
typedef FX_BOOL (*FX_AdjustCharDisplayPos)(FX_WCHAR wch,
FX_BOOL bMBCSCode,
- IFGAS_Font* pFont,
+ CFGAS_GEFont* pFont,
FX_FLOAT fFontSize,
FX_BOOL bVertical,
CFX_PointF& ptOffset);