Fix nits in CFX_FontMapper.
- Use Google style variable names consistently in more places.
- Make UseInternalSubst()'s parameter ordering match that of
FindSubstFont().
- Replace numbers with StandardFont enum values where applicable.
Change-Id: Ie97699980884504e8d6f6e18f1cd2a8de72ad488
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/91934
Reviewed-by: Nigi <nigi@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
diff --git a/core/fxge/cfx_fontmapper.cpp b/core/fxge/cfx_fontmapper.cpp
index b9c9dc8..c5275a1 100644
--- a/core/fxge/cfx_fontmapper.cpp
+++ b/core/fxge/cfx_fontmapper.cpp
@@ -217,7 +217,7 @@
// <exists, index, length>
std::tuple<bool, uint32_t, size_t> GetStyleType(const ByteString& bsStyle,
- bool bReverse) {
+ bool reverse_search) {
if (bsStyle.IsEmpty())
return std::make_tuple(false, FXFONT_NORMAL, 0);
@@ -226,7 +226,7 @@
if (!pStyle || pStyle->len > bsStyle.GetLength())
continue;
- if (bReverse) {
+ if (reverse_search) {
if (bsStyle.Last(pStyle->len) == pStyle->name)
return std::make_tuple(true, pStyle->style, pStyle->len);
} else {
@@ -237,20 +237,20 @@
return std::make_tuple(false, FXFONT_NORMAL, 0);
}
-bool CheckSupportThirdPartFont(const ByteString& name, int* PitchFamily) {
+bool CheckSupportThirdPartFont(const ByteString& name, int* pitch_family) {
if (name != "MyriadPro")
return false;
- *PitchFamily &= ~FXFONT_FF_ROMAN;
+ *pitch_family &= ~FXFONT_FF_ROMAN;
return true;
}
-void UpdatePitchFamily(uint32_t flags, int* PitchFamily) {
+void UpdatePitchFamily(uint32_t flags, int* pitch_family) {
if (FontStyleIsSerif(flags))
- *PitchFamily |= FXFONT_FF_ROMAN;
+ *pitch_family |= FXFONT_FF_ROMAN;
if (FontStyleIsScript(flags))
- *PitchFamily |= FXFONT_FF_SCRIPT;
+ *pitch_family |= FXFONT_FF_SCRIPT;
if (FontStyleIsFixedPitch(flags))
- *PitchFamily |= FXFONT_FF_FIXEDPITCH;
+ *pitch_family |= FXFONT_FF_FIXEDPITCH;
}
bool IsStrUpper(const ByteString& str) {
@@ -303,10 +303,11 @@
return std::move(m_pFontInfo);
}
-uint32_t CFX_FontMapper::GetChecksumFromTT(void* hFont) {
+uint32_t CFX_FontMapper::GetChecksumFromTT(void* font_handle) {
uint32_t buffer[256];
m_pFontInfo->GetFontData(
- hFont, kTableTTCF, pdfium::as_writable_bytes(pdfium::make_span(buffer)));
+ font_handle, kTableTTCF,
+ pdfium::as_writable_bytes(pdfium::make_span(buffer)));
uint32_t checksum = 0;
for (auto x : buffer)
@@ -315,13 +316,13 @@
return checksum;
}
-ByteString CFX_FontMapper::GetPSNameFromTT(void* hFont) {
- size_t size = m_pFontInfo->GetFontData(hFont, kTableNAME, {});
+ByteString CFX_FontMapper::GetPSNameFromTT(void* font_handle) {
+ size_t size = m_pFontInfo->GetFontData(font_handle, kTableNAME, {});
if (!size)
return ByteString();
std::vector<uint8_t, FxAllocAllocator<uint8_t>> buffer(size);
- size_t bytes_read = m_pFontInfo->GetFontData(hFont, kTableNAME, buffer);
+ size_t bytes_read = m_pFontInfo->GetFontData(font_handle, kTableNAME, buffer);
return bytes_read == size ? GetNameFromTT(buffer, 6) : ByteString();
}
@@ -334,20 +335,21 @@
if (name == m_LastFamily)
return;
- bool bLocalized = std::any_of(name.begin(), name.end(), [](const char& c) {
+ bool is_localized = std::any_of(name.begin(), name.end(), [](const char& c) {
return static_cast<uint8_t>(c) > 0x80;
});
- if (bLocalized) {
- void* hFont = m_pFontInfo->GetFont(name);
- if (!hFont) {
- hFont = m_pFontInfo->MapFont(0, false, FX_Charset::kDefault, 0, name);
- if (!hFont)
+ if (is_localized) {
+ void* font_handle = m_pFontInfo->GetFont(name);
+ if (!font_handle) {
+ font_handle =
+ m_pFontInfo->MapFont(0, false, FX_Charset::kDefault, 0, name);
+ if (!font_handle)
return;
}
- ScopedFontDeleter scoped_font(m_pFontInfo.get(), hFont);
- ByteString new_name = GetPSNameFromTT(hFont);
+ ScopedFontDeleter scoped_font(m_pFontInfo.get(), font_handle);
+ ByteString new_name = GetPSNameFromTT(font_handle);
if (!new_name.IsEmpty())
m_LocalizedTTFonts.push_back(std::make_pair(new_name, name));
}
@@ -377,32 +379,33 @@
return ByteString();
}
-RetainPtr<CFX_Face> CFX_FontMapper::UseInternalSubst(CFX_SubstFont* pSubstFont,
- int iBaseFont,
- int italic_angle,
- int weight,
- int pitch_family) {
- if (iBaseFont < kNumStandardFonts) {
- if (!m_StandardFaces[iBaseFont]) {
- m_StandardFaces[iBaseFont] = m_pFontMgr->NewFixedFace(
- nullptr, m_pFontMgr->GetStandardFont(iBaseFont), 0);
+RetainPtr<CFX_Face> CFX_FontMapper::UseInternalSubst(
+ int base_font,
+ int weight,
+ int italic_angle,
+ int pitch_family,
+ CFX_SubstFont* subst_font) {
+ if (base_font < kNumStandardFonts) {
+ if (!m_StandardFaces[base_font]) {
+ m_StandardFaces[base_font] = m_pFontMgr->NewFixedFace(
+ nullptr, m_pFontMgr->GetStandardFont(base_font), 0);
}
- return m_StandardFaces[iBaseFont];
+ return m_StandardFaces[base_font];
}
- pSubstFont->m_bFlagMM = true;
- pSubstFont->m_ItalicAngle = italic_angle;
+ subst_font->m_bFlagMM = true;
+ subst_font->m_ItalicAngle = italic_angle;
if (weight)
- pSubstFont->m_Weight = weight;
+ subst_font->m_Weight = weight;
if (FontFamilyIsRoman(pitch_family)) {
- pSubstFont->UseChromeSerif();
+ subst_font->UseChromeSerif();
if (!m_GenericSerifFace) {
m_GenericSerifFace = m_pFontMgr->NewFixedFace(
nullptr, m_pFontMgr->GetGenericSerifFont(), 0);
}
return m_GenericSerifFace;
}
- pSubstFont->m_Family = "Chrome Sans";
+ subst_font->m_Family = "Chrome Sans";
if (!m_GenericSansFace) {
m_GenericSansFace =
m_pFontMgr->NewFixedFace(nullptr, m_pFontMgr->GetGenericSansFont(), 0);
@@ -411,12 +414,12 @@
}
RetainPtr<CFX_Face> CFX_FontMapper::FindSubstFont(const ByteString& name,
- bool bTrueType,
+ bool is_truetype,
uint32_t flags,
int weight,
int italic_angle,
FX_CodePage code_page,
- CFX_SubstFont* pSubstFont) {
+ CFX_SubstFont* subst_font) {
if (weight == 0)
weight = FXFONT_FW_NORMAL;
@@ -424,76 +427,77 @@
weight = FXFONT_FW_NORMAL;
italic_angle = 0;
}
- ByteString SubstName = name;
- SubstName.Remove(' ');
- if (bTrueType && name.GetLength() > 0 && name[0] == '@')
- SubstName = name.Last(name.GetLength() - 1);
- RemoveSubsettedFontPrefix(&SubstName);
- GetStandardFontName(&SubstName);
- if (SubstName == "Symbol" && !bTrueType) {
- pSubstFont->m_Family = "Chrome Symbol";
- pSubstFont->m_Charset = FX_Charset::kSymbol;
- return UseInternalSubst(pSubstFont, 12, italic_angle, weight, 0);
+ ByteString subst_name = name;
+ subst_name.Remove(' ');
+ if (is_truetype && name.GetLength() > 0 && name[0] == '@')
+ subst_name = name.Last(name.GetLength() - 1);
+ RemoveSubsettedFontPrefix(&subst_name);
+ GetStandardFontName(&subst_name);
+ if (subst_name == "Symbol" && !is_truetype) {
+ subst_font->m_Family = "Chrome Symbol";
+ subst_font->m_Charset = FX_Charset::kSymbol;
+ return UseInternalSubst(kSymbol, weight, italic_angle, 0, subst_font);
}
- if (SubstName == "ZapfDingbats") {
- pSubstFont->m_Family = "Chrome Dingbats";
- pSubstFont->m_Charset = FX_Charset::kSymbol;
- return UseInternalSubst(pSubstFont, 13, italic_angle, weight, 0);
+ if (subst_name == "ZapfDingbats") {
+ subst_font->m_Family = "Chrome Dingbats";
+ subst_font->m_Charset = FX_Charset::kSymbol;
+ return UseInternalSubst(kDingbats, weight, italic_angle, 0, subst_font);
}
- int iBaseFont = 0;
+ int base_font = 0;
ByteString family;
ByteString style;
- bool bHasComma = false;
- bool bHasHyphen = false;
+ bool has_comma = false;
+ bool has_hyphen = false;
{
- absl::optional<size_t> pos = SubstName.Find(",");
+ absl::optional<size_t> pos = subst_name.Find(",");
if (pos.has_value()) {
- family = SubstName.First(pos.value());
+ family = subst_name.First(pos.value());
GetStandardFontName(&family);
- style = SubstName.Last(SubstName.GetLength() - (pos.value() + 1));
- bHasComma = true;
+ style = subst_name.Last(subst_name.GetLength() - (pos.value() + 1));
+ has_comma = true;
} else {
- family = SubstName;
+ family = subst_name;
}
}
- for (; iBaseFont < 12; iBaseFont++) {
- if (family == kBase14FontNames[iBaseFont])
+ for (; base_font < kSymbol; base_font++) {
+ if (family == kBase14FontNames[base_font])
break;
}
- int PitchFamily = 0;
+ int pitch_family = 0;
uint32_t nStyle = FXFONT_NORMAL;
- bool bStyleAvail = false;
- if (iBaseFont < 12) {
- if ((iBaseFont % 4) == 1 || (iBaseFont % 4) == 2)
+ bool is_style_available = false;
+ if (base_font < kSymbol) {
+ if ((base_font % 4) == 1 || (base_font % 4) == 2)
nStyle |= FXFONT_FORCE_BOLD;
- if ((iBaseFont % 4) / 2)
+ if ((base_font % 4) / 2)
nStyle |= FXFONT_ITALIC;
- if (iBaseFont < 4)
- PitchFamily |= FXFONT_FF_FIXEDPITCH;
- if (iBaseFont >= 8)
- PitchFamily |= FXFONT_FF_ROMAN;
+ if (base_font < 4)
+ pitch_family |= FXFONT_FF_FIXEDPITCH;
+ if (base_font >= 8)
+ pitch_family |= FXFONT_FF_ROMAN;
} else {
- iBaseFont = kNumStandardFonts;
- if (!bHasComma) {
+ base_font = kNumStandardFonts;
+ if (!has_comma) {
absl::optional<size_t> pos = family.ReverseFind('-');
if (pos.has_value()) {
style = family.Last(family.GetLength() - (pos.value() + 1));
family = family.First(pos.value());
- bHasHyphen = true;
+ has_hyphen = true;
}
}
- if (!bHasHyphen) {
+ if (!has_hyphen) {
size_t nLen = family.GetLength();
- bool hasStyleType;
- uint32_t styleType;
+ bool has_style_type;
+ uint32_t style_type;
size_t len;
- std::tie(hasStyleType, styleType, len) = GetStyleType(family, true);
- if (hasStyleType) {
+ std::tie(has_style_type, style_type, len) =
+ GetStyleType(family, /*reverse_search=*/true);
+ if (has_style_type) {
family = family.First(nLen - len);
- nStyle |= styleType;
+ nStyle |= style_type;
}
}
- UpdatePitchFamily(flags, &PitchFamily);
+ UpdatePitchFamily(flags, &pitch_family);
}
const int old_weight = weight;
@@ -502,22 +506,23 @@
if (!style.IsEmpty()) {
size_t i = 0;
- bool bFirstItem = true;
+ bool is_first_item = true;
while (i < style.GetLength()) {
ByteString buf = ParseStyle(style, i);
- bool hasStyleType;
- uint32_t styleType;
+ bool has_style_type;
+ uint32_t style_type;
size_t len;
- std::tie(hasStyleType, styleType, len) = GetStyleType(buf, false);
- if ((i && !bStyleAvail) || (!i && !hasStyleType)) {
- family = SubstName;
- iBaseFont = kNumStandardFonts;
+ std::tie(has_style_type, style_type, len) =
+ GetStyleType(buf, /*reverse_search=*/false);
+ if ((i && !is_style_available) || (!i && !has_style_type)) {
+ family = subst_name;
+ base_font = kNumStandardFonts;
break;
}
- if (hasStyleType)
- bStyleAvail = true;
+ if (has_style_type)
+ is_style_available = true;
- if (FontStyleIsForceBold(styleType)) {
+ if (FontStyleIsForceBold(style_type)) {
// If we're already bold, then we're double bold, use special weight.
if (FontStyleIsForceBold(nStyle)) {
weight = FXFONT_FW_BOLD_BOLD;
@@ -526,16 +531,16 @@
nStyle |= FXFONT_FORCE_BOLD;
}
- bFirstItem = false;
+ is_first_item = false;
}
- if (FontStyleIsItalic(styleType) && FontStyleIsForceBold(styleType)) {
+ if (FontStyleIsItalic(style_type) && FontStyleIsForceBold(style_type)) {
nStyle |= FXFONT_ITALIC;
- } else if (FontStyleIsItalic(styleType)) {
- if (bFirstItem) {
+ } else if (FontStyleIsItalic(style_type)) {
+ if (is_first_item) {
nStyle |= FXFONT_ITALIC;
} else {
- family = SubstName;
- iBaseFont = kNumStandardFonts;
+ family = subst_name;
+ base_font = kNumStandardFonts;
}
break;
}
@@ -544,42 +549,42 @@
}
if (!m_pFontInfo) {
- return UseInternalSubst(pSubstFont, iBaseFont, italic_angle, old_weight,
- PitchFamily);
+ return UseInternalSubst(base_font, old_weight, italic_angle, pitch_family,
+ subst_font);
}
FX_Charset Charset = FX_Charset::kANSI;
if (code_page != FX_CodePage::kDefANSI)
Charset = FX_GetCharsetFromCodePage(code_page);
- else if (iBaseFont == kNumStandardFonts && FontStyleIsSymbolic(flags))
+ else if (base_font == kNumStandardFonts && FontStyleIsSymbolic(flags))
Charset = FX_Charset::kSymbol;
- const bool bCJK = FX_CharSetIsCJK(Charset);
- bool bItalic = FontStyleIsItalic(nStyle);
+ const bool is_cjk = FX_CharSetIsCJK(Charset);
+ bool is_italic = FontStyleIsItalic(nStyle);
GetFontFamily(nStyle, &family);
ByteString match = MatchInstalledFonts(TT_NormalizeName(family));
- if (match.IsEmpty() && family != SubstName &&
- (!bHasComma && (!bHasHyphen || (bHasHyphen && !bStyleAvail)))) {
- match = MatchInstalledFonts(TT_NormalizeName(SubstName));
+ if (match.IsEmpty() && family != subst_name &&
+ (!has_comma && (!has_hyphen || (has_hyphen && !is_style_available)))) {
+ match = MatchInstalledFonts(TT_NormalizeName(subst_name));
}
- if (match.IsEmpty() && iBaseFont >= kNumStandardFonts) {
- if (!bCJK) {
- if (!CheckSupportThirdPartFont(family, &PitchFamily)) {
- bItalic = italic_angle != 0;
+ if (match.IsEmpty() && base_font >= kNumStandardFonts) {
+ if (!is_cjk) {
+ if (!CheckSupportThirdPartFont(family, &pitch_family)) {
+ is_italic = italic_angle != 0;
weight = old_weight;
}
- absl::optional<size_t> pos = SubstName.Find("Narrow");
+ absl::optional<size_t> pos = subst_name.Find("Narrow");
if (pos.has_value() && pos.value() != 0)
family = kNarrowFamily;
- pos = SubstName.Find("Condensed");
+ pos = subst_name.Find("Condensed");
if (pos.has_value() && pos.value() != 0)
family = kNarrowFamily;
} else {
- pSubstFont->m_bSubstCJK = true;
+ subst_font->m_bSubstCJK = true;
if (nStyle)
- pSubstFont->m_WeightCJK = nStyle ? weight : FXFONT_FW_NORMAL;
+ subst_font->m_WeightCJK = nStyle ? weight : FXFONT_FW_NORMAL;
if (FontStyleIsItalic(nStyle))
- pSubstFont->m_bItalicCJK = true;
+ subst_font->m_bItalicCJK = true;
}
} else {
italic_angle = 0;
@@ -587,53 +592,53 @@
weight = FXFONT_FW_NORMAL;
}
- if (!match.IsEmpty() || iBaseFont < kNumStandardFonts) {
+ if (!match.IsEmpty() || base_font < kNumStandardFonts) {
if (!match.IsEmpty())
family = match;
- if (iBaseFont < kNumStandardFonts) {
- if (nStyle && !(iBaseFont % 4)) {
+ if (base_font < kNumStandardFonts) {
+ if (nStyle && !(base_font % 4)) {
if (FontStyleIsForceBold(nStyle) && FontStyleIsItalic(nStyle))
- iBaseFont += 2;
+ base_font += 2;
else if (FontStyleIsForceBold(nStyle))
- iBaseFont += 1;
+ base_font += 1;
else if (FontStyleIsItalic(nStyle))
- iBaseFont += 3;
+ base_font += 3;
}
- family = kBase14FontNames[iBaseFont];
+ family = kBase14FontNames[base_font];
}
} else if (FontStyleIsItalic(flags)) {
- bItalic = true;
+ is_italic = true;
}
- void* hFont =
- m_pFontInfo->MapFont(weight, bItalic, Charset, PitchFamily, family);
- if (!hFont) {
- if (bCJK) {
- bItalic = italic_angle != 0;
+ void* font_handle =
+ m_pFontInfo->MapFont(weight, is_italic, Charset, pitch_family, family);
+ if (!font_handle) {
+ if (is_cjk) {
+ is_italic = italic_angle != 0;
weight = old_weight;
}
if (!match.IsEmpty()) {
- hFont = m_pFontInfo->GetFont(match);
- if (!hFont) {
- return UseInternalSubst(pSubstFont, iBaseFont, italic_angle, old_weight,
- PitchFamily);
+ font_handle = m_pFontInfo->GetFont(match);
+ if (!font_handle) {
+ return UseInternalSubst(base_font, old_weight, italic_angle,
+ pitch_family, subst_font);
}
} else {
if (Charset == FX_Charset::kSymbol) {
#if BUILDFLAG(IS_APPLE) || BUILDFLAG(IS_ANDROID)
- if (SubstName == "Symbol") {
- pSubstFont->m_Family = "Chrome Symbol";
- pSubstFont->m_Charset = FX_Charset::kSymbol;
- return UseInternalSubst(pSubstFont, 12, italic_angle, old_weight,
- PitchFamily);
+ if (subst_name == "Symbol") {
+ subst_font->m_Family = "Chrome Symbol";
+ subst_font->m_Charset = FX_Charset::kSymbol;
+ return UseInternalSubst(kSymbol, old_weight, italic_angle,
+ pitch_family, subst_font);
}
#endif
- return FindSubstFont(family, bTrueType, flags & ~FXFONT_SYMBOLIC,
+ return FindSubstFont(family, is_truetype, flags & ~FXFONT_SYMBOLIC,
weight, italic_angle, FX_CodePage::kDefANSI,
- pSubstFont);
+ subst_font);
}
if (Charset == FX_Charset::kANSI) {
- return UseInternalSubst(pSubstFont, iBaseFont, italic_angle, old_weight,
- PitchFamily);
+ return UseInternalSubst(base_font, old_weight, italic_angle,
+ pitch_family, subst_font);
}
auto it =
@@ -642,47 +647,47 @@
return face.charset == static_cast<uint32_t>(Charset);
});
if (it == m_FaceArray.end()) {
- return UseInternalSubst(pSubstFont, iBaseFont, italic_angle, old_weight,
- PitchFamily);
+ return UseInternalSubst(base_font, old_weight, italic_angle,
+ pitch_family, subst_font);
}
- hFont = m_pFontInfo->GetFont(it->name);
+ font_handle = m_pFontInfo->GetFont(it->name);
}
}
- if (!hFont)
+ if (!font_handle)
return nullptr;
- ScopedFontDeleter scoped_font(m_pFontInfo.get(), hFont);
- m_pFontInfo->GetFaceName(hFont, &SubstName);
+ ScopedFontDeleter scoped_font(m_pFontInfo.get(), font_handle);
+ m_pFontInfo->GetFaceName(font_handle, &subst_name);
if (Charset == FX_Charset::kDefault)
- m_pFontInfo->GetFontCharset(hFont, &Charset);
- size_t ttc_size = m_pFontInfo->GetFontData(hFont, kTableTTCF, {});
- size_t font_size = m_pFontInfo->GetFontData(hFont, 0, {});
+ m_pFontInfo->GetFontCharset(font_handle, &Charset);
+ size_t ttc_size = m_pFontInfo->GetFontData(font_handle, kTableTTCF, {});
+ size_t font_size = m_pFontInfo->GetFontData(font_handle, 0, {});
if (font_size == 0 && ttc_size == 0)
return nullptr;
RetainPtr<CFX_Face> face;
if (ttc_size)
- face = GetCachedTTCFace(hFont, ttc_size, font_size);
+ face = GetCachedTTCFace(font_handle, ttc_size, font_size);
else
- face = GetCachedFace(hFont, SubstName, weight, bItalic, font_size);
+ face = GetCachedFace(font_handle, subst_name, weight, is_italic, font_size);
if (!face)
return nullptr;
- pSubstFont->m_Family = SubstName;
- pSubstFont->m_Charset = Charset;
+ subst_font->m_Family = subst_name;
+ subst_font->m_Charset = Charset;
bool bNeedUpdateWeight = false;
if (FXFT_Is_Face_Bold(face->GetRec()))
bNeedUpdateWeight = weight != FXFONT_FW_BOLD;
else
bNeedUpdateWeight = weight != FXFONT_FW_NORMAL;
if (bNeedUpdateWeight)
- pSubstFont->m_Weight = weight;
- if (bItalic && !FXFT_Is_Face_Italic(face->GetRec())) {
+ subst_font->m_Weight = weight;
+ if (is_italic && !FXFT_Is_Face_Italic(face->GetRec())) {
if (italic_angle == 0)
italic_angle = -12;
else if (abs(italic_angle) < 5)
italic_angle = 0;
- pSubstFont->m_ItalicAngle = italic_angle;
+ subst_font->m_ItalicAngle = italic_angle;
}
return face;
}
@@ -738,34 +743,35 @@
size_t* returned_length) {
CHECK_LT(index, m_FaceArray.size());
- void* hFont = m_pFontInfo->MapFont(0, false, FX_Charset::kDefault, 0,
- GetFaceName(index));
- if (!hFont)
+ void* font_handle = m_pFontInfo->MapFont(0, false, FX_Charset::kDefault, 0,
+ GetFaceName(index));
+ if (!font_handle)
return nullptr;
- ScopedFontDeleter scoped_font(m_pFontInfo.get(), hFont);
- size_t required_size = m_pFontInfo->GetFontData(hFont, 0, {});
+ ScopedFontDeleter scoped_font(m_pFontInfo.get(), font_handle);
+ size_t required_size = m_pFontInfo->GetFontData(font_handle, 0, {});
if (required_size == 0)
return nullptr;
std::unique_ptr<uint8_t, FxFreeDeleter> pBuffer(
FX_Alloc(uint8_t, required_size + 1));
*returned_length =
- m_pFontInfo->GetFontData(hFont, 0, {pBuffer.get(), required_size});
+ m_pFontInfo->GetFontData(font_handle, 0, {pBuffer.get(), required_size});
return pBuffer;
}
#endif // PDF_ENABLE_XFA
-RetainPtr<CFX_Face> CFX_FontMapper::GetCachedTTCFace(void* hFont,
+RetainPtr<CFX_Face> CFX_FontMapper::GetCachedTTCFace(void* font_handle,
size_t ttc_size,
size_t data_size) {
- uint32_t checksum = GetChecksumFromTT(hFont);
+ uint32_t checksum = GetChecksumFromTT(font_handle);
RetainPtr<CFX_FontMgr::FontDesc> pFontDesc =
m_pFontMgr->GetCachedTTCFontDesc(ttc_size, checksum);
if (!pFontDesc) {
std::unique_ptr<uint8_t, FxFreeDeleter> pFontData(
FX_Alloc(uint8_t, ttc_size));
- m_pFontInfo->GetFontData(hFont, kTableTTCF, {pFontData.get(), ttc_size});
+ m_pFontInfo->GetFontData(font_handle, kTableTTCF,
+ {pFontData.get(), ttc_size});
pFontDesc = m_pFontMgr->AddCachedTTCFontDesc(
ttc_size, checksum, std::move(pFontData), ttc_size);
}
@@ -786,18 +792,18 @@
return pFace;
}
-RetainPtr<CFX_Face> CFX_FontMapper::GetCachedFace(void* hFont,
- ByteString SubstName,
+RetainPtr<CFX_Face> CFX_FontMapper::GetCachedFace(void* font_handle,
+ ByteString subst_name,
int weight,
- bool bItalic,
+ bool is_italic,
size_t data_size) {
RetainPtr<CFX_FontMgr::FontDesc> pFontDesc =
- m_pFontMgr->GetCachedFontDesc(SubstName, weight, bItalic);
+ m_pFontMgr->GetCachedFontDesc(subst_name, weight, is_italic);
if (!pFontDesc) {
std::unique_ptr<uint8_t, FxFreeDeleter> pFontData(
FX_Alloc(uint8_t, data_size));
- m_pFontInfo->GetFontData(hFont, 0, {pFontData.get(), data_size});
- pFontDesc = m_pFontMgr->AddCachedFontDesc(SubstName, weight, bItalic,
+ m_pFontInfo->GetFontData(font_handle, 0, {pFontData.get(), data_size});
+ pFontDesc = m_pFontMgr->AddCachedFontDesc(subst_name, weight, is_italic,
std::move(pFontData), data_size);
}
RetainPtr<CFX_Face> pFace(pFontDesc->GetFace(0));
diff --git a/core/fxge/cfx_fontmapper.h b/core/fxge/cfx_fontmapper.h
index 2a7d7c8..89cda94 100644
--- a/core/fxge/cfx_fontmapper.h
+++ b/core/fxge/cfx_fontmapper.h
@@ -63,12 +63,12 @@
void LoadInstalledFonts();
RetainPtr<CFX_Face> FindSubstFont(const ByteString& face_name,
- bool bTrueType,
+ bool is_truetype,
uint32_t flags,
int weight,
int italic_angle,
FX_CodePage code_page,
- CFX_SubstFont* pSubstFont);
+ CFX_SubstFont* subst_font);
size_t GetFaceSize() const;
// `index` must be less than GetFaceSize().
@@ -91,21 +91,21 @@
#endif // PDF_ENABLE_XFA
private:
- uint32_t GetChecksumFromTT(void* hFont);
- ByteString GetPSNameFromTT(void* hFont);
+ uint32_t GetChecksumFromTT(void* font_handle);
+ ByteString GetPSNameFromTT(void* font_handle);
ByteString MatchInstalledFonts(const ByteString& norm_name);
- RetainPtr<CFX_Face> UseInternalSubst(CFX_SubstFont* pSubstFont,
- int iBaseFont,
- int italic_angle,
+ RetainPtr<CFX_Face> UseInternalSubst(int base_font,
int weight,
- int pitch_family);
- RetainPtr<CFX_Face> GetCachedTTCFace(void* hFont,
+ int italic_angle,
+ int pitch_family,
+ CFX_SubstFont* subst_font);
+ RetainPtr<CFX_Face> GetCachedTTCFace(void* font_handle,
size_t ttc_size,
size_t data_size);
- RetainPtr<CFX_Face> GetCachedFace(void* hFont,
- ByteString SubstName,
+ RetainPtr<CFX_Face> GetCachedFace(void* font_handle,
+ ByteString subst_name,
int weight,
- bool bItalic,
+ bool is_italic,
size_t data_size);
struct FaceData {