From 4b91a2dfacee0c0f4068a7ab899c211480712d38 Mon Sep 17 00:00:00 2001 From: npm Date: Mon, 21 Nov 2016 15:19:44 -0800 Subject: Clean up CFGAS_GEFont Removed some unused method, named files properly, cleaned up a bit. Review-Url: https://codereview.chromium.org/2524493002 --- BUILD.gn | 4 +- xfa/fde/fde_gedevice.cpp | 2 +- xfa/fgas/font/cfgas_fontmgr.cpp | 2 +- xfa/fgas/font/cfgas_gefont.cpp | 461 ++++++++++++++++++++++++++++++++++ xfa/fgas/font/cfgas_gefont.h | 113 +++++++++ xfa/fgas/font/fgas_gefont.cpp | 489 ------------------------------------- xfa/fgas/font/fgas_gefont.h | 115 --------- xfa/fgas/layout/fgas_rtfbreak.cpp | 2 +- xfa/fgas/layout/fgas_textbreak.cpp | 2 +- xfa/fwl/core/ifwl_barcode.cpp | 2 +- xfa/fwl/core/ifwl_edit.cpp | 2 +- xfa/fwl/theme/cfwl_widgettp.cpp | 2 +- xfa/fxfa/app/xfa_fontmgr.cpp | 2 +- xfa/fxfa/app/xfa_fwltheme.cpp | 2 +- 14 files changed, 585 insertions(+), 615 deletions(-) create mode 100644 xfa/fgas/font/cfgas_gefont.cpp create mode 100644 xfa/fgas/font/cfgas_gefont.h delete mode 100644 xfa/fgas/font/fgas_gefont.cpp delete mode 100644 xfa/fgas/font/fgas_gefont.h diff --git a/BUILD.gn b/BUILD.gn index 13c40d606e..11174aeb64 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -1161,10 +1161,10 @@ if (pdf_enable_xfa) { "xfa/fgas/crt/fgas_utils.h", "xfa/fgas/font/cfgas_fontmgr.cpp", "xfa/fgas/font/cfgas_fontmgr.h", + "xfa/fgas/font/cfgas_gefont.cpp", + "xfa/fgas/font/cfgas_gefont.h", "xfa/fgas/font/fgas_fontutils.cpp", "xfa/fgas/font/fgas_fontutils.h", - "xfa/fgas/font/fgas_gefont.cpp", - "xfa/fgas/font/fgas_gefont.h", "xfa/fgas/layout/fgas_linebreak.cpp", "xfa/fgas/layout/fgas_linebreak.h", "xfa/fgas/layout/fgas_rtfbreak.cpp", diff --git a/xfa/fde/fde_gedevice.cpp b/xfa/fde/fde_gedevice.cpp index 254193659d..bf34135f3e 100644 --- a/xfa/fde/fde_gedevice.cpp +++ b/xfa/fde/fde_gedevice.cpp @@ -16,7 +16,7 @@ #include "xfa/fde/cfde_path.h" #include "xfa/fde/fde_object.h" #include "xfa/fgas/font/cfgas_fontmgr.h" -#include "xfa/fgas/font/fgas_gefont.h" +#include "xfa/fgas/font/cfgas_gefont.h" CFDE_RenderDevice::CFDE_RenderDevice(CFX_RenderDevice* pDevice, bool bOwnerDevice) diff --git a/xfa/fgas/font/cfgas_fontmgr.cpp b/xfa/fgas/font/cfgas_fontmgr.cpp index 1830850ce6..9b95318bd0 100644 --- a/xfa/fgas/font/cfgas_fontmgr.cpp +++ b/xfa/fgas/font/cfgas_fontmgr.cpp @@ -16,8 +16,8 @@ #include "core/fxge/ifx_systemfontinfo.h" #include "third_party/base/ptr_util.h" #include "xfa/fgas/crt/fgas_codepage.h" +#include "xfa/fgas/font/cfgas_gefont.h" #include "xfa/fgas/font/fgas_fontutils.h" -#include "xfa/fgas/font/fgas_gefont.h" #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ diff --git a/xfa/fgas/font/cfgas_gefont.cpp b/xfa/fgas/font/cfgas_gefont.cpp new file mode 100644 index 0000000000..ffe791aab5 --- /dev/null +++ b/xfa/fgas/font/cfgas_gefont.cpp @@ -0,0 +1,461 @@ +// Copyright 2014 PDFium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com + +#include "xfa/fgas/font/cfgas_gefont.h" + +#include +#include + +#include "core/fxge/cfx_substfont.h" +#include "core/fxge/cfx_unicodeencoding.h" +#include "core/fxge/cfx_unicodeencodingex.h" +#include "third_party/base/ptr_util.h" +#include "xfa/fgas/crt/fgas_codepage.h" +#include "xfa/fgas/font/fgas_fontutils.h" +#include "xfa/fxfa/xfa_fontmgr.h" + +// static +CFGAS_GEFont* CFGAS_GEFont::LoadFont(const FX_WCHAR* pszFontFamily, + uint32_t dwFontStyles, + uint16_t wCodePage, + CFGAS_FontMgr* pFontMgr) { +#if _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_ + if (pFontMgr) + return pFontMgr->GetFontByCodePage(wCodePage, dwFontStyles, pszFontFamily); + return nullptr; +#else + CFGAS_GEFont* pFont = new CFGAS_GEFont(pFontMgr); + if (!pFont->LoadFontInternal(pszFontFamily, dwFontStyles, wCodePage)) { + pFont->Release(); + return nullptr; + } + return pFont; +#endif +} + +// static +CFGAS_GEFont* CFGAS_GEFont::LoadFont(CFX_Font* pExternalFont, + CFGAS_FontMgr* pFontMgr) { + CFGAS_GEFont* pFont = new CFGAS_GEFont(pFontMgr); + if (!pFont->LoadFontInternal(pExternalFont)) { + pFont->Release(); + return nullptr; + } + return pFont; +} + +// static +CFGAS_GEFont* CFGAS_GEFont::LoadFont(std::unique_ptr pInternalFont, + CFGAS_FontMgr* pFontMgr) { + CFGAS_GEFont* pFont = new CFGAS_GEFont(pFontMgr); + if (!pFont->LoadFontInternal(std::move(pInternalFont))) { + pFont->Release(); + return nullptr; + } + return pFont; +} + +#if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ +// static +CFGAS_GEFont* CFGAS_GEFont::LoadFont(const uint8_t* pBuffer, + int32_t iLength, + CFGAS_FontMgr* pFontMgr) { + CFGAS_GEFont* pFont = new CFGAS_GEFont(pFontMgr); + if (!pFont->LoadFontInternal(pBuffer, iLength)) { + pFont->Release(); + return nullptr; + } + return pFont; +} + +// static +CFGAS_GEFont* CFGAS_GEFont::LoadFont(IFX_Stream* pFontStream, + CFGAS_FontMgr* pFontMgr, + bool bSaveStream) { + CFGAS_GEFont* pFont = new CFGAS_GEFont(pFontMgr); + if (!pFont->LoadFontInternal(pFontStream, bSaveStream)) { + pFont->Release(); + return nullptr; + } + return pFont; +} +#endif // _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ + +CFGAS_GEFont::CFGAS_GEFont(CFGAS_FontMgr* pFontMgr) + : +#if _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_ + m_bUseLogFontStyle(false), + m_dwLogFontStyle(0), +#endif + m_pFont(nullptr), + m_pSrcFont(nullptr), + m_pFontMgr(pFontMgr), + m_iRefCount(1), + m_bExternalFont(false), + m_pProvider(nullptr) { +} + +CFGAS_GEFont::CFGAS_GEFont(CFGAS_GEFont* src, uint32_t dwFontStyles) + : +#if _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_ + m_bUseLogFontStyle(false), + m_dwLogFontStyle(0), +#endif + m_pFont(nullptr), + m_pSrcFont(src), + m_pFontMgr(src->m_pFontMgr), + m_iRefCount(1), + m_bExternalFont(false), + m_pProvider(nullptr) { + ASSERT(m_pSrcFont->m_pFont); + m_pSrcFont->Retain(); + m_pFont = new CFX_Font; + m_pFont->LoadClone(m_pSrcFont->m_pFont); + CFX_SubstFont* pSubst = m_pFont->GetSubstFont(); + if (!pSubst) { + pSubst = new CFX_SubstFont; + m_pFont->SetSubstFont(std::unique_ptr(pSubst)); + } + pSubst->m_Weight = + (dwFontStyles & FX_FONTSTYLE_Bold) ? FXFONT_FW_BOLD : FXFONT_FW_NORMAL; + if (dwFontStyles & FX_FONTSTYLE_Italic) + pSubst->m_SubstFlags |= FXFONT_SUBST_ITALIC; + InitFont(); +} + +CFGAS_GEFont::~CFGAS_GEFont() { + for (int32_t i = 0; i < m_SubstFonts.GetSize(); i++) + m_SubstFonts[i]->Release(); + + m_SubstFonts.RemoveAll(); + m_FontMapper.clear(); + + if (!m_bExternalFont) + delete m_pFont; + + // If it is a shallow copy of another source font, + // decrease the refcount of the source font. + if (m_pSrcFont) + m_pSrcFont->Release(); +} + +void CFGAS_GEFont::Release() { + if (--m_iRefCount < 1) { + if (m_pFontMgr) + m_pFontMgr->RemoveFont(this); + delete this; + } +} +CFGAS_GEFont* CFGAS_GEFont::Retain() { + ++m_iRefCount; + return this; +} + +#if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ +bool CFGAS_GEFont::LoadFontInternal(const FX_WCHAR* pszFontFamily, + uint32_t dwFontStyles, + uint16_t wCodePage) { + if (m_pFont) + return false; + CFX_ByteString csFontFamily; + if (pszFontFamily) + csFontFamily = CFX_ByteString::FromUnicode(pszFontFamily); + uint32_t dwFlags = 0; + if (dwFontStyles & FX_FONTSTYLE_FixedPitch) + dwFlags |= FXFONT_FIXED_PITCH; + if (dwFontStyles & FX_FONTSTYLE_Serif) + dwFlags |= FXFONT_SERIF; + if (dwFontStyles & FX_FONTSTYLE_Symbolic) + dwFlags |= FXFONT_SYMBOLIC; + if (dwFontStyles & FX_FONTSTYLE_Script) + dwFlags |= FXFONT_SCRIPT; + if (dwFontStyles & FX_FONTSTYLE_Italic) + dwFlags |= FXFONT_ITALIC; + if (dwFontStyles & FX_FONTSTYLE_Bold) + dwFlags |= FXFONT_BOLD; + if (dwFontStyles & FX_FONTSTYLE_ExactMatch) + dwFlags |= FXFONT_EXACTMATCH; + int32_t iWeight = + (dwFontStyles & FX_FONTSTYLE_Bold) ? FXFONT_FW_BOLD : FXFONT_FW_NORMAL; + m_pFont = new CFX_Font; + if ((dwFlags & FXFONT_ITALIC) && (dwFlags & FXFONT_BOLD)) + csFontFamily += ",BoldItalic"; + else if (dwFlags & FXFONT_BOLD) + csFontFamily += ",Bold"; + else if (dwFlags & FXFONT_ITALIC) + csFontFamily += ",Italic"; + m_pFont->LoadSubst(csFontFamily, true, dwFlags, iWeight, 0, wCodePage, false); + if (!m_pFont->GetFace()) + return false; + return InitFont(); +} + +bool CFGAS_GEFont::LoadFontInternal(const uint8_t* pBuffer, int32_t length) { + if (m_pFont) + return false; + + m_pFont = new CFX_Font; + if (!m_pFont->LoadEmbedded(pBuffer, length)) + return false; + return InitFont(); +} + +bool CFGAS_GEFont::LoadFontInternal(IFX_Stream* pFontStream, bool bSaveStream) { + if (m_pFont || m_pFileRead || !pFontStream || pFontStream->GetLength() < 1) + return false; + if (bSaveStream) + m_pStream.reset(pFontStream); + + m_pFileRead.reset(FX_CreateFileRead(pFontStream, false)); + m_pFont = new CFX_Font; + if (m_pFont->LoadFile(m_pFileRead.get())) + return InitFont(); + m_pFileRead.reset(); + return false; +} +#endif // _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ + +bool CFGAS_GEFont::LoadFontInternal(CFX_Font* pExternalFont) { + if (m_pFont || !pExternalFont) + return false; + + m_pFont = pExternalFont; + m_bExternalFont = true; + return InitFont(); +} + +bool CFGAS_GEFont::LoadFontInternal(std::unique_ptr pInternalFont) { + if (m_pFont || !pInternalFont) + return false; + + m_pFont = pInternalFont.release(); + m_bExternalFont = false; + return InitFont(); +} + +bool CFGAS_GEFont::InitFont() { + if (!m_pFont) + return false; + if (!m_pFontEncoding) { + m_pFontEncoding.reset(FX_CreateFontEncodingEx(m_pFont)); + if (!m_pFontEncoding) + return false; + } + if (!m_pCharWidthMap) { + m_pCharWidthMap = + pdfium::MakeUnique>(1024); + } + if (!m_pRectArray) + m_pRectArray = pdfium::MakeUnique>(16); + if (!m_pBBoxMap) + m_pBBoxMap = pdfium::MakeUnique(16); + + return true; +} + +CFGAS_GEFont* CFGAS_GEFont::Derive(uint32_t dwFontStyles, uint16_t wCodePage) { + if (GetFontStyles() == dwFontStyles) + return Retain(); + return new CFGAS_GEFont(this, dwFontStyles); +} + +CFX_WideString CFGAS_GEFont::GetFamilyName() const { + if (!m_pFont->GetSubstFont() || + m_pFont->GetSubstFont()->m_Family.GetLength() == 0) { + return CFX_WideString::FromLocal(m_pFont->GetFamilyName().AsStringC()); + } + return CFX_WideString::FromLocal( + m_pFont->GetSubstFont()->m_Family.AsStringC()); +} + +uint32_t CFGAS_GEFont::GetFontStyles() const { + ASSERT(m_pFont); +#if _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_ + if (m_bUseLogFontStyle) + return m_dwLogFontStyle; +#endif + + uint32_t dwStyles = 0; + auto* pSubstFont = m_pFont->GetSubstFont(); + if (pSubstFont) { + if (pSubstFont->m_Weight == FXFONT_FW_BOLD) + dwStyles |= FX_FONTSTYLE_Bold; + if (pSubstFont->m_SubstFlags & FXFONT_SUBST_ITALIC) + dwStyles |= FX_FONTSTYLE_Italic; + } else { + if (m_pFont->IsBold()) + dwStyles |= FX_FONTSTYLE_Bold; + if (m_pFont->IsItalic()) + dwStyles |= FX_FONTSTYLE_Italic; + } + return dwStyles; +} + +bool CFGAS_GEFont::GetCharWidth(FX_WCHAR wUnicode, + int32_t& iWidth, + bool bCharCode) { + return GetCharWidthInternal(wUnicode, iWidth, true, bCharCode); +} + +bool CFGAS_GEFont::GetCharWidthInternal(FX_WCHAR wUnicode, + int32_t& iWidth, + bool bRecursive, + bool bCharCode) { + ASSERT(m_pCharWidthMap); + iWidth = m_pCharWidthMap->GetAt(wUnicode, 0); + if (iWidth == 65535) + return false; + + if (iWidth > 0) + return true; + + if (!m_pProvider || + !m_pProvider->GetCharWidth(this, wUnicode, bCharCode, &iWidth)) { + CFGAS_GEFont* pFont = nullptr; + int32_t iGlyph = GetGlyphIndex(wUnicode, true, &pFont, bCharCode); + if (iGlyph != 0xFFFF && pFont) { + if (pFont == this) { + iWidth = m_pFont->GetGlyphWidth(iGlyph); + if (iWidth < 0) + iWidth = -1; + } else if (pFont->GetCharWidthInternal(wUnicode, iWidth, false, + bCharCode)) { + return true; + } + } else { + iWidth = -1; + } + } + m_pCharWidthMap->SetAtGrow(wUnicode, iWidth); + return iWidth > 0; +} + +bool CFGAS_GEFont::GetCharBBox(FX_WCHAR wUnicode, + CFX_Rect& bbox, + bool bCharCode) { + return GetCharBBoxInternal(wUnicode, bbox, true, bCharCode); +} + +bool CFGAS_GEFont::GetCharBBoxInternal(FX_WCHAR wUnicode, + CFX_Rect& bbox, + bool bRecursive, + bool bCharCode) { + ASSERT(m_pRectArray); + ASSERT(m_pBBoxMap); + void* pRect = nullptr; + if (!m_pBBoxMap->Lookup((void*)(uintptr_t)wUnicode, pRect)) { + CFGAS_GEFont* pFont = nullptr; + int32_t iGlyph = GetGlyphIndex(wUnicode, true, &pFont, bCharCode); + if (iGlyph != 0xFFFF && pFont) { + if (pFont == this) { + FX_RECT rtBBox; + if (m_pFont->GetGlyphBBox(iGlyph, rtBBox)) { + CFX_Rect rt; + rt.Set(rtBBox.left, rtBBox.top, rtBBox.Width(), rtBBox.Height()); + int32_t index = m_pRectArray->Add(rt); + pRect = m_pRectArray->GetPtrAt(index); + m_pBBoxMap->SetAt((void*)(uintptr_t)wUnicode, pRect); + } + } else if (pFont->GetCharBBoxInternal(wUnicode, bbox, false, bCharCode)) { + return true; + } + } + } + if (!pRect) + return false; + + bbox = *static_cast(pRect); + return true; +} + +bool CFGAS_GEFont::GetBBox(CFX_Rect& bbox) { + FX_RECT rt(0, 0, 0, 0); + if (!m_pFont->GetBBox(rt)) + return false; + bbox.left = rt.left; + bbox.width = rt.Width(); + bbox.top = rt.bottom; + bbox.height = -rt.Height(); + return true; +} + +int32_t CFGAS_GEFont::GetGlyphIndex(FX_WCHAR wUnicode, bool bCharCode) { + return GetGlyphIndex(wUnicode, true, nullptr, bCharCode); +} + +int32_t CFGAS_GEFont::GetGlyphIndex(FX_WCHAR wUnicode, + bool bRecursive, + CFGAS_GEFont** ppFont, + bool bCharCode) { + ASSERT(m_pFontEncoding); + int32_t iGlyphIndex = m_pFontEncoding->GlyphFromCharCode(wUnicode); + if (iGlyphIndex > 0) { + if (ppFont) + *ppFont = this; + return iGlyphIndex; + } + const FGAS_FONTUSB* pFontUSB = FGAS_GetUnicodeBitField(wUnicode); + if (!pFontUSB) + return 0xFFFF; + + uint16_t wBitField = pFontUSB->wBitField; + if (wBitField >= 128) + return 0xFFFF; + + auto it = m_FontMapper.find(wUnicode); + CFGAS_GEFont* pFont = it != m_FontMapper.end() ? it->second : nullptr; + if (pFont && pFont != this) { + iGlyphIndex = pFont->GetGlyphIndex(wUnicode, false, nullptr, bCharCode); + if (iGlyphIndex != 0xFFFF) { + int32_t i = m_SubstFonts.Find(pFont); + if (i > -1) { + iGlyphIndex |= ((i + 1) << 24); + if (ppFont) + *ppFont = pFont; + return iGlyphIndex; + } + } + } + if (!m_pFontMgr || !bRecursive) + return 0xFFFF; + CFX_WideString wsFamily = GetFamilyName(); + pFont = + m_pFontMgr->GetFontByUnicode(wUnicode, GetFontStyles(), wsFamily.c_str()); +#if _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_ + if (!pFont) + pFont = m_pFontMgr->GetFontByUnicode(wUnicode, GetFontStyles(), nullptr); +#endif + if (!pFont) + return 0xFFFF; + if (pFont == this) { + pFont->Release(); + return 0xFFFF; + } + m_FontMapper[wUnicode] = pFont; + int32_t i = m_SubstFonts.GetSize(); + m_SubstFonts.Add(pFont); + iGlyphIndex = pFont->GetGlyphIndex(wUnicode, false, nullptr, bCharCode); + if (iGlyphIndex == 0xFFFF) + return 0xFFFF; + iGlyphIndex |= ((i + 1) << 24); + if (ppFont) + *ppFont = pFont; + return iGlyphIndex; +} + +int32_t CFGAS_GEFont::GetAscent() const { + return m_pFont->GetAscent(); +} + +int32_t CFGAS_GEFont::GetDescent() const { + return m_pFont->GetDescent(); +} + +CFGAS_GEFont* CFGAS_GEFont::GetSubstFont(int32_t iGlyphIndex) const { + iGlyphIndex = static_cast(iGlyphIndex) >> 24; + return iGlyphIndex == 0 ? const_cast(this) + : m_SubstFonts[iGlyphIndex - 1]; +} diff --git a/xfa/fgas/font/cfgas_gefont.h b/xfa/fgas/font/cfgas_gefont.h new file mode 100644 index 0000000000..acad51af79 --- /dev/null +++ b/xfa/fgas/font/cfgas_gefont.h @@ -0,0 +1,113 @@ +// Copyright 2014 PDFium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com + +#ifndef XFA_FGAS_FONT_CFGAS_GEFONT_H_ +#define XFA_FGAS_FONT_CFGAS_GEFONT_H_ + +#include +#include + +#include "core/fxcrt/fx_memory.h" +#include "xfa/fgas/crt/fgas_utils.h" +#include "xfa/fgas/font/cfgas_fontmgr.h" + +#define FXFONT_SUBST_ITALIC 0x02 + +class CFX_UnicodeEncoding; +class CXFA_PDFFontMgr; + +class CFGAS_GEFont { + public: + static CFGAS_GEFont* LoadFont(const FX_WCHAR* pszFontFamily, + uint32_t dwFontStyles, + uint16_t wCodePage, + CFGAS_FontMgr* pFontMgr); + static CFGAS_GEFont* LoadFont(CFX_Font* pExternalFont, + CFGAS_FontMgr* pFontMgr); + static CFGAS_GEFont* LoadFont(std::unique_ptr pInternalFont, + CFGAS_FontMgr* pFontMgr); +#if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ + static CFGAS_GEFont* LoadFont(const uint8_t* pBuffer, + int32_t iLength, + CFGAS_FontMgr* pFontMgr); + static CFGAS_GEFont* LoadFont(IFX_Stream* pFontStream, + CFGAS_FontMgr* pFontMgr, + bool bSaveStream); +#endif + + ~CFGAS_GEFont(); + + void Release(); + CFGAS_GEFont* Retain(); + CFGAS_GEFont* Derive(uint32_t dwFontStyles, uint16_t wCodePage = 0); + uint32_t GetFontStyles() const; + bool GetCharWidth(FX_WCHAR wUnicode, int32_t& iWidth, bool bCharCode); + int32_t GetGlyphIndex(FX_WCHAR wUnicode, bool bCharCode = false); + int32_t GetAscent() const; + int32_t GetDescent() const; + bool GetCharBBox(FX_WCHAR wUnicode, CFX_Rect& bbox, bool bCharCode = false); + bool GetBBox(CFX_Rect& bbox); + 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 + + private: + explicit CFGAS_GEFont(CFGAS_FontMgr* pFontMgr); + CFGAS_GEFont(CFGAS_GEFont* src, uint32_t dwFontStyles); + +#if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ + bool LoadFontInternal(const FX_WCHAR* pszFontFamily, + uint32_t dwFontStyles, + uint16_t wCodePage); + bool LoadFontInternal(const uint8_t* pBuffer, int32_t length); + bool LoadFontInternal(IFX_Stream* pFontStream, bool bSaveStream); +#endif + bool LoadFontInternal(CFX_Font* pExternalFont); + bool LoadFontInternal(std::unique_ptr pInternalFont); + bool InitFont(); + bool GetCharBBoxInternal(FX_WCHAR wUnicode, + CFX_Rect& bbox, + bool bRecursive, + bool bCharCode = false); + bool GetCharWidthInternal(FX_WCHAR wUnicode, + int32_t& iWidth, + bool bRecursive, + bool bCharCode); + int32_t GetGlyphIndex(FX_WCHAR wUnicode, + bool bRecursive, + CFGAS_GEFont** ppFont, + bool bCharCode = false); + CFX_WideString GetFamilyName() const; + +#if _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_ + bool m_bUseLogFontStyle; + uint32_t m_dwLogFontStyle; +#endif + CFX_Font* m_pFont; + CFGAS_GEFont* const m_pSrcFont; + CFGAS_FontMgr* const m_pFontMgr; + int32_t m_iRefCount; + bool m_bExternalFont; + std::unique_ptr> m_pStream; + std::unique_ptr> + m_pFileRead; + std::unique_ptr m_pFontEncoding; + std::unique_ptr> m_pCharWidthMap; + std::unique_ptr> m_pRectArray; + std::unique_ptr m_pBBoxMap; + CXFA_PDFFontMgr* m_pProvider; // not owned. + CFX_ArrayTemplate m_SubstFonts; + std::map m_FontMapper; +}; + +#endif // XFA_FGAS_FONT_CFGAS_GEFONT_H_ diff --git a/xfa/fgas/font/fgas_gefont.cpp b/xfa/fgas/font/fgas_gefont.cpp deleted file mode 100644 index 7fa352c23c..0000000000 --- a/xfa/fgas/font/fgas_gefont.cpp +++ /dev/null @@ -1,489 +0,0 @@ -// Copyright 2014 PDFium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com - -#include "xfa/fgas/font/fgas_gefont.h" - -#include -#include - -#include "core/fxge/cfx_substfont.h" -#include "core/fxge/cfx_unicodeencoding.h" -#include "core/fxge/cfx_unicodeencodingex.h" -#include "xfa/fgas/crt/fgas_codepage.h" -#include "xfa/fgas/font/fgas_fontutils.h" -#include "xfa/fxfa/xfa_fontmgr.h" - -// static -CFGAS_GEFont* CFGAS_GEFont::LoadFont(const FX_WCHAR* pszFontFamily, - uint32_t dwFontStyles, - uint16_t wCodePage, - CFGAS_FontMgr* pFontMgr) { -#if _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_ - if (pFontMgr) - return pFontMgr->GetFontByCodePage(wCodePage, dwFontStyles, pszFontFamily); - return nullptr; -#else - CFGAS_GEFont* pFont = new CFGAS_GEFont(pFontMgr); - if (!pFont->LoadFontInternal(pszFontFamily, dwFontStyles, wCodePage)) { - pFont->Release(); - return nullptr; - } - return pFont; -#endif -} - -// static -CFGAS_GEFont* CFGAS_GEFont::LoadFont(CFX_Font* pExternalFont, - CFGAS_FontMgr* pFontMgr) { - CFGAS_GEFont* pFont = new CFGAS_GEFont(pFontMgr); - if (!pFont->LoadFontInternal(pExternalFont)) { - pFont->Release(); - return nullptr; - } - return pFont; -} - -// static -CFGAS_GEFont* CFGAS_GEFont::LoadFont(std::unique_ptr pInternalFont, - CFGAS_FontMgr* pFontMgr) { - CFGAS_GEFont* pFont = new CFGAS_GEFont(pFontMgr); - if (!pFont->LoadFontInternal(std::move(pInternalFont))) { - pFont->Release(); - return nullptr; - } - return pFont; -} - -#if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ -// static -CFGAS_GEFont* CFGAS_GEFont::LoadFont(const uint8_t* pBuffer, - int32_t iLength, - CFGAS_FontMgr* pFontMgr) { - CFGAS_GEFont* pFont = new CFGAS_GEFont(pFontMgr); - if (!pFont->LoadFontInternal(pBuffer, iLength)) { - pFont->Release(); - return nullptr; - } - return pFont; -} - -// static -CFGAS_GEFont* CFGAS_GEFont::LoadFont(IFX_Stream* pFontStream, - CFGAS_FontMgr* pFontMgr, - bool bSaveStream) { - CFGAS_GEFont* pFont = new CFGAS_GEFont(pFontMgr); - if (!pFont->LoadFontInternal(pFontStream, bSaveStream)) { - pFont->Release(); - return nullptr; - } - return pFont; -} -#endif // _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ - -CFGAS_GEFont::CFGAS_GEFont(CFGAS_FontMgr* pFontMgr) - : -#if _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_ - m_bUseLogFontStyle(false), - m_dwLogFontStyle(0), -#endif - m_pFont(nullptr), - m_pSrcFont(nullptr), - m_pFontMgr(pFontMgr), - m_iRefCount(1), - m_bExternalFont(false), - m_pProvider(nullptr) { -} - -CFGAS_GEFont::CFGAS_GEFont(CFGAS_GEFont* src, uint32_t dwFontStyles) - : -#if _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_ - m_bUseLogFontStyle(false), - m_dwLogFontStyle(0), -#endif - m_pFont(nullptr), - m_pSrcFont(src), - m_pFontMgr(src->m_pFontMgr), - m_iRefCount(1), - m_bExternalFont(false), - m_pProvider(nullptr) { - ASSERT(m_pSrcFont->m_pFont); - m_pSrcFont->Retain(); - m_pFont = new CFX_Font; - m_pFont->LoadClone(m_pSrcFont->m_pFont); - CFX_SubstFont* pSubst = m_pFont->GetSubstFont(); - if (!pSubst) { - pSubst = new CFX_SubstFont; - m_pFont->SetSubstFont(std::unique_ptr(pSubst)); - } - pSubst->m_Weight = - (dwFontStyles & FX_FONTSTYLE_Bold) ? FXFONT_FW_BOLD : FXFONT_FW_NORMAL; - if (dwFontStyles & FX_FONTSTYLE_Italic) { - pSubst->m_SubstFlags |= FXFONT_SUBST_ITALIC; - } - InitFont(); -} - -CFGAS_GEFont::~CFGAS_GEFont() { - for (int32_t i = 0; i < m_SubstFonts.GetSize(); i++) - m_SubstFonts[i]->Release(); - - m_SubstFonts.RemoveAll(); - m_FontMapper.clear(); - - if (!m_bExternalFont) - delete m_pFont; - - // If it is a shallow copy of another source font, - // decrease the refcount of the source font. - if (m_pSrcFont) - m_pSrcFont->Release(); -} - -void CFGAS_GEFont::Release() { - if (--m_iRefCount < 1) { - if (m_pFontMgr) { - m_pFontMgr->RemoveFont(this); - } - delete this; - } -} -CFGAS_GEFont* CFGAS_GEFont::Retain() { - ++m_iRefCount; - return this; -} - -#if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ -bool CFGAS_GEFont::LoadFontInternal(const FX_WCHAR* pszFontFamily, - uint32_t dwFontStyles, - uint16_t wCodePage) { - if (m_pFont) { - return false; - } - CFX_ByteString csFontFamily; - if (pszFontFamily) { - csFontFamily = CFX_ByteString::FromUnicode(pszFontFamily); - } - uint32_t dwFlags = 0; - if (dwFontStyles & FX_FONTSTYLE_FixedPitch) { - dwFlags |= FXFONT_FIXED_PITCH; - } - if (dwFontStyles & FX_FONTSTYLE_Serif) { - dwFlags |= FXFONT_SERIF; - } - if (dwFontStyles & FX_FONTSTYLE_Symbolic) { - dwFlags |= FXFONT_SYMBOLIC; - } - if (dwFontStyles & FX_FONTSTYLE_Script) { - dwFlags |= FXFONT_SCRIPT; - } - if (dwFontStyles & FX_FONTSTYLE_Italic) { - dwFlags |= FXFONT_ITALIC; - } - if (dwFontStyles & FX_FONTSTYLE_Bold) { - dwFlags |= FXFONT_BOLD; - } - if (dwFontStyles & FX_FONTSTYLE_ExactMatch) { - dwFlags |= FXFONT_EXACTMATCH; - } - int32_t iWeight = - (dwFontStyles & FX_FONTSTYLE_Bold) ? FXFONT_FW_BOLD : FXFONT_FW_NORMAL; - m_pFont = new CFX_Font; - if ((dwFlags & FXFONT_ITALIC) && (dwFlags & FXFONT_BOLD)) { - csFontFamily += ",BoldItalic"; - } else if (dwFlags & FXFONT_BOLD) { - csFontFamily += ",Bold"; - } else if (dwFlags & FXFONT_ITALIC) { - csFontFamily += ",Italic"; - } - m_pFont->LoadSubst(csFontFamily, true, dwFlags, iWeight, 0, wCodePage, false); - if (!m_pFont->GetFace()) - return false; - return InitFont(); -} - -bool CFGAS_GEFont::LoadFontInternal(const uint8_t* pBuffer, int32_t length) { - if (m_pFont) - return false; - - m_pFont = new CFX_Font; - if (!m_pFont->LoadEmbedded(pBuffer, length)) - return false; - return InitFont(); -} - -bool CFGAS_GEFont::LoadFontInternal(IFX_Stream* pFontStream, bool bSaveStream) { - if (m_pFont || m_pFileRead || !pFontStream || pFontStream->GetLength() < 1) - return false; - if (bSaveStream) - m_pStream.reset(pFontStream); - - m_pFileRead.reset(FX_CreateFileRead(pFontStream, false)); - m_pFont = new CFX_Font; - if (m_pFont->LoadFile(m_pFileRead.get())) - return InitFont(); - m_pFileRead.reset(); - return false; -} -#endif // _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ - -bool CFGAS_GEFont::LoadFontInternal(CFX_Font* pExternalFont) { - if (m_pFont || !pExternalFont) - return false; - - m_pFont = pExternalFont; - m_bExternalFont = true; - return InitFont(); -} - -bool CFGAS_GEFont::LoadFontInternal(std::unique_ptr pInternalFont) { - if (m_pFont || !pInternalFont) - return false; - - m_pFont = pInternalFont.release(); - m_bExternalFont = false; - return InitFont(); -} - -bool CFGAS_GEFont::InitFont() { - if (!m_pFont) - return false; - if (!m_pFontEncoding) { - m_pFontEncoding.reset(FX_CreateFontEncodingEx(m_pFont)); - if (!m_pFontEncoding) - return false; - } - if (!m_pCharWidthMap) - m_pCharWidthMap.reset(new CFX_DiscreteArrayTemplate(1024)); - if (!m_pRectArray) - m_pRectArray.reset(new CFX_MassArrayTemplate(16)); - if (!m_pBBoxMap) - m_pBBoxMap.reset(new CFX_MapPtrToPtr(16)); - - return true; -} - -CFGAS_GEFont* CFGAS_GEFont::Derive(uint32_t dwFontStyles, uint16_t wCodePage) { - if (GetFontStyles() == dwFontStyles) - return Retain(); - return new CFGAS_GEFont(this, dwFontStyles); -} - -void CFGAS_GEFont::GetFamilyName(CFX_WideString& wsFamily) const { - if (!m_pFont->GetSubstFont() || - m_pFont->GetSubstFont()->m_Family.GetLength() == 0) { - wsFamily = CFX_WideString::FromLocal(m_pFont->GetFamilyName().AsStringC()); - } else { - wsFamily = CFX_WideString::FromLocal( - m_pFont->GetSubstFont()->m_Family.AsStringC()); - } -} - -uint32_t CFGAS_GEFont::GetFontStyles() const { - ASSERT(m_pFont); -#if _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_ - if (m_bUseLogFontStyle) - return m_dwLogFontStyle; -#endif - - uint32_t dwStyles = 0; - auto* pSubstFont = m_pFont->GetSubstFont(); - if (pSubstFont) { - if (pSubstFont->m_Weight == FXFONT_FW_BOLD) - dwStyles |= FX_FONTSTYLE_Bold; - if (pSubstFont->m_SubstFlags & FXFONT_SUBST_ITALIC) - dwStyles |= FX_FONTSTYLE_Italic; - } else { - if (m_pFont->IsBold()) - dwStyles |= FX_FONTSTYLE_Bold; - if (m_pFont->IsItalic()) - dwStyles |= FX_FONTSTYLE_Italic; - } - return dwStyles; -} - -bool CFGAS_GEFont::GetCharWidth(FX_WCHAR wUnicode, - int32_t& iWidth, - bool bCharCode) { - return GetCharWidthInternal(wUnicode, iWidth, true, bCharCode); -} - -bool CFGAS_GEFont::GetCharWidthInternal(FX_WCHAR wUnicode, - int32_t& iWidth, - bool bRecursive, - bool bCharCode) { - ASSERT(m_pCharWidthMap); - iWidth = m_pCharWidthMap->GetAt(wUnicode, 0); - if (iWidth == 65535) - return false; - - if (iWidth > 0) - return true; - - if (!m_pProvider || - !m_pProvider->GetCharWidth(this, wUnicode, bCharCode, &iWidth)) { - CFGAS_GEFont* pFont = nullptr; - int32_t iGlyph = GetGlyphIndex(wUnicode, true, &pFont, bCharCode); - if (iGlyph != 0xFFFF && pFont) { - if (pFont == this) { - iWidth = m_pFont->GetGlyphWidth(iGlyph); - if (iWidth < 0) { - iWidth = -1; - } - } else if (pFont->GetCharWidthInternal(wUnicode, iWidth, false, - bCharCode)) { - return true; - } - } else { - iWidth = -1; - } - } - m_pCharWidthMap->SetAtGrow(wUnicode, iWidth); - return iWidth > 0; -} - -bool CFGAS_GEFont::GetCharBBox(FX_WCHAR wUnicode, - CFX_Rect& bbox, - bool bCharCode) { - return GetCharBBoxInternal(wUnicode, bbox, true, bCharCode); -} - -bool CFGAS_GEFont::GetCharBBoxInternal(FX_WCHAR wUnicode, - CFX_Rect& bbox, - bool bRecursive, - bool bCharCode) { - ASSERT(m_pRectArray); - ASSERT(m_pBBoxMap); - void* pRect = nullptr; - if (!m_pBBoxMap->Lookup((void*)(uintptr_t)wUnicode, pRect)) { - CFGAS_GEFont* pFont = nullptr; - int32_t iGlyph = GetGlyphIndex(wUnicode, true, &pFont, bCharCode); - if (iGlyph != 0xFFFF && pFont) { - if (pFont == this) { - FX_RECT rtBBox; - if (m_pFont->GetGlyphBBox(iGlyph, rtBBox)) { - CFX_Rect rt; - rt.Set(rtBBox.left, rtBBox.top, rtBBox.Width(), rtBBox.Height()); - int32_t index = m_pRectArray->Add(rt); - pRect = m_pRectArray->GetPtrAt(index); - m_pBBoxMap->SetAt((void*)(uintptr_t)wUnicode, pRect); - } - } else if (pFont->GetCharBBoxInternal(wUnicode, bbox, false, bCharCode)) { - return true; - } - } - } - if (!pRect) - return false; - - bbox = *static_cast(pRect); - return true; -} -bool CFGAS_GEFont::GetBBox(CFX_Rect& bbox) { - FX_RECT rt(0, 0, 0, 0); - bool bRet = m_pFont->GetBBox(rt); - if (bRet) { - bbox.left = rt.left; - bbox.width = rt.Width(); - bbox.top = rt.bottom; - bbox.height = -rt.Height(); - } - return bRet; -} -int32_t CFGAS_GEFont::GetItalicAngle() const { - if (!m_pFont->GetSubstFont()) { - return 0; - } - return m_pFont->GetSubstFont()->m_ItalicAngle; -} -int32_t CFGAS_GEFont::GetGlyphIndex(FX_WCHAR wUnicode, bool bCharCode) { - return GetGlyphIndex(wUnicode, true, nullptr, bCharCode); -} -int32_t CFGAS_GEFont::GetGlyphIndex(FX_WCHAR wUnicode, - bool bRecursive, - CFGAS_GEFont** ppFont, - bool bCharCode) { - ASSERT(m_pFontEncoding); - int32_t iGlyphIndex = m_pFontEncoding->GlyphFromCharCode(wUnicode); - if (iGlyphIndex > 0) { - if (ppFont) { - *ppFont = this; - } - return iGlyphIndex; - } - const FGAS_FONTUSB* pFontUSB = FGAS_GetUnicodeBitField(wUnicode); - if (!pFontUSB) { - return 0xFFFF; - } - uint16_t wBitField = pFontUSB->wBitField; - if (wBitField >= 128) { - return 0xFFFF; - } - auto it = m_FontMapper.find(wUnicode); - CFGAS_GEFont* pFont = it != m_FontMapper.end() ? it->second : nullptr; - if (pFont && pFont != this) { - iGlyphIndex = pFont->GetGlyphIndex(wUnicode, false, nullptr, bCharCode); - if (iGlyphIndex != 0xFFFF) { - int32_t i = m_SubstFonts.Find(pFont); - if (i > -1) { - iGlyphIndex |= ((i + 1) << 24); - if (ppFont) - *ppFont = pFont; - return iGlyphIndex; - } - } - } - if (m_pFontMgr && bRecursive) { - CFX_WideString wsFamily; - GetFamilyName(wsFamily); - CFGAS_GEFont* pFont = m_pFontMgr->GetFontByUnicode( - wUnicode, GetFontStyles(), wsFamily.c_str()); -#if _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_ - if (!pFont) - pFont = m_pFontMgr->GetFontByUnicode(wUnicode, GetFontStyles(), nullptr); -#endif - if (pFont) { - if (pFont == this) { - pFont->Release(); - return 0xFFFF; - } - m_FontMapper[wUnicode] = pFont; - int32_t i = m_SubstFonts.GetSize(); - m_SubstFonts.Add(pFont); - iGlyphIndex = pFont->GetGlyphIndex(wUnicode, false, nullptr, bCharCode); - if (iGlyphIndex != 0xFFFF) { - iGlyphIndex |= ((i + 1) << 24); - if (ppFont) - *ppFont = pFont; - return iGlyphIndex; - } - } - } - return 0xFFFF; -} -int32_t CFGAS_GEFont::GetAscent() const { - return m_pFont->GetAscent(); -} -int32_t CFGAS_GEFont::GetDescent() const { - return m_pFont->GetDescent(); -} -void CFGAS_GEFont::Reset() { - for (int32_t i = 0; i < m_SubstFonts.GetSize(); i++) - m_SubstFonts[i]->Reset(); - if (m_pCharWidthMap) { - m_pCharWidthMap->RemoveAll(); - } - if (m_pBBoxMap) { - m_pBBoxMap->RemoveAll(); - } - if (m_pRectArray) { - m_pRectArray->RemoveAll(false); - } -} -CFGAS_GEFont* CFGAS_GEFont::GetSubstFont(int32_t iGlyphIndex) const { - iGlyphIndex = ((uint32_t)iGlyphIndex) >> 24; - return iGlyphIndex == 0 ? const_cast(this) - : m_SubstFonts[iGlyphIndex - 1]; -} diff --git a/xfa/fgas/font/fgas_gefont.h b/xfa/fgas/font/fgas_gefont.h deleted file mode 100644 index afe628fc66..0000000000 --- a/xfa/fgas/font/fgas_gefont.h +++ /dev/null @@ -1,115 +0,0 @@ -// Copyright 2014 PDFium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com - -#ifndef XFA_FGAS_FONT_FGAS_GEFONT_H_ -#define XFA_FGAS_FONT_FGAS_GEFONT_H_ - -#include -#include - -#include "core/fxcrt/fx_memory.h" -#include "xfa/fgas/crt/fgas_utils.h" -#include "xfa/fgas/font/cfgas_fontmgr.h" - -#define FXFONT_SUBST_ITALIC 0x02 - -class CFX_UnicodeEncoding; -class CXFA_PDFFontMgr; - -class CFGAS_GEFont { - public: - static CFGAS_GEFont* LoadFont(const FX_WCHAR* pszFontFamily, - uint32_t dwFontStyles, - uint16_t wCodePage, - CFGAS_FontMgr* pFontMgr); - static CFGAS_GEFont* LoadFont(CFX_Font* pExternalFont, - CFGAS_FontMgr* pFontMgr); - static CFGAS_GEFont* LoadFont(std::unique_ptr pInternalFont, - CFGAS_FontMgr* pFontMgr); -#if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ - static CFGAS_GEFont* LoadFont(const uint8_t* pBuffer, - int32_t iLength, - CFGAS_FontMgr* pFontMgr); - static CFGAS_GEFont* LoadFont(IFX_Stream* pFontStream, - CFGAS_FontMgr* pFontMgr, - bool bSaveStream); -#endif - - ~CFGAS_GEFont(); - - 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; - bool GetCharWidth(FX_WCHAR wUnicode, int32_t& iWidth, bool bCharCode); - int32_t GetGlyphIndex(FX_WCHAR wUnicode, bool bCharCode = false); - int32_t GetAscent() const; - int32_t GetDescent() const; - bool GetCharBBox(FX_WCHAR wUnicode, CFX_Rect& bbox, bool bCharCode = false); - 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(CFGAS_FontMgr* pFontMgr); - CFGAS_GEFont(CFGAS_GEFont* src, uint32_t dwFontStyles); - -#if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ - bool LoadFontInternal(const FX_WCHAR* pszFontFamily, - uint32_t dwFontStyles, - uint16_t wCodePage); - bool LoadFontInternal(const uint8_t* pBuffer, int32_t length); - bool LoadFontInternal(IFX_Stream* pFontStream, bool bSaveStream); -#endif - bool LoadFontInternal(CFX_Font* pExternalFont); - bool LoadFontInternal(std::unique_ptr pInternalFont); - bool InitFont(); - bool GetCharBBoxInternal(FX_WCHAR wUnicode, - CFX_Rect& bbox, - bool bRecursive, - bool bCharCode = false); - bool GetCharWidthInternal(FX_WCHAR wUnicode, - int32_t& iWidth, - bool bRecursive, - bool bCharCode); - int32_t GetGlyphIndex(FX_WCHAR wUnicode, - bool bRecursive, - CFGAS_GEFont** ppFont, - bool bCharCode = false); - -#if _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_ - bool m_bUseLogFontStyle; - uint32_t m_dwLogFontStyle; -#endif - CFX_Font* m_pFont; - CFGAS_GEFont* const m_pSrcFont; - CFGAS_FontMgr* const m_pFontMgr; - int32_t m_iRefCount; - bool m_bExternalFont; - std::unique_ptr> m_pStream; - std::unique_ptr> - m_pFileRead; - std::unique_ptr m_pFontEncoding; - std::unique_ptr> m_pCharWidthMap; - std::unique_ptr> m_pRectArray; - std::unique_ptr m_pBBoxMap; - CXFA_PDFFontMgr* m_pProvider; // not owned. - CFX_ArrayTemplate m_SubstFonts; - std::map m_FontMapper; -}; - -#endif // XFA_FGAS_FONT_FGAS_GEFONT_H_ diff --git a/xfa/fgas/layout/fgas_rtfbreak.cpp b/xfa/fgas/layout/fgas_rtfbreak.cpp index 642fe73bc7..ef65bf9779 100644 --- a/xfa/fgas/layout/fgas_rtfbreak.cpp +++ b/xfa/fgas/layout/fgas_rtfbreak.cpp @@ -10,7 +10,7 @@ #include "core/fxcrt/fx_arabic.h" #include "core/fxcrt/fx_arb.h" -#include "xfa/fgas/font/fgas_gefont.h" +#include "xfa/fgas/font/cfgas_gefont.h" #include "xfa/fgas/layout/fgas_linebreak.h" #include "xfa/fgas/layout/fgas_unicode.h" diff --git a/xfa/fgas/layout/fgas_textbreak.cpp b/xfa/fgas/layout/fgas_textbreak.cpp index 4551809463..4b6e22593d 100644 --- a/xfa/fgas/layout/fgas_textbreak.cpp +++ b/xfa/fgas/layout/fgas_textbreak.cpp @@ -11,7 +11,7 @@ #include "core/fxcrt/fx_arabic.h" #include "core/fxcrt/fx_arb.h" #include "core/fxcrt/fx_memory.h" -#include "xfa/fgas/font/fgas_gefont.h" +#include "xfa/fgas/font/cfgas_gefont.h" #include "xfa/fgas/layout/fgas_linebreak.h" #include "xfa/fgas/layout/fgas_unicode.h" diff --git a/xfa/fwl/core/ifwl_barcode.cpp b/xfa/fwl/core/ifwl_barcode.cpp index e4084aa9c6..26d60aa4c9 100644 --- a/xfa/fwl/core/ifwl_barcode.cpp +++ b/xfa/fwl/core/ifwl_barcode.cpp @@ -9,7 +9,7 @@ #include #include "third_party/base/ptr_util.h" -#include "xfa/fgas/font/fgas_gefont.h" +#include "xfa/fgas/font/cfgas_gefont.h" #include "xfa/fwl/core/cfwl_themepart.h" #include "xfa/fwl/core/cfx_barcode.h" #include "xfa/fwl/core/fwl_noteimp.h" diff --git a/xfa/fwl/core/ifwl_edit.cpp b/xfa/fwl/core/ifwl_edit.cpp index d129e70a8c..4a95f2c462 100644 --- a/xfa/fwl/core/ifwl_edit.cpp +++ b/xfa/fwl/core/ifwl_edit.cpp @@ -17,7 +17,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/fgas/font/cfgas_gefont.h" #include "xfa/fwl/core/cfwl_evtcheckword.h" #include "xfa/fwl/core/cfwl_evttextchanged.h" #include "xfa/fwl/core/cfwl_evttextfull.h" diff --git a/xfa/fwl/theme/cfwl_widgettp.cpp b/xfa/fwl/theme/cfwl_widgettp.cpp index 1b05be72dd..3f294aab30 100644 --- a/xfa/fwl/theme/cfwl_widgettp.cpp +++ b/xfa/fwl/theme/cfwl_widgettp.cpp @@ -10,8 +10,8 @@ #include #include "xfa/fde/tto/fde_textout.h" -#include "xfa/fgas/font/fgas_gefont.h" #include "xfa/fgas/font/cfgas_fontmgr.h" +#include "xfa/fgas/font/cfgas_gefont.h" #include "xfa/fwl/core/cfwl_themebackground.h" #include "xfa/fwl/core/cfwl_themepart.h" #include "xfa/fwl/core/cfwl_themetext.h" diff --git a/xfa/fxfa/app/xfa_fontmgr.cpp b/xfa/fxfa/app/xfa_fontmgr.cpp index 857c1d53f7..e83cf48eb8 100644 --- a/xfa/fxfa/app/xfa_fontmgr.cpp +++ b/xfa/fxfa/app/xfa_fontmgr.cpp @@ -13,7 +13,7 @@ #include "core/fpdfapi/font/cpdf_font.h" #include "core/fpdfapi/parser/cpdf_dictionary.h" #include "core/fpdfapi/parser/cpdf_document.h" -#include "xfa/fgas/font/fgas_gefont.h" +#include "xfa/fgas/font/cfgas_gefont.h" #include "xfa/fxfa/xfa_ffapp.h" #include "xfa/fxfa/xfa_ffdoc.h" diff --git a/xfa/fxfa/app/xfa_fwltheme.cpp b/xfa/fxfa/app/xfa_fwltheme.cpp index 34023a4f87..eb45cf12b7 100644 --- a/xfa/fxfa/app/xfa_fwltheme.cpp +++ b/xfa/fxfa/app/xfa_fwltheme.cpp @@ -8,7 +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/fgas/font/cfgas_gefont.h" #include "xfa/fwl/core/cfwl_themebackground.h" #include "xfa/fwl/core/cfwl_themetext.h" #include "xfa/fwl/core/ifwl_barcode.h" -- cgit v1.2.3