Rename FXFONT_BOLD flag to FXFONT_FORCE_BOLD.
Better reflect what the PDF spec actually says, so readers do not look
at the flag name and misinterpret what it means. Similarly, rename
FontStyleIsBold() to FontStyleIsForceBold().
Change-Id: Ie9bde3b5fff5ed0e499a3c1fc655cb2fa062b646
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/61591
Reviewed-by: Henrique Nakashima <hnakashima@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
diff --git a/core/fpdfapi/page/cpdf_docpagedata.cpp b/core/fpdfapi/page/cpdf_docpagedata.cpp
index 5cec27a..19d205e 100644
--- a/core/fpdfapi/page/cpdf_docpagedata.cpp
+++ b/core/fpdfapi/page/cpdf_docpagedata.cpp
@@ -100,7 +100,7 @@
bool symbolic) {
int flags = 0;
if (bold)
- flags |= FXFONT_BOLD;
+ flags |= FXFONT_FORCE_BOLD;
if (italic)
flags |= FXFONT_ITALIC;
if (fixedPitch)
diff --git a/core/fxge/android/cfpf_skiafontmgr.cpp b/core/fxge/android/cfpf_skiafontmgr.cpp
index dc84f26..2420ea5 100644
--- a/core/fxge/android/cfpf_skiafontmgr.cpp
+++ b/core/fxge/android/cfpf_skiafontmgr.cpp
@@ -152,7 +152,7 @@
uint32_t dwStyle,
uint8_t uCharset) {
ByteString bsFont(bsFamily);
- if (FontStyleIsBold(dwStyle))
+ if (FontStyleIsForceBold(dwStyle))
bsFont += "Bold";
if (FontStyleIsItalic(dwStyle))
bsFont += "Italic";
@@ -289,7 +289,7 @@
if (dwFaceName == dwSysFontName)
nFind += FPF_SKIAMATCHWEIGHT_NAME1;
bool bMatchedName = (nFind == FPF_SKIAMATCHWEIGHT_NAME1);
- if (FontStyleIsBold(dwStyle) == FontStyleIsBold(pFont->style()))
+ if (FontStyleIsForceBold(dwStyle) == FontStyleIsForceBold(pFont->style()))
nFind += FPF_SKIAMATCHWEIGHT_1;
if (FontStyleIsItalic(dwStyle) == FontStyleIsItalic(pFont->style()))
nFind += FPF_SKIAMATCHWEIGHT_1;
@@ -398,7 +398,7 @@
const ByteString& file) {
uint32_t dwStyle = 0;
if (FXFT_Is_Face_Bold(face->GetRec()))
- dwStyle |= FXFONT_BOLD;
+ dwStyle |= FXFONT_FORCE_BOLD;
if (FXFT_Is_Face_Italic(face->GetRec()))
dwStyle |= FXFONT_ITALIC;
if (FT_IS_FIXED_WIDTH(face->GetRec()))
diff --git a/core/fxge/android/cfx_androidfontinfo.cpp b/core/fxge/android/cfx_androidfontinfo.cpp
index b033eab..206003d 100644
--- a/core/fxge/android/cfx_androidfontinfo.cpp
+++ b/core/fxge/android/cfx_androidfontinfo.cpp
@@ -37,7 +37,7 @@
uint32_t dwStyle = 0;
if (weight >= 700)
- dwStyle |= FXFONT_BOLD;
+ dwStyle |= FXFONT_FORCE_BOLD;
if (bItalic)
dwStyle |= FXFONT_ITALIC;
if (FontFamilyIsFixedPitch(pitch_family))
diff --git a/core/fxge/cfx_folderfontinfo.cpp b/core/fxge/cfx_folderfontinfo.cpp
index f2145a0..d1212ac 100644
--- a/core/fxge/cfx_folderfontinfo.cpp
+++ b/core/fxge/cfx_folderfontinfo.cpp
@@ -110,7 +110,7 @@
int pitch_family,
uint32_t style) {
int32_t iSimilarValue = 0;
- if (FontStyleIsBold(style) == (weight > 400))
+ if (FontStyleIsForceBold(style) == (weight > 400))
iSimilarValue += 16;
if (FontStyleIsItalic(style) == bItalic)
iSimilarValue += 16;
@@ -270,7 +270,7 @@
pInfo->m_Charsets |= CHARSET_FLAG_ANSI;
pInfo->m_Styles = 0;
if (style.Contains("Bold"))
- pInfo->m_Styles |= FXFONT_BOLD;
+ pInfo->m_Styles |= FXFONT_FORCE_BOLD;
if (style.Contains("Italic") || style.Contains("Oblique"))
pInfo->m_Styles |= FXFONT_ITALIC;
if (facename.Contains("Serif"))
diff --git a/core/fxge/cfx_fontmapper.cpp b/core/fxge/cfx_fontmapper.cpp
index 2cf2ebb..6c2dac7 100644
--- a/core/fxge/cfx_fontmapper.cpp
+++ b/core/fxge/cfx_fontmapper.cpp
@@ -174,7 +174,7 @@
void GetFontFamily(uint32_t nStyle, ByteString* fontName) {
if (fontName->Contains("Script")) {
- if (FontStyleIsBold(nStyle))
+ if (FontStyleIsForceBold(nStyle))
*fontName = "ScriptMTBold";
else if (fontName->Contains("Palace"))
*fontName = "PalaceScriptMT";
@@ -210,9 +210,9 @@
size_t len;
uint32_t style;
} g_FontStyles[] = {
- {"Bold", 4, FXFONT_BOLD},
+ {"Bold", 4, FXFONT_FORCE_BOLD},
{"Italic", 6, FXFONT_ITALIC},
- {"BoldItalic", 10, FXFONT_BOLD | FXFONT_ITALIC},
+ {"BoldItalic", 10, FXFONT_FORCE_BOLD | FXFONT_ITALIC},
{"Reg", 3, FXFONT_NORMAL},
{"Regular", 7, FXFONT_NORMAL},
};
@@ -435,7 +435,7 @@
bool bStyleAvail = false;
if (iBaseFont < 12) {
if ((iBaseFont % 4) == 1 || (iBaseFont % 4) == 2)
- nStyle |= FXFONT_BOLD;
+ nStyle |= FXFONT_FORCE_BOLD;
if ((iBaseFont % 4) / 2)
nStyle |= FXFONT_ITALIC;
if (iBaseFont < 4)
@@ -467,7 +467,7 @@
}
const int old_weight = weight;
- if (FontStyleIsBold(nStyle))
+ if (FontStyleIsForceBold(nStyle))
weight = FXFONT_FW_BOLD;
if (!style.IsEmpty()) {
@@ -491,18 +491,18 @@
if (hasStyleType)
bStyleAvail = true;
- if (FontStyleIsBold(styleType)) {
+ if (FontStyleIsForceBold(styleType)) {
// If we're already bold, then we're double bold, use special weight.
- if (FontStyleIsBold(nStyle)) {
+ if (FontStyleIsForceBold(nStyle)) {
weight = FXFONT_FW_BOLD_BOLD;
} else {
weight = FXFONT_FW_BOLD;
- nStyle |= FXFONT_BOLD;
+ nStyle |= FXFONT_FORCE_BOLD;
}
bFirstItem = false;
}
- if (FontStyleIsItalic(styleType) && FontStyleIsBold(styleType)) {
+ if (FontStyleIsItalic(styleType) && FontStyleIsForceBold(styleType)) {
nStyle |= FXFONT_ITALIC;
} else if (FontStyleIsItalic(styleType)) {
if (bFirstItem) {
@@ -566,9 +566,9 @@
family = match;
if (iBaseFont < kNumStandardFonts) {
if (nStyle && !(iBaseFont % 4)) {
- if (FontStyleIsBold(nStyle) && FontStyleIsItalic(nStyle))
+ if (FontStyleIsForceBold(nStyle) && FontStyleIsItalic(nStyle))
iBaseFont += 2;
- else if (FontStyleIsBold(nStyle))
+ else if (FontStyleIsForceBold(nStyle))
iBaseFont += 1;
else if (FontStyleIsItalic(nStyle))
iBaseFont += 3;
diff --git a/core/fxge/fx_font.h b/core/fxge/fx_font.h
index 78bed86..b748d55 100644
--- a/core/fxge/fx_font.h
+++ b/core/fxge/fx_font.h
@@ -35,7 +35,7 @@
#define FXFONT_ITALIC (1 << 6)
#define FXFONT_ALLCAP (1 << 16)
#define FXFONT_SMALLCAP (1 << 17)
-#define FXFONT_BOLD (1 << 18)
+#define FXFONT_FORCE_BOLD (1 << 18)
/* Other font flags */
#define FXFONT_USEEXTERNATTR 0x80000
@@ -58,8 +58,8 @@
ByteString GetNameFromTT(pdfium::span<const uint8_t> name_table, uint32_t name);
int GetTTCIndex(pdfium::span<const uint8_t> pFontData, uint32_t font_offset);
-inline bool FontStyleIsBold(uint32_t style) {
- return !!(style & FXFONT_BOLD);
+inline bool FontStyleIsForceBold(uint32_t style) {
+ return !!(style & FXFONT_FORCE_BOLD);
}
inline bool FontStyleIsItalic(uint32_t style) {
return !!(style & FXFONT_ITALIC);
diff --git a/fpdfsdk/fpdf_edit_embeddertest.cpp b/fpdfsdk/fpdf_edit_embeddertest.cpp
index 4c08626..f743406 100644
--- a/fpdfsdk/fpdf_edit_embeddertest.cpp
+++ b/fpdfsdk/fpdf_edit_embeddertest.cpp
@@ -54,7 +54,7 @@
ASSERT_TRUE(font_desc->KeyExist("Flags"));
int font_flags = font_desc->GetIntegerFor("Flags");
- EXPECT_EQ(bold, FontStyleIsBold(font_flags));
+ EXPECT_EQ(bold, FontStyleIsForceBold(font_flags));
EXPECT_EQ(italic, FontStyleIsItalic(font_flags));
EXPECT_TRUE(FontStyleIsNonSymbolic(font_flags));
ASSERT_TRUE(font_desc->KeyExist("FontBBox"));
diff --git a/fpdfsdk/fpdf_edittext.cpp b/fpdfsdk/fpdf_edittext.cpp
index 5d19781..366d6c1 100644
--- a/fpdfsdk/fpdf_edittext.cpp
+++ b/fpdfsdk/fpdf_edittext.cpp
@@ -73,7 +73,7 @@
if (FXFT_Is_Face_Italic(pFont->GetFaceRec()))
flags |= FXFONT_ITALIC;
if (FXFT_Is_Face_Bold(pFont->GetFaceRec()))
- flags |= FXFONT_BOLD;
+ flags |= FXFONT_FORCE_BOLD;
// TODO(npm): How do I know if a font is symbolic, script, allcap, smallcap
flags |= FXFONT_NONSYMBOLIC;
diff --git a/xfa/fde/cfde_textout.cpp b/xfa/fde/cfde_textout.cpp
index cc7d6dc..c03f5b9 100644
--- a/xfa/fde/cfde_textout.cpp
+++ b/xfa/fde/cfde_textout.cpp
@@ -60,7 +60,7 @@
uint32_t dwFontStyle = pFont->GetFontStyles();
CFX_Font FxFont;
auto SubstFxFont = pdfium::MakeUnique<CFX_SubstFont>();
- SubstFxFont->m_Weight = FontStyleIsBold(dwFontStyle) ? 700 : 400;
+ SubstFxFont->m_Weight = FontStyleIsForceBold(dwFontStyle) ? 700 : 400;
SubstFxFont->m_ItalicAngle = FontStyleIsItalic(dwFontStyle) ? -12 : 0;
SubstFxFont->m_WeightCJK = SubstFxFont->m_Weight;
SubstFxFont->m_bItalicCJK = FontStyleIsItalic(dwFontStyle);
diff --git a/xfa/fgas/font/cfgas_defaultfontmanager.cpp b/xfa/fgas/font/cfgas_defaultfontmanager.cpp
index 6f5e566..239dfa7 100644
--- a/xfa/fgas/font/cfgas_defaultfontmanager.cpp
+++ b/xfa/fgas/font/cfgas_defaultfontmanager.cpp
@@ -28,8 +28,8 @@
uint32_t dwStyle = 0;
// TODO(dsinclair): Why doesn't this check the other flags?
- if (FontStyleIsBold(dwFontStyles))
- dwStyle |= FXFONT_BOLD;
+ if (FontStyleIsForceBold(dwFontStyles))
+ dwStyle |= FXFONT_FORCE_BOLD;
if (FontStyleIsItalic(dwFontStyles))
dwStyle |= FXFONT_ITALIC;
diff --git a/xfa/fgas/font/cfgas_fontmgr.cpp b/xfa/fgas/font/cfgas_fontmgr.cpp
index bdd5ddc..4058f7a 100644
--- a/xfa/fgas/font/cfgas_fontmgr.cpp
+++ b/xfa/fgas/font/cfgas_fontmgr.cpp
@@ -77,7 +77,7 @@
const FX_FONTDESCRIPTOR* pBestFont = nullptr;
int32_t iBestSimilar = 0;
for (const auto& font : fonts) {
- if (FontStyleIsBold(font.dwFontStyles) &&
+ if (FontStyleIsForceBold(font.dwFontStyles) &&
FontStyleIsItalic(font.dwFontStyles)) {
continue;
}
@@ -424,7 +424,7 @@
uint32_t GetFlags(FXFT_FaceRec* pFace) {
uint32_t flags = 0;
if (FXFT_Is_Face_Bold(pFace))
- flags |= FXFONT_BOLD;
+ flags |= FXFONT_FORCE_BOLD;
if (FXFT_Is_Face_Italic(pFace))
flags |= FXFONT_ITALIC;
if (FT_IS_FIXED_WIDTH(pFace))
@@ -579,7 +579,7 @@
}
}
uint32_t dwStyleMask = pInstalled->m_dwFontStyles ^ dwFontStyles;
- if (FontStyleIsBold(dwStyleMask))
+ if (FontStyleIsForceBold(dwStyleMask))
nPenalty += 4500;
if (FontStyleIsFixedPitch(dwStyleMask))
nPenalty += 10000;
diff --git a/xfa/fgas/font/cfgas_gefont.cpp b/xfa/fgas/font/cfgas_gefont.cpp
index 3f4c886..69aa702 100644
--- a/xfa/fgas/font/cfgas_gefont.cpp
+++ b/xfa/fgas/font/cfgas_gefont.cpp
@@ -82,11 +82,11 @@
csFontFamily = WideString(pszFontFamily).ToDefANSI();
int32_t iWeight =
- FontStyleIsBold(dwFontStyles) ? FXFONT_FW_BOLD : FXFONT_FW_NORMAL;
+ FontStyleIsForceBold(dwFontStyles) ? FXFONT_FW_BOLD : FXFONT_FW_NORMAL;
m_pFont = pdfium::MakeUnique<CFX_Font>();
- if (FontStyleIsItalic(dwFontStyles) && FontStyleIsBold(dwFontStyles))
+ if (FontStyleIsItalic(dwFontStyles) && FontStyleIsForceBold(dwFontStyles))
csFontFamily += ",BoldItalic";
- else if (FontStyleIsBold(dwFontStyles))
+ else if (FontStyleIsForceBold(dwFontStyles))
csFontFamily += ",Bold";
else if (FontStyleIsItalic(dwFontStyles))
csFontFamily += ",Italic";
@@ -147,10 +147,10 @@
auto* pSubstFont = m_pFont->GetSubstFont();
if (pSubstFont) {
if (pSubstFont->m_Weight == FXFONT_FW_BOLD)
- dwStyles |= FXFONT_BOLD;
+ dwStyles |= FXFONT_FORCE_BOLD;
} else {
if (m_pFont->IsBold())
- dwStyles |= FXFONT_BOLD;
+ dwStyles |= FXFONT_FORCE_BOLD;
if (m_pFont->IsItalic())
dwStyles |= FXFONT_ITALIC;
}
diff --git a/xfa/fgas/font/cfgas_pdffontmgr.cpp b/xfa/fgas/font/cfgas_pdffontmgr.cpp
index e020007..b67c449 100644
--- a/xfa/fgas/font/cfgas_pdffontmgr.cpp
+++ b/xfa/fgas/font/cfgas_pdffontmgr.cpp
@@ -83,7 +83,7 @@
return it->second;
ByteString bsPsName = WideString(wsFontFamily).ToDefANSI();
- bool bBold = FontStyleIsBold(dwFontStyles);
+ bool bBold = FontStyleIsForceBold(dwFontStyles);
bool bItalic = FontStyleIsItalic(dwFontStyles);
ByteString strFontName = PsNameToFontName(bsPsName, bBold, bItalic);
RetainPtr<CFGAS_GEFont> pFont =
diff --git a/xfa/fxfa/cxfa_textparser.cpp b/xfa/fxfa/cxfa_textparser.cpp
index 2acc820..61b9a28 100644
--- a/xfa/fxfa/cxfa_textparser.cpp
+++ b/xfa/fxfa/cxfa_textparser.cpp
@@ -345,9 +345,9 @@
if (font) {
wsFamily = font->GetTypeface();
if (font->IsBold())
- dwStyle |= FXFONT_BOLD;
+ dwStyle |= FXFONT_FORCE_BOLD;
if (font->IsItalic())
- dwStyle |= FXFONT_BOLD;
+ dwStyle |= FXFONT_FORCE_BOLD;
}
if (pStyle) {
@@ -357,7 +357,7 @@
dwStyle = 0;
if (pStyle->GetFontWeight() > FXFONT_FW_NORMAL)
- dwStyle |= FXFONT_BOLD;
+ dwStyle |= FXFONT_FORCE_BOLD;
if (pStyle->GetFontStyle() == CFX_CSSFontStyle::Italic)
dwStyle |= FXFONT_ITALIC;
}
diff --git a/xfa/fxfa/parser/cxfa_node.cpp b/xfa/fxfa/parser/cxfa_node.cpp
index 59d5b73..7c69295 100644
--- a/xfa/fxfa/parser/cxfa_node.cpp
+++ b/xfa/fxfa/parser/cxfa_node.cpp
@@ -3867,7 +3867,7 @@
CXFA_Font* font = GetFontIfExists();
if (font) {
if (font->IsBold())
- dwFontStyle |= FXFONT_BOLD;
+ dwFontStyle |= FXFONT_FORCE_BOLD;
if (font->IsItalic())
dwFontStyle |= FXFONT_ITALIC;