summaryrefslogtreecommitdiff
path: root/core/fxge
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 /core/fxge
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>
Diffstat (limited to 'core/fxge')
-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
6 files changed, 29 insertions, 17 deletions
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