summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Sinclair <dsinclair@chromium.org>2017-09-28 11:51:24 -0400
committerChromium commit bot <commit-bot@chromium.org>2017-09-28 20:39:56 +0000
commitdd0e6e1eba14c76dedd4b4e55ab47406856c9a76 (patch)
tree36f27e3ec86b5c376d51bcd753cbdfbe3402e6c7
parent58418a24debb15019ec71eca193eff02c2a4846c (diff)
downloadpdfium-dd0e6e1eba14c76dedd4b4e55ab47406856c9a76.tar.xz
Cleanup font defines
This CL removes duplicate defines between XFA and core. Several OR'd values have been coverted into individual booleans to make the code clearer. Change-Id: Ic32a71c711cffd9a0cf1136e5a22f0502e085c39 Reviewed-on: https://pdfium-review.googlesource.com/15071 Reviewed-by: Ryan Harrison <rharrison@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
-rw-r--r--core/fpdfapi/font/cpdf_cidfont.cpp2
-rw-r--r--core/fpdfapi/render/cpdf_charposlist.cpp2
-rw-r--r--core/fxge/cfx_facecache.cpp5
-rw-r--r--core/fxge/cfx_font.cpp12
-rw-r--r--core/fxge/cfx_fontmapper.cpp4
-rw-r--r--core/fxge/cfx_substfont.cpp11
-rw-r--r--core/fxge/cfx_substfont.h12
-rw-r--r--core/fxge/fx_font.h2
-rw-r--r--xfa/fde/cfde_textout.cpp9
-rw-r--r--xfa/fgas/font/cfgas_defaultfontmanager.cpp9
-rw-r--r--xfa/fgas/font/cfgas_fontmgr.cpp74
-rw-r--r--xfa/fgas/font/cfgas_fontmgr.h16
-rw-r--r--xfa/fgas/font/cfgas_gefont.cpp44
-rw-r--r--xfa/fgas/font/cfgas_gefont.h6
-rw-r--r--xfa/fgas/font/cfgas_pdffontmgr.cpp4
-rw-r--r--xfa/fxfa/cxfa_textparser.cpp8
-rw-r--r--xfa/fxfa/cxfa_widgetacc.cpp4
17 files changed, 102 insertions, 122 deletions
diff --git a/core/fpdfapi/font/cpdf_cidfont.cpp b/core/fpdfapi/font/cpdf_cidfont.cpp
index 49413d24f5..611afc0787 100644
--- a/core/fpdfapi/font/cpdf_cidfont.cpp
+++ b/core/fpdfapi/font/cpdf_cidfont.cpp
@@ -401,7 +401,7 @@ bool CPDF_CIDFont::Load() {
if (!IsEmbedded())
LoadSubstFont();
- if (m_pFontFile || (GetSubstFont()->m_SubstFlags & FXFONT_SUBST_EXACT)) {
+ if (m_pFontFile || GetSubstFont()->m_bFlagExact) {
CPDF_Object* pmap = pCIDFontDict->GetDirectObjectFor("CIDToGIDMap");
if (pmap) {
if (CPDF_Stream* pStream = pmap->AsStream()) {
diff --git a/core/fpdfapi/render/cpdf_charposlist.cpp b/core/fpdfapi/render/cpdf_charposlist.cpp
index 16fb3c140c..5739c8af02 100644
--- a/core/fpdfapi/render/cpdf_charposlist.cpp
+++ b/core/fpdfapi/render/cpdf_charposlist.cpp
@@ -70,7 +70,7 @@ void CPDF_CharPosList::Load(const std::vector<uint32_t>& charCodes,
float scalingFactor = 1.0f;
if (!pFont->IsEmbedded() && pFont->HasFontWidths() && !bVertWriting &&
- !(pCurrentFont->GetSubstFont()->m_SubstFlags & FXFONT_SUBST_MM)) {
+ !pCurrentFont->GetSubstFont()->m_bFlagMM) {
int pdfGlyphWidth = pFont->GetCharWidthF(CharCode);
int ftGlyphWidth =
pCurrentFont ? pCurrentFont->GetGlyphWidth(charpos.m_GlyphIndex) : 0;
diff --git a/core/fxge/cfx_facecache.cpp b/core/fxge/cfx_facecache.cpp
index 07d7339c2d..a3e58ff29c 100644
--- a/core/fxge/cfx_facecache.cpp
+++ b/core/fxge/cfx_facecache.cpp
@@ -146,7 +146,7 @@ std::unique_ptr<CFX_GlyphBitmap> CFX_FaceCache::RenderGlyph(
else
ft_matrix.xy -= ft_matrix.xx * skew / 100;
}
- if (pSubstFont->m_SubstFlags & FXFONT_SUBST_MM) {
+ if (pSubstFont->m_bFlagMM) {
pFont->AdjustMMParams(glyph_index, dest_width,
pFont->GetSubstFont()->m_Weight);
}
@@ -172,8 +172,7 @@ std::unique_ptr<CFX_GlyphBitmap> CFX_FaceCache::RenderGlyph(
weight = pSubstFont->m_WeightCJK;
else
weight = pSubstFont ? pSubstFont->m_Weight : 0;
- if (pSubstFont && !(pSubstFont->m_SubstFlags & FXFONT_SUBST_MM) &&
- weight > 400) {
+ if (pSubstFont && !pSubstFont->m_bFlagMM && weight > 400) {
uint32_t index = (weight - 400) / 10;
if (index >= CFX_Font::kWeightPowArraySize)
return nullptr;
diff --git a/core/fxge/cfx_font.cpp b/core/fxge/cfx_font.cpp
index e893c13357..11fa45710d 100644
--- a/core/fxge/cfx_font.cpp
+++ b/core/fxge/cfx_font.cpp
@@ -233,7 +233,11 @@ bool CFX_Font::LoadClone(const CFX_Font* pFont) {
if (pFont->m_pSubstFont) {
m_pSubstFont = pdfium::MakeUnique<CFX_SubstFont>();
m_pSubstFont->m_Charset = pFont->m_pSubstFont->m_Charset;
- m_pSubstFont->m_SubstFlags = pFont->m_pSubstFont->m_SubstFlags;
+ m_pSubstFont->m_bFlagMM = pFont->m_pSubstFont->m_bFlagMM;
+ m_pSubstFont->m_bFlagExact = pFont->m_pSubstFont->m_bFlagExact;
+#ifdef PDF_ENABLE_XFA
+ m_pSubstFont->m_bFlagItalic = pFont->m_pSubstFont->m_bFlagItalic;
+#endif // PDF_ENABLE_XFA
m_pSubstFont->m_Weight = pFont->m_pSubstFont->m_Weight;
m_pSubstFont->m_Family = pFont->m_pSubstFont->m_Family;
m_pSubstFont->m_ItalicAngle = pFont->m_pSubstFont->m_ItalicAngle;
@@ -331,7 +335,7 @@ bool CFX_Font::LoadFile(const RetainPtr<IFX_SeekableReadStream>& pFile,
int CFX_Font::GetGlyphWidth(uint32_t glyph_index) {
if (!m_Face)
return 0;
- if (m_pSubstFont && (m_pSubstFont->m_SubstFlags & FXFONT_SUBST_MM))
+ if (m_pSubstFont && m_pSubstFont->m_bFlagMM)
AdjustMMParams(glyph_index, 0, 0);
int err = FXFT_Load_Glyph(
m_Face, glyph_index,
@@ -590,7 +594,7 @@ CFX_PathData* CFX_Font::LoadGlyphPathImpl(uint32_t glyph_index,
else
ft_matrix.xy -= ft_matrix.xx * skew / 100;
}
- if (m_pSubstFont->m_SubstFlags & FXFONT_SUBST_MM)
+ if (m_pSubstFont->m_bFlagMM)
AdjustMMParams(glyph_index, dest_width, m_pSubstFont->m_Weight);
}
ScopedFontTransform scoped_transform(m_Face, &ft_matrix);
@@ -599,7 +603,7 @@ CFX_PathData* CFX_Font::LoadGlyphPathImpl(uint32_t glyph_index,
load_flags |= FT_LOAD_NO_HINTING;
if (FXFT_Load_Glyph(m_Face, glyph_index, load_flags))
return nullptr;
- if (m_pSubstFont && !(m_pSubstFont->m_SubstFlags & FXFONT_SUBST_MM) &&
+ if (m_pSubstFont && !m_pSubstFont->m_bFlagMM &&
m_pSubstFont->m_Weight > 400) {
uint32_t index = (m_pSubstFont->m_Weight - 400) / 10;
index = std::min(index, static_cast<uint32_t>(kWeightPowArraySize - 1));
diff --git a/core/fxge/cfx_fontmapper.cpp b/core/fxge/cfx_fontmapper.cpp
index ac840ea168..e7d27af573 100644
--- a/core/fxge/cfx_fontmapper.cpp
+++ b/core/fxge/cfx_fontmapper.cpp
@@ -391,7 +391,7 @@ FXFT_Face CFX_FontMapper::UseInternalSubst(CFX_SubstFont* pSubstFont,
return m_FoxitFaces[iBaseFont];
}
}
- pSubstFont->m_SubstFlags |= FXFONT_SUBST_MM;
+ pSubstFont->m_bFlagMM = true;
pSubstFont->m_ItalicAngle = italic_angle;
if (weight)
pSubstFont->m_Weight = weight;
@@ -626,7 +626,7 @@ FXFT_Face CFX_FontMapper::FindSubstFont(const ByteString& name,
void* hFont = m_pFontInfo->MapFont(weight, bItalic, Charset, PitchFamily,
family.c_str(), iExact);
if (iExact)
- pSubstFont->m_SubstFlags |= FXFONT_SUBST_EXACT;
+ pSubstFont->m_bFlagExact = true;
if (!hFont) {
#ifdef PDF_ENABLE_XFA
if (flags & FXFONT_EXACTMATCH)
diff --git a/core/fxge/cfx_substfont.cpp b/core/fxge/cfx_substfont.cpp
index 27d3bc3059..9058ab3d3c 100644
--- a/core/fxge/cfx_substfont.cpp
+++ b/core/fxge/cfx_substfont.cpp
@@ -11,9 +11,14 @@
CFX_SubstFont::CFX_SubstFont()
: m_Charset(FX_CHARSET_ANSI),
- m_SubstFlags(0),
m_Weight(0),
m_ItalicAngle(0),
- m_bSubstCJK(false),
m_WeightCJK(0),
- m_bItalicCJK(false) {}
+ m_bSubstCJK(false),
+ m_bItalicCJK(false),
+#ifdef PDF_ENABLE_XFA
+ m_bFlagItalic(false),
+#endif // PDF_ENABLE_XFA
+ m_bFlagMM(false),
+ m_bFlagExact(false) {
+}
diff --git a/core/fxge/cfx_substfont.h b/core/fxge/cfx_substfont.h
index 5225bd38f3..2076a09093 100644
--- a/core/fxge/cfx_substfont.h
+++ b/core/fxge/cfx_substfont.h
@@ -9,21 +9,23 @@
#include "core/fxcrt/fx_string.h"
-#define FXFONT_SUBST_MM 0x01
-#define FXFONT_SUBST_EXACT 0x40
-
class CFX_SubstFont {
public:
CFX_SubstFont();
ByteString m_Family;
int m_Charset;
- uint32_t m_SubstFlags;
int m_Weight;
int m_ItalicAngle;
- bool m_bSubstCJK;
int m_WeightCJK;
+ bool m_bSubstCJK;
bool m_bItalicCJK;
+
+#ifdef PDF_ENABLE_XFA
+ bool m_bFlagItalic;
+#endif // PDF_ENABLE_XFA
+ bool m_bFlagMM;
+ bool m_bFlagExact;
};
#endif // CORE_FXGE_CFX_SUBSTFONT_H_
diff --git a/core/fxge/fx_font.h b/core/fxge/fx_font.h
index 0271b78a22..8f559829b6 100644
--- a/core/fxge/fx_font.h
+++ b/core/fxge/fx_font.h
@@ -34,6 +34,7 @@ using CFX_TypeFace = SkTypeface;
#define FXFONT_FW_BOLD 700
/* Font styles as defined in PDF 1.7 Table 5.20 */
+#define FXFONT_NORMAL (0)
#define FXFONT_FIXED_PITCH (1 << 0)
#define FXFONT_SERIF (1 << 1)
#define FXFONT_SYMBOLIC (1 << 2)
@@ -43,6 +44,7 @@ using CFX_TypeFace = SkTypeface;
#define FXFONT_ALLCAP (1 << 16)
#define FXFONT_SMALLCAP (1 << 17)
#define FXFONT_BOLD (1 << 18)
+#define FXFONT_BOLD_ITALIC (FXFONT_BOLD | FXFONT_ITALIC)
/* Other font flags */
#define FXFONT_USEEXTERNATTR 0x80000
diff --git a/xfa/fde/cfde_textout.cpp b/xfa/fde/cfde_textout.cpp
index 8a1f56876c..2cdaeba27b 100644
--- a/xfa/fde/cfde_textout.cpp
+++ b/xfa/fde/cfde_textout.cpp
@@ -42,8 +42,7 @@ bool CFDE_TextOut::DrawString(CFX_RenderDevice* device,
ASSERT(pFont && pCharPos && iCount > 0);
CFX_Font* pFxFont = pFont->GetDevFont();
- if ((pFont->GetFontStyles() & FX_FONTSTYLE_Italic) != 0 &&
- !pFxFont->IsItalic()) {
+ if ((pFont->GetFontStyles() & FXFONT_ITALIC) != 0 && !pFxFont->IsItalic()) {
for (int32_t i = 0; i < iCount; ++i) {
static const float mc = 0.267949f;
float* pAM = pCharPos->m_AdjustMatrix;
@@ -57,10 +56,10 @@ bool CFDE_TextOut::DrawString(CFX_RenderDevice* device,
uint32_t dwFontStyle = pFont->GetFontStyles();
CFX_Font FxFont;
auto SubstFxFont = pdfium::MakeUnique<CFX_SubstFont>();
- SubstFxFont->m_Weight = dwFontStyle & FX_FONTSTYLE_Bold ? 700 : 400;
- SubstFxFont->m_ItalicAngle = dwFontStyle & FX_FONTSTYLE_Italic ? -12 : 0;
+ SubstFxFont->m_Weight = dwFontStyle & FXFONT_BOLD ? 700 : 400;
+ SubstFxFont->m_ItalicAngle = dwFontStyle & FXFONT_ITALIC ? -12 : 0;
SubstFxFont->m_WeightCJK = SubstFxFont->m_Weight;
- SubstFxFont->m_bItalicCJK = !!(dwFontStyle & FX_FONTSTYLE_Italic);
+ SubstFxFont->m_bItalicCJK = !!(dwFontStyle & FXFONT_ITALIC);
FxFont.SetSubstFont(std::move(SubstFxFont));
#endif // _FX_PLATFORM_ != _FX_PLATFORM_WINDOWS_
diff --git a/xfa/fgas/font/cfgas_defaultfontmanager.cpp b/xfa/fgas/font/cfgas_defaultfontmanager.cpp
index 6f39797927..322d06b384 100644
--- a/xfa/fgas/font/cfgas_defaultfontmanager.cpp
+++ b/xfa/fgas/font/cfgas_defaultfontmanager.cpp
@@ -24,10 +24,11 @@ RetainPtr<CFGAS_GEFont> CFGAS_DefaultFontManager::GetFont(
FGAS_FontInfoByFontName(wsFontName.AsStringView());
if (pCurFont && pCurFont->pReplaceFont) {
uint32_t dwStyle = 0;
- if (dwFontStyles & FX_FONTSTYLE_Bold)
- dwStyle |= FX_FONTSTYLE_Bold;
- if (dwFontStyles & FX_FONTSTYLE_Italic)
- dwStyle |= FX_FONTSTYLE_Italic;
+ // TODO(dsinclair): Why doesn't this check the other flags?
+ if (dwFontStyles & FXFONT_BOLD)
+ dwStyle |= FXFONT_BOLD;
+ if (dwFontStyles & FXFONT_ITALIC)
+ dwStyle |= FXFONT_ITALIC;
const wchar_t* pReplace = pCurFont->pReplaceFont;
int32_t iLength = wcslen(pReplace);
diff --git a/xfa/fgas/font/cfgas_fontmgr.cpp b/xfa/fgas/font/cfgas_fontmgr.cpp
index 1809a7a52c..e2fbd19ba5 100644
--- a/xfa/fgas/font/cfgas_fontmgr.cpp
+++ b/xfa/fgas/font/cfgas_fontmgr.cpp
@@ -16,6 +16,7 @@
#include "core/fxge/cfx_fontmapper.h"
#include "core/fxge/cfx_fontmgr.h"
#include "core/fxge/cfx_gemodule.h"
+#include "core/fxge/fx_font.h"
#include "core/fxge/ifx_systemfontinfo.h"
#include "third_party/base/ptr_util.h"
#include "third_party/base/stl_util.h"
@@ -23,7 +24,6 @@
#include "xfa/fgas/font/fgas_fontutils.h"
#if _FX_PLATFORM_ == _FX_PLATFORM_WINDOWS_
-
namespace {
struct FX_CHARSET_MAP {
@@ -86,22 +86,18 @@ uint16_t GetCodePageFromCharset(uint8_t charset) {
int32_t GetSimilarityScore(FX_FONTDESCRIPTOR const* pFont,
uint32_t dwFontStyles) {
int32_t iValue = 0;
- if ((dwFontStyles & FX_FONTSTYLE_Symbolic) ==
- (pFont->dwFontStyles & FX_FONTSTYLE_Symbolic)) {
+ if ((dwFontStyles & FXFONT_SYMBOLIC) ==
+ (pFont->dwFontStyles & FXFONT_SYMBOLIC)) {
iValue += 64;
}
- if ((dwFontStyles & FX_FONTSTYLE_FixedPitch) ==
- (pFont->dwFontStyles & FX_FONTSTYLE_FixedPitch)) {
+ if ((dwFontStyles & FXFONT_FIXED_PITCH) ==
+ (pFont->dwFontStyles & FXFONT_FIXED_PITCH)) {
iValue += 32;
}
- if ((dwFontStyles & FX_FONTSTYLE_Serif) ==
- (pFont->dwFontStyles & FX_FONTSTYLE_Serif)) {
+ if ((dwFontStyles & FXFONT_SERIF) == (pFont->dwFontStyles & FXFONT_SERIF))
iValue += 16;
- }
- if ((dwFontStyles & FX_FONTSTYLE_Script) ==
- (pFont->dwFontStyles & FX_FONTSTYLE_Script)) {
+ if ((dwFontStyles & FXFONT_SCRIPT) == (pFont->dwFontStyles & FXFONT_SCRIPT))
iValue += 8;
- }
return iValue;
}
@@ -110,12 +106,10 @@ const FX_FONTDESCRIPTOR* MatchDefaultFont(
const std::deque<FX_FONTDESCRIPTOR>& fonts) {
const FX_FONTDESCRIPTOR* pBestFont = nullptr;
int32_t iBestSimilar = 0;
- bool bMatchStyle = (pParams->dwMatchFlags & FX_FONTMATCHPARA_MatchStyle) > 0;
for (const auto& font : fonts) {
- if ((font.dwFontStyles & FX_FONTSTYLE_BoldItalic) ==
- FX_FONTSTYLE_BoldItalic) {
+ if ((font.dwFontStyles & FXFONT_BOLD_ITALIC) == FXFONT_BOLD_ITALIC)
continue;
- }
+
if (pParams->pwsFamily) {
if (FXSYS_wcsicmp(pParams->pwsFamily, font.wsFontFace))
continue;
@@ -135,7 +129,7 @@ const FX_FONTDESCRIPTOR* MatchDefaultFont(
continue;
}
}
- if (bMatchStyle) {
+ if (pParams->matchParagraphStyle) {
if ((font.dwFontStyles & 0x0F) == (pParams->dwFontStyles & 0x0F))
return &font;
continue;
@@ -155,17 +149,17 @@ const FX_FONTDESCRIPTOR* MatchDefaultFont(
uint32_t GetFontHashCode(uint16_t wCodePage, uint32_t dwFontStyles) {
uint32_t dwHash = wCodePage;
- if (dwFontStyles & FX_FONTSTYLE_FixedPitch)
+ if (dwFontStyles & FXFONT_FIXED_PITCH)
dwHash |= 0x00010000;
- if (dwFontStyles & FX_FONTSTYLE_Serif)
+ if (dwFontStyles & FXFONT_SERIF)
dwHash |= 0x00020000;
- if (dwFontStyles & FX_FONTSTYLE_Symbolic)
+ if (dwFontStyles & FXFONT_SYMBOLIC)
dwHash |= 0x00040000;
- if (dwFontStyles & FX_FONTSTYLE_Script)
+ if (dwFontStyles & FXFONT_SCRIPT)
dwHash |= 0x00080000;
- if (dwFontStyles & FX_FONTSTYLE_Italic)
+ if (dwFontStyles & FXFONT_ITALIC)
dwHash |= 0x00100000;
- if (dwFontStyles & FX_FONTSTYLE_Bold)
+ if (dwFontStyles & FXFONT_BOLD)
dwHash |= 0x00200000;
return dwHash;
}
@@ -174,9 +168,9 @@ uint32_t GetFontFamilyHash(const wchar_t* pszFontFamily,
uint32_t dwFontStyles,
uint16_t wCodePage) {
WideString wsFont(pszFontFamily);
- if (dwFontStyles & FX_FONTSTYLE_Bold)
+ if (dwFontStyles & FXFONT_BOLD)
wsFont += L"Bold";
- if (dwFontStyles & FX_FONTSTYLE_Italic)
+ if (dwFontStyles & FXFONT_ITALIC)
wsFont += L"Italic";
wsFont += wCodePage;
@@ -186,14 +180,14 @@ uint32_t GetFontFamilyHash(const wchar_t* pszFontFamily,
uint32_t GetGdiFontStyles(const LOGFONTW& lf) {
uint32_t dwStyles = 0;
if ((lf.lfPitchAndFamily & 0x03) == FIXED_PITCH)
- dwStyles |= FX_FONTSTYLE_FixedPitch;
+ dwStyles |= FXFONT_FIXED_PITCH;
uint8_t nFamilies = lf.lfPitchAndFamily & 0xF0;
if (nFamilies == FF_ROMAN)
- dwStyles |= FX_FONTSTYLE_Serif;
+ dwStyles |= FXFONT_SERIF;
if (nFamilies == FF_SCRIPT)
- dwStyles |= FX_FONTSTYLE_Script;
+ dwStyles |= FXFONT_SCRIPT;
if (lf.lfCharSet == SYMBOL_CHARSET)
- dwStyles |= FX_FONTSTYLE_Symbolic;
+ dwStyles |= FXFONT_SYMBOLIC;
return dwStyles;
}
@@ -399,7 +393,7 @@ void CFGAS_FontMgr::RemoveFont(const RetainPtr<CFGAS_GEFont>& pFont) {
const FX_FONTDESCRIPTOR* CFGAS_FontMgr::FindFont(const wchar_t* pszFontFamily,
uint32_t dwFontStyles,
- uint32_t dwMatchFlags,
+ bool matchParagraphStyle,
uint16_t wCodePage,
uint32_t dwUSB,
wchar_t wUnicode) {
@@ -410,7 +404,7 @@ const FX_FONTDESCRIPTOR* CFGAS_FontMgr::FindFont(const wchar_t* pszFontFamily,
params.wCodePage = wCodePage;
params.pwsFamily = pszFontFamily;
params.dwFontStyles = dwFontStyles;
- params.dwMatchFlags = dwMatchFlags;
+ params.matchParagraphStyle = matchParagraphStyle;
const FX_FONTDESCRIPTOR* pDesc = MatchDefaultFont(&params, m_FontFaces);
if (pDesc)
return pDesc;
@@ -1046,15 +1040,15 @@ int32_t CFGAS_FontMgr::CalcPenalty(CFX_FontDescriptor* pInstalled,
}
}
uint32_t dwStyleMask = pInstalled->m_dwFontStyles ^ dwFontStyles;
- if (dwStyleMask & FX_FONTSTYLE_Bold)
+ if (dwStyleMask & FXFONT_BOLD)
nPenalty += 4500;
- if (dwStyleMask & FX_FONTSTYLE_FixedPitch)
+ if (dwStyleMask & FXFONT_FIXED_PITCH)
nPenalty += 10000;
- if (dwStyleMask & FX_FONTSTYLE_Italic)
+ if (dwStyleMask & FXFONT_ITALIC)
nPenalty += 10000;
- if (dwStyleMask & FX_FONTSTYLE_Serif)
+ if (dwStyleMask & FXFONT_SERIF)
nPenalty += 500;
- if (dwStyleMask & FX_FONTSTYLE_Symbolic)
+ if (dwStyleMask & FXFONT_SYMBOLIC)
nPenalty += 0xFFFF;
if (nPenalty >= 0xFFFF)
return 0xFFFF;
@@ -1107,8 +1101,8 @@ void CFGAS_FontMgr::RegisterFace(FXFT_Face pFace, const WideString* pFaceName) {
return;
auto pFont = pdfium::MakeUnique<CFX_FontDescriptor>();
- pFont->m_dwFontStyles |= FXFT_Is_Face_Bold(pFace) ? FX_FONTSTYLE_Bold : 0;
- pFont->m_dwFontStyles |= FXFT_Is_Face_Italic(pFace) ? FX_FONTSTYLE_Italic : 0;
+ pFont->m_dwFontStyles |= FXFT_Is_Face_Bold(pFace) ? FXFONT_BOLD : 0;
+ pFont->m_dwFontStyles |= FXFT_Is_Face_Italic(pFace) ? FXFONT_ITALIC : 0;
pFont->m_dwFontStyles |= GetFlags(pFace);
std::vector<uint16_t> charsets = GetCharsets(pFace);
@@ -1156,17 +1150,17 @@ void CFGAS_FontMgr::RegisterFaces(
uint32_t CFGAS_FontMgr::GetFlags(FXFT_Face pFace) {
uint32_t flag = 0;
if (FT_IS_FIXED_WIDTH(pFace))
- flag |= FX_FONTSTYLE_FixedPitch;
+ flag |= FXFONT_FIXED_PITCH;
TT_OS2* pOS2 = (TT_OS2*)FT_Get_Sfnt_Table(pFace, ft_sfnt_os2);
if (!pOS2)
return flag;
if (pOS2->ulCodePageRange1 & (1 << 31))
- flag |= FX_FONTSTYLE_Symbolic;
+ flag |= FXFONT_SYMBOLIC;
if (pOS2->panose[0] == 2) {
uint8_t uSerif = pOS2->panose[1];
if ((uSerif > 1 && uSerif < 10) || uSerif > 13)
- flag |= FX_FONTSTYLE_Serif;
+ flag |= FXFONT_SERIF;
}
return flag;
}
diff --git a/xfa/fgas/font/cfgas_fontmgr.h b/xfa/fgas/font/cfgas_fontmgr.h
index b97c4b219d..f1e75bad95 100644
--- a/xfa/fgas/font/cfgas_fontmgr.h
+++ b/xfa/fgas/font/cfgas_fontmgr.h
@@ -23,27 +23,15 @@
#include "core/fxge/ifx_systemfontinfo.h"
#include "xfa/fgas/font/cfgas_pdffontmgr.h"
-#define FX_FONTSTYLE_Normal 0x00
-#define FX_FONTSTYLE_FixedPitch 0x01
-#define FX_FONTSTYLE_Serif 0x02
-#define FX_FONTSTYLE_Symbolic 0x04
-#define FX_FONTSTYLE_Script 0x08
-#define FX_FONTSTYLE_Italic 0x40
-#define FX_FONTSTYLE_Bold 0x40000
-#define FX_FONTSTYLE_BoldItalic (FX_FONTSTYLE_Bold | FX_FONTSTYLE_Italic)
-#define FX_FONTSTYLE_ExactMatch 0x80000000
-
class CFX_FontSourceEnum_File;
class CFGAS_GEFont;
#if _FX_PLATFORM_ == _FX_PLATFORM_WINDOWS_
-#define FX_FONTMATCHPARA_MatchStyle 0x01
-
struct FX_FONTMATCHPARAMS {
const wchar_t* pwsFamily;
uint32_t dwFontStyles;
uint32_t dwUSB;
- uint32_t dwMatchFlags;
+ bool matchParagraphStyle;
wchar_t wUnicode;
uint16_t wCodePage;
};
@@ -165,7 +153,7 @@ class CFGAS_FontMgr : public Observable<CFGAS_FontMgr> {
const RetainPtr<CFGAS_GEFont>& pFont);
const FX_FONTDESCRIPTOR* FindFont(const wchar_t* pszFontFamily,
uint32_t dwFontStyles,
- uint32_t dwMatchFlags,
+ bool matchParagraphStyle,
uint16_t wCodePage,
uint32_t dwUSB,
wchar_t wUnicode);
diff --git a/xfa/fgas/font/cfgas_gefont.cpp b/xfa/fgas/font/cfgas_gefont.cpp
index 58b1381a38..f364e6c506 100644
--- a/xfa/fgas/font/cfgas_gefont.cpp
+++ b/xfa/fgas/font/cfgas_gefont.cpp
@@ -85,9 +85,9 @@ CFGAS_GEFont::CFGAS_GEFont(const RetainPtr<CFGAS_GEFont>& src,
m_pFont->SetSubstFont(std::unique_ptr<CFX_SubstFont>(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;
+ (dwFontStyles & FXFONT_BOLD) ? FXFONT_FW_BOLD : FXFONT_FW_NORMAL;
+ if (dwFontStyles & FXFONT_ITALIC)
+ pSubst->m_bFlagItalic = true;
InitFont();
}
@@ -105,31 +105,19 @@ bool CFGAS_GEFont::LoadFontInternal(const wchar_t* pszFontFamily,
ByteString csFontFamily;
if (pszFontFamily)
csFontFamily = 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;
+ (dwFontStyles & FXFONT_BOLD) ? FXFONT_FW_BOLD : FXFONT_FW_NORMAL;
m_pFont = new CFX_Font;
- if ((dwFlags & FXFONT_ITALIC) && (dwFlags & FXFONT_BOLD))
+ if ((dwFontStyles & FXFONT_ITALIC) && (dwFontStyles & FXFONT_BOLD))
csFontFamily += ",BoldItalic";
- else if (dwFlags & FXFONT_BOLD)
+ else if (dwFontStyles & FXFONT_BOLD)
csFontFamily += ",Bold";
- else if (dwFlags & FXFONT_ITALIC)
+ else if (dwFontStyles & FXFONT_ITALIC)
csFontFamily += ",Italic";
- m_pFont->LoadSubst(csFontFamily, true, dwFlags, iWeight, 0, wCodePage, false);
+
+ m_pFont->LoadSubst(csFontFamily, true, dwFontStyles, iWeight, 0, wCodePage,
+ false);
if (!m_pFont->GetFace())
return false;
return InitFont();
@@ -195,14 +183,14 @@ uint32_t CFGAS_GEFont::GetFontStyles() const {
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;
+ dwStyles |= FXFONT_BOLD;
+ if (pSubstFont->m_bFlagItalic)
+ dwStyles |= FXFONT_ITALIC;
} else {
if (m_pFont->IsBold())
- dwStyles |= FX_FONTSTYLE_Bold;
+ dwStyles |= FXFONT_BOLD;
if (m_pFont->IsItalic())
- dwStyles |= FX_FONTSTYLE_Italic;
+ dwStyles |= FXFONT_ITALIC;
}
return dwStyles;
}
diff --git a/xfa/fgas/font/cfgas_gefont.h b/xfa/fgas/font/cfgas_gefont.h
index a1d6b82cb6..2e63ee5367 100644
--- a/xfa/fgas/font/cfgas_gefont.h
+++ b/xfa/fgas/font/cfgas_gefont.h
@@ -18,8 +18,6 @@
#include "xfa/fgas/font/cfgas_fontmgr.h"
#include "xfa/fgas/font/cfgas_pdffontmgr.h"
-#define FXFONT_SUBST_ITALIC 0x02
-
class CFGAS_FontMgr;
class CFX_UnicodeEncoding;
@@ -77,9 +75,9 @@ class CFGAS_GEFont : public Retainable {
bool LoadFontInternal(const uint8_t* pBuffer, int32_t length);
bool LoadFontInternal(const RetainPtr<CFX_SeekableStreamProxy>& pFontStream,
bool bSaveStream);
-#endif
- bool LoadFontInternal(CFX_Font* pExternalFont);
+#endif // _FX_PLATFORM_ == _FX_PLATFORM_WINDOWS_
bool LoadFontInternal(std::unique_ptr<CFX_Font> pInternalFont);
+ bool LoadFontInternal(CFX_Font* pExternalFont);
bool InitFont();
std::pair<int32_t, RetainPtr<CFGAS_GEFont>> GetGlyphIndexAndFont(
wchar_t wUnicode,
diff --git a/xfa/fgas/font/cfgas_pdffontmgr.cpp b/xfa/fgas/font/cfgas_pdffontmgr.cpp
index a860d05a5a..34d4ff1649 100644
--- a/xfa/fgas/font/cfgas_pdffontmgr.cpp
+++ b/xfa/fgas/font/cfgas_pdffontmgr.cpp
@@ -85,8 +85,8 @@ RetainPtr<CFGAS_GEFont> CFGAS_PDFFontMgr::GetFont(
return it->second;
ByteString bsPsName = ByteString::FromUnicode(WideString(wsFontFamily));
- bool bBold = (dwFontStyles & FX_FONTSTYLE_Bold) == FX_FONTSTYLE_Bold;
- bool bItalic = (dwFontStyles & FX_FONTSTYLE_Italic) == FX_FONTSTYLE_Italic;
+ bool bBold = (dwFontStyles & FXFONT_BOLD) == FXFONT_BOLD;
+ bool bItalic = (dwFontStyles & FXFONT_ITALIC) == FXFONT_ITALIC;
ByteString strFontName = PsNameToFontName(bsPsName, bBold, bItalic);
RetainPtr<CFGAS_GEFont> pFont =
FindFont(strFontName, bBold, bItalic, pPDFFont, bStrictMatch);
diff --git a/xfa/fxfa/cxfa_textparser.cpp b/xfa/fxfa/cxfa_textparser.cpp
index 35e9b01580..af9a274a94 100644
--- a/xfa/fxfa/cxfa_textparser.cpp
+++ b/xfa/fxfa/cxfa_textparser.cpp
@@ -324,9 +324,9 @@ RetainPtr<CFGAS_GEFont> CXFA_TextParser::GetFont(
if (font) {
font.GetTypeface(wsFamily);
if (font.IsBold())
- dwStyle |= FX_FONTSTYLE_Bold;
+ dwStyle |= FXFONT_BOLD;
if (font.IsItalic())
- dwStyle |= FX_FONTSTYLE_Italic;
+ dwStyle |= FXFONT_BOLD;
}
if (pStyle) {
@@ -336,9 +336,9 @@ RetainPtr<CFGAS_GEFont> CXFA_TextParser::GetFont(
dwStyle = 0;
if (pStyle->GetFontWeight() > FXFONT_FW_NORMAL)
- dwStyle |= FX_FONTSTYLE_Bold;
+ dwStyle |= FXFONT_BOLD;
if (pStyle->GetFontStyle() == CFX_CSSFontStyle::Italic)
- dwStyle |= FX_FONTSTYLE_Italic;
+ dwStyle |= FXFONT_ITALIC;
}
CXFA_FFDoc* pDoc = pTextProvider->GetDocNode();
diff --git a/xfa/fxfa/cxfa_widgetacc.cpp b/xfa/fxfa/cxfa_widgetacc.cpp
index 260581e73b..82eec9e16d 100644
--- a/xfa/fxfa/cxfa_widgetacc.cpp
+++ b/xfa/fxfa/cxfa_widgetacc.cpp
@@ -1497,9 +1497,9 @@ RetainPtr<CFGAS_GEFont> CXFA_WidgetAcc::GetFDEFont() {
uint32_t dwFontStyle = 0;
if (CXFA_Font font = GetFont(false)) {
if (font.IsBold())
- dwFontStyle |= FX_FONTSTYLE_Bold;
+ dwFontStyle |= FXFONT_BOLD;
if (font.IsItalic())
- dwFontStyle |= FX_FONTSTYLE_Italic;
+ dwFontStyle |= FXFONT_ITALIC;
font.GetTypeface(wsFontName);
}