diff options
author | thestig <thestig@chromium.org> | 2016-06-07 17:33:37 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-06-07 17:33:37 -0700 |
commit | a4fdfc5ed0e8d2e6acc52cc34eac42c6072f0ccc (patch) | |
tree | 255d0e11679bd1f54f94dd717e74db5827f967e9 /xfa | |
parent | 759de3828419522e8ecd7cdaee469e55061a7c08 (diff) | |
download | pdfium-a4fdfc5ed0e8d2e6acc52cc34eac42c6072f0ccc.tar.xz |
Replace IFGAS_Font with underlying concrete type
Review-Url: https://codereview.chromium.org/2037563002
Diffstat (limited to 'xfa')
32 files changed, 468 insertions, 505 deletions
diff --git a/xfa/fde/cfde_txtedttextset.cpp b/xfa/fde/cfde_txtedttextset.cpp index b06e430b1d..9213d650f3 100644 --- a/xfa/fde/cfde_txtedttextset.cpp +++ b/xfa/fde/cfde_txtedttextset.cpp @@ -32,7 +32,7 @@ int32_t CFDE_TxtEdtTextSet::GetString(FDE_TEXTEDITPIECE* pPiece, return pPiece->nCount; } -IFGAS_Font* CFDE_TxtEdtTextSet::GetFont() { +CFGAS_GEFont* CFDE_TxtEdtTextSet::GetFont() { return m_pPage->GetEngine()->GetEditParams()->pFont; } diff --git a/xfa/fde/cfde_txtedttextset.h b/xfa/fde/cfde_txtedttextset.h index 78a9aabfd4..a2121659ba 100644 --- a/xfa/fde/cfde_txtedttextset.h +++ b/xfa/fde/cfde_txtedttextset.h @@ -22,7 +22,7 @@ class CFDE_TxtEdtTextSet : public IFDE_TextSet { // IFDE_TextSet int32_t GetString(FDE_TEXTEDITPIECE* pPiece, CFX_WideString& wsText) override; - IFGAS_Font* GetFont() override; + CFGAS_GEFont* GetFont() override; FX_FLOAT GetFontSize() override; FX_ARGB GetFontColor() override; int32_t GetDisplayPos(FDE_TEXTEDITPIECE* pPiece, diff --git a/xfa/fde/fde_gedevice.cpp b/xfa/fde/fde_gedevice.cpp index 005387f83a..03065d751c 100644 --- a/xfa/fde/fde_gedevice.cpp +++ b/xfa/fde/fde_gedevice.cpp @@ -11,6 +11,7 @@ #include "xfa/fde/cfde_path.h" #include "xfa/fde/fde_object.h" #include "xfa/fgas/font/fgas_font.h" +#include "xfa/fgas/font/fgas_gefont.h" CFDE_RenderDevice::CFDE_RenderDevice(CFX_RenderDevice* pDevice, FX_BOOL bOwnerDevice) @@ -104,7 +105,7 @@ FX_BOOL CFDE_RenderDevice::DrawImage(CFX_DIBSource* pDib, return handle != NULL; } FX_BOOL CFDE_RenderDevice::DrawString(CFDE_Brush* pBrush, - IFGAS_Font* pFont, + CFGAS_GEFont* pFont, const FXTEXT_CHARPOS* pCharPos, int32_t iCount, FX_FLOAT fFontSize, @@ -126,8 +127,8 @@ FX_BOOL CFDE_RenderDevice::DrawString(CFDE_Brush* pBrush, } } FXTEXT_CHARPOS* pCP = (FXTEXT_CHARPOS*)pCharPos; - IFGAS_Font* pCurFont = NULL; - IFGAS_Font* pSTFont = NULL; + CFGAS_GEFont* pCurFont = NULL; + CFGAS_GEFont* pSTFont = NULL; FXTEXT_CHARPOS* pCurCP = NULL; int32_t iCurCount = 0; diff --git a/xfa/fde/fde_gedevice.h b/xfa/fde/fde_gedevice.h index 4f30bd57a4..debb69115c 100644 --- a/xfa/fde/fde_gedevice.h +++ b/xfa/fde/fde_gedevice.h @@ -13,7 +13,7 @@ class CFDE_Brush; class CFDE_Path; class CFDE_Pen; -class IFGAS_Font; +class CFGAS_GEFont; class CFDE_RenderDevice : public CFX_Target { public: @@ -38,7 +38,7 @@ class CFDE_RenderDevice : public CFX_Target { const CFX_Matrix* pImgMatrix = NULL, const CFX_Matrix* pDevMatrix = NULL); FX_BOOL DrawString(CFDE_Brush* pBrush, - IFGAS_Font* pFont, + CFGAS_GEFont* pFont, const FXTEXT_CHARPOS* pCharPos, int32_t iCount, FX_FLOAT fFontSize, @@ -99,13 +99,13 @@ class CFDE_RenderDevice : public CFX_Target { const CFX_Matrix* pMatrix = NULL); FX_BOOL DrawSolidString(CFDE_Brush* pBrush, - IFGAS_Font* pFont, + CFGAS_GEFont* pFont, const FXTEXT_CHARPOS* pCharPos, int32_t iCount, FX_FLOAT fFontSize, const CFX_Matrix* pMatrix); FX_BOOL DrawStringPath(CFDE_Brush* pBrush, - IFGAS_Font* pFont, + CFGAS_GEFont* pFont, const FXTEXT_CHARPOS* pCharPos, int32_t iCount, FX_FLOAT fFontSize, diff --git a/xfa/fde/fde_render.cpp b/xfa/fde/fde_render.cpp index 6e6d739cf9..04d52549c6 100644 --- a/xfa/fde/fde_render.cpp +++ b/xfa/fde/fde_render.cpp @@ -111,7 +111,7 @@ void CFDE_RenderContext::RenderText(IFDE_TextSet* pTextSet, ASSERT(m_pRenderDevice); ASSERT(pTextSet && pText); - IFGAS_Font* pFont = pTextSet->GetFont(); + CFGAS_GEFont* pFont = pTextSet->GetFont(); if (!pFont) return; diff --git a/xfa/fde/fde_visualset.h b/xfa/fde/fde_visualset.h index e6898d83fa..2005f73f84 100644 --- a/xfa/fde/fde_visualset.h +++ b/xfa/fde/fde_visualset.h @@ -46,7 +46,7 @@ class IFDE_TextSet : public IFDE_VisualSet { public: virtual int32_t GetString(FDE_TEXTEDITPIECE* hText, CFX_WideString& wsText) = 0; - virtual IFGAS_Font* GetFont() = 0; + virtual CFGAS_GEFont* GetFont() = 0; virtual FX_FLOAT GetFontSize() = 0; virtual FX_ARGB GetFontColor() = 0; virtual int32_t GetDisplayPos(FDE_TEXTEDITPIECE* hText, diff --git a/xfa/fde/ifde_txtedtengine.h b/xfa/fde/ifde_txtedtengine.h index b13dc593b3..8ecf46e5c8 100644 --- a/xfa/fde/ifde_txtedtengine.h +++ b/xfa/fde/ifde_txtedtengine.h @@ -109,7 +109,7 @@ struct FDE_TXTEDTPARAMS { uint32_t dwLayoutStyles; uint32_t dwAlignment; uint32_t dwMode; - IFGAS_Font* pFont; + CFGAS_GEFont* pFont; FX_FLOAT fFontSize; FX_ARGB dwFontColor; FX_FLOAT fLineSpace; diff --git a/xfa/fde/tto/fde_textout.cpp b/xfa/fde/tto/fde_textout.cpp index d9ada61d77..6b9f8522b5 100644 --- a/xfa/fde/tto/fde_textout.cpp +++ b/xfa/fde/tto/fde_textout.cpp @@ -53,7 +53,7 @@ CFDE_TextOut::~CFDE_TextOut() { FX_Free(m_pCharPos); m_ttoLines.RemoveAll(); } -void CFDE_TextOut::SetFont(IFGAS_Font* pFont) { +void CFDE_TextOut::SetFont(CFGAS_GEFont* pFont) { ASSERT(pFont); m_pFont = pFont; m_pTxtBreak->SetFont(pFont); diff --git a/xfa/fde/tto/fde_textout.h b/xfa/fde/tto/fde_textout.h index e08a1487bb..4959f2bc69 100644 --- a/xfa/fde/tto/fde_textout.h +++ b/xfa/fde/tto/fde_textout.h @@ -75,7 +75,7 @@ class CFDE_TextOut : public CFX_Target { CFDE_TextOut(); ~CFDE_TextOut() override; - void SetFont(IFGAS_Font* pFont); + void SetFont(CFGAS_GEFont* pFont); void SetFontSize(FX_FLOAT fFontSize); void SetTextColor(FX_ARGB color); void SetStyles(uint32_t dwStyles); @@ -151,7 +151,7 @@ class CFDE_TextOut : public CFX_Target { void DrawLine(const FDE_TTOPIECE* pPiece, CFDE_Pen*& pPen); CFX_TxtBreak* m_pTxtBreak; - IFGAS_Font* m_pFont; + CFGAS_GEFont* m_pFont; FX_FLOAT m_fFontSize; FX_FLOAT m_fLineSpace; FX_FLOAT m_fLinePos; 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); diff --git a/xfa/fwl/basewidget/fwl_barcodeimp.cpp b/xfa/fwl/basewidget/fwl_barcodeimp.cpp index 1c55f5a9f0..1789f9f075 100644 --- a/xfa/fwl/basewidget/fwl_barcodeimp.cpp +++ b/xfa/fwl/basewidget/fwl_barcodeimp.cpp @@ -6,6 +6,7 @@ #include "xfa/fwl/basewidget/fwl_barcodeimp.h" +#include "xfa/fgas/font/fgas_gefont.h" #include "xfa/fwl/basewidget/fwl_editimp.h" #include "xfa/fwl/basewidget/fxmath_barcodeimp.h" #include "xfa/fwl/core/cfwl_themepart.h" @@ -111,7 +112,7 @@ void CFWL_BarcodeImp::GenerateBarcodeImageCache() { CFWL_ThemePart part; part.m_pWidget = m_pInterface; IFWL_ThemeProvider* pTheme = GetAvailableTheme(); - IFGAS_Font* pFont = static_cast<IFGAS_Font*>( + CFGAS_GEFont* pFont = static_cast<CFGAS_GEFont*>( pTheme->GetCapacity(&part, CFWL_WidgetCapacity::Font)); CFX_Font* pCXFont = pFont ? pFont->GetDevFont() : nullptr; if (pCXFont) { diff --git a/xfa/fwl/basewidget/fwl_editimp.cpp b/xfa/fwl/basewidget/fwl_editimp.cpp index e1b82a07c6..bf1d19f294 100644 --- a/xfa/fwl/basewidget/fwl_editimp.cpp +++ b/xfa/fwl/basewidget/fwl_editimp.cpp @@ -15,6 +15,7 @@ #include "xfa/fde/fde_gedevice.h" #include "xfa/fde/fde_render.h" #include "xfa/fde/ifde_txtedtpage.h" +#include "xfa/fgas/font/fgas_gefont.h" #include "xfa/fwl/basewidget/fwl_caretimp.h" #include "xfa/fwl/basewidget/fwl_comboboximp.h" #include "xfa/fwl/basewidget/fwl_scrollbarimp.h" @@ -1194,8 +1195,8 @@ void CFWL_EditImp::UpdateEditParams() { if (!pLineHeight) return; params.fLineSpace = *pLineHeight; - IFGAS_Font* pFont = - static_cast<IFGAS_Font*>(GetThemeCapacity(CFWL_WidgetCapacity::Font)); + CFGAS_GEFont* pFont = + static_cast<CFGAS_GEFont*>(GetThemeCapacity(CFWL_WidgetCapacity::Font)); if (!pFont) return; params.pFont = pFont; diff --git a/xfa/fwl/theme/cfwl_widgettp.cpp b/xfa/fwl/theme/cfwl_widgettp.cpp index 1b437ebe9b..867e908a0e 100644 --- a/xfa/fwl/theme/cfwl_widgettp.cpp +++ b/xfa/fwl/theme/cfwl_widgettp.cpp @@ -9,6 +9,7 @@ #include <algorithm> #include "xfa/fde/tto/fde_textout.h" +#include "xfa/fgas/font/fgas_gefont.h" #include "xfa/fgas/font/fgas_stdfontmgr.h" #include "xfa/fwl/core/cfwl_themebackground.h" #include "xfa/fwl/core/cfwl_themepart.h" @@ -201,7 +202,7 @@ FWL_Error CFWL_WidgetTP::SetFont(IFWL_Widget* pWidget, return FWL_Error::Succeeded; } FWL_Error CFWL_WidgetTP::SetFont(IFWL_Widget* pWidget, - IFGAS_Font* pFont, + CFGAS_GEFont* pFont, FX_FLOAT fFontSize, FX_ARGB rgbFont) { if (!m_pTextOut) @@ -212,7 +213,7 @@ FWL_Error CFWL_WidgetTP::SetFont(IFWL_Widget* pWidget, m_pTextOut->SetTextColor(rgbFont); return FWL_Error::Succeeded; } -IFGAS_Font* CFWL_WidgetTP::GetFont(IFWL_Widget* pWidget) { +CFGAS_GEFont* CFWL_WidgetTP::GetFont(IFWL_Widget* pWidget) { return m_pFDEFont; } @@ -711,8 +712,8 @@ FX_BOOL CFWL_FontData::LoadFont(const CFX_WideStringC& wsFontFamily, m_pFontMgr = IFGAS_FontMgr::Create(m_pFontSource); #endif } - m_pFont = IFGAS_Font::LoadFont(wsFontFamily.c_str(), dwFontStyles, dwCodePage, - m_pFontMgr); + m_pFont = CFGAS_GEFont::LoadFont(wsFontFamily.c_str(), dwFontStyles, + dwCodePage, m_pFontMgr); return m_pFont != NULL; } @@ -728,9 +729,9 @@ void CFWL_FontManager::DestroyInstance() { } CFWL_FontManager::CFWL_FontManager() {} CFWL_FontManager::~CFWL_FontManager() {} -IFGAS_Font* CFWL_FontManager::FindFont(const CFX_WideStringC& wsFontFamily, - uint32_t dwFontStyles, - uint16_t wCodePage) { +CFGAS_GEFont* CFWL_FontManager::FindFont(const CFX_WideStringC& wsFontFamily, + uint32_t dwFontStyles, + uint16_t wCodePage) { for (const auto& pData : m_FontsArray) { if (pData->Equal(wsFontFamily, dwFontStyles, wCodePage)) return pData->GetFont(); diff --git a/xfa/fwl/theme/cfwl_widgettp.h b/xfa/fwl/theme/cfwl_widgettp.h index 971b6f09b1..20be62619e 100644 --- a/xfa/fwl/theme/cfwl_widgettp.h +++ b/xfa/fwl/theme/cfwl_widgettp.h @@ -91,14 +91,14 @@ enum class CFWL_WidgetCapacity { Width }; -class IFWL_Widget; class CFDE_TextOut; -class IFGAS_Font; -class IFGAS_FontMgr; +class CFGAS_GEFont; class CFWL_ArrowData; class CFWL_ThemeBackground; class CFWL_ThemePart; class CFWL_ThemeText; +class IFGAS_FontMgr; +class IFWL_Widget; #if _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_ class CFX_FontSourceEnum_File; @@ -135,10 +135,10 @@ class CFWL_WidgetTP { FX_FLOAT fFontSize, FX_ARGB rgbFont); FWL_Error SetFont(IFWL_Widget* pWidget, - IFGAS_Font* pFont, + CFGAS_GEFont* pFont, FX_FLOAT fFontSize, FX_ARGB rgbFont); - IFGAS_Font* GetFont(IFWL_Widget* pWidget); + CFGAS_GEFont* GetFont(IFWL_Widget* pWidget); protected: CFWL_WidgetTP(); @@ -221,7 +221,7 @@ class CFWL_WidgetTP { CFX_Matrix* pMatrix = NULL); uint32_t m_dwRefCount; std::unique_ptr<CFDE_TextOut> m_pTextOut; - IFGAS_Font* m_pFDEFont; + CFGAS_GEFont* m_pFDEFont; FX_FLOAT m_fValue; uint32_t m_dwValue; CFX_RectF m_rtMargin; @@ -264,13 +264,13 @@ class CFWL_FontData { FX_BOOL LoadFont(const CFX_WideStringC& wsFontFamily, uint32_t dwFontStyles, uint16_t wCodePage); - IFGAS_Font* GetFont() const { return m_pFont; } + CFGAS_GEFont* GetFont() const { return m_pFont; } protected: CFX_WideString m_wsFamily; uint32_t m_dwStyles; uint32_t m_dwCodePage; - IFGAS_Font* m_pFont; + CFGAS_GEFont* m_pFont; IFGAS_FontMgr* m_pFontMgr; #if _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_ CFX_FontSourceEnum_File* m_pFontSource; @@ -282,9 +282,9 @@ class CFWL_FontManager { static CFWL_FontManager* GetInstance(); static void DestroyInstance(); - IFGAS_Font* FindFont(const CFX_WideStringC& wsFontFamily, - uint32_t dwFontStyles, - uint16_t dwCodePage); + CFGAS_GEFont* FindFont(const CFX_WideStringC& wsFontFamily, + uint32_t dwFontStyles, + uint16_t dwCodePage); protected: CFWL_FontManager(); diff --git a/xfa/fxfa/app/xfa_ffwidgetacc.cpp b/xfa/fxfa/app/xfa_ffwidgetacc.cpp index c440848941..1a579e222e 100644 --- a/xfa/fxfa/app/xfa_ffwidgetacc.cpp +++ b/xfa/fxfa/app/xfa_ffwidgetacc.cpp @@ -1517,7 +1517,7 @@ CXFA_WidgetLayoutData* CXFA_WidgetAcc::GetWidgetLayoutData() { return m_pLayoutData.get(); } -IFGAS_Font* CXFA_WidgetAcc::GetFDEFont() { +CFGAS_GEFont* CXFA_WidgetAcc::GetFDEFont() { CFX_WideStringC wsFontName = FX_WSTRC(L"Courier"); uint32_t dwFontStyle = 0; if (CXFA_Font font = GetFont()) { diff --git a/xfa/fxfa/app/xfa_fontmgr.cpp b/xfa/fxfa/app/xfa_fontmgr.cpp index ed93b16ad2..964c0352b8 100644 --- a/xfa/fxfa/app/xfa_fontmgr.cpp +++ b/xfa/fxfa/app/xfa_fontmgr.cpp @@ -12,6 +12,7 @@ #include "core/fpdfapi/fpdf_font/include/cpdf_font.h" #include "core/fpdfapi/fpdf_parser/include/cpdf_dictionary.h" #include "core/fpdfapi/fpdf_parser/include/cpdf_document.h" +#include "xfa/fgas/font/fgas_gefont.h" #include "xfa/fxfa/include/xfa_ffapp.h" #include "xfa/fxfa/include/xfa_ffdoc.h" @@ -1742,13 +1743,13 @@ CXFA_DefFontMgr::~CXFA_DefFontMgr() { m_CacheFonts[i]->Release(); } -IFGAS_Font* CXFA_DefFontMgr::GetFont(CXFA_FFDoc* hDoc, - const CFX_WideStringC& wsFontFamily, - uint32_t dwFontStyles, - uint16_t wCodePage) { +CFGAS_GEFont* CXFA_DefFontMgr::GetFont(CXFA_FFDoc* hDoc, + const CFX_WideStringC& wsFontFamily, + uint32_t dwFontStyles, + uint16_t wCodePage) { CFX_WideString wsFontName(wsFontFamily); IFGAS_FontMgr* pFDEFontMgr = hDoc->GetApp()->GetFDEFontMgr(); - IFGAS_Font* pFont = + CFGAS_GEFont* pFont = pFDEFontMgr->LoadFont(wsFontName.c_str(), dwFontStyles, wCodePage); if (!pFont) { const XFA_FONTINFO* pCurFont = @@ -1787,12 +1788,13 @@ IFGAS_Font* CXFA_DefFontMgr::GetFont(CXFA_FFDoc* hDoc, return pFont; } -IFGAS_Font* CXFA_DefFontMgr::GetDefaultFont(CXFA_FFDoc* hDoc, - const CFX_WideStringC& wsFontFamily, - uint32_t dwFontStyles, - uint16_t wCodePage) { +CFGAS_GEFont* CXFA_DefFontMgr::GetDefaultFont( + CXFA_FFDoc* hDoc, + const CFX_WideStringC& wsFontFamily, + uint32_t dwFontStyles, + uint16_t wCodePage) { IFGAS_FontMgr* pFDEFontMgr = hDoc->GetApp()->GetFDEFontMgr(); - IFGAS_Font* pFont = + CFGAS_GEFont* pFont = pFDEFontMgr->LoadFont(L"Arial Narrow", dwFontStyles, wCodePage); if (!pFont) pFont = @@ -1824,11 +1826,11 @@ CXFA_PDFFontMgr::~CXFA_PDFFontMgr() { pair.second->Release(); } } -IFGAS_Font* CXFA_PDFFontMgr::FindFont(CFX_ByteString strPsName, - FX_BOOL bBold, - FX_BOOL bItalic, - CPDF_Font** pDstPDFFont, - FX_BOOL bStrictMatch) { +CFGAS_GEFont* CXFA_PDFFontMgr::FindFont(CFX_ByteString strPsName, + FX_BOOL bBold, + FX_BOOL bItalic, + CPDF_Font** pDstPDFFont, + FX_BOOL bStrictMatch) { CPDF_Document* pDoc = m_pDoc->GetPDFDoc(); if (pDoc == NULL) { return NULL; @@ -1867,15 +1869,15 @@ IFGAS_Font* CXFA_PDFFontMgr::FindFont(CFX_ByteString strPsName, *pDstPDFFont = pPDFFont; return NULL; } - return IFGAS_Font::LoadFont(&pPDFFont->m_Font, pFDEFontMgr); + return CFGAS_GEFont::LoadFont(&pPDFFont->m_Font, pFDEFontMgr, FALSE); } return NULL; } -IFGAS_Font* CXFA_PDFFontMgr::GetFont(const CFX_WideStringC& wsFontFamily, - uint32_t dwFontStyles, - CPDF_Font** pPDFFont, - FX_BOOL bStrictMatch) { +CFGAS_GEFont* CXFA_PDFFontMgr::GetFont(const CFX_WideStringC& wsFontFamily, + uint32_t dwFontStyles, + CPDF_Font** pPDFFont, + FX_BOOL bStrictMatch) { uint32_t dwHashCode = FX_HashCode_GetW(wsFontFamily, false); CFX_ByteString strKey; strKey.Format("%u%u", dwHashCode, dwFontStyles); @@ -1887,7 +1889,7 @@ IFGAS_Font* CXFA_PDFFontMgr::GetFont(const CFX_WideStringC& wsFontFamily, FX_BOOL bBold = (dwFontStyles & FX_FONTSTYLE_Bold) == FX_FONTSTYLE_Bold; FX_BOOL bItalic = (dwFontStyles & FX_FONTSTYLE_Italic) == FX_FONTSTYLE_Italic; CFX_ByteString strFontName = PsNameToFontName(bsPsName, bBold, bItalic); - IFGAS_Font* pFont = + CFGAS_GEFont* pFont = FindFont(strFontName, bBold, bItalic, pPDFFont, bStrictMatch); if (pFont) m_FontMap[strKey] = pFont; @@ -1982,7 +1984,7 @@ FX_BOOL CXFA_PDFFontMgr::PsNameMatchDRFontName( } return TRUE; } -FX_BOOL CXFA_PDFFontMgr::GetCharWidth(IFGAS_Font* pFont, +FX_BOOL CXFA_PDFFontMgr::GetCharWidth(CFGAS_GEFont* pFont, FX_WCHAR wUnicode, int32_t& iWidth, FX_BOOL bCharCode) { @@ -2002,10 +2004,10 @@ CXFA_FontMgr::CXFA_FontMgr() {} CXFA_FontMgr::~CXFA_FontMgr() {} -IFGAS_Font* CXFA_FontMgr::GetFont(CXFA_FFDoc* hDoc, - const CFX_WideStringC& wsFontFamily, - uint32_t dwFontStyles, - uint16_t wCodePage) { +CFGAS_GEFont* CXFA_FontMgr::GetFont(CXFA_FFDoc* hDoc, + const CFX_WideStringC& wsFontFamily, + uint32_t dwFontStyles, + uint16_t wCodePage) { uint32_t dwHash = FX_HashCode_GetW(wsFontFamily, false); CFX_ByteString bsKey; bsKey.Format("%u%u%u", dwHash, dwFontStyles, wCodePage); @@ -2018,7 +2020,7 @@ IFGAS_Font* CXFA_FontMgr::GetFont(CXFA_FFDoc* hDoc, CXFA_PDFFontMgr* pMgr = it != m_PDFFontMgrMap.end() ? it->second.get() : nullptr; CPDF_Font* pPDFFont = nullptr; - IFGAS_Font* pFont = nullptr; + CFGAS_GEFont* pFont = nullptr; if (pMgr) { pFont = pMgr->GetFont(wsEnglishName.AsStringC(), dwFontStyles, &pPDFFont); if (pFont) diff --git a/xfa/fxfa/app/xfa_fwltheme.cpp b/xfa/fxfa/app/xfa_fwltheme.cpp index 0c8e346066..e2e1b29c08 100644 --- a/xfa/fxfa/app/xfa_fwltheme.cpp +++ b/xfa/fxfa/app/xfa_fwltheme.cpp @@ -8,6 +8,7 @@ #include "xfa/fde/tto/fde_textout.h" #include "xfa/fgas/crt/fgas_codepage.h" +#include "xfa/fgas/font/fgas_gefont.h" #include "xfa/fwl/basewidget/ifwl_barcode.h" #include "xfa/fwl/basewidget/ifwl_caret.h" #include "xfa/fwl/basewidget/ifwl_checkbox.h" @@ -78,8 +79,8 @@ FWL_Error CXFA_FWLTheme::Initialize() { m_pTextOut.reset(new CFDE_TextOut); for (size_t i = 0; !m_pCalendarFont && i < FX_ArraySize(g_FWLTheme_CalFonts); ++i) { - m_pCalendarFont = IFGAS_Font::LoadFont(g_FWLTheme_CalFonts[i], 0, 0, - m_pApp->GetFDEFontMgr()); + m_pCalendarFont = CFGAS_GEFont::LoadFont(g_FWLTheme_CalFonts[i], 0, 0, + m_pApp->GetFDEFontMgr()); } if (!m_pCalendarFont) { #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ diff --git a/xfa/fxfa/app/xfa_fwltheme.h b/xfa/fxfa/app/xfa_fwltheme.h index b73239c003..fdd12c37ba 100644 --- a/xfa/fxfa/app/xfa_fwltheme.h +++ b/xfa/fxfa/app/xfa_fwltheme.h @@ -81,7 +81,7 @@ class CXFA_FWLTheme final : public IFWL_ThemeProvider { std::unique_ptr<CFDE_TextOut> m_pTextOut; FX_FLOAT m_fCapacity; uint32_t m_dwCapacity; - IFGAS_Font* m_pCalendarFont; + CFGAS_GEFont* m_pCalendarFont; CFX_WideString m_wsResource; CXFA_FFApp* m_pApp; CFX_RectF m_Rect; diff --git a/xfa/fxfa/app/xfa_textlayout.cpp b/xfa/fxfa/app/xfa_textlayout.cpp index c40e29c04b..4e23fc39f9 100644 --- a/xfa/fxfa/app/xfa_textlayout.cpp +++ b/xfa/fxfa/app/xfa_textlayout.cpp @@ -332,8 +332,8 @@ FX_BOOL CXFA_TextParser::IsSpaceRun(IFDE_CSSComputedStyle* pStyle) const { } return FALSE; } -IFGAS_Font* CXFA_TextParser::GetFont(CXFA_TextProvider* pTextProvider, - IFDE_CSSComputedStyle* pStyle) const { +CFGAS_GEFont* CXFA_TextParser::GetFont(CXFA_TextProvider* pTextProvider, + IFDE_CSSComputedStyle* pStyle) const { CFX_WideStringC wsFamily = FX_WSTRC(L"Courier"); uint32_t dwStyle = 0; CXFA_Font font = pTextProvider->GetFontNode(); diff --git a/xfa/fxfa/app/xfa_textlayout.h b/xfa/fxfa/app/xfa_textlayout.h index a4bd9cede7..842c6ec731 100644 --- a/xfa/fxfa/app/xfa_textlayout.h +++ b/xfa/fxfa/app/xfa_textlayout.h @@ -95,8 +95,8 @@ class CXFA_TextParser { FX_BOOL IsSpaceRun(IFDE_CSSComputedStyle* pStyle) const; FX_BOOL GetTabstops(IFDE_CSSComputedStyle* pStyle, CXFA_TextTabstopsContext* pTabstopContext); - IFGAS_Font* GetFont(CXFA_TextProvider* pTextProvider, - IFDE_CSSComputedStyle* pStyle) const; + CFGAS_GEFont* GetFont(CXFA_TextProvider* pTextProvider, + IFDE_CSSComputedStyle* pStyle) const; FX_FLOAT GetFontSize(CXFA_TextProvider* pTextProvider, IFDE_CSSComputedStyle* pStyle) const; int32_t GetHorScale(CXFA_TextProvider* pTextProvider, @@ -259,7 +259,7 @@ class XFA_TextPiece : public CFX_Target { int32_t iUnderline; int32_t iPeriod; int32_t iLineThrough; - IFGAS_Font* pFont; + CFGAS_GEFont* pFont; FX_ARGB dwColor; FX_FLOAT fFontSize; CFX_RectF rtPiece; diff --git a/xfa/fxfa/include/fxfa.h b/xfa/fxfa/include/fxfa.h index 7b40cd8cb1..981fcabffc 100644 --- a/xfa/fxfa/include/fxfa.h +++ b/xfa/fxfa/include/fxfa.h @@ -12,6 +12,7 @@ #include "xfa/fxfa/include/fxfa_basic.h" #include "xfa/fxfa/include/fxfa_widget.h" +class CFGAS_GEFont; class CFX_Graphics; class CPDF_Document; class CXFA_FFPageView; @@ -19,7 +20,6 @@ class CXFA_Node; class CXFA_NodeList; class CXFA_WidgetAcc; class IFWL_AdapterTimerMgr; -class IFGAS_Font; class IXFA_AppProvider; class IXFA_DocProvider; class IXFA_WidgetAccIterator; diff --git a/xfa/fxfa/include/fxfa_widget.h b/xfa/fxfa/include/fxfa_widget.h index b4a0080425..a8bed176ab 100644 --- a/xfa/fxfa/include/fxfa_widget.h +++ b/xfa/fxfa/include/fxfa_widget.h @@ -17,15 +17,15 @@ #include "xfa/fxfa/parser/cxfa_value.h" #include "xfa/fxfa/parser/cxfa_widgetdata.h" -class CXFA_Node; -class CXFA_FFDocView; -class CXFA_FFDoc; -class CXFA_FFApp; +class CFGAS_GEFont; class CXFA_EventParam; +class CXFA_FFApp; +class CXFA_FFDoc; +class CXFA_FFDocView; class CXFA_FFWidget; +class CXFA_Node; class CXFA_TextLayout; class CXFA_WidgetLayoutData; -class IFGAS_Font; class IXFA_AppProvider; class CXFA_WidgetAcc : public CXFA_WidgetData { @@ -73,7 +73,7 @@ class CXFA_WidgetAcc : public CXFA_WidgetData { void UpdateUIDisplay(CXFA_FFWidget* pExcept = NULL); CXFA_Node* GetDatasets(); - IFGAS_Font* GetFDEFont(); + CFGAS_GEFont* GetFDEFont(); FX_FLOAT GetFontSize(); FX_ARGB GetTextColor(); FX_FLOAT GetLineHeight(); diff --git a/xfa/fxfa/include/xfa_fontmgr.h b/xfa/fxfa/include/xfa_fontmgr.h index 90418441de..121df588d2 100644 --- a/xfa/fxfa/include/xfa_fontmgr.h +++ b/xfa/fxfa/include/xfa_fontmgr.h @@ -30,17 +30,17 @@ class CXFA_DefFontMgr { CXFA_DefFontMgr() {} ~CXFA_DefFontMgr(); - IFGAS_Font* GetFont(CXFA_FFDoc* hDoc, - const CFX_WideStringC& wsFontFamily, - uint32_t dwFontStyles, - uint16_t wCodePage = 0xFFFF); - IFGAS_Font* GetDefaultFont(CXFA_FFDoc* hDoc, - const CFX_WideStringC& wsFontFamily, - uint32_t dwFontStyles, - uint16_t wCodePage = 0xFFFF); + CFGAS_GEFont* GetFont(CXFA_FFDoc* hDoc, + const CFX_WideStringC& wsFontFamily, + uint32_t dwFontStyles, + uint16_t wCodePage = 0xFFFF); + CFGAS_GEFont* GetDefaultFont(CXFA_FFDoc* hDoc, + const CFX_WideStringC& wsFontFamily, + uint32_t dwFontStyles, + uint16_t wCodePage = 0xFFFF); protected: - CFX_ArrayTemplate<IFGAS_Font*> m_CacheFonts; + CFX_ArrayTemplate<CFGAS_GEFont*> m_CacheFonts; }; class CXFA_PDFFontMgr { @@ -48,22 +48,22 @@ class CXFA_PDFFontMgr { explicit CXFA_PDFFontMgr(CXFA_FFDoc* pDoc); ~CXFA_PDFFontMgr(); - IFGAS_Font* GetFont(const CFX_WideStringC& wsFontFamily, - uint32_t dwFontStyles, - CPDF_Font** pPDFFont, - FX_BOOL bStrictMatch = TRUE); - FX_BOOL GetCharWidth(IFGAS_Font* pFont, + CFGAS_GEFont* GetFont(const CFX_WideStringC& wsFontFamily, + uint32_t dwFontStyles, + CPDF_Font** pPDFFont, + FX_BOOL bStrictMatch = TRUE); + FX_BOOL GetCharWidth(CFGAS_GEFont* pFont, FX_WCHAR wUnicode, int32_t& iWidth, FX_BOOL bCharCode); - std::map<IFGAS_Font*, CPDF_Font*> m_FDE2PDFFont; + std::map<CFGAS_GEFont*, CPDF_Font*> m_FDE2PDFFont; protected: - IFGAS_Font* FindFont(CFX_ByteString strFamilyName, - FX_BOOL bBold, - FX_BOOL bItalic, - CPDF_Font** pPDFFont, - FX_BOOL bStrictMatch = TRUE); + CFGAS_GEFont* FindFont(CFX_ByteString strFamilyName, + FX_BOOL bBold, + FX_BOOL bItalic, + CPDF_Font** pPDFFont, + FX_BOOL bStrictMatch = TRUE); CFX_ByteString PsNameToFontName(const CFX_ByteString& strPsName, FX_BOOL bBold, FX_BOOL bItalic); @@ -74,7 +74,7 @@ class CXFA_PDFFontMgr { FX_BOOL bStrictMatch = TRUE); CXFA_FFDoc* m_pDoc; - std::map<CFX_ByteString, IFGAS_Font*> m_FontMap; + std::map<CFX_ByteString, CFGAS_GEFont*> m_FontMap; }; class CXFA_FontMgr { @@ -82,10 +82,10 @@ class CXFA_FontMgr { CXFA_FontMgr(); ~CXFA_FontMgr(); - IFGAS_Font* GetFont(CXFA_FFDoc* hDoc, - const CFX_WideStringC& wsFontFamily, - uint32_t dwFontStyles, - uint16_t wCodePage = 0xFFFF); + CFGAS_GEFont* GetFont(CXFA_FFDoc* hDoc, + const CFX_WideStringC& wsFontFamily, + uint32_t dwFontStyles, + uint16_t wCodePage = 0xFFFF); void LoadDocFonts(CXFA_FFDoc* hDoc); void ReleaseDocFonts(CXFA_FFDoc* hDoc); void SetDefFontMgr(std::unique_ptr<CXFA_DefFontMgr> pFontMgr); @@ -93,7 +93,7 @@ class CXFA_FontMgr { protected: std::unique_ptr<CXFA_DefFontMgr> m_pDefFontMgr; std::map<CXFA_FFDoc*, std::unique_ptr<CXFA_PDFFontMgr>> m_PDFFontMgrMap; - std::map<CFX_ByteString, IFGAS_Font*> m_FontMap; + std::map<CFX_ByteString, CFGAS_GEFont*> m_FontMap; }; #endif // XFA_FXFA_INCLUDE_XFA_FONTMGR_H_ |