summaryrefslogtreecommitdiff
path: root/xfa
diff options
context:
space:
mode:
Diffstat (limited to 'xfa')
-rw-r--r--xfa/fde/fde_gedevice.cpp2
-rw-r--r--xfa/fgas/font/cfgas_fontmgr.cpp2
-rw-r--r--xfa/fgas/font/cfgas_gefont.cpp (renamed from xfa/fgas/font/fgas_gefont.cpp)164
-rw-r--r--xfa/fgas/font/cfgas_gefont.h (renamed from xfa/fgas/font/fgas_gefont.h)12
-rw-r--r--xfa/fgas/layout/fgas_rtfbreak.cpp2
-rw-r--r--xfa/fgas/layout/fgas_textbreak.cpp2
-rw-r--r--xfa/fwl/core/ifwl_barcode.cpp2
-rw-r--r--xfa/fwl/core/ifwl_edit.cpp2
-rw-r--r--xfa/fwl/theme/cfwl_widgettp.cpp2
-rw-r--r--xfa/fxfa/app/xfa_fontmgr.cpp2
-rw-r--r--xfa/fxfa/app/xfa_fwltheme.cpp2
11 files changed, 82 insertions, 112 deletions
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/fgas_gefont.cpp b/xfa/fgas/font/cfgas_gefont.cpp
index 7fa352c23c..ffe791aab5 100644
--- a/xfa/fgas/font/fgas_gefont.cpp
+++ b/xfa/fgas/font/cfgas_gefont.cpp
@@ -4,7 +4,7 @@
// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-#include "xfa/fgas/font/fgas_gefont.h"
+#include "xfa/fgas/font/cfgas_gefont.h"
#include <memory>
#include <utility>
@@ -12,6 +12,7 @@
#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"
@@ -120,9 +121,8 @@ CFGAS_GEFont::CFGAS_GEFont(CFGAS_GEFont* src, uint32_t dwFontStyles)
}
pSubst->m_Weight =
(dwFontStyles & FX_FONTSTYLE_Bold) ? FXFONT_FW_BOLD : FXFONT_FW_NORMAL;
- if (dwFontStyles & FX_FONTSTYLE_Italic) {
+ if (dwFontStyles & FX_FONTSTYLE_Italic)
pSubst->m_SubstFlags |= FXFONT_SUBST_ITALIC;
- }
InitFont();
}
@@ -144,9 +144,8 @@ CFGAS_GEFont::~CFGAS_GEFont() {
void CFGAS_GEFont::Release() {
if (--m_iRefCount < 1) {
- if (m_pFontMgr) {
+ if (m_pFontMgr)
m_pFontMgr->RemoveFont(this);
- }
delete this;
}
}
@@ -159,45 +158,35 @@ CFGAS_GEFont* CFGAS_GEFont::Retain() {
bool CFGAS_GEFont::LoadFontInternal(const FX_WCHAR* pszFontFamily,
uint32_t dwFontStyles,
uint16_t wCodePage) {
- if (m_pFont) {
+ if (m_pFont)
return false;
- }
CFX_ByteString csFontFamily;
- if (pszFontFamily) {
+ if (pszFontFamily)
csFontFamily = CFX_ByteString::FromUnicode(pszFontFamily);
- }
uint32_t dwFlags = 0;
- if (dwFontStyles & FX_FONTSTYLE_FixedPitch) {
+ if (dwFontStyles & FX_FONTSTYLE_FixedPitch)
dwFlags |= FXFONT_FIXED_PITCH;
- }
- if (dwFontStyles & FX_FONTSTYLE_Serif) {
+ if (dwFontStyles & FX_FONTSTYLE_Serif)
dwFlags |= FXFONT_SERIF;
- }
- if (dwFontStyles & FX_FONTSTYLE_Symbolic) {
+ if (dwFontStyles & FX_FONTSTYLE_Symbolic)
dwFlags |= FXFONT_SYMBOLIC;
- }
- if (dwFontStyles & FX_FONTSTYLE_Script) {
+ if (dwFontStyles & FX_FONTSTYLE_Script)
dwFlags |= FXFONT_SCRIPT;
- }
- if (dwFontStyles & FX_FONTSTYLE_Italic) {
+ if (dwFontStyles & FX_FONTSTYLE_Italic)
dwFlags |= FXFONT_ITALIC;
- }
- if (dwFontStyles & FX_FONTSTYLE_Bold) {
+ if (dwFontStyles & FX_FONTSTYLE_Bold)
dwFlags |= FXFONT_BOLD;
- }
- if (dwFontStyles & FX_FONTSTYLE_ExactMatch) {
+ 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)) {
+ if ((dwFlags & FXFONT_ITALIC) && (dwFlags & FXFONT_BOLD))
csFontFamily += ",BoldItalic";
- } else if (dwFlags & FXFONT_BOLD) {
+ else if (dwFlags & FXFONT_BOLD)
csFontFamily += ",Bold";
- } else if (dwFlags & FXFONT_ITALIC) {
+ else if (dwFlags & FXFONT_ITALIC)
csFontFamily += ",Italic";
- }
m_pFont->LoadSubst(csFontFamily, true, dwFlags, iWeight, 0, wCodePage, false);
if (!m_pFont->GetFace())
return false;
@@ -255,12 +244,14 @@ bool CFGAS_GEFont::InitFont() {
if (!m_pFontEncoding)
return false;
}
- if (!m_pCharWidthMap)
- m_pCharWidthMap.reset(new CFX_DiscreteArrayTemplate<uint16_t>(1024));
+ if (!m_pCharWidthMap) {
+ m_pCharWidthMap =
+ pdfium::MakeUnique<CFX_DiscreteArrayTemplate<uint16_t>>(1024);
+ }
if (!m_pRectArray)
- m_pRectArray.reset(new CFX_MassArrayTemplate<CFX_Rect>(16));
+ m_pRectArray = pdfium::MakeUnique<CFX_MassArrayTemplate<CFX_Rect>>(16);
if (!m_pBBoxMap)
- m_pBBoxMap.reset(new CFX_MapPtrToPtr(16));
+ m_pBBoxMap = pdfium::MakeUnique<CFX_MapPtrToPtr>(16);
return true;
}
@@ -271,14 +262,13 @@ CFGAS_GEFont* CFGAS_GEFont::Derive(uint32_t dwFontStyles, uint16_t wCodePage) {
return new CFGAS_GEFont(this, dwFontStyles);
}
-void CFGAS_GEFont::GetFamilyName(CFX_WideString& wsFamily) const {
+CFX_WideString CFGAS_GEFont::GetFamilyName() 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());
+ return CFX_WideString::FromLocal(m_pFont->GetFamilyName().AsStringC());
}
+ return CFX_WideString::FromLocal(
+ m_pFont->GetSubstFont()->m_Family.AsStringC());
}
uint32_t CFGAS_GEFont::GetFontStyles() const {
@@ -329,9 +319,8 @@ bool CFGAS_GEFont::GetCharWidthInternal(FX_WCHAR wUnicode,
if (iGlyph != 0xFFFF && pFont) {
if (pFont == this) {
iWidth = m_pFont->GetGlyphWidth(iGlyph);
- if (iWidth < 0) {
+ if (iWidth < 0)
iWidth = -1;
- }
} else if (pFont->GetCharWidthInternal(wUnicode, iWidth, false,
bCharCode)) {
return true;
@@ -381,26 +370,22 @@ bool CFGAS_GEFont::GetCharBBoxInternal(FX_WCHAR wUnicode,
bbox = *static_cast<const CFX_Rect*>(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;
+ 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,
@@ -408,19 +393,18 @@ int32_t CFGAS_GEFont::GetGlyphIndex(FX_WCHAR wUnicode,
ASSERT(m_pFontEncoding);
int32_t iGlyphIndex = m_pFontEncoding->GlyphFromCharCode(wUnicode);
if (iGlyphIndex > 0) {
- if (ppFont) {
+ if (ppFont)
*ppFont = this;
- }
return iGlyphIndex;
}
const FGAS_FONTUSB* pFontUSB = FGAS_GetUnicodeBitField(wUnicode);
- if (!pFontUSB) {
+ if (!pFontUSB)
return 0xFFFF;
- }
+
uint16_t wBitField = pFontUSB->wBitField;
- if (wBitField >= 128) {
+ 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) {
@@ -435,55 +419,43 @@ int32_t CFGAS_GEFont::GetGlyphIndex(FX_WCHAR wUnicode,
}
}
}
- if (m_pFontMgr && bRecursive) {
- CFX_WideString wsFamily;
- GetFamilyName(wsFamily);
- CFGAS_GEFont* pFont = m_pFontMgr->GetFontByUnicode(
- wUnicode, GetFontStyles(), wsFamily.c_str());
+ 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);
+ 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;
- }
- }
+ if (!pFont)
+ return 0xFFFF;
+ if (pFont == this) {
+ pFont->Release();
+ return 0xFFFF;
}
- 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();
}
-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;
+ iGlyphIndex = static_cast<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/cfgas_gefont.h
index afe628fc66..acad51af79 100644
--- a/xfa/fgas/font/fgas_gefont.h
+++ b/xfa/fgas/font/cfgas_gefont.h
@@ -4,8 +4,8 @@
// 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_
+#ifndef XFA_FGAS_FONT_CFGAS_GEFONT_H_
+#define XFA_FGAS_FONT_CFGAS_GEFONT_H_
#include <map>
#include <memory>
@@ -43,7 +43,6 @@ class 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);
@@ -51,8 +50,6 @@ class CFGAS_GEFont {
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; }
@@ -63,7 +60,7 @@ class CFGAS_GEFont {
}
#endif
- protected:
+ private:
explicit CFGAS_GEFont(CFGAS_FontMgr* pFontMgr);
CFGAS_GEFont(CFGAS_GEFont* src, uint32_t dwFontStyles);
@@ -89,6 +86,7 @@ class CFGAS_GEFont {
bool bRecursive,
CFGAS_GEFont** ppFont,
bool bCharCode = false);
+ CFX_WideString GetFamilyName() const;
#if _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_
bool m_bUseLogFontStyle;
@@ -112,4 +110,4 @@ class CFGAS_GEFont {
std::map<FX_WCHAR, CFGAS_GEFont*> m_FontMapper;
};
-#endif // XFA_FGAS_FONT_FGAS_GEFONT_H_
+#endif // XFA_FGAS_FONT_CFGAS_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 <utility>
#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 <utility>
#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"