Rewrite core/fpdfapi/{cmaps,font} to google_style_ members
No affected callers, it would seem. Hooray for encapsulation.
Bug: 42271580
Change-Id: I1ee1612e1beebe1b59ee5f06ed705d7b53181ddc
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/130790
Reviewed-by: Lei Zhang <thestig@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
diff --git a/core/fpdfapi/cmaps/fpdf_cmaps.cpp b/core/fpdfapi/cmaps/fpdf_cmaps.cpp
index 28a195f..e46d6be 100644
--- a/core/fpdfapi/cmaps/fpdf_cmaps.cpp
+++ b/core/fpdfapi/cmaps/fpdf_cmaps.cpp
@@ -27,7 +27,7 @@
};
const CMap* FindNextCMap(const CMap* pMap) {
- return pMap->m_UseOffset ? UNSAFE_TODO(pMap + pMap->m_UseOffset) : nullptr;
+ return pMap->use_offset_ ? UNSAFE_TODO(pMap + pMap->use_offset_) : nullptr;
}
} // namespace
@@ -37,21 +37,21 @@
const uint16_t loword = static_cast<uint16_t>(charcode);
if (charcode >> 16) {
while (pMap) {
- if (pMap->m_pDWordMap) {
- const DWordCIDMap* begin = pMap->m_pDWordMap;
- const auto* end = UNSAFE_TODO(begin + pMap->m_DWordCount);
+ if (pMap->dword_map_) {
+ const DWordCIDMap* begin = pMap->dword_map_;
+ const auto* end = UNSAFE_TODO(begin + pMap->dword_count_);
const auto* found = std::lower_bound(
begin, end, charcode,
[](const DWordCIDMap& element, uint32_t charcode) {
uint16_t hiword = static_cast<uint16_t>(charcode >> 16);
- if (element.m_HiWord != hiword) {
- return element.m_HiWord < hiword;
+ if (element.hi_word_ != hiword) {
+ return element.hi_word_ < hiword;
}
- return element.m_LoWordHigh < static_cast<uint16_t>(charcode);
+ return element.lo_word_high_ < static_cast<uint16_t>(charcode);
});
- if (found != end && loword >= found->m_LoWordLow &&
- loword <= found->m_LoWordHigh) {
- return found->m_CID + loword - found->m_LoWordLow;
+ if (found != end && loword >= found->lo_word_low_ &&
+ loword <= found->lo_word_high_) {
+ return found->cid_ + loword - found->lo_word_low_;
}
}
pMap = FindNextCMap(pMap);
@@ -59,12 +59,12 @@
return 0;
}
- while (pMap && pMap->m_pWordMap) {
- switch (pMap->m_WordMapType) {
+ while (pMap && pMap->word_map_) {
+ switch (pMap->word_map_type_) {
case CMap::Type::kSingle: {
const auto* begin =
- reinterpret_cast<const SingleCmap*>(pMap->m_pWordMap);
- const auto* end = UNSAFE_TODO(begin + pMap->m_WordCount);
+ reinterpret_cast<const SingleCmap*>(pMap->word_map_);
+ const auto* end = UNSAFE_TODO(begin + pMap->word_count_);
const auto* found = std::lower_bound(
begin, end, loword, [](const SingleCmap& element, uint16_t code) {
return element.code < code;
@@ -75,9 +75,8 @@
break;
}
case CMap::Type::kRange: {
- const auto* begin =
- reinterpret_cast<const RangeCmap*>(pMap->m_pWordMap);
- const auto* end = UNSAFE_TODO(begin + pMap->m_WordCount);
+ const auto* begin = reinterpret_cast<const RangeCmap*>(pMap->word_map_);
+ const auto* end = UNSAFE_TODO(begin + pMap->word_count_);
const auto* found = std::lower_bound(
begin, end, loword, [](const RangeCmap& element, uint16_t code) {
return element.high < code;
@@ -95,18 +94,18 @@
}
uint32_t CharCodeFromCID(const CMap* pMap, uint16_t cid) {
- // TODO(dsinclair): This should be checking both pMap->m_WordMap and
- // pMap->m_DWordMap. There was a second while() but it was never reached as
+ // TODO(dsinclair): This should be checking both pMap->word_map_ and
+ // pMap->dword_map_. There was a second while() but it was never reached as
// the first always returns. Investigate and determine how this should
// really be working. (https://codereview.chromium.org/2235743003 removed the
// second while loop.)
DCHECK(pMap);
while (pMap) {
- switch (pMap->m_WordMapType) {
+ switch (pMap->word_map_type_) {
case CMap::Type::kSingle: {
auto single_span = UNSAFE_TODO(pdfium::make_span(
- reinterpret_cast<const SingleCmap*>(pMap->m_pWordMap),
- pMap->m_WordCount));
+ reinterpret_cast<const SingleCmap*>(pMap->word_map_),
+ pMap->word_count_));
for (const auto& single : single_span) {
if (single.cid == cid) {
return single.code;
@@ -116,8 +115,8 @@
}
case CMap::Type::kRange: {
auto range_span = UNSAFE_TODO(pdfium::make_span(
- reinterpret_cast<const RangeCmap*>(pMap->m_pWordMap),
- pMap->m_WordCount));
+ reinterpret_cast<const RangeCmap*>(pMap->word_map_),
+ pMap->word_count_));
for (const auto& range : range_span) {
if (cid >= range.cid && cid <= range.cid + range.high - range.low) {
return range.low + cid - range.cid;
diff --git a/core/fpdfapi/cmaps/fpdf_cmaps.h b/core/fpdfapi/cmaps/fpdf_cmaps.h
index 795427f..87ad849 100644
--- a/core/fpdfapi/cmaps/fpdf_cmaps.h
+++ b/core/fpdfapi/cmaps/fpdf_cmaps.h
@@ -14,22 +14,22 @@
namespace fxcmap {
struct DWordCIDMap {
- uint16_t m_HiWord;
- uint16_t m_LoWordLow;
- uint16_t m_LoWordHigh;
- uint16_t m_CID;
+ uint16_t hi_word_;
+ uint16_t lo_word_low_;
+ uint16_t lo_word_high_;
+ uint16_t cid_;
};
struct CMap {
enum class Type : bool { kSingle, kRange };
- UNOWNED_PTR_EXCLUSION const char* m_Name; // POD struct.
- UNOWNED_PTR_EXCLUSION const uint16_t* m_pWordMap; // POD struct.
- UNOWNED_PTR_EXCLUSION const DWordCIDMap* m_pDWordMap; // POD struct.
- uint16_t m_WordCount;
- uint16_t m_DWordCount;
- Type m_WordMapType;
- int8_t m_UseOffset;
+ UNOWNED_PTR_EXCLUSION const char* name_; // POD struct.
+ UNOWNED_PTR_EXCLUSION const uint16_t* word_map_; // POD struct.
+ UNOWNED_PTR_EXCLUSION const DWordCIDMap* dword_map_; // POD struct.
+ uint16_t word_count_;
+ uint16_t dword_count_;
+ Type word_map_type_;
+ int8_t use_offset_;
};
uint16_t CIDFromCharCode(const CMap* pMap, uint32_t charcode);
diff --git a/core/fpdfapi/font/cfx_stockfontarray.cpp b/core/fpdfapi/font/cfx_stockfontarray.cpp
index be58953..b09005b 100644
--- a/core/fpdfapi/font/cfx_stockfontarray.cpp
+++ b/core/fpdfapi/font/cfx_stockfontarray.cpp
@@ -16,26 +16,26 @@
CFX_StockFontArray::CFX_StockFontArray() = default;
CFX_StockFontArray::~CFX_StockFontArray() {
- for (size_t i = 0; i < std::size(m_StockFonts); ++i) {
- if (m_StockFonts[i]) {
- // Ensure m_StockFonts[i]'s dict is cleared before releasing what
+ for (size_t i = 0; i < std::size(stock_fonts_); ++i) {
+ if (stock_fonts_[i]) {
+ // Ensure stock_fonts_[i]'s dict is cleared before releasing what
// may be the last reference to it.
RetainPtr<CPDF_Dictionary> destroy =
- m_StockFonts[i]->GetMutableFontDict();
- m_StockFonts[i]->ClearFontDict();
+ stock_fonts_[i]->GetMutableFontDict();
+ stock_fonts_[i]->ClearFontDict();
}
}
}
RetainPtr<CPDF_Font> CFX_StockFontArray::GetFont(
CFX_FontMapper::StandardFont index) const {
- CHECK_LT(index, std::size(m_StockFonts));
- return m_StockFonts[index];
+ CHECK_LT(index, std::size(stock_fonts_));
+ return stock_fonts_[index];
}
void CFX_StockFontArray::SetFont(CFX_FontMapper::StandardFont index,
RetainPtr<CPDF_Font> pFont) {
- if (index < std::size(m_StockFonts)) {
- m_StockFonts[index] = std::move(pFont);
+ if (index < std::size(stock_fonts_)) {
+ stock_fonts_[index] = std::move(pFont);
}
}
diff --git a/core/fpdfapi/font/cfx_stockfontarray.h b/core/fpdfapi/font/cfx_stockfontarray.h
index 9971361..646ac69 100644
--- a/core/fpdfapi/font/cfx_stockfontarray.h
+++ b/core/fpdfapi/font/cfx_stockfontarray.h
@@ -23,7 +23,7 @@
void SetFont(CFX_FontMapper::StandardFont index, RetainPtr<CPDF_Font> pFont);
private:
- std::array<RetainPtr<CPDF_Font>, 14> m_StockFonts;
+ std::array<RetainPtr<CPDF_Font>, 14> stock_fonts_;
};
#endif // CORE_FPDFAPI_FONT_CFX_STOCKFONTARRAY_H_
diff --git a/core/fpdfapi/font/cpdf_cid2unicodemap.cpp b/core/fpdfapi/font/cpdf_cid2unicodemap.cpp
index 8c86292..ab8907c 100644
--- a/core/fpdfapi/font/cpdf_cid2unicodemap.cpp
+++ b/core/fpdfapi/font/cpdf_cid2unicodemap.cpp
@@ -9,19 +9,19 @@
#include "core/fpdfapi/font/cpdf_fontglobals.h"
CPDF_CID2UnicodeMap::CPDF_CID2UnicodeMap(CIDSet charset)
- : m_Charset(charset),
- m_pEmbeddedMap(
- CPDF_FontGlobals::GetInstance()->GetEmbeddedToUnicode(m_Charset)) {}
+ : charset_(charset),
+ embedded_map_(
+ CPDF_FontGlobals::GetInstance()->GetEmbeddedToUnicode(charset_)) {}
CPDF_CID2UnicodeMap::~CPDF_CID2UnicodeMap() = default;
bool CPDF_CID2UnicodeMap::IsLoaded() const {
- return !m_pEmbeddedMap.empty();
+ return !embedded_map_.empty();
}
wchar_t CPDF_CID2UnicodeMap::UnicodeFromCID(uint16_t cid) const {
- if (m_Charset == CIDSET_UNICODE) {
+ if (charset_ == CIDSET_UNICODE) {
return cid;
}
- return cid < m_pEmbeddedMap.size() ? m_pEmbeddedMap[cid] : 0;
+ return cid < embedded_map_.size() ? embedded_map_[cid] : 0;
}
diff --git a/core/fpdfapi/font/cpdf_cid2unicodemap.h b/core/fpdfapi/font/cpdf_cid2unicodemap.h
index 9c53f42..c66b8a9 100644
--- a/core/fpdfapi/font/cpdf_cid2unicodemap.h
+++ b/core/fpdfapi/font/cpdf_cid2unicodemap.h
@@ -19,8 +19,8 @@
wchar_t UnicodeFromCID(uint16_t cid) const;
private:
- const CIDSet m_Charset;
- const pdfium::raw_span<const uint16_t> m_pEmbeddedMap;
+ const CIDSet charset_;
+ const pdfium::raw_span<const uint16_t> embedded_map_;
};
#endif // CORE_FPDFAPI_FONT_CPDF_CID2UNICODEMAP_H_
diff --git a/core/fpdfapi/font/cpdf_cidfont.cpp b/core/fpdfapi/font/cpdf_cidfont.cpp
index 8b8335e..dee643a 100644
--- a/core/fpdfapi/font/cpdf_cidfont.cpp
+++ b/core/fpdfapi/font/cpdf_cidfont.cpp
@@ -284,8 +284,8 @@
CPDF_CIDFont::CPDF_CIDFont(CPDF_Document* pDocument,
RetainPtr<CPDF_Dictionary> pFontDict)
: CPDF_Font(pDocument, std::move(pFontDict)) {
- for (size_t i = 0; i < std::size(m_CharBBox); ++i) {
- m_CharBBox[i] = FX_RECT(-1, -1, -1, -1);
+ for (size_t i = 0; i < std::size(char_bbox_); ++i) {
+ char_bbox_[i] = FX_RECT(-1, -1, -1, -1);
}
}
@@ -304,12 +304,12 @@
}
uint16_t CPDF_CIDFont::CIDFromCharCode(uint32_t charcode) const {
- return m_pCMap ? m_pCMap->CIDFromCharCode(charcode)
- : static_cast<uint16_t>(charcode);
+ return cmap_ ? cmap_->CIDFromCharCode(charcode)
+ : static_cast<uint16_t>(charcode);
}
bool CPDF_CIDFont::IsVertWriting() const {
- return m_pCMap && m_pCMap->IsVertWriting();
+ return cmap_ && cmap_->IsVertWriting();
}
WideString CPDF_CIDFont::UnicodeFromCharCode(uint32_t charcode) const {
@@ -322,21 +322,20 @@
}
wchar_t CPDF_CIDFont::GetUnicodeFromCharCode(uint32_t charcode) const {
- switch (m_pCMap->GetCoding()) {
+ switch (cmap_->GetCoding()) {
case CIDCoding::kUCS2:
case CIDCoding::kUTF16:
return static_cast<wchar_t>(charcode);
case CIDCoding::kCID:
- if (!m_pCID2UnicodeMap || !m_pCID2UnicodeMap->IsLoaded()) {
+ if (!cid2unicode_map_ || !cid2unicode_map_->IsLoaded()) {
return 0;
}
- return m_pCID2UnicodeMap->UnicodeFromCID(static_cast<uint16_t>(charcode));
+ return cid2unicode_map_->UnicodeFromCID(static_cast<uint16_t>(charcode));
default:
break;
}
- if (m_pCID2UnicodeMap && m_pCID2UnicodeMap->IsLoaded() &&
- m_pCMap->IsLoaded()) {
- return m_pCID2UnicodeMap->UnicodeFromCID(CIDFromCharCode(charcode));
+ if (cid2unicode_map_ && cid2unicode_map_->IsLoaded() && cmap_->IsLoaded()) {
+ return cid2unicode_map_->UnicodeFromCID(CIDFromCharCode(charcode));
}
#if BUILDFLAG(IS_WIN)
@@ -350,16 +349,16 @@
}
wchar_t unicode;
size_t ret = FX_MultiByteToWideChar(
- kCharsetCodePages[static_cast<size_t>(m_pCMap->GetCoding())],
+ kCharsetCodePages[static_cast<size_t>(cmap_->GetCoding())],
ByteStringView(pdfium::make_span(sequence).first(charsize)),
pdfium::span_from_ref(unicode));
return ret == 1 ? unicode : 0;
#else
- if (!m_pCMap->GetEmbedMap()) {
+ if (!cmap_->GetEmbedMap()) {
return 0;
}
- return EmbeddedUnicodeFromCharcode(m_pCMap->GetEmbedMap(),
- m_pCMap->GetCharset(), charcode);
+ return EmbeddedUnicodeFromCharcode(cmap_->GetEmbedMap(), cmap_->GetCharset(),
+ charcode);
#endif
}
@@ -369,20 +368,20 @@
return charcode;
}
- switch (m_pCMap->GetCoding()) {
+ switch (cmap_->GetCoding()) {
case CIDCoding::kUNKNOWN:
return 0;
case CIDCoding::kUCS2:
case CIDCoding::kUTF16:
return unicode;
case CIDCoding::kCID: {
- if (!m_pCID2UnicodeMap || !m_pCID2UnicodeMap->IsLoaded()) {
+ if (!cid2unicode_map_ || !cid2unicode_map_->IsLoaded()) {
return 0;
}
uint32_t cid = 0;
while (cid < 65536) {
wchar_t this_unicode =
- m_pCID2UnicodeMap->UnicodeFromCID(static_cast<uint16_t>(cid));
+ cid2unicode_map_->UnicodeFromCID(static_cast<uint16_t>(cid));
if (this_unicode == unicode) {
return cid;
}
@@ -397,13 +396,13 @@
if (unicode < 0x80) {
return static_cast<uint32_t>(unicode);
}
- if (m_pCMap->GetCoding() == CIDCoding::kCID) {
+ if (cmap_->GetCoding() == CIDCoding::kCID) {
return 0;
}
#if BUILDFLAG(IS_WIN)
uint8_t buffer[32];
size_t ret = FX_WideCharToMultiByte(
- kCharsetCodePages[static_cast<size_t>(m_pCMap->GetCoding())],
+ kCharsetCodePages[static_cast<size_t>(cmap_->GetCoding())],
WideStringView(unicode),
pdfium::as_writable_chars(pdfium::make_span(buffer).first(4u)));
if (ret == 1) {
@@ -413,22 +412,22 @@
return buffer[0] * 256 + buffer[1];
}
#else
- if (m_pCMap->GetEmbedMap()) {
- return EmbeddedCharcodeFromUnicode(m_pCMap->GetEmbedMap(),
- m_pCMap->GetCharset(), unicode);
+ if (cmap_->GetEmbedMap()) {
+ return EmbeddedCharcodeFromUnicode(cmap_->GetEmbedMap(),
+ cmap_->GetCharset(), unicode);
}
#endif
return 0;
}
bool CPDF_CIDFont::Load() {
- if (m_pFontDict->GetByteStringFor("Subtype") == "TrueType") {
+ if (font_dict_->GetByteStringFor("Subtype") == "TrueType") {
LoadGB2312();
return true;
}
RetainPtr<const CPDF_Array> pFonts =
- m_pFontDict->GetArrayFor("DescendantFonts");
+ font_dict_->GetArrayFor("DescendantFonts");
if (!pFonts || pFonts->size() != 1) {
return false;
}
@@ -438,22 +437,23 @@
return false;
}
- m_BaseFontName = pCIDFontDict->GetByteStringFor("BaseFont");
- if ((m_BaseFontName == "CourierStd" || m_BaseFontName == "CourierStd-Bold" ||
- m_BaseFontName == "CourierStd-BoldOblique" ||
- m_BaseFontName == "CourierStd-Oblique") &&
+ base_font_name_ = pCIDFontDict->GetByteStringFor("BaseFont");
+ if ((base_font_name_ == "CourierStd" ||
+ base_font_name_ == "CourierStd-Bold" ||
+ base_font_name_ == "CourierStd-BoldOblique" ||
+ base_font_name_ == "CourierStd-Oblique") &&
!IsEmbedded()) {
- m_bAdobeCourierStd = true;
+ adobe_courier_std_ = true;
}
RetainPtr<const CPDF_Object> pEncoding =
- m_pFontDict->GetDirectObjectFor("Encoding");
+ font_dict_->GetDirectObjectFor("Encoding");
if (!pEncoding) {
return false;
}
ByteString subtype = pCIDFontDict->GetByteStringFor("Subtype");
- m_FontType =
+ font_type_ =
subtype == "CIDFontType0" ? CIDFontType::kType1 : CIDFontType::kTrueType;
if (!pEncoding->IsName() && !pEncoding->IsStream()) {
@@ -467,11 +467,11 @@
pdfium::MakeRetain<CPDF_StreamAcc>(pdfium::WrapRetain(pEncodingStream));
pAcc->LoadAllDataFiltered();
pdfium::span<const uint8_t> span = pAcc->GetSpan();
- m_pCMap = pdfium::MakeRetain<CPDF_CMap>(span);
+ cmap_ = pdfium::MakeRetain<CPDF_CMap>(span);
} else {
DCHECK(pEncoding->IsName());
ByteString cmap = pEncoding->GetString();
- m_pCMap = pFontGlobals->GetPredefinedCMap(cmap);
+ cmap_ = pFontGlobals->GetPredefinedCMap(cmap);
}
RetainPtr<const CPDF_Dictionary> pFontDesc =
@@ -480,30 +480,30 @@
LoadFontDescriptor(pFontDesc.Get());
}
- m_Charset = m_pCMap->GetCharset();
- if (m_Charset == CIDSET_UNKNOWN) {
+ charset_ = cmap_->GetCharset();
+ if (charset_ == CIDSET_UNKNOWN) {
RetainPtr<const CPDF_Dictionary> pCIDInfo =
pCIDFontDict->GetDictFor("CIDSystemInfo");
if (pCIDInfo) {
- m_Charset = CPDF_CMapParser::CharsetFromOrdering(
+ charset_ = CPDF_CMapParser::CharsetFromOrdering(
pCIDInfo->GetByteStringFor("Ordering").AsStringView());
}
}
- if (m_Charset != CIDSET_UNKNOWN) {
- m_pCID2UnicodeMap = pFontGlobals->GetCID2UnicodeMap(m_Charset);
+ if (charset_ != CIDSET_UNKNOWN) {
+ cid2unicode_map_ = pFontGlobals->GetCID2UnicodeMap(charset_);
}
- RetainPtr<CFX_Face> face = m_Font.GetFace();
+ RetainPtr<CFX_Face> face = font_.GetFace();
if (face) {
- if (m_FontType == CIDFontType::kType1) {
+ if (font_type_ == CIDFontType::kType1) {
face->SelectCharMap(fxge::FontEncoding::kUnicode);
} else {
- UseCIDCharmap(face, m_pCMap->GetCoding());
+ UseCIDCharmap(face, cmap_->GetCoding());
}
}
- m_DefaultWidth = pCIDFontDict->GetIntegerFor("DW", 1000);
+ default_width_ = pCIDFontDict->GetIntegerFor("DW", 1000);
RetainPtr<const CPDF_Array> pWidthArray = pCIDFontDict->GetArrayFor("W");
if (pWidthArray) {
- LoadMetricsArray(std::move(pWidthArray), &m_WidthList, 1);
+ LoadMetricsArray(std::move(pWidthArray), &width_list_, 1);
}
if (!IsEmbedded()) {
@@ -515,11 +515,11 @@
if (pmap) {
RetainPtr<const CPDF_Stream> pMapStream(pmap->AsStream());
if (pMapStream) {
- m_pStreamAcc = pdfium::MakeRetain<CPDF_StreamAcc>(std::move(pMapStream));
- m_pStreamAcc->LoadAllDataFiltered();
- } else if (m_pFontFile && pmap->IsName() &&
+ stream_acc_ = pdfium::MakeRetain<CPDF_StreamAcc>(std::move(pMapStream));
+ stream_acc_->LoadAllDataFiltered();
+ } else if (font_file_ && pmap->IsName() &&
pmap->GetString() == "Identity") {
- m_bCIDIsGID = true;
+ cid_is_gid_ = true;
}
}
@@ -527,38 +527,38 @@
if (IsVertWriting()) {
RetainPtr<const CPDF_Array> pWidth2Array = pCIDFontDict->GetArrayFor("W2");
if (pWidth2Array) {
- LoadMetricsArray(std::move(pWidth2Array), &m_VertMetrics, 3);
+ LoadMetricsArray(std::move(pWidth2Array), &vert_metrics_, 3);
}
RetainPtr<const CPDF_Array> pDefaultArray =
pCIDFontDict->GetArrayFor("DW2");
if (pDefaultArray) {
- m_DefaultVY = pDefaultArray->GetIntegerAt(0);
- m_DefaultW1 = pDefaultArray->GetIntegerAt(1);
+ default_vy_ = pDefaultArray->GetIntegerAt(0);
+ default_w1_ = pDefaultArray->GetIntegerAt(1);
}
}
// TODO(thestig): Better identify font types and identify more font types.
- if (m_FontType == CIDFontType::kTrueType && IsEmbedded()) {
- m_Font.SetFontType(CFX_Font::FontType::kCIDTrueType);
+ if (font_type_ == CIDFontType::kTrueType && IsEmbedded()) {
+ font_.SetFontType(CFX_Font::FontType::kCIDTrueType);
}
return true;
}
FX_RECT CPDF_CIDFont::GetCharBBox(uint32_t charcode) {
- if (charcode < 256 && m_CharBBox[charcode].right != -1) {
- return m_CharBBox[charcode];
+ if (charcode < 256 && char_bbox_[charcode].right != -1) {
+ return char_bbox_[charcode];
}
FX_RECT rect;
bool bVert = false;
int glyph_index = GlyphFromCharCode(charcode, &bVert);
- RetainPtr<CFX_Face> face = m_Font.GetFace();
+ RetainPtr<CFX_Face> face = font_.GetFace();
if (face) {
rect = face->GetCharBBox(charcode, glyph_index);
}
- if (!m_pFontFile && m_Charset == CIDSET_JAPAN1) {
+ if (!font_file_ && charset_ == CIDSET_JAPAN1) {
uint16_t cid = CIDFromCharCode(charcode);
const CIDTransform* pTransform = GetCIDTransform(cid);
if (pTransform && !bVert) {
@@ -572,56 +572,56 @@
}
}
if (charcode < 256) {
- m_CharBBox[charcode] = rect;
+ char_bbox_[charcode] = rect;
}
return rect;
}
int CPDF_CIDFont::GetCharWidthF(uint32_t charcode) {
- if (charcode < 0x80 && m_bAnsiWidthsFixed) {
+ if (charcode < 0x80 && ansi_widths_fixed_) {
return (charcode >= 32 && charcode < 127) ? 500 : 0;
}
uint16_t cid = CIDFromCharCode(charcode);
auto lhv_span =
- fxcrt::reinterpret_span<const LowHighVal>(pdfium::make_span(m_WidthList));
+ fxcrt::reinterpret_span<const LowHighVal>(pdfium::make_span(width_list_));
for (const auto& lhv : lhv_span) {
if (IsMetricForCID(lhv, cid)) {
return lhv.val;
}
}
- return m_DefaultWidth;
+ return default_width_;
}
int16_t CPDF_CIDFont::GetVertWidth(uint16_t cid) const {
auto lhvxy_span = fxcrt::reinterpret_span<const LowHighValXY>(
- pdfium::make_span(m_VertMetrics));
+ pdfium::make_span(vert_metrics_));
for (const auto& lhvxy : lhvxy_span) {
if (IsMetricForCID(lhvxy, cid)) {
return lhvxy.val;
}
}
- return m_DefaultW1;
+ return default_w1_;
}
CFX_Point16 CPDF_CIDFont::GetVertOrigin(uint16_t cid) const {
auto lhvxy_span = fxcrt::reinterpret_span<const LowHighValXY>(
- pdfium::make_span(m_VertMetrics));
+ pdfium::make_span(vert_metrics_));
for (const auto& lhvxy : lhvxy_span) {
if (IsMetricForCID(lhvxy, cid)) {
return {static_cast<int16_t>(lhvxy.x), static_cast<int16_t>(lhvxy.y)};
}
}
- int width = m_DefaultWidth;
+ int width = default_width_;
auto lhv_span =
- fxcrt::reinterpret_span<const LowHighVal>(pdfium::make_span(m_WidthList));
+ fxcrt::reinterpret_span<const LowHighVal>(pdfium::make_span(width_list_));
for (const auto& lhv : lhv_span) {
if (IsMetricForCID(lhv, cid)) {
width = lhv.val;
break;
}
}
- return {static_cast<int16_t>(width / 2), m_DefaultVY};
+ return {static_cast<int16_t>(width / 2), default_vy_};
}
int CPDF_CIDFont::GetGlyphIndex(uint32_t unicode, bool* pVertGlyph) {
@@ -629,7 +629,7 @@
*pVertGlyph = false;
}
- int index = m_Font.GetFace()->GetCharIndex(unicode);
+ int index = font_.GetFace()->GetCharIndex(unicode);
if (unicode == pdfium::unicode::kBoxDrawingsLightVerical) {
return index;
}
@@ -638,13 +638,13 @@
return index;
}
- if (m_pTTGSUBTable) {
+ if (ttg_subtable_) {
return GetVerticalGlyph(index, pVertGlyph);
}
static constexpr uint32_t kGsubTag =
CFX_FontMapper::MakeTag('G', 'S', 'U', 'B');
- RetainPtr<CFX_Face> face = m_Font.GetFace();
+ RetainPtr<CFX_Face> face = font_.GetFace();
size_t length = face->GetSfntTable(kGsubTag, {});
if (!length) {
return index;
@@ -657,12 +657,12 @@
// CFX_CTTGSUBTable parses the data and stores all the values in its structs.
// It does not store pointers into `sub_data`.
- m_pTTGSUBTable = std::make_unique<CFX_CTTGSUBTable>(sub_data.span());
+ ttg_subtable_ = std::make_unique<CFX_CTTGSUBTable>(sub_data.span());
return GetVerticalGlyph(index, pVertGlyph);
}
int CPDF_CIDFont::GetVerticalGlyph(int index, bool* pVertGlyph) {
- uint32_t vindex = m_pTTGSUBTable->GetVerticalGlyph(index);
+ uint32_t vindex = ttg_subtable_->GetVerticalGlyph(index);
if (!vindex) {
return index;
}
@@ -679,12 +679,12 @@
*pVertGlyph = false;
}
- if (!m_pFontFile && (!m_pStreamAcc || m_pCID2UnicodeMap)) {
+ if (!font_file_ && (!stream_acc_ || cid2unicode_map_)) {
uint16_t cid = CIDFromCharCode(charcode);
wchar_t unicode = 0;
- if (m_bCIDIsGID) {
+ if (cid_is_gid_) {
#if BUILDFLAG(IS_APPLE)
- if (FontStyleIsSymbolic(m_Flags)) {
+ if (FontStyleIsSymbolic(flags_)) {
return cid;
}
@@ -698,8 +698,8 @@
return cid;
#endif
} else {
- if (cid && m_pCID2UnicodeMap && m_pCID2UnicodeMap->IsLoaded()) {
- unicode = m_pCID2UnicodeMap->UnicodeFromCID(cid);
+ if (cid && cid2unicode_map_ && cid2unicode_map_->IsLoaded()) {
+ unicode = cid2unicode_map_->UnicodeFromCID(cid);
}
if (unicode == 0) {
unicode = GetUnicodeFromCharCode(charcode);
@@ -712,12 +712,12 @@
}
}
if (unicode == 0) {
- if (!m_bAdobeCourierStd) {
+ if (!adobe_courier_std_) {
return charcode ? static_cast<int>(charcode) : -1;
}
charcode += 31;
- RetainPtr<CFX_Face> face = m_Font.GetFace();
+ RetainPtr<CFX_Face> face = font_.GetFace();
bool bMSUnicode = UseTTCharmapMSUnicode(face);
bool bMacRoman = !bMSUnicode && UseTTCharmapMacRoman(face);
FontEncoding base_encoding = FontEncoding::kStandard;
@@ -756,7 +756,7 @@
}
return index;
}
- if (m_Charset == CIDSET_JAPAN1) {
+ if (charset_ == CIDSET_JAPAN1) {
if (unicode == '\\') {
unicode = '/';
#if !BUILDFLAG(IS_APPLE)
@@ -766,7 +766,7 @@
}
}
- RetainPtr<CFX_Face> face = m_Font.GetFace();
+ RetainPtr<CFX_Face> face = font_.GetFace();
if (!face) {
return unicode;
}
@@ -796,20 +796,20 @@
return unicode;
}
- RetainPtr<CFX_Face> face = m_Font.GetFace();
+ RetainPtr<CFX_Face> face = font_.GetFace();
if (!face) {
return -1;
}
uint16_t cid = CIDFromCharCode(charcode);
- if (!m_pStreamAcc) {
- if (m_FontType == CIDFontType::kType1) {
+ if (!stream_acc_) {
+ if (font_type_ == CIDFontType::kType1) {
return cid;
}
- if (m_pFontFile && m_pCMap->IsDirectCharcodeToCIDTableIsEmpty()) {
+ if (font_file_ && cmap_->IsDirectCharcodeToCIDTableIsEmpty()) {
return cid;
}
- if (m_pCMap->GetCoding() == CIDCoding::kUNKNOWN) {
+ if (cmap_->GetCoding() == CIDCoding::kUNKNOWN) {
return cid;
}
@@ -830,46 +830,44 @@
return GetGlyphIndex(charcode, pVertGlyph);
}
uint32_t byte_pos = cid * 2;
- if (byte_pos + 2 > m_pStreamAcc->GetSize()) {
+ if (byte_pos + 2 > stream_acc_->GetSize()) {
return -1;
}
- pdfium::span<const uint8_t> span = m_pStreamAcc->GetSpan().subspan(byte_pos);
+ pdfium::span<const uint8_t> span = stream_acc_->GetSpan().subspan(byte_pos);
return span[0] * 256 + span[1];
}
uint32_t CPDF_CIDFont::GetNextChar(ByteStringView pString,
size_t* pOffset) const {
- return m_pCMap->GetNextChar(pString, pOffset);
+ return cmap_->GetNextChar(pString, pOffset);
}
int CPDF_CIDFont::GetCharSize(uint32_t charcode) const {
- return m_pCMap->GetCharSize(charcode);
+ return cmap_->GetCharSize(charcode);
}
size_t CPDF_CIDFont::CountChar(ByteStringView pString) const {
- return m_pCMap->CountChar(pString);
+ return cmap_->CountChar(pString);
}
void CPDF_CIDFont::AppendChar(ByteString* str, uint32_t charcode) const {
- m_pCMap->AppendChar(str, charcode);
+ cmap_->AppendChar(str, charcode);
}
bool CPDF_CIDFont::IsUnicodeCompatible() const {
- if (m_pCID2UnicodeMap && m_pCID2UnicodeMap->IsLoaded() &&
- m_pCMap->IsLoaded()) {
+ if (cid2unicode_map_ && cid2unicode_map_->IsLoaded() && cmap_->IsLoaded()) {
return true;
}
- return m_pCMap->GetCoding() != CIDCoding::kUNKNOWN;
+ return cmap_->GetCoding() != CIDCoding::kUNKNOWN;
}
void CPDF_CIDFont::LoadSubstFont() {
- FX_SAFE_INT32 safe_stem_v(m_StemV);
+ FX_SAFE_INT32 safe_stem_v(stem_v_);
safe_stem_v *= 5;
- m_Font.LoadSubst(
- m_BaseFontName, m_FontType == CIDFontType::kTrueType, m_Flags,
- safe_stem_v.ValueOrDefault(pdfium::kFontWeightNormal), m_ItalicAngle,
- kCharsetCodePages[m_Charset], IsVertWriting());
+ font_.LoadSubst(base_font_name_, font_type_ == CIDFontType::kTrueType, flags_,
+ safe_stem_v.ValueOrDefault(pdfium::kFontWeightNormal),
+ italic_angle_, kCharsetCodePages[charset_], IsVertWriting());
}
// static
@@ -878,14 +876,14 @@
}
void CPDF_CIDFont::LoadGB2312() {
- m_BaseFontName = m_pFontDict->GetByteStringFor("BaseFont");
- m_Charset = CIDSET_GB1;
+ base_font_name_ = font_dict_->GetByteStringFor("BaseFont");
+ charset_ = CIDSET_GB1;
auto* pFontGlobals = CPDF_FontGlobals::GetInstance();
- m_pCMap = pFontGlobals->GetPredefinedCMap("GBK-EUC-H");
- m_pCID2UnicodeMap = pFontGlobals->GetCID2UnicodeMap(m_Charset);
+ cmap_ = pFontGlobals->GetPredefinedCMap("GBK-EUC-H");
+ cid2unicode_map_ = pFontGlobals->GetCID2UnicodeMap(charset_);
RetainPtr<const CPDF_Dictionary> pFontDesc =
- m_pFontDict->GetDictFor("FontDescriptor");
+ font_dict_->GetDictFor("FontDescriptor");
if (pFontDesc) {
LoadFontDescriptor(pFontDesc.Get());
}
@@ -894,11 +892,11 @@
LoadSubstFont();
}
CheckFontMetrics();
- m_bAnsiWidthsFixed = true;
+ ansi_widths_fixed_ = true;
}
const CIDTransform* CPDF_CIDFont::GetCIDTransform(uint16_t cid) const {
- if (m_Charset != CIDSET_JAPAN1 || m_pFontFile) {
+ if (charset_ != CIDSET_JAPAN1 || font_file_) {
return nullptr;
}
diff --git a/core/fpdfapi/font/cpdf_cidfont.h b/core/fpdfapi/font/cpdf_cidfont.h
index 381af67..04c2c2f 100644
--- a/core/fpdfapi/font/cpdf_cidfont.h
+++ b/core/fpdfapi/font/cpdf_cidfont.h
@@ -87,21 +87,21 @@
void LoadSubstFont();
wchar_t GetUnicodeFromCharCode(uint32_t charcode) const;
- RetainPtr<const CPDF_CMap> m_pCMap;
- UnownedPtr<const CPDF_CID2UnicodeMap> m_pCID2UnicodeMap;
- RetainPtr<CPDF_StreamAcc> m_pStreamAcc;
- std::unique_ptr<CFX_CTTGSUBTable> m_pTTGSUBTable;
- CIDFontType m_FontType = CIDFontType::kTrueType;
- bool m_bCIDIsGID = false;
- bool m_bAnsiWidthsFixed = false;
- bool m_bAdobeCourierStd = false;
- CIDSet m_Charset = CIDSET_UNKNOWN;
- int16_t m_DefaultWidth = 1000;
- int16_t m_DefaultVY = 880;
- int16_t m_DefaultW1 = -1000;
- std::vector<int> m_WidthList;
- std::vector<int> m_VertMetrics;
- std::array<FX_RECT, 256> m_CharBBox;
+ RetainPtr<const CPDF_CMap> cmap_;
+ UnownedPtr<const CPDF_CID2UnicodeMap> cid2unicode_map_;
+ RetainPtr<CPDF_StreamAcc> stream_acc_;
+ std::unique_ptr<CFX_CTTGSUBTable> ttg_subtable_;
+ CIDFontType font_type_ = CIDFontType::kTrueType;
+ bool cid_is_gid_ = false;
+ bool ansi_widths_fixed_ = false;
+ bool adobe_courier_std_ = false;
+ CIDSet charset_ = CIDSET_UNKNOWN;
+ int16_t default_width_ = 1000;
+ int16_t default_vy_ = 880;
+ int16_t default_w1_ = -1000;
+ std::vector<int> width_list_;
+ std::vector<int> vert_metrics_;
+ std::array<FX_RECT, 256> char_bbox_;
};
#endif // CORE_FPDFAPI_FONT_CPDF_CIDFONT_H_
diff --git a/core/fpdfapi/font/cpdf_cmap.cpp b/core/fpdfapi/font/cpdf_cmap.cpp
index 3093452..f93a390 100644
--- a/core/fpdfapi/font/cpdf_cmap.cpp
+++ b/core/fpdfapi/font/cpdf_cmap.cpp
@@ -21,16 +21,16 @@
namespace {
struct ByteRange {
- uint8_t m_First;
- uint8_t m_Last; // Inclusive.
+ uint8_t first_;
+ uint8_t last_; // Inclusive.
};
struct PredefinedCMap {
- const char* m_pName; // Raw, POD struct.
- CIDSet m_Charset;
- CIDCoding m_Coding;
- CPDF_CMap::CodingScheme m_CodingScheme;
- ByteRange m_LeadingSegs[2];
+ const char* name_; // Raw, POD struct.
+ CIDSet charset_;
+ CIDCoding coding_;
+ CPDF_CMap::CodingScheme coding_scheme_;
+ ByteRange leading_segs_[2];
};
constexpr PredefinedCMap kPredefinedCMaps[] = {
@@ -161,7 +161,7 @@
cmapid = cmapid.First(cmapid.GetLength() - 2);
}
for (const auto& map : kPredefinedCMaps) {
- if (cmapid == map.m_pName) {
+ if (cmapid == map.name_) {
return ↦
}
}
@@ -170,12 +170,12 @@
std::vector<bool> LoadLeadingSegments(const PredefinedCMap& map) {
std::vector<bool> segments(256);
- const auto seg_span = pdfium::make_span(map.m_LeadingSegs);
+ const auto seg_span = pdfium::make_span(map.leading_segs_);
for (const ByteRange& seg : seg_span) {
- if (seg.m_First == 0 && seg.m_Last == 0) {
+ if (seg.first_ == 0 && seg.last_ == 0) {
break;
}
- for (int b = seg.m_First; b <= seg.m_Last; ++b) {
+ for (int b = seg.first_; b <= seg.last_; ++b) {
segments[b] = true;
}
}
@@ -186,22 +186,22 @@
pdfium::span<const CPDF_CMap::CodeRange> ranges) {
for (size_t i = ranges.size(); i > 0; i--) {
const auto& range = ranges[i - 1];
- if (range.m_CharSize < codes.size()) {
+ if (range.char_size_ < codes.size()) {
continue;
}
size_t iChar = 0;
while (iChar < codes.size()) {
- if (codes[iChar] < range.m_Lower[iChar] ||
- codes[iChar] > range.m_Upper[iChar]) {
+ if (codes[iChar] < range.lower_[iChar] ||
+ codes[iChar] > range.upper_[iChar]) {
break;
}
++iChar;
}
- if (iChar == range.m_CharSize) {
+ if (iChar == range.char_size_) {
return 2;
}
if (iChar) {
- return (codes.size() == range.m_CharSize) ? 2 : 1;
+ return (codes.size() == range.char_size_) ? 2 : 1;
}
}
return 0;
@@ -224,18 +224,18 @@
size_t size = 4 - offset;
for (size_t j = 0; j < ranges.size(); j++) {
size_t iSeg = (ranges.size() - 1) - j;
- if (ranges[iSeg].m_CharSize < size) {
+ if (ranges[iSeg].char_size_ < size) {
continue;
}
size_t iChar = 0;
while (iChar < size) {
- if (codes[offset + iChar] < ranges[iSeg].m_Lower[iChar] ||
- codes[offset + iChar] > ranges[iSeg].m_Upper[iChar]) {
+ if (codes[offset + iChar] < ranges[iSeg].lower_[iChar] ||
+ codes[offset + iChar] > ranges[iSeg].upper_[iChar]) {
break;
}
++iChar;
}
- if (iChar == ranges[iSeg].m_CharSize) {
+ if (iChar == ranges[iSeg].char_size_) {
return size;
}
}
@@ -246,7 +246,7 @@
const fxcmap::CMap* FindEmbeddedCMap(pdfium::span<const fxcmap::CMap> pCMaps,
ByteStringView bsName) {
for (size_t i = 0; i < pCMaps.size(); i++) {
- if (bsName == pCMaps[i].m_Name) {
+ if (bsName == pCMaps[i].name_) {
return &pCMaps[i];
}
}
@@ -256,10 +256,10 @@
} // namespace
CPDF_CMap::CPDF_CMap(ByteStringView bsPredefinedName)
- : m_bVertical(bsPredefinedName.Back() == 'V') {
+ : vertical_(bsPredefinedName.Back() == 'V') {
if (bsPredefinedName == "Identity-H" || bsPredefinedName == "Identity-V") {
- m_Coding = CIDCoding::kCID;
- m_bLoaded = true;
+ coding_ = CIDCoding::kCID;
+ loaded_ = true;
return;
}
@@ -268,24 +268,24 @@
return;
}
- m_Charset = map->m_Charset;
- m_Coding = map->m_Coding;
- m_CodingScheme = map->m_CodingScheme;
- if (m_CodingScheme == MixedTwoBytes) {
- m_MixedTwoByteLeadingBytes = LoadLeadingSegments(*map);
+ charset_ = map->charset_;
+ coding_ = map->coding_;
+ coding_scheme_ = map->coding_scheme_;
+ if (coding_scheme_ == MixedTwoBytes) {
+ mixed_two_byte_leading_bytes_ = LoadLeadingSegments(*map);
}
- m_pEmbedMap = FindEmbeddedCMap(
- CPDF_FontGlobals::GetInstance()->GetEmbeddedCharset(m_Charset),
+ embed_map_ = FindEmbeddedCMap(
+ CPDF_FontGlobals::GetInstance()->GetEmbeddedCharset(charset_),
bsPredefinedName);
- if (!m_pEmbedMap) {
+ if (!embed_map_) {
return;
}
- m_bLoaded = true;
+ loaded_ = true;
}
CPDF_CMap::CPDF_CMap(pdfium::span<const uint8_t> spEmbeddedData)
- : m_DirectCharcodeToCIDTable(
+ : direct_charcode_to_cidtable_(
FixedSizeDataVector<uint16_t>::Zeroed(kDirectMapTableSize)) {
CPDF_CMapParser parser(this);
CPDF_SimpleParser syntax(spEmbeddedData);
@@ -301,39 +301,40 @@
CPDF_CMap::~CPDF_CMap() = default;
uint16_t CPDF_CMap::CIDFromCharCode(uint32_t charcode) const {
- if (m_Coding == CIDCoding::kCID) {
+ if (coding_ == CIDCoding::kCID) {
return static_cast<uint16_t>(charcode);
}
- if (m_pEmbedMap) {
- return fxcmap::CIDFromCharCode(m_pEmbedMap, charcode);
+ if (embed_map_) {
+ return fxcmap::CIDFromCharCode(embed_map_, charcode);
}
- if (m_DirectCharcodeToCIDTable.empty()) {
+ if (direct_charcode_to_cidtable_.empty()) {
return static_cast<uint16_t>(charcode);
}
- auto table_span = m_DirectCharcodeToCIDTable.span();
+ auto table_span = direct_charcode_to_cidtable_.span();
if (charcode < table_span.size()) {
return table_span[charcode];
}
- auto it = std::lower_bound(m_AdditionalCharcodeToCIDMappings.begin(),
- m_AdditionalCharcodeToCIDMappings.end(), charcode,
- [](const CPDF_CMap::CIDRange& arg, uint32_t val) {
- return arg.m_EndCode < val;
- });
- if (it == m_AdditionalCharcodeToCIDMappings.end() ||
- it->m_StartCode > charcode) {
+ auto it =
+ std::lower_bound(additional_charcode_to_cidmappings_.begin(),
+ additional_charcode_to_cidmappings_.end(), charcode,
+ [](const CPDF_CMap::CIDRange& arg, uint32_t val) {
+ return arg.end_code_ < val;
+ });
+ if (it == additional_charcode_to_cidmappings_.end() ||
+ it->start_code_ > charcode) {
return 0;
}
- return it->m_StartCID + charcode - it->m_StartCode;
+ return it->start_cid_ + charcode - it->start_code_;
}
uint32_t CPDF_CMap::GetNextChar(ByteStringView pString, size_t* pOffset) const {
size_t& offset = *pOffset;
auto pBytes = pString.unsigned_span();
- switch (m_CodingScheme) {
+ switch (coding_scheme_) {
case OneByte: {
return offset < pBytes.size() ? pBytes[offset++] : 0;
}
@@ -344,7 +345,7 @@
}
case MixedTwoBytes: {
uint8_t byte1 = offset < pBytes.size() ? pBytes[offset++] : 0;
- if (!m_MixedTwoByteLeadingBytes[byte1]) {
+ if (!mixed_two_byte_leading_bytes_[byte1]) {
return byte1;
}
uint8_t byte2 = offset < pBytes.size() ? pBytes[offset++] : 0;
@@ -357,7 +358,7 @@
while (true) {
int ret =
CheckFourByteCodeRange(pdfium::make_span(codes).first(char_size),
- m_MixedFourByteLeadingRanges);
+ mixed_four_byte_leading_ranges_);
if (ret == 0) {
return 0;
}
@@ -379,7 +380,7 @@
}
int CPDF_CMap::GetCharSize(uint32_t charcode) const {
- switch (m_CodingScheme) {
+ switch (coding_scheme_) {
case OneByte:
return 1;
case TwoBytes:
@@ -405,7 +406,7 @@
}
size_t CPDF_CMap::CountChar(ByteStringView pString) const {
- switch (m_CodingScheme) {
+ switch (coding_scheme_) {
case OneByte:
return pString.GetLength();
case TwoBytes:
@@ -414,7 +415,7 @@
size_t count = 0;
for (size_t i = 0; i < pString.GetLength(); i++) {
count++;
- if (m_MixedTwoByteLeadingBytes[pString[i]]) {
+ if (mixed_two_byte_leading_bytes_[pString[i]]) {
i++;
}
}
@@ -434,7 +435,7 @@
}
void CPDF_CMap::AppendChar(ByteString* str, uint32_t charcode) const {
- switch (m_CodingScheme) {
+ switch (coding_scheme_) {
case OneByte:
*str += static_cast<char>(charcode);
return;
@@ -443,7 +444,7 @@
*str += static_cast<char>(charcode % 256);
return;
case MixedTwoBytes:
- if (charcode < 0x100 && !m_MixedTwoByteLeadingBytes[charcode]) {
+ if (charcode < 0x100 && !mixed_two_byte_leading_bytes_[charcode]) {
*str += static_cast<char>(charcode);
return;
}
@@ -453,7 +454,7 @@
case MixedFourBytes:
if (charcode < 0x100) {
int iSize = static_cast<int>(
- GetFourByteCharSizeImpl(charcode, m_MixedFourByteLeadingRanges));
+ GetFourByteCharSizeImpl(charcode, mixed_four_byte_leading_ranges_));
int pad = iSize != 0 ? iSize - 1 : 0;
for (int i = 0; i < pad; ++i) {
*str += static_cast<char>(0);
@@ -482,27 +483,27 @@
}
void CPDF_CMap::SetAdditionalMappings(std::vector<CIDRange> mappings) {
- DCHECK(m_AdditionalCharcodeToCIDMappings.empty());
- if (m_CodingScheme != MixedFourBytes || mappings.empty()) {
+ DCHECK(additional_charcode_to_cidmappings_.empty());
+ if (coding_scheme_ != MixedFourBytes || mappings.empty()) {
return;
}
std::sort(
mappings.begin(), mappings.end(),
[](const CPDF_CMap::CIDRange& arg1, const CPDF_CMap::CIDRange& arg2) {
- return arg1.m_EndCode < arg2.m_EndCode;
+ return arg1.end_code_ < arg2.end_code_;
});
- m_AdditionalCharcodeToCIDMappings = std::move(mappings);
+ additional_charcode_to_cidmappings_ = std::move(mappings);
}
void CPDF_CMap::SetMixedFourByteLeadingRanges(std::vector<CodeRange> ranges) {
- m_MixedFourByteLeadingRanges = std::move(ranges);
+ mixed_four_byte_leading_ranges_ = std::move(ranges);
}
void CPDF_CMap::SetDirectCharcodeToCIDTableRange(uint32_t start_code,
uint32_t end_code,
uint16_t start_cid) {
- pdfium::span<uint16_t> span = m_DirectCharcodeToCIDTable.span();
+ pdfium::span<uint16_t> span = direct_charcode_to_cidtable_.span();
for (uint32_t code = start_code; code <= end_code; ++code) {
span[code] = static_cast<uint16_t>(start_cid + code - start_code);
}
diff --git a/core/fpdfapi/font/cpdf_cmap.h b/core/fpdfapi/font/cpdf_cmap.h
index 66a4bab..45779e4 100644
--- a/core/fpdfapi/font/cpdf_cmap.h
+++ b/core/fpdfapi/font/cpdf_cmap.h
@@ -45,21 +45,21 @@
};
struct CodeRange {
- size_t m_CharSize;
- std::array<uint8_t, 4> m_Lower;
- std::array<uint8_t, 4> m_Upper;
+ size_t char_size_;
+ std::array<uint8_t, 4> lower_;
+ std::array<uint8_t, 4> upper_;
};
struct CIDRange {
- uint32_t m_StartCode;
- uint32_t m_EndCode;
- uint16_t m_StartCID;
+ uint32_t start_code_;
+ uint32_t end_code_;
+ uint16_t start_cid_;
};
CONSTRUCT_VIA_MAKE_RETAIN;
- bool IsLoaded() const { return m_bLoaded; }
- bool IsVertWriting() const { return m_bVertical; }
+ bool IsLoaded() const { return loaded_; }
+ bool IsVertWriting() const { return vertical_; }
uint16_t CIDFromCharCode(uint32_t charcode) const;
@@ -68,21 +68,21 @@
size_t CountChar(ByteStringView pString) const;
void AppendChar(ByteString* str, uint32_t charcode) const;
- void SetVertical(bool vert) { m_bVertical = vert; }
- void SetCodingScheme(CodingScheme scheme) { m_CodingScheme = scheme; }
+ void SetVertical(bool vert) { vertical_ = vert; }
+ void SetCodingScheme(CodingScheme scheme) { coding_scheme_ = scheme; }
void SetAdditionalMappings(std::vector<CIDRange> mappings);
void SetMixedFourByteLeadingRanges(std::vector<CodeRange> ranges);
- CIDCoding GetCoding() const { return m_Coding; }
- const fxcmap::CMap* GetEmbedMap() const { return m_pEmbedMap; }
- CIDSet GetCharset() const { return m_Charset; }
- void SetCharset(CIDSet set) { m_Charset = set; }
+ CIDCoding GetCoding() const { return coding_; }
+ const fxcmap::CMap* GetEmbedMap() const { return embed_map_; }
+ CIDSet GetCharset() const { return charset_; }
+ void SetCharset(CIDSet set) { charset_ = set; }
void SetDirectCharcodeToCIDTableRange(uint32_t start_code,
uint32_t end_code,
uint16_t start_cid);
bool IsDirectCharcodeToCIDTableIsEmpty() const {
- return m_DirectCharcodeToCIDTable.empty();
+ return direct_charcode_to_cidtable_.empty();
}
private:
@@ -90,16 +90,16 @@
explicit CPDF_CMap(pdfium::span<const uint8_t> spEmbeddedData);
~CPDF_CMap() override;
- bool m_bLoaded = false;
- bool m_bVertical = false;
- CIDSet m_Charset = CIDSET_UNKNOWN;
- CodingScheme m_CodingScheme = TwoBytes;
- CIDCoding m_Coding = CIDCoding::kUNKNOWN;
- std::vector<bool> m_MixedTwoByteLeadingBytes;
- std::vector<CodeRange> m_MixedFourByteLeadingRanges;
- FixedSizeDataVector<uint16_t> m_DirectCharcodeToCIDTable;
- std::vector<CIDRange> m_AdditionalCharcodeToCIDMappings;
- UnownedPtr<const fxcmap::CMap> m_pEmbedMap;
+ bool loaded_ = false;
+ bool vertical_ = false;
+ CIDSet charset_ = CIDSET_UNKNOWN;
+ CodingScheme coding_scheme_ = TwoBytes;
+ CIDCoding coding_ = CIDCoding::kUNKNOWN;
+ std::vector<bool> mixed_two_byte_leading_bytes_;
+ std::vector<CodeRange> mixed_four_byte_leading_ranges_;
+ FixedSizeDataVector<uint16_t> direct_charcode_to_cidtable_;
+ std::vector<CIDRange> additional_charcode_to_cidmappings_;
+ UnownedPtr<const fxcmap::CMap> embed_map_;
};
#endif // CORE_FPDFAPI_FONT_CPDF_CMAP_H_
diff --git a/core/fpdfapi/font/cpdf_cmapparser.cpp b/core/fpdfapi/font/cpdf_cmapparser.cpp
index aace019..e6f018c 100644
--- a/core/fpdfapi/font/cpdf_cmapparser.cpp
+++ b/core/fpdfapi/font/cpdf_cmapparser.cpp
@@ -28,83 +28,84 @@
} // namespace
-CPDF_CMapParser::CPDF_CMapParser(CPDF_CMap* pCMap) : m_pCMap(pCMap) {}
+CPDF_CMapParser::CPDF_CMapParser(CPDF_CMap* pCMap) : cmap_(pCMap) {}
CPDF_CMapParser::~CPDF_CMapParser() {
- m_pCMap->SetAdditionalMappings(std::move(m_AdditionalCharcodeToCIDMappings));
- m_pCMap->SetMixedFourByteLeadingRanges(std::move(m_Ranges));
+ cmap_->SetAdditionalMappings(std::move(additional_charcode_to_cidmappings_));
+ cmap_->SetMixedFourByteLeadingRanges(std::move(ranges_));
}
void CPDF_CMapParser::ParseWord(ByteStringView word) {
DCHECK(!word.IsEmpty());
if (word == "begincidchar") {
- m_Status = kProcessingCidChar;
- m_CodeSeq = 0;
+ status_ = kProcessingCidChar;
+ code_seq_ = 0;
} else if (word == "begincidrange") {
- m_Status = kProcessingCidRange;
- m_CodeSeq = 0;
+ status_ = kProcessingCidRange;
+ code_seq_ = 0;
} else if (word == "endcidrange" || word == "endcidchar") {
- m_Status = kStart;
+ status_ = kStart;
} else if (word == "/WMode") {
- m_Status = kProcessingWMode;
+ status_ = kProcessingWMode;
} else if (word == "/Registry") {
- m_Status = kProcessingRegistry;
+ status_ = kProcessingRegistry;
} else if (word == "/Ordering") {
- m_Status = kProcessingOrdering;
+ status_ = kProcessingOrdering;
} else if (word == "/Supplement") {
- m_Status = kProcessingSupplement;
+ status_ = kProcessingSupplement;
} else if (word == "begincodespacerange") {
- m_Status = kProcessingCodeSpaceRange;
- m_CodeSeq = 0;
+ status_ = kProcessingCodeSpaceRange;
+ code_seq_ = 0;
} else if (word == "usecmap") {
- } else if (m_Status == kProcessingCidChar) {
+ } else if (status_ == kProcessingCidChar) {
HandleCid(word);
- } else if (m_Status == kProcessingCidRange) {
+ } else if (status_ == kProcessingCidRange) {
HandleCid(word);
- } else if (m_Status == kProcessingRegistry) {
- m_Status = kStart;
- } else if (m_Status == kProcessingOrdering) {
- m_pCMap->SetCharset(CharsetFromOrdering(CMap_GetString(word)));
- m_Status = kStart;
- } else if (m_Status == kProcessingSupplement) {
- m_Status = kStart;
- } else if (m_Status == kProcessingWMode) {
- m_pCMap->SetVertical(GetCode(word) != 0);
- m_Status = kStart;
- } else if (m_Status == kProcessingCodeSpaceRange) {
+ } else if (status_ == kProcessingRegistry) {
+ status_ = kStart;
+ } else if (status_ == kProcessingOrdering) {
+ cmap_->SetCharset(CharsetFromOrdering(CMap_GetString(word)));
+ status_ = kStart;
+ } else if (status_ == kProcessingSupplement) {
+ status_ = kStart;
+ } else if (status_ == kProcessingWMode) {
+ cmap_->SetVertical(GetCode(word) != 0);
+ status_ = kStart;
+ } else if (status_ == kProcessingCodeSpaceRange) {
HandleCodeSpaceRange(word);
}
- m_LastWord = word;
+ last_word_ = word;
}
void CPDF_CMapParser::HandleCid(ByteStringView word) {
- DCHECK(m_Status == kProcessingCidChar || m_Status == kProcessingCidRange);
- bool bChar = m_Status == kProcessingCidChar;
+ DCHECK(status_ == kProcessingCidChar || status_ == kProcessingCidRange);
+ bool bChar = status_ == kProcessingCidChar;
- m_CodePoints[m_CodeSeq] = GetCode(word);
- m_CodeSeq++;
+ code_points_[code_seq_] = GetCode(word);
+ code_seq_++;
int nRequiredCodePoints = bChar ? 2 : 3;
- if (m_CodeSeq < nRequiredCodePoints) {
+ if (code_seq_ < nRequiredCodePoints) {
return;
}
- uint32_t StartCode = m_CodePoints[0];
+ uint32_t StartCode = code_points_[0];
uint32_t EndCode;
uint16_t StartCID;
if (bChar) {
EndCode = StartCode;
- StartCID = static_cast<uint16_t>(m_CodePoints[1]);
+ StartCID = static_cast<uint16_t>(code_points_[1]);
} else {
- EndCode = m_CodePoints[1];
- StartCID = static_cast<uint16_t>(m_CodePoints[2]);
+ EndCode = code_points_[1];
+ StartCID = static_cast<uint16_t>(code_points_[2]);
}
if (EndCode < CPDF_CMap::kDirectMapTableSize) {
- m_pCMap->SetDirectCharcodeToCIDTableRange(StartCode, EndCode, StartCID);
+ cmap_->SetDirectCharcodeToCIDTableRange(StartCode, EndCode, StartCID);
} else {
- m_AdditionalCharcodeToCIDMappings.push_back({StartCode, EndCode, StartCID});
+ additional_charcode_to_cidmappings_.push_back(
+ {StartCode, EndCode, StartCID});
}
- m_CodeSeq = 0;
+ code_seq_ = 0;
}
void CPDF_CMapParser::HandleCodeSpaceRange(ByteStringView word) {
@@ -113,31 +114,31 @@
return;
}
- if (m_CodeSeq % 2) {
+ if (code_seq_ % 2) {
std::optional<CPDF_CMap::CodeRange> range =
- GetCodeRange(m_LastWord.AsStringView(), word);
+ GetCodeRange(last_word_.AsStringView(), word);
if (range.has_value()) {
- m_PendingRanges.push_back(range.value());
+ pending_ranges_.push_back(range.value());
}
}
- m_CodeSeq++;
+ code_seq_++;
return;
}
- size_t nSegs = m_Ranges.size() + m_PendingRanges.size();
+ size_t nSegs = ranges_.size() + pending_ranges_.size();
if (nSegs == 1) {
const auto& first_range =
- !m_Ranges.empty() ? m_Ranges[0] : m_PendingRanges[0];
- m_pCMap->SetCodingScheme(first_range.m_CharSize == 2 ? CPDF_CMap::TwoBytes
- : CPDF_CMap::OneByte);
+ !ranges_.empty() ? ranges_[0] : pending_ranges_[0];
+ cmap_->SetCodingScheme(first_range.char_size_ == 2 ? CPDF_CMap::TwoBytes
+ : CPDF_CMap::OneByte);
} else if (nSegs > 1) {
- m_pCMap->SetCodingScheme(CPDF_CMap::MixedFourBytes);
- m_Ranges.reserve(nSegs);
- std::move(m_PendingRanges.begin(), m_PendingRanges.end(),
- std::back_inserter(m_Ranges));
- m_PendingRanges.clear();
+ cmap_->SetCodingScheme(CPDF_CMap::MixedFourBytes);
+ ranges_.reserve(nSegs);
+ std::move(pending_ranges_.begin(), pending_ranges_.end(),
+ std::back_inserter(ranges_));
+ pending_ranges_.clear();
}
- m_Status = kStart;
+ status_ = kStart;
}
// static
@@ -187,21 +188,21 @@
}
CPDF_CMap::CodeRange range;
- range.m_CharSize = char_size;
- for (i = 0; i < range.m_CharSize; ++i) {
+ range.char_size_ = char_size;
+ for (i = 0; i < range.char_size_; ++i) {
uint8_t digit1 = first[i * 2 + 1];
uint8_t digit2 = first[i * 2 + 2];
- range.m_Lower[i] =
+ range.lower_[i] =
FXSYS_HexCharToInt(digit1) * 16 + FXSYS_HexCharToInt(digit2);
}
size_t size = second.GetLength();
- for (i = 0; i < range.m_CharSize; ++i) {
+ for (i = 0; i < range.char_size_; ++i) {
size_t i1 = i * 2 + 1;
size_t i2 = i1 + 1;
uint8_t digit1 = i1 < size ? second[i1] : '0';
uint8_t digit2 = i2 < size ? second[i2] : '0';
- range.m_Upper[i] =
+ range.upper_[i] =
FXSYS_HexCharToInt(digit1) * 16 + FXSYS_HexCharToInt(digit2);
}
return range;
diff --git a/core/fpdfapi/font/cpdf_cmapparser.h b/core/fpdfapi/font/cpdf_cmapparser.h
index 8cefabf..386880d 100644
--- a/core/fpdfapi/font/cpdf_cmapparser.h
+++ b/core/fpdfapi/font/cpdf_cmapparser.h
@@ -48,14 +48,14 @@
ByteStringView first,
ByteStringView second);
- Status m_Status = kStart;
- int m_CodeSeq = 0;
- UnownedPtr<CPDF_CMap> const m_pCMap;
- std::vector<CPDF_CMap::CodeRange> m_Ranges;
- std::vector<CPDF_CMap::CodeRange> m_PendingRanges;
- std::vector<CPDF_CMap::CIDRange> m_AdditionalCharcodeToCIDMappings;
- ByteString m_LastWord;
- std::array<uint32_t, 4> m_CodePoints = {};
+ Status status_ = kStart;
+ int code_seq_ = 0;
+ UnownedPtr<CPDF_CMap> const cmap_;
+ std::vector<CPDF_CMap::CodeRange> ranges_;
+ std::vector<CPDF_CMap::CodeRange> pending_ranges_;
+ std::vector<CPDF_CMap::CIDRange> additional_charcode_to_cidmappings_;
+ ByteString last_word_;
+ std::array<uint32_t, 4> code_points_ = {};
};
#endif // CORE_FPDFAPI_FONT_CPDF_CMAPPARSER_H_
diff --git a/core/fpdfapi/font/cpdf_cmapparser_unittest.cpp b/core/fpdfapi/font/cpdf_cmapparser_unittest.cpp
index 03fbdc5..472e441 100644
--- a/core/fpdfapi/font/cpdf_cmapparser_unittest.cpp
+++ b/core/fpdfapi/font/cpdf_cmapparser_unittest.cpp
@@ -46,31 +46,31 @@
range = CPDF_CMapParser::GetCodeRange("A", "");
EXPECT_FALSE(range.has_value());
- // m_CharSize must be <= 4
+ // char_size_ must be <= 4
range = CPDF_CMapParser::GetCodeRange("<aaaaaaaaaa>", "");
EXPECT_FALSE(range.has_value());
range = CPDF_CMapParser::GetCodeRange("<12345678>", "<87654321>");
ASSERT_TRUE(range.has_value());
- ASSERT_EQ(4u, range.value().m_CharSize);
+ ASSERT_EQ(4u, range.value().char_size_);
{
static constexpr uint8_t kLower[4] = {18, 52, 86, 120};
static constexpr uint8_t kUpper[4] = {135, 101, 67, 33};
- EXPECT_TRUE(uint_ranges_equal(kLower, range.value().m_Lower));
- EXPECT_TRUE(uint_ranges_equal(kUpper, range.value().m_Upper));
+ EXPECT_TRUE(uint_ranges_equal(kLower, range.value().lower_));
+ EXPECT_TRUE(uint_ranges_equal(kUpper, range.value().upper_));
}
// Hex characters
range = CPDF_CMapParser::GetCodeRange("<a1>", "<F3>");
ASSERT_TRUE(range.has_value());
- ASSERT_EQ(1u, range.value().m_CharSize);
- EXPECT_EQ(161, range.value().m_Lower[0]);
- EXPECT_EQ(243, range.value().m_Upper[0]);
+ ASSERT_EQ(1u, range.value().char_size_);
+ EXPECT_EQ(161, range.value().lower_[0]);
+ EXPECT_EQ(243, range.value().upper_[0]);
// The second string should return 0's if it is shorter
range = CPDF_CMapParser::GetCodeRange("<a1>", "");
ASSERT_TRUE(range.has_value());
- ASSERT_EQ(1u, range.value().m_CharSize);
- EXPECT_EQ(161, range.value().m_Lower[0]);
- EXPECT_EQ(0, range.value().m_Upper[0]);
+ ASSERT_EQ(1u, range.value().char_size_);
+ EXPECT_EQ(161, range.value().lower_[0]);
+ EXPECT_EQ(0, range.value().upper_[0]);
}
diff --git a/core/fpdfapi/font/cpdf_font.cpp b/core/fpdfapi/font/cpdf_font.cpp
index db711a2..3a5c5fb 100644
--- a/core/fpdfapi/font/cpdf_font.cpp
+++ b/core/fpdfapi/font/cpdf_font.cpp
@@ -49,13 +49,13 @@
CPDF_Font::CPDF_Font(CPDF_Document* pDocument,
RetainPtr<CPDF_Dictionary> pFontDict)
- : m_pDocument(pDocument),
- m_pFontDict(std::move(pFontDict)),
- m_BaseFontName(m_pFontDict->GetByteStringFor("BaseFont")) {}
+ : document_(pDocument),
+ font_dict_(std::move(pFontDict)),
+ base_font_name_(font_dict_->GetByteStringFor("BaseFont")) {}
CPDF_Font::~CPDF_Font() {
- if (!m_bWillBeDestroyed && m_pFontFile) {
- m_pDocument->MaybePurgeFontFileStreamAcc(std::move(m_pFontFile));
+ if (!will_be_destroyed_ && font_file_) {
+ document_->MaybePurgeFontFileStreamAcc(std::move(font_file_));
}
}
@@ -118,12 +118,12 @@
#endif
void CPDF_Font::WillBeDestroyed() {
- m_bWillBeDestroyed = true;
+ will_be_destroyed_ = true;
}
bool CPDF_Font::IsVertWriting() const {
const CPDF_CIDFont* pCIDFont = AsCIDFont();
- return pCIDFont ? pCIDFont->IsVertWriting() : m_Font.IsVertical();
+ return pCIDFont ? pCIDFont->IsVertWriting() : font_.IsVertical();
}
void CPDF_Font::AppendChar(ByteString* str, uint32_t charcode) const {
@@ -131,19 +131,19 @@
}
WideString CPDF_Font::UnicodeFromCharCode(uint32_t charcode) const {
- if (!m_bToUnicodeLoaded) {
+ if (!to_unicode_loaded_) {
LoadUnicodeMap();
}
- return m_pToUnicodeMap ? m_pToUnicodeMap->Lookup(charcode) : WideString();
+ return to_unicode_map_ ? to_unicode_map_->Lookup(charcode) : WideString();
}
uint32_t CPDF_Font::CharCodeFromUnicode(wchar_t unicode) const {
- if (!m_bToUnicodeLoaded) {
+ if (!to_unicode_loaded_) {
LoadUnicodeMap();
}
- return m_pToUnicodeMap ? m_pToUnicodeMap->ReverseLookup(unicode) : 0;
+ return to_unicode_map_ ? to_unicode_map_->ReverseLookup(unicode) : 0;
}
bool CPDF_Font::HasFontWidths() const {
@@ -151,7 +151,7 @@
}
void CPDF_Font::LoadFontDescriptor(const CPDF_Dictionary* pFontDesc) {
- m_Flags = pFontDesc->GetIntegerFor("Flags", pdfium::kFontStyleNonSymbolic);
+ flags_ = pFontDesc->GetIntegerFor("Flags", pdfium::kFontStyleNonSymbolic);
int ItalicAngle = 0;
bool bExistItalicAngle = false;
if (pFontDesc->KeyExist("ItalicAngle")) {
@@ -159,22 +159,22 @@
bExistItalicAngle = true;
}
if (ItalicAngle < 0) {
- m_Flags |= pdfium::kFontStyleItalic;
- m_ItalicAngle = ItalicAngle;
+ flags_ |= pdfium::kFontStyleItalic;
+ italic_angle_ = ItalicAngle;
}
bool bExistStemV = false;
if (pFontDesc->KeyExist("StemV")) {
- m_StemV = pFontDesc->GetIntegerFor("StemV");
+ stem_v_ = pFontDesc->GetIntegerFor("StemV");
bExistStemV = true;
}
bool bExistAscent = false;
if (pFontDesc->KeyExist("Ascent")) {
- m_Ascent = pFontDesc->GetIntegerFor("Ascent");
+ ascent_ = pFontDesc->GetIntegerFor("Ascent");
bExistAscent = true;
}
bool bExistDescent = false;
if (pFontDesc->KeyExist("Descent")) {
- m_Descent = pFontDesc->GetIntegerFor("Descent");
+ descent_ = pFontDesc->GetIntegerFor("Descent");
bExistDescent = true;
}
bool bExistCapHeight = false;
@@ -183,17 +183,17 @@
}
if (bExistItalicAngle && bExistAscent && bExistCapHeight && bExistDescent &&
bExistStemV) {
- m_Flags |= FXFONT_USEEXTERNATTR;
+ flags_ |= FXFONT_USEEXTERNATTR;
}
- if (m_Descent > 10) {
- m_Descent = -m_Descent;
+ if (descent_ > 10) {
+ descent_ = -descent_;
}
RetainPtr<const CPDF_Array> pBBox = pFontDesc->GetArrayFor("FontBBox");
if (pBBox) {
- m_FontBBox.left = pBBox->GetIntegerAt(0);
- m_FontBBox.bottom = pBBox->GetIntegerAt(1);
- m_FontBBox.right = pBBox->GetIntegerAt(2);
- m_FontBBox.top = pBBox->GetIntegerAt(3);
+ font_bbox_.left = pBBox->GetIntegerAt(0);
+ font_bbox_.bottom = pBBox->GetIntegerAt(1);
+ font_bbox_.right = pBBox->GetIntegerAt(2);
+ font_bbox_.top = pBBox->GetIntegerAt(3);
}
RetainPtr<const CPDF_Stream> pFontFile = pFontDesc->GetStreamFor("FontFile");
@@ -208,30 +208,30 @@
}
const uint64_t key = pFontFile->KeyForCache();
- m_pFontFile = m_pDocument->GetFontFileStreamAcc(std::move(pFontFile));
- if (!m_pFontFile) {
+ font_file_ = document_->GetFontFileStreamAcc(std::move(pFontFile));
+ if (!font_file_) {
return;
}
- if (!m_Font.LoadEmbedded(m_pFontFile->GetSpan(), IsVertWriting(), key)) {
- m_pDocument->MaybePurgeFontFileStreamAcc(std::move(m_pFontFile));
+ if (!font_.LoadEmbedded(font_file_->GetSpan(), IsVertWriting(), key)) {
+ document_->MaybePurgeFontFileStreamAcc(std::move(font_file_));
}
}
void CPDF_Font::CheckFontMetrics() {
- if (m_FontBBox.top == 0 && m_FontBBox.bottom == 0 && m_FontBBox.left == 0 &&
- m_FontBBox.right == 0) {
- RetainPtr<CFX_Face> face = m_Font.GetFace();
+ if (font_bbox_.top == 0 && font_bbox_.bottom == 0 && font_bbox_.left == 0 &&
+ font_bbox_.right == 0) {
+ RetainPtr<CFX_Face> face = font_.GetFace();
if (face) {
- // Note that `m_FontBBox` is deliberately flipped.
+ // Note that `font_bbox_` is deliberately flipped.
const FX_RECT raw_bbox = face->GetBBox();
const uint16_t upem = face->GetUnitsPerEm();
- m_FontBBox.left = NormalizeFontMetric(raw_bbox.left, upem);
- m_FontBBox.bottom = NormalizeFontMetric(raw_bbox.top, upem);
- m_FontBBox.right = NormalizeFontMetric(raw_bbox.right, upem);
- m_FontBBox.top = NormalizeFontMetric(raw_bbox.bottom, upem);
- m_Ascent = NormalizeFontMetric(face->GetAscender(), upem);
- m_Descent = NormalizeFontMetric(face->GetDescender(), upem);
+ font_bbox_.left = NormalizeFontMetric(raw_bbox.left, upem);
+ font_bbox_.bottom = NormalizeFontMetric(raw_bbox.top, upem);
+ font_bbox_.right = NormalizeFontMetric(raw_bbox.right, upem);
+ font_bbox_.top = NormalizeFontMetric(raw_bbox.bottom, upem);
+ ascent_ = NormalizeFontMetric(face->GetAscender(), upem);
+ descent_ = NormalizeFontMetric(face->GetDescender(), upem);
} else {
bool bFirst = true;
for (int i = 0; i < 256; i++) {
@@ -240,33 +240,33 @@
continue;
}
if (bFirst) {
- m_FontBBox = rect;
+ font_bbox_ = rect;
bFirst = false;
} else {
- m_FontBBox.left = std::min(m_FontBBox.left, rect.left);
- m_FontBBox.top = std::max(m_FontBBox.top, rect.top);
- m_FontBBox.right = std::max(m_FontBBox.right, rect.right);
- m_FontBBox.bottom = std::min(m_FontBBox.bottom, rect.bottom);
+ font_bbox_.left = std::min(font_bbox_.left, rect.left);
+ font_bbox_.top = std::max(font_bbox_.top, rect.top);
+ font_bbox_.right = std::max(font_bbox_.right, rect.right);
+ font_bbox_.bottom = std::min(font_bbox_.bottom, rect.bottom);
}
}
}
}
- if (m_Ascent == 0 && m_Descent == 0) {
+ if (ascent_ == 0 && descent_ == 0) {
FX_RECT rect = GetCharBBox('A');
- m_Ascent = rect.bottom == rect.top ? m_FontBBox.top : rect.top;
+ ascent_ = rect.bottom == rect.top ? font_bbox_.top : rect.top;
rect = GetCharBBox('g');
- m_Descent = rect.bottom == rect.top ? m_FontBBox.bottom : rect.bottom;
+ descent_ = rect.bottom == rect.top ? font_bbox_.bottom : rect.bottom;
}
}
void CPDF_Font::LoadUnicodeMap() const {
- m_bToUnicodeLoaded = true;
- RetainPtr<const CPDF_Stream> pStream = m_pFontDict->GetStreamFor("ToUnicode");
+ to_unicode_loaded_ = true;
+ RetainPtr<const CPDF_Stream> pStream = font_dict_->GetStreamFor("ToUnicode");
if (!pStream) {
return;
}
- m_pToUnicodeMap = std::make_unique<CPDF_ToUnicodeMap>(std::move(pStream));
+ to_unicode_map_ = std::make_unique<CPDF_ToUnicodeMap>(std::move(pStream));
}
int CPDF_Font::GetStringWidth(ByteStringView pString) {
@@ -354,14 +354,14 @@
if (!IsType1Font()) {
return false;
}
- if (m_pFontFile) {
+ if (font_file_) {
return false;
}
return AsType1Font()->IsBase14Font();
}
std::optional<FX_Charset> CPDF_Font::GetSubstFontCharset() const {
- CFX_SubstFont* pFont = m_Font.GetSubstFont();
+ CFX_SubstFont* pFont = font_.GetSubstFont();
if (!pFont) {
return std::nullopt;
}
@@ -394,26 +394,26 @@
}
uint32_t CPDF_Font::FallbackFontFromCharcode(uint32_t charcode) {
- if (m_FontFallbacks.empty()) {
- m_FontFallbacks.push_back(std::make_unique<CFX_Font>());
- FX_SAFE_INT32 safe_weight = m_StemV;
+ if (font_fallbacks_.empty()) {
+ font_fallbacks_.push_back(std::make_unique<CFX_Font>());
+ FX_SAFE_INT32 safe_weight = stem_v_;
safe_weight *= 5;
- m_FontFallbacks[0]->LoadSubst(
- "Arial", IsTrueTypeFont(), m_Flags,
- safe_weight.ValueOrDefault(pdfium::kFontWeightNormal), m_ItalicAngle,
+ font_fallbacks_[0]->LoadSubst(
+ "Arial", IsTrueTypeFont(), flags_,
+ safe_weight.ValueOrDefault(pdfium::kFontWeightNormal), italic_angle_,
FX_CodePage::kDefANSI, IsVertWriting());
}
return 0;
}
int CPDF_Font::FallbackGlyphFromCharcode(int fallbackFont, uint32_t charcode) {
- if (!fxcrt::IndexInBounds(m_FontFallbacks, fallbackFont)) {
+ if (!fxcrt::IndexInBounds(font_fallbacks_, fallbackFont)) {
return -1;
}
WideString str = UnicodeFromCharCode(charcode);
uint32_t unicode = !str.IsEmpty() ? str[0] : charcode;
- int glyph = m_FontFallbacks[fallbackFont]->GetFace()->GetCharIndex(unicode);
+ int glyph = font_fallbacks_[fallbackFont]->GetFace()->GetCharIndex(unicode);
if (glyph == 0) {
return -1;
}
@@ -422,10 +422,10 @@
}
CFX_Font* CPDF_Font::GetFontFallback(int position) {
- if (position < 0 || static_cast<size_t>(position) >= m_FontFallbacks.size()) {
+ if (position < 0 || static_cast<size_t>(position) >= font_fallbacks_.size()) {
return nullptr;
}
- return m_FontFallbacks[position].get();
+ return font_fallbacks_[position].get();
}
// static
@@ -443,8 +443,8 @@
}
std::optional<int> CPDF_Font::GetFontWeight() const {
- FX_SAFE_INT32 safe_stem_v(m_StemV);
- if (m_StemV < 140) {
+ FX_SAFE_INT32 safe_stem_v(stem_v_);
+ if (stem_v_ < 140) {
safe_stem_v *= 5;
} else {
safe_stem_v = safe_stem_v * 4 + 140;
diff --git a/core/fpdfapi/font/cpdf_font.h b/core/fpdfapi/font/cpdf_font.h
index d940a06..ca1a0fe 100644
--- a/core/fpdfapi/font/cpdf_font.h
+++ b/core/fpdfapi/font/cpdf_font.h
@@ -95,27 +95,27 @@
virtual uint32_t CharCodeFromUnicode(wchar_t Unicode) const;
virtual bool HasFontWidths() const;
- ByteString GetBaseFontName() const { return m_BaseFontName; }
+ ByteString GetBaseFontName() const { return base_font_name_; }
std::optional<FX_Charset> GetSubstFontCharset() const;
- bool IsEmbedded() const { return IsType3Font() || m_pFontFile != nullptr; }
- RetainPtr<CPDF_Dictionary> GetMutableFontDict() { return m_pFontDict; }
- RetainPtr<const CPDF_Dictionary> GetFontDict() const { return m_pFontDict; }
- uint32_t GetFontDictObjNum() const { return m_pFontDict->GetObjNum(); }
+ bool IsEmbedded() const { return IsType3Font() || font_file_ != nullptr; }
+ RetainPtr<CPDF_Dictionary> GetMutableFontDict() { return font_dict_; }
+ RetainPtr<const CPDF_Dictionary> GetFontDict() const { return font_dict_; }
+ uint32_t GetFontDictObjNum() const { return font_dict_->GetObjNum(); }
bool FontDictIs(const CPDF_Dictionary* pThat) const {
- return m_pFontDict == pThat;
+ return font_dict_ == pThat;
}
- void ClearFontDict() { m_pFontDict = nullptr; }
+ void ClearFontDict() { font_dict_ = nullptr; }
bool IsStandardFont() const;
- bool HasFace() const { return !!m_Font.GetFace(); }
+ bool HasFace() const { return !!font_.GetFace(); }
- const FX_RECT& GetFontBBox() const { return m_FontBBox; }
- int GetTypeAscent() const { return m_Ascent; }
- int GetTypeDescent() const { return m_Descent; }
+ const FX_RECT& GetFontBBox() const { return font_bbox_; }
+ int GetTypeAscent() const { return ascent_; }
+ int GetTypeDescent() const { return descent_; }
int GetStringWidth(ByteStringView pString);
uint32_t FallbackFontFromCharcode(uint32_t charcode);
int FallbackGlyphFromCharcode(int fallbackFont, uint32_t charcode);
- int GetFontFlags() const { return m_Flags; }
- int GetItalicAngle() const { return m_ItalicAngle; }
+ int GetFontFlags() const { return flags_; }
+ int GetItalicAngle() const { return italic_angle_; }
// Note that even when non-nullopt, the value may be outside the normal range
// of [100, 900].
@@ -126,15 +126,15 @@
// Can return nullptr for stock Type1 fonts. Always returns non-null for other
// font types.
- CPDF_Document* GetDocument() const { return m_pDocument; }
+ CPDF_Document* GetDocument() const { return document_; }
- CFX_Font* GetFont() { return &m_Font; }
- const CFX_Font* GetFont() const { return &m_Font; }
+ CFX_Font* GetFont() { return &font_; }
+ const CFX_Font* GetFont() const { return &font_; }
CFX_Font* GetFontFallback(int position);
- const ByteString& GetResourceName() const { return m_ResourceName; }
- void SetResourceName(const ByteString& name) { m_ResourceName = name; }
+ const ByteString& GetResourceName() const { return resource_name_; }
+ void SetResourceName(const ByteString& name) { resource_name_ = name; }
protected:
CPDF_Font(CPDF_Document* pDocument, RetainPtr<CPDF_Dictionary> pFontDict);
@@ -164,22 +164,22 @@
void LoadFontDescriptor(const CPDF_Dictionary* pFontDesc);
void CheckFontMetrics();
- UnownedPtr<CPDF_Document> const m_pDocument;
- ByteString m_ResourceName; // The resource name for this font.
- CFX_Font m_Font;
- std::vector<std::unique_ptr<CFX_Font>> m_FontFallbacks;
- RetainPtr<CPDF_StreamAcc> m_pFontFile;
- RetainPtr<CPDF_Dictionary> m_pFontDict;
- ByteString m_BaseFontName;
- mutable std::unique_ptr<CPDF_ToUnicodeMap> m_pToUnicodeMap;
- mutable bool m_bToUnicodeLoaded = false;
- bool m_bWillBeDestroyed = false;
- int m_Flags = 0;
- int m_StemV = 0;
- int m_Ascent = 0;
- int m_Descent = 0;
- int m_ItalicAngle = 0;
- FX_RECT m_FontBBox;
+ UnownedPtr<CPDF_Document> const document_;
+ ByteString resource_name_; // The resource name for this font.
+ CFX_Font font_;
+ std::vector<std::unique_ptr<CFX_Font>> font_fallbacks_;
+ RetainPtr<CPDF_StreamAcc> font_file_;
+ RetainPtr<CPDF_Dictionary> font_dict_;
+ ByteString base_font_name_;
+ mutable std::unique_ptr<CPDF_ToUnicodeMap> to_unicode_map_;
+ mutable bool to_unicode_loaded_ = false;
+ bool will_be_destroyed_ = false;
+ int flags_ = 0;
+ int stem_v_ = 0;
+ int ascent_ = 0;
+ int descent_ = 0;
+ int italic_angle_ = 0;
+ FX_RECT font_bbox_;
};
#endif // CORE_FPDFAPI_FONT_CPDF_FONT_H_
diff --git a/core/fpdfapi/font/cpdf_fontencoding.cpp b/core/fpdfapi/font/cpdf_fontencoding.cpp
index f035826..cd9108c3 100644
--- a/core/fpdfapi/font/cpdf_fontencoding.cpp
+++ b/core/fpdfapi/font/cpdf_fontencoding.cpp
@@ -1658,8 +1658,8 @@
} // namespace
int CPDF_FontEncoding::CharCodeFromUnicode(wchar_t unicode) const {
- for (size_t i = 0; i < std::size(m_Unicodes); i++) {
- if (m_Unicodes[i] == unicode) {
+ for (size_t i = 0; i < std::size(unicodes_); i++) {
+ if (unicodes_[i] == unicode) {
return static_cast<int>(i);
}
}
@@ -1673,13 +1673,13 @@
return;
}
- for (size_t i = 0; i < std::size(m_Unicodes); i++) {
- m_Unicodes[i] = src[i];
+ for (size_t i = 0; i < std::size(unicodes_); i++) {
+ unicodes_[i] = src[i];
}
}
bool CPDF_FontEncoding::IsIdentical(const CPDF_FontEncoding* pAnother) const {
- return m_Unicodes == pAnother->m_Unicodes;
+ return unicodes_ == pAnother->unicodes_;
}
RetainPtr<CPDF_Object> CPDF_FontEncoding::Realize(
@@ -1694,8 +1694,8 @@
for (FontEncoding cs : kEncodings) {
pdfium::span<const uint16_t> src = UnicodesForPredefinedCharSet(cs);
bool match = true;
- for (size_t i = 0; i < std::size(m_Unicodes); i++) {
- if (m_Unicodes[i] != src[i]) {
+ for (size_t i = 0; i < std::size(unicodes_); i++) {
+ if (unicodes_[i] != src[i]) {
match = false;
break;
}
@@ -1722,13 +1722,13 @@
pdfium::span<const uint16_t> standard =
UnicodesForPredefinedCharSet(FontEncoding::kWinAnsi);
auto pDiff = pdfium::MakeRetain<CPDF_Array>();
- for (size_t i = 0; i < std::size(m_Unicodes); i++) {
- if (standard[i] == m_Unicodes[i]) {
+ for (size_t i = 0; i < std::size(unicodes_); i++) {
+ if (standard[i] == unicodes_[i]) {
continue;
}
pDiff->AppendNew<CPDF_Number>(static_cast<int>(i));
- pDiff->AppendNew<CPDF_Name>(AdobeNameFromUnicode(m_Unicodes[i]));
+ pDiff->AppendNew<CPDF_Name>(AdobeNameFromUnicode(unicodes_[i]));
}
auto pDict = pdfium::MakeRetain<CPDF_Dictionary>(pPool);
diff --git a/core/fpdfapi/font/cpdf_fontencoding.h b/core/fpdfapi/font/cpdf_fontencoding.h
index c136ba3..18ebd06 100644
--- a/core/fpdfapi/font/cpdf_fontencoding.h
+++ b/core/fpdfapi/font/cpdf_fontencoding.h
@@ -49,18 +49,18 @@
bool IsIdentical(const CPDF_FontEncoding* pAnother) const;
wchar_t UnicodeFromCharCode(uint8_t charcode) const {
- return m_Unicodes[charcode];
+ return unicodes_[charcode];
}
int CharCodeFromUnicode(wchar_t unicode) const;
void SetUnicode(uint8_t charcode, wchar_t unicode) {
- m_Unicodes[charcode] = unicode;
+ unicodes_[charcode] = unicode;
}
RetainPtr<CPDF_Object> Realize(WeakPtr<ByteStringPool> pPool) const;
private:
- std::array<wchar_t, kEncodingTableSize> m_Unicodes = {};
+ std::array<wchar_t, kEncodingTableSize> unicodes_ = {};
};
#endif // CORE_FPDFAPI_FONT_CPDF_FONTENCODING_H_
diff --git a/core/fpdfapi/font/cpdf_fontglobals.cpp b/core/fpdfapi/font/cpdf_fontglobals.cpp
index 2d0e035..71c12f3 100644
--- a/core/fpdfapi/font/cpdf_fontglobals.cpp
+++ b/core/fpdfapi/font/cpdf_fontglobals.cpp
@@ -65,8 +65,8 @@
RetainPtr<CPDF_Font> CPDF_FontGlobals::Find(
CPDF_Document* pDoc,
CFX_FontMapper::StandardFont index) {
- auto it = m_StockMap.find(pDoc);
- if (it == m_StockMap.end() || !it->second) {
+ auto it = stock_map_.find(pDoc);
+ if (it == stock_map_.end() || !it->second) {
return nullptr;
}
@@ -77,18 +77,18 @@
CFX_FontMapper::StandardFont index,
RetainPtr<CPDF_Font> pFont) {
UnownedPtr<CPDF_Document> pKey(pDoc);
- if (!pdfium::Contains(m_StockMap, pKey)) {
- m_StockMap[pKey] = std::make_unique<CFX_StockFontArray>();
+ if (!pdfium::Contains(stock_map_, pKey)) {
+ stock_map_[pKey] = std::make_unique<CFX_StockFontArray>();
}
- m_StockMap[pKey]->SetFont(index, std::move(pFont));
+ stock_map_[pKey]->SetFont(index, std::move(pFont));
}
void CPDF_FontGlobals::Clear(CPDF_Document* pDoc) {
// Avoid constructing smart-pointer key as erase() doesn't invoke
// transparent lookup in the same way find() does.
- auto it = m_StockMap.find(pDoc);
- if (it != m_StockMap.end()) {
- m_StockMap.erase(it);
+ auto it = stock_map_.find(pDoc);
+ if (it != stock_map_.end()) {
+ stock_map_.erase(it);
}
}
@@ -114,22 +114,22 @@
RetainPtr<const CPDF_CMap> CPDF_FontGlobals::GetPredefinedCMap(
const ByteString& name) {
- auto it = m_CMaps.find(name);
- if (it != m_CMaps.end()) {
+ auto it = cmaps_.find(name);
+ if (it != cmaps_.end()) {
return it->second;
}
RetainPtr<const CPDF_CMap> pCMap = LoadPredefinedCMap(name.AsStringView());
if (!name.IsEmpty()) {
- m_CMaps[name] = pCMap;
+ cmaps_[name] = pCMap;
}
return pCMap;
}
CPDF_CID2UnicodeMap* CPDF_FontGlobals::GetCID2UnicodeMap(CIDSet charset) {
- if (!m_CID2UnicodeMaps[charset]) {
- m_CID2UnicodeMaps[charset] = std::make_unique<CPDF_CID2UnicodeMap>(charset);
+ if (!cid2unicode_maps_[charset]) {
+ cid2unicode_maps_[charset] = std::make_unique<CPDF_CID2UnicodeMap>(charset);
}
- return m_CID2UnicodeMaps[charset].get();
+ return cid2unicode_maps_[charset].get();
}
diff --git a/core/fpdfapi/font/cpdf_fontglobals.h b/core/fpdfapi/font/cpdf_fontglobals.h
index 9df50f8..e17dc56 100644
--- a/core/fpdfapi/font/cpdf_fontglobals.h
+++ b/core/fpdfapi/font/cpdf_fontglobals.h
@@ -40,16 +40,16 @@
RetainPtr<CPDF_Font> pFont);
void SetEmbeddedCharset(CIDSet idx, pdfium::span<const fxcmap::CMap> map) {
- m_EmbeddedCharsets[idx] = map;
+ embedded_charsets_[idx] = map;
}
pdfium::span<const fxcmap::CMap> GetEmbeddedCharset(CIDSet idx) const {
- return m_EmbeddedCharsets[idx];
+ return embedded_charsets_[idx];
}
void SetEmbeddedToUnicode(CIDSet idx, pdfium::span<const uint16_t> map) {
- m_EmbeddedToUnicodes[idx] = map;
+ embedded_to_unicodes_[idx] = map;
}
pdfium::span<const uint16_t> GetEmbeddedToUnicode(CIDSet idx) {
- return m_EmbeddedToUnicodes[idx];
+ return embedded_to_unicodes_[idx];
}
RetainPtr<const CPDF_CMap> GetPredefinedCMap(const ByteString& name);
@@ -64,17 +64,17 @@
void LoadEmbeddedJapan1CMaps();
void LoadEmbeddedKorea1CMaps();
- std::map<ByteString, RetainPtr<const CPDF_CMap>> m_CMaps;
+ std::map<ByteString, RetainPtr<const CPDF_CMap>> cmaps_;
std::array<std::unique_ptr<CPDF_CID2UnicodeMap>, CIDSET_NUM_SETS>
- m_CID2UnicodeMaps;
+ cid2unicode_maps_;
std::array<pdfium::raw_span<const fxcmap::CMap>, CIDSET_NUM_SETS>
- m_EmbeddedCharsets;
+ embedded_charsets_;
std::array<pdfium::raw_span<const uint16_t>, CIDSET_NUM_SETS>
- m_EmbeddedToUnicodes;
+ embedded_to_unicodes_;
std::map<UnownedPtr<CPDF_Document>,
std::unique_ptr<CFX_StockFontArray>,
std::less<>>
- m_StockMap;
+ stock_map_;
};
#endif // CORE_FPDFAPI_FONT_CPDF_FONTGLOBALS_H_
diff --git a/core/fpdfapi/font/cpdf_simplefont.cpp b/core/fpdfapi/font/cpdf_simplefont.cpp
index 40a1bbb..7fac067 100644
--- a/core/fpdfapi/font/cpdf_simplefont.cpp
+++ b/core/fpdfapi/font/cpdf_simplefont.cpp
@@ -38,9 +38,9 @@
CPDF_SimpleFont::CPDF_SimpleFont(CPDF_Document* pDocument,
RetainPtr<CPDF_Dictionary> pFontDict)
: CPDF_Font(pDocument, std::move(pFontDict)) {
- m_CharWidth.fill(0xffff);
- m_GlyphIndex.fill(0xffff);
- m_CharBBox.fill(FX_RECT(-1, -1, -1, -1));
+ char_width_.fill(0xffff);
+ glyph_index_.fill(0xffff);
+ char_bbox_.fill(FX_RECT(-1, -1, -1, -1));
}
CPDF_SimpleFont::~CPDF_SimpleFont() = default;
@@ -54,7 +54,7 @@
return -1;
}
- int index = m_GlyphIndex[charcode];
+ int index = glyph_index_[charcode];
if (index == 0xffff) {
return -1;
}
@@ -63,25 +63,25 @@
}
void CPDF_SimpleFont::LoadCharMetrics(int charcode) {
- if (!m_Font.GetFaceRec()) {
+ if (!font_.GetFaceRec()) {
return;
}
if (charcode < 0 || charcode > 0xff) {
return;
}
- int glyph_index = m_GlyphIndex[charcode];
+ int glyph_index = glyph_index_[charcode];
if (glyph_index == 0xffff) {
- if (!m_pFontFile && charcode != 32) {
+ if (!font_file_ && charcode != 32) {
LoadCharMetrics(32);
- m_CharBBox[charcode] = m_CharBBox[32];
- if (m_bUseFontWidth) {
- m_CharWidth[charcode] = m_CharWidth[32];
+ char_bbox_[charcode] = char_bbox_[32];
+ if (use_font_width_) {
+ char_width_[charcode] = char_width_[32];
}
}
return;
}
- RetainPtr<CFX_Face> face = m_Font.GetFace();
+ RetainPtr<CFX_Face> face = font_.GetFace();
if (!face) {
return;
}
@@ -94,36 +94,36 @@
return;
}
- m_CharBBox[charcode] = face->GetGlyphBBox();
+ char_bbox_[charcode] = face->GetGlyphBBox();
- if (m_bUseFontWidth) {
+ if (use_font_width_) {
int TT_Width = NormalizeFontMetric(FXFT_Get_Glyph_HoriAdvance(face_rec),
face->GetUnitsPerEm());
- if (m_CharWidth[charcode] == 0xffff) {
- m_CharWidth[charcode] = TT_Width;
+ if (char_width_[charcode] == 0xffff) {
+ char_width_[charcode] = TT_Width;
} else if (TT_Width && !IsEmbedded()) {
- m_CharBBox[charcode].right =
- m_CharBBox[charcode].right * m_CharWidth[charcode] / TT_Width;
- m_CharBBox[charcode].left =
- m_CharBBox[charcode].left * m_CharWidth[charcode] / TT_Width;
+ char_bbox_[charcode].right =
+ char_bbox_[charcode].right * char_width_[charcode] / TT_Width;
+ char_bbox_[charcode].left =
+ char_bbox_[charcode].left * char_width_[charcode] / TT_Width;
}
}
}
void CPDF_SimpleFont::LoadCharWidths(const CPDF_Dictionary* font_desc) {
- RetainPtr<const CPDF_Array> width_array = m_pFontDict->GetArrayFor("Widths");
- m_bUseFontWidth = !width_array;
+ RetainPtr<const CPDF_Array> width_array = font_dict_->GetArrayFor("Widths");
+ use_font_width_ = !width_array;
if (!width_array) {
return;
}
if (font_desc && font_desc->KeyExist("MissingWidth")) {
int missing_width = font_desc->GetIntegerFor("MissingWidth");
- std::fill(std::begin(m_CharWidth), std::end(m_CharWidth), missing_width);
+ std::fill(std::begin(char_width_), std::end(char_width_), missing_width);
}
- size_t width_start = m_pFontDict->GetIntegerFor("FirstChar", 0);
- size_t width_end = m_pFontDict->GetIntegerFor("LastChar", 0);
+ size_t width_start = font_dict_->GetIntegerFor("FirstChar", 0);
+ size_t width_end = font_dict_->GetIntegerFor("LastChar", 0);
if (width_start > 255) {
return;
}
@@ -135,7 +135,7 @@
width_end = 255;
}
for (size_t i = width_start; i <= width_end; i++) {
- m_CharWidth[i] = width_array->GetIntegerAt(i - width_start);
+ char_width_[i] = width_array->GetIntegerAt(i - width_start);
}
}
@@ -145,7 +145,7 @@
return;
}
- m_CharNames.resize(kInternalTableSize);
+ char_names_.resize(kInternalTableSize);
uint32_t cur_code = 0;
for (uint32_t i = 0; i < diffs->size(); i++) {
RetainPtr<const CPDF_Object> element = diffs->GetDirectObjectAt(i);
@@ -155,8 +155,8 @@
const CPDF_Name* name = element->AsName();
if (name) {
- if (cur_code < m_CharNames.size()) {
- m_CharNames[cur_code] = name->GetString();
+ if (cur_code < char_names_.size()) {
+ char_names_[cur_code] = name->GetString();
}
cur_code++;
} else {
@@ -167,24 +167,24 @@
void CPDF_SimpleFont::LoadPDFEncoding(bool bEmbedded, bool bTrueType) {
RetainPtr<const CPDF_Object> pEncoding =
- m_pFontDict->GetDirectObjectFor("Encoding");
+ font_dict_->GetDirectObjectFor("Encoding");
if (!pEncoding) {
- if (m_BaseFontName == "Symbol") {
- m_BaseEncoding =
+ if (base_font_name_ == "Symbol") {
+ base_encoding_ =
bTrueType ? FontEncoding::kMsSymbol : FontEncoding::kAdobeSymbol;
- } else if (!bEmbedded && m_BaseEncoding == FontEncoding::kBuiltin) {
- m_BaseEncoding = FontEncoding::kWinAnsi;
+ } else if (!bEmbedded && base_encoding_ == FontEncoding::kBuiltin) {
+ base_encoding_ = FontEncoding::kWinAnsi;
}
return;
}
if (pEncoding->IsName()) {
- if (m_BaseEncoding == FontEncoding::kAdobeSymbol ||
- m_BaseEncoding == FontEncoding::kZapfDingbats) {
+ if (base_encoding_ == FontEncoding::kAdobeSymbol ||
+ base_encoding_ == FontEncoding::kZapfDingbats) {
return;
}
- if (FontStyleIsSymbolic(m_Flags) && m_BaseFontName == "Symbol") {
+ if (FontStyleIsSymbolic(flags_) && base_font_name_ == "Symbol") {
if (!bTrueType) {
- m_BaseEncoding = FontEncoding::kAdobeSymbol;
+ base_encoding_ = FontEncoding::kAdobeSymbol;
}
return;
}
@@ -192,7 +192,7 @@
if (bsEncoding == pdfium::font_encodings::kMacExpertEncoding) {
bsEncoding = pdfium::font_encodings::kWinAnsiEncoding;
}
- GetPredefinedEncoding(bsEncoding, &m_BaseEncoding);
+ GetPredefinedEncoding(bsEncoding, &base_encoding_);
return;
}
@@ -201,16 +201,16 @@
return;
}
- if (m_BaseEncoding != FontEncoding::kAdobeSymbol &&
- m_BaseEncoding != FontEncoding::kZapfDingbats) {
+ if (base_encoding_ != FontEncoding::kAdobeSymbol &&
+ base_encoding_ != FontEncoding::kZapfDingbats) {
ByteString bsEncoding = pDict->GetByteStringFor("BaseEncoding");
if (bTrueType && bsEncoding == pdfium::font_encodings::kMacExpertEncoding) {
bsEncoding = pdfium::font_encodings::kWinAnsiEncoding;
}
- GetPredefinedEncoding(bsEncoding, &m_BaseEncoding);
+ GetPredefinedEncoding(bsEncoding, &base_encoding_);
}
- if ((!bEmbedded || bTrueType) && m_BaseEncoding == FontEncoding::kBuiltin) {
- m_BaseEncoding = FontEncoding::kStandard;
+ if ((!bEmbedded || bTrueType) && base_encoding_ == FontEncoding::kBuiltin) {
+ base_encoding_ = FontEncoding::kStandard;
}
LoadDifferences(pDict);
@@ -221,13 +221,13 @@
charcode = 0;
}
- if (m_CharWidth[charcode] == 0xffff) {
+ if (char_width_[charcode] == 0xffff) {
LoadCharMetrics(charcode);
- if (m_CharWidth[charcode] == 0xffff) {
- m_CharWidth[charcode] = 0;
+ if (char_width_[charcode] == 0xffff) {
+ char_width_[charcode] = 0;
}
}
- return m_CharWidth[charcode];
+ return char_width_[charcode];
}
FX_RECT CPDF_SimpleFont::GetCharBBox(uint32_t charcode) {
@@ -235,51 +235,51 @@
charcode = 0;
}
- if (m_CharBBox[charcode].left == -1) {
+ if (char_bbox_[charcode].left == -1) {
LoadCharMetrics(charcode);
}
- return m_CharBBox[charcode];
+ return char_bbox_[charcode];
}
bool CPDF_SimpleFont::LoadCommon() {
RetainPtr<const CPDF_Dictionary> pFontDesc =
- m_pFontDict->GetDictFor("FontDescriptor");
+ font_dict_->GetDictFor("FontDescriptor");
if (pFontDesc) {
LoadFontDescriptor(pFontDesc.Get());
}
LoadCharWidths(pFontDesc.Get());
- if (m_pFontFile) {
- if (m_BaseFontName.GetLength() > 7 && m_BaseFontName[6] == '+') {
- m_BaseFontName = m_BaseFontName.Last(m_BaseFontName.GetLength() - 7);
+ if (font_file_) {
+ if (base_font_name_.GetLength() > 7 && base_font_name_[6] == '+') {
+ base_font_name_ = base_font_name_.Last(base_font_name_.GetLength() - 7);
}
} else {
LoadSubstFont();
}
- if (!FontStyleIsSymbolic(m_Flags)) {
- m_BaseEncoding = FontEncoding::kStandard;
+ if (!FontStyleIsSymbolic(flags_)) {
+ base_encoding_ = FontEncoding::kStandard;
}
- LoadPDFEncoding(!!m_pFontFile, m_Font.IsTTFont());
+ LoadPDFEncoding(!!font_file_, font_.IsTTFont());
LoadGlyphMap();
- m_CharNames.clear();
+ char_names_.clear();
if (!HasFace()) {
return true;
}
- if (FontStyleIsAllCaps(m_Flags)) {
+ if (FontStyleIsAllCaps(flags_)) {
static const auto kLowercases =
fxcrt::ToArray<std::pair<const uint8_t, const uint8_t>>(
{{'a', 'z'}, {0xe0, 0xf6}, {0xf8, 0xfd}});
for (const auto& lower : kLowercases) {
for (int i = lower.first; i <= lower.second; ++i) {
- if (m_GlyphIndex[i] != 0xffff && m_pFontFile) {
+ if (glyph_index_[i] != 0xffff && font_file_) {
continue;
}
int j = i - 32;
- m_GlyphIndex[i] = m_GlyphIndex[j];
- if (m_CharWidth[j]) {
- m_CharWidth[i] = m_CharWidth[j];
- m_CharBBox[i] = m_CharBBox[j];
+ glyph_index_[i] = glyph_index_[j];
+ if (char_width_[j]) {
+ char_width_[i] = char_width_[j];
+ char_bbox_[i] = char_bbox_[j];
}
}
}
@@ -289,22 +289,22 @@
}
void CPDF_SimpleFont::LoadSubstFont() {
- if (!m_bUseFontWidth && !FontStyleIsFixedPitch(m_Flags)) {
+ if (!use_font_width_ && !FontStyleIsFixedPitch(flags_)) {
int width = 0;
size_t i;
for (i = 0; i < kInternalTableSize; i++) {
- if (m_CharWidth[i] == 0 || m_CharWidth[i] == 0xffff) {
+ if (char_width_[i] == 0 || char_width_[i] == 0xffff) {
continue;
}
if (width == 0) {
- width = m_CharWidth[i];
- } else if (width != m_CharWidth[i]) {
+ width = char_width_[i];
+ } else if (width != char_width_[i]) {
break;
}
}
if (i == kInternalTableSize && width) {
- m_Flags |= pdfium::kFontStyleFixedPitch;
+ flags_ |= pdfium::kFontStyleFixedPitch;
}
}
@@ -313,14 +313,14 @@
weight > pdfium::kFontWeightExtraBold) {
weight = pdfium::kFontWeightNormal;
}
- m_Font.LoadSubst(m_BaseFontName, IsTrueTypeFont(), m_Flags, weight,
- m_ItalicAngle, FX_CodePage::kDefANSI, /*bVertical=*/false);
+ font_.LoadSubst(base_font_name_, IsTrueTypeFont(), flags_, weight,
+ italic_angle_, FX_CodePage::kDefANSI, /*bVertical=*/false);
}
bool CPDF_SimpleFont::IsUnicodeCompatible() const {
- return m_BaseEncoding != FontEncoding::kBuiltin &&
- m_BaseEncoding != FontEncoding::kAdobeSymbol &&
- m_BaseEncoding != FontEncoding::kZapfDingbats;
+ return base_encoding_ != FontEncoding::kBuiltin &&
+ base_encoding_ != FontEncoding::kAdobeSymbol &&
+ base_encoding_ != FontEncoding::kZapfDingbats;
}
WideString CPDF_SimpleFont::UnicodeFromCharCode(uint32_t charcode) const {
@@ -328,7 +328,7 @@
if (!unicode.IsEmpty()) {
return unicode;
}
- wchar_t ret = m_Encoding.UnicodeFromCharCode((uint8_t)charcode);
+ wchar_t ret = encoding_.UnicodeFromCharCode((uint8_t)charcode);
if (ret == 0) {
return WideString();
}
@@ -340,9 +340,9 @@
if (ret) {
return ret;
}
- return m_Encoding.CharCodeFromUnicode(unicode);
+ return encoding_.CharCodeFromUnicode(unicode);
}
bool CPDF_SimpleFont::HasFontWidths() const {
- return !m_bUseFontWidth;
+ return !use_font_width_;
}
diff --git a/core/fpdfapi/font/cpdf_simplefont.h b/core/fpdfapi/font/cpdf_simplefont.h
index a7c7992..cf4719c 100644
--- a/core/fpdfapi/font/cpdf_simplefont.h
+++ b/core/fpdfapi/font/cpdf_simplefont.h
@@ -28,7 +28,7 @@
WideString UnicodeFromCharCode(uint32_t charcode) const override;
uint32_t CharCodeFromUnicode(wchar_t Unicode) const override;
- const CPDF_FontEncoding* GetEncoding() const { return &m_Encoding; }
+ const CPDF_FontEncoding* GetEncoding() const { return &encoding_; }
bool HasFontWidths() const override;
@@ -50,13 +50,13 @@
void LoadDifferences(const CPDF_Dictionary* encoding);
void LoadPDFEncoding(bool bEmbedded, bool bTrueType);
- CPDF_FontEncoding m_Encoding{FontEncoding::kBuiltin};
- FontEncoding m_BaseEncoding = FontEncoding::kBuiltin;
- bool m_bUseFontWidth = false;
- std::vector<ByteString> m_CharNames;
- std::array<uint16_t, kInternalTableSize> m_GlyphIndex;
- std::array<uint16_t, kInternalTableSize> m_CharWidth;
- std::array<FX_RECT, kInternalTableSize> m_CharBBox;
+ CPDF_FontEncoding encoding_{FontEncoding::kBuiltin};
+ FontEncoding base_encoding_ = FontEncoding::kBuiltin;
+ bool use_font_width_ = false;
+ std::vector<ByteString> char_names_;
+ std::array<uint16_t, kInternalTableSize> glyph_index_;
+ std::array<uint16_t, kInternalTableSize> char_width_;
+ std::array<FX_RECT, kInternalTableSize> char_bbox_;
};
#endif // CORE_FPDFAPI_FONT_CPDF_SIMPLEFONT_H_
diff --git a/core/fpdfapi/font/cpdf_tounicodemap.cpp b/core/fpdfapi/font/cpdf_tounicodemap.cpp
index 566d791..a105486 100644
--- a/core/fpdfapi/font/cpdf_tounicodemap.cpp
+++ b/core/fpdfapi/font/cpdf_tounicodemap.cpp
@@ -56,13 +56,13 @@
CPDF_ToUnicodeMap::~CPDF_ToUnicodeMap() = default;
WideString CPDF_ToUnicodeMap::Lookup(uint32_t charcode) const {
- auto it = m_Multimap.find(charcode);
- if (it == m_Multimap.end()) {
- if (!m_pBaseMap) {
+ auto it = multimap_.find(charcode);
+ if (it == multimap_.end()) {
+ if (!base_map_) {
return WideString();
}
return WideString(
- m_pBaseMap->UnicodeFromCID(static_cast<uint16_t>(charcode)));
+ base_map_->UnicodeFromCID(static_cast<uint16_t>(charcode)));
}
uint32_t value = *it->second.begin();
@@ -72,11 +72,11 @@
}
size_t index = value >> 16;
- return index < m_MultiCharVec.size() ? m_MultiCharVec[index] : WideString();
+ return index < multi_char_vec_.size() ? multi_char_vec_[index] : WideString();
}
uint32_t CPDF_ToUnicodeMap::ReverseLookup(wchar_t unicode) const {
- for (const auto& pair : m_Multimap) {
+ for (const auto& pair : multimap_) {
if (pdfium::Contains(pair.second, static_cast<uint32_t>(unicode))) {
return pair.first;
}
@@ -86,8 +86,8 @@
size_t CPDF_ToUnicodeMap::GetUnicodeCountByCharcodeForTesting(
uint32_t charcode) const {
- auto it = m_Multimap.find(charcode);
- return it != m_Multimap.end() ? it->second.size() : 0u;
+ auto it = multimap_.find(charcode);
+ return it != multimap_.end() ? it->second.size() : 0u;
}
// static
@@ -187,7 +187,7 @@
previous_word = word;
}
if (cid_set != CIDSET_UNKNOWN) {
- m_pBaseMap = CPDF_FontGlobals::GetInstance()->GetCID2UnicodeMap(cid_set);
+ base_map_ = CPDF_FontGlobals::GetInstance()->GetCID2UnicodeMap(cid_set);
}
}
@@ -366,7 +366,7 @@
uint32_t code = range.low_code;
for (const auto& retcode : range.retcodes) {
InsertIntoMultimap(code, GetMultiCharIndexIndicator());
- m_MultiCharVec.push_back(retcode);
+ multi_char_vec_.push_back(retcode);
++code;
}
}
@@ -376,7 +376,7 @@
}
uint32_t CPDF_ToUnicodeMap::GetMultiCharIndexIndicator() const {
- FX_SAFE_UINT32 uni = m_MultiCharVec.size();
+ FX_SAFE_UINT32 uni = multi_char_vec_.size();
uni = uni * 0x10000 + 0xffff;
return uni.ValueOrDefault(0);
}
@@ -391,14 +391,14 @@
InsertIntoMultimap(srccode, destcode[0]);
} else {
InsertIntoMultimap(srccode, GetMultiCharIndexIndicator());
- m_MultiCharVec.push_back(destcode);
+ multi_char_vec_.push_back(destcode);
}
}
void CPDF_ToUnicodeMap::InsertIntoMultimap(uint32_t code, uint32_t destcode) {
- auto it = m_Multimap.find(code);
- if (it == m_Multimap.end()) {
- m_Multimap.emplace(code, std::set<uint32_t>{destcode});
+ auto it = multimap_.find(code);
+ if (it == multimap_.end()) {
+ multimap_.emplace(code, std::set<uint32_t>{destcode});
return;
}
diff --git a/core/fpdfapi/font/cpdf_tounicodemap.h b/core/fpdfapi/font/cpdf_tounicodemap.h
index abb701f..3a2c48e 100644
--- a/core/fpdfapi/font/cpdf_tounicodemap.h
+++ b/core/fpdfapi/font/cpdf_tounicodemap.h
@@ -49,13 +49,13 @@
uint32_t GetMultiCharIndexIndicator() const;
void SetCode(uint32_t srccode, WideString destcode);
- // Inserts a new entry which hasn't not been inserted into `m_Multimap`
+ // Inserts a new entry which hasn't not been inserted into `multimap_`
// before.
void InsertIntoMultimap(uint32_t code, uint32_t destcode);
- std::map<uint32_t, std::set<uint32_t>> m_Multimap;
- UnownedPtr<const CPDF_CID2UnicodeMap> m_pBaseMap;
- std::vector<WideString> m_MultiCharVec;
+ std::map<uint32_t, std::set<uint32_t>> multimap_;
+ UnownedPtr<const CPDF_CID2UnicodeMap> base_map_;
+ std::vector<WideString> multi_char_vec_;
};
#endif // CORE_FPDFAPI_FONT_CPDF_TOUNICODEMAP_H_
diff --git a/core/fpdfapi/font/cpdf_tounicodemap_unittest.cpp b/core/fpdfapi/font/cpdf_tounicodemap_unittest.cpp
index b16163f..3081ad4 100644
--- a/core/fpdfapi/font/cpdf_tounicodemap_unittest.cpp
+++ b/core/fpdfapi/font/cpdf_tounicodemap_unittest.cpp
@@ -339,7 +339,7 @@
}
{
// Duplicate mappings of CID 0 to unicode "A". There should be only 1 entry
- // in `m_Multimap`.
+ // in `multimap_`.
static constexpr uint8_t kInput3[] =
"1 beginbfrange<0><0>[<0041>]endbfrange\n"
"1 beginbfchar<0><0041>endbfchar";
diff --git a/core/fpdfapi/font/cpdf_truetypefont.cpp b/core/fpdfapi/font/cpdf_truetypefont.cpp
index dc7e084..7384904 100644
--- a/core/fpdfapi/font/cpdf_truetypefont.cpp
+++ b/core/fpdfapi/font/cpdf_truetypefont.cpp
@@ -58,84 +58,83 @@
}
void CPDF_TrueTypeFont::LoadGlyphMap() {
- RetainPtr<CFX_Face> face = m_Font.GetFace();
+ RetainPtr<CFX_Face> face = font_.GetFace();
if (!face) {
return;
}
const FontEncoding base_encoding = DetermineEncoding();
- if ((IsWinAnsiOrMacRomanEncoding(base_encoding) && m_CharNames.empty()) ||
- FontStyleIsNonSymbolic(m_Flags)) {
- if (m_Font.GetFace()->HasGlyphNames() && face->GetCharMapCount() == 0) {
+ if ((IsWinAnsiOrMacRomanEncoding(base_encoding) && char_names_.empty()) ||
+ FontStyleIsNonSymbolic(flags_)) {
+ if (font_.GetFace()->HasGlyphNames() && face->GetCharMapCount() == 0) {
SetGlyphIndicesFromFirstChar();
return;
}
const CharmapType charmap_type = DetermineCharmapType();
- bool bToUnicode = m_pFontDict->KeyExist("ToUnicode");
+ bool bToUnicode = font_dict_->KeyExist("ToUnicode");
for (uint32_t charcode = 0; charcode < 256; charcode++) {
- const char* name = GetAdobeCharName(base_encoding, m_CharNames, charcode);
+ const char* name = GetAdobeCharName(base_encoding, char_names_, charcode);
if (!name) {
- m_GlyphIndex[charcode] =
- m_pFontFile ? face->GetCharIndex(charcode) : -1;
+ glyph_index_[charcode] = font_file_ ? face->GetCharIndex(charcode) : -1;
continue;
}
- m_Encoding.SetUnicode(charcode, UnicodeFromAdobeName(name));
+ encoding_.SetUnicode(charcode, UnicodeFromAdobeName(name));
if (charmap_type == CharmapType::kMSSymbol) {
- m_GlyphIndex[charcode] = GetGlyphIndexForMSSymbol(face, charcode);
- } else if (m_Encoding.UnicodeFromCharCode(charcode)) {
+ glyph_index_[charcode] = GetGlyphIndexForMSSymbol(face, charcode);
+ } else if (encoding_.UnicodeFromCharCode(charcode)) {
if (charmap_type == CharmapType::kMSUnicode) {
- m_GlyphIndex[charcode] =
- face->GetCharIndex(m_Encoding.UnicodeFromCharCode(charcode));
+ glyph_index_[charcode] =
+ face->GetCharIndex(encoding_.UnicodeFromCharCode(charcode));
} else if (charmap_type == CharmapType::kMacRoman) {
uint32_t maccode = CharCodeFromUnicodeForEncoding(
fxge::FontEncoding::kAppleRoman,
- m_Encoding.UnicodeFromCharCode(charcode));
+ encoding_.UnicodeFromCharCode(charcode));
if (!maccode) {
- m_GlyphIndex[charcode] = face->GetNameIndex(name);
+ glyph_index_[charcode] = face->GetNameIndex(name);
} else {
- m_GlyphIndex[charcode] = face->GetCharIndex(maccode);
+ glyph_index_[charcode] = face->GetCharIndex(maccode);
}
}
}
- if ((m_GlyphIndex[charcode] != 0 && m_GlyphIndex[charcode] != 0xffff) ||
+ if ((glyph_index_[charcode] != 0 && glyph_index_[charcode] != 0xffff) ||
!name) {
continue;
}
if (UNSAFE_TODO(strcmp(name, kNotDef)) == 0) {
- m_GlyphIndex[charcode] = face->GetCharIndex(32);
+ glyph_index_[charcode] = face->GetCharIndex(32);
continue;
}
- m_GlyphIndex[charcode] = face->GetNameIndex(name);
- if (m_GlyphIndex[charcode] != 0 || !bToUnicode) {
+ glyph_index_[charcode] = face->GetNameIndex(name);
+ if (glyph_index_[charcode] != 0 || !bToUnicode) {
continue;
}
WideString wsUnicode = UnicodeFromCharCode(charcode);
if (!wsUnicode.IsEmpty()) {
- m_GlyphIndex[charcode] = face->GetCharIndex(wsUnicode[0]);
- m_Encoding.SetUnicode(charcode, wsUnicode[0]);
+ glyph_index_[charcode] = face->GetCharIndex(wsUnicode[0]);
+ encoding_.SetUnicode(charcode, wsUnicode[0]);
}
}
return;
}
if (UseTTCharmapMSSymbol(face)) {
for (uint32_t charcode = 0; charcode < 256; charcode++) {
- m_GlyphIndex[charcode] = GetGlyphIndexForMSSymbol(face, charcode);
+ glyph_index_[charcode] = GetGlyphIndexForMSSymbol(face, charcode);
}
if (HasAnyGlyphIndex()) {
if (base_encoding != FontEncoding::kBuiltin) {
for (uint32_t charcode = 0; charcode < 256; charcode++) {
const char* name =
- GetAdobeCharName(base_encoding, m_CharNames, charcode);
+ GetAdobeCharName(base_encoding, char_names_, charcode);
if (name) {
- m_Encoding.SetUnicode(charcode, UnicodeFromAdobeName(name));
+ encoding_.SetUnicode(charcode, UnicodeFromAdobeName(name));
}
}
} else if (UseTTCharmapMacRoman(face)) {
for (uint32_t charcode = 0; charcode < 256; charcode++) {
- m_Encoding.SetUnicode(charcode,
- UnicodeFromAppleRomanCharCode(charcode));
+ encoding_.SetUnicode(charcode,
+ UnicodeFromAppleRomanCharCode(charcode));
}
}
return;
@@ -143,43 +142,43 @@
}
if (UseTTCharmapMacRoman(face)) {
for (uint32_t charcode = 0; charcode < 256; charcode++) {
- m_GlyphIndex[charcode] = face->GetCharIndex(charcode);
- m_Encoding.SetUnicode(charcode, UnicodeFromAppleRomanCharCode(charcode));
+ glyph_index_[charcode] = face->GetCharIndex(charcode);
+ encoding_.SetUnicode(charcode, UnicodeFromAppleRomanCharCode(charcode));
}
- if (m_pFontFile || HasAnyGlyphIndex()) {
+ if (font_file_ || HasAnyGlyphIndex()) {
return;
}
}
- if (m_Font.GetFace()->SelectCharMap(fxge::FontEncoding::kUnicode)) {
+ if (font_.GetFace()->SelectCharMap(fxge::FontEncoding::kUnicode)) {
pdfium::span<const uint16_t> unicodes =
UnicodesForPredefinedCharSet(base_encoding);
for (uint32_t charcode = 0; charcode < 256; charcode++) {
- if (m_pFontFile) {
- m_Encoding.SetUnicode(charcode, charcode);
+ if (font_file_) {
+ encoding_.SetUnicode(charcode, charcode);
} else {
const char* name =
- GetAdobeCharName(FontEncoding::kBuiltin, m_CharNames, charcode);
+ GetAdobeCharName(FontEncoding::kBuiltin, char_names_, charcode);
if (name) {
- m_Encoding.SetUnicode(charcode, UnicodeFromAdobeName(name));
+ encoding_.SetUnicode(charcode, UnicodeFromAdobeName(name));
} else if (!unicodes.empty()) {
- m_Encoding.SetUnicode(charcode, unicodes[charcode]);
+ encoding_.SetUnicode(charcode, unicodes[charcode]);
}
}
- m_GlyphIndex[charcode] =
- face->GetCharIndex(m_Encoding.UnicodeFromCharCode(charcode));
+ glyph_index_[charcode] =
+ face->GetCharIndex(encoding_.UnicodeFromCharCode(charcode));
}
if (HasAnyGlyphIndex()) {
return;
}
}
for (int charcode = 0; charcode < 256; charcode++) {
- m_GlyphIndex[charcode] = charcode;
+ glyph_index_[charcode] = charcode;
}
}
bool CPDF_TrueTypeFont::HasAnyGlyphIndex() const {
for (uint32_t charcode = 0; charcode < kInternalTableSize; charcode++) {
- if (m_GlyphIndex[charcode]) {
+ if (glyph_index_[charcode]) {
return true;
}
}
@@ -187,22 +186,22 @@
}
CPDF_TrueTypeFont::CharmapType CPDF_TrueTypeFont::DetermineCharmapType() const {
- if (UseTTCharmapMSUnicode(m_Font.GetFace())) {
+ if (UseTTCharmapMSUnicode(font_.GetFace())) {
return CharmapType::kMSUnicode;
}
- if (FontStyleIsNonSymbolic(m_Flags)) {
- if (UseTTCharmapMacRoman(m_Font.GetFace())) {
+ if (FontStyleIsNonSymbolic(flags_)) {
+ if (UseTTCharmapMacRoman(font_.GetFace())) {
return CharmapType::kMacRoman;
}
- if (UseTTCharmapMSSymbol(m_Font.GetFace())) {
+ if (UseTTCharmapMSSymbol(font_.GetFace())) {
return CharmapType::kMSSymbol;
}
} else {
- if (UseTTCharmapMSSymbol(m_Font.GetFace())) {
+ if (UseTTCharmapMSSymbol(font_.GetFace())) {
return CharmapType::kMSSymbol;
}
- if (UseTTCharmapMacRoman(m_Font.GetFace())) {
+ if (UseTTCharmapMacRoman(font_.GetFace())) {
return CharmapType::kMacRoman;
}
}
@@ -210,16 +209,16 @@
}
FontEncoding CPDF_TrueTypeFont::DetermineEncoding() const {
- if (!m_pFontFile || !FontStyleIsSymbolic(m_Flags) ||
- !IsWinAnsiOrMacRomanEncoding(m_BaseEncoding)) {
- return m_BaseEncoding;
+ if (!font_file_ || !FontStyleIsSymbolic(flags_) ||
+ !IsWinAnsiOrMacRomanEncoding(base_encoding_)) {
+ return base_encoding_;
}
// Not null - caller checked.
- RetainPtr<CFX_Face> face = m_Font.GetFace();
+ RetainPtr<CFX_Face> face = font_.GetFace();
const size_t num_charmaps = face->GetCharMapCount();
if (num_charmaps == 0) {
- return m_BaseEncoding;
+ return base_encoding_;
}
bool support_win = false;
@@ -237,25 +236,25 @@
}
}
- if (m_BaseEncoding == FontEncoding::kWinAnsi && !support_win) {
+ if (base_encoding_ == FontEncoding::kWinAnsi && !support_win) {
return support_mac ? FontEncoding::kMacRoman : FontEncoding::kBuiltin;
}
- if (m_BaseEncoding == FontEncoding::kMacRoman && !support_mac) {
+ if (base_encoding_ == FontEncoding::kMacRoman && !support_mac) {
return support_win ? FontEncoding::kWinAnsi : FontEncoding::kBuiltin;
}
- return m_BaseEncoding;
+ return base_encoding_;
}
void CPDF_TrueTypeFont::SetGlyphIndicesFromFirstChar() {
- int start_char = m_pFontDict->GetIntegerFor("FirstChar");
+ int start_char = font_dict_->GetIntegerFor("FirstChar");
if (start_char < 0 || start_char > 255) {
return;
}
- auto it = std::begin(m_GlyphIndex);
+ auto it = std::begin(glyph_index_);
std::fill(it, it + start_char, 0);
uint16_t glyph = 3;
for (int charcode = start_char; charcode < 256; charcode++, glyph++) {
- m_GlyphIndex[charcode] = glyph;
+ glyph_index_[charcode] = glyph;
}
}
diff --git a/core/fpdfapi/font/cpdf_type1font.cpp b/core/fpdfapi/font/cpdf_type1font.cpp
index 79f8432..77e1a75 100644
--- a/core/fpdfapi/font/cpdf_type1font.cpp
+++ b/core/fpdfapi/font/cpdf_type1font.cpp
@@ -31,8 +31,8 @@
#if BUILDFLAG(IS_APPLE)
struct GlyphNameMap {
- const char* m_pStrAdobe; // Raw, POD struct.
- const char* m_pStrUnicode; // Raw, POD struct.
+ const char* str_adobe_; // Raw, POD struct.
+ const char* str_unicode_; // Raw, POD struct.
};
const GlyphNameMap kGlyphNameSubsts[] = {{"ff", "uniFB00"},
@@ -43,8 +43,8 @@
const char* GlyphNameRemap(const char* pStrAdobe) {
for (const auto& element : kGlyphNameSubsts) {
- if (!FXSYS_stricmp(element.m_pStrAdobe, pStrAdobe)) {
- return element.m_pStrUnicode;
+ if (!FXSYS_stricmp(element.str_adobe_, pStrAdobe)) {
+ return element.str_unicode_;
}
}
return nullptr;
@@ -75,7 +75,7 @@
RetainPtr<CPDF_Dictionary> pFontDict)
: CPDF_SimpleFont(pDocument, std::move(pFontDict)) {
#if BUILDFLAG(IS_APPLE)
- m_ExtGID.fill(0xffff);
+ ext_gid_.fill(0xffff);
#endif
}
@@ -94,29 +94,29 @@
}
bool CPDF_Type1Font::Load() {
- m_Base14Font = CFX_FontMapper::GetStandardFontName(&m_BaseFontName);
+ base14_font_ = CFX_FontMapper::GetStandardFontName(&base_font_name_);
if (!IsBase14Font()) {
return LoadCommon();
}
RetainPtr<const CPDF_Dictionary> pFontDesc =
- m_pFontDict->GetDictFor("FontDescriptor");
+ font_dict_->GetDictFor("FontDescriptor");
if (pFontDesc && pFontDesc->KeyExist("Flags")) {
- m_Flags = pFontDesc->GetIntegerFor("Flags");
+ flags_ = pFontDesc->GetIntegerFor("Flags");
} else if (IsSymbolicFont()) {
- m_Flags = pdfium::kFontStyleSymbolic;
+ flags_ = pdfium::kFontStyleSymbolic;
} else {
- m_Flags = pdfium::kFontStyleNonSymbolic;
+ flags_ = pdfium::kFontStyleNonSymbolic;
}
if (IsFixedFont()) {
- std::fill(std::begin(m_CharWidth), std::end(m_CharWidth), 600);
+ std::fill(std::begin(char_width_), std::end(char_width_), 600);
}
- if (m_Base14Font == CFX_FontMapper::kSymbol) {
- m_BaseEncoding = FontEncoding::kAdobeSymbol;
- } else if (m_Base14Font == CFX_FontMapper::kDingbats) {
- m_BaseEncoding = FontEncoding::kZapfDingbats;
- } else if (FontStyleIsNonSymbolic(m_Flags)) {
- m_BaseEncoding = FontEncoding::kStandard;
+ if (base14_font_ == CFX_FontMapper::kSymbol) {
+ base_encoding_ = FontEncoding::kAdobeSymbol;
+ } else if (base14_font_ == CFX_FontMapper::kDingbats) {
+ base_encoding_ = FontEncoding::kZapfDingbats;
+ } else if (FontStyleIsNonSymbolic(flags_)) {
+ base_encoding_ = FontEncoding::kStandard;
}
return LoadCommon();
}
@@ -127,33 +127,33 @@
return -1;
}
- int index = m_ExtGID[static_cast<uint8_t>(charcode)];
+ int index = ext_gid_[static_cast<uint8_t>(charcode)];
return index != 0xffff ? index : -1;
}
#endif
void CPDF_Type1Font::LoadGlyphMap() {
- RetainPtr<CFX_Face> face = m_Font.GetFace();
+ RetainPtr<CFX_Face> face = font_.GetFace();
if (!face) {
return;
}
#if BUILDFLAG(IS_APPLE)
bool bCoreText = true;
- if (!m_Font.GetPlatformFont()) {
- if (m_Font.GetPsName() == "DFHeiStd-W5") {
+ if (!font_.GetPlatformFont()) {
+ if (font_.GetPsName() == "DFHeiStd-W5") {
bCoreText = false;
}
auto* pPlatform = CFX_GEModule::Get()->GetPlatform();
- pdfium::span<const uint8_t> span = m_Font.GetFontSpan();
- m_Font.SetPlatformFont(pPlatform->CreatePlatformFont(span));
- if (!m_Font.GetPlatformFont()) {
+ pdfium::span<const uint8_t> span = font_.GetFontSpan();
+ font_.SetPlatformFont(pPlatform->CreatePlatformFont(span));
+ if (!font_.GetPlatformFont()) {
bCoreText = false;
}
}
#endif
- if (!IsEmbedded() && !IsSymbolicFont() && m_Font.IsTTFont()) {
+ if (!IsEmbedded() && !IsSymbolicFont() && font_.IsTTFont()) {
if (UseTTCharmapMSSymbol(face)) {
bool bGotOne = false;
for (uint32_t charcode = 0; charcode < kInternalTableSize; charcode++) {
@@ -161,11 +161,11 @@
{0x00, 0xf0, 0xf1, 0xf2}};
for (int j = 0; j < 4; j++) {
uint16_t unicode = prefix[j] * 256 + charcode;
- m_GlyphIndex[charcode] = face->GetCharIndex(unicode);
+ glyph_index_[charcode] = face->GetCharIndex(unicode);
#if BUILDFLAG(IS_APPLE)
CalcExtGID(charcode);
#endif
- if (m_GlyphIndex[charcode]) {
+ if (glyph_index_[charcode]) {
bGotOne = true;
break;
}
@@ -174,34 +174,34 @@
if (bGotOne) {
#if BUILDFLAG(IS_APPLE)
if (!bCoreText) {
- m_ExtGID = m_GlyphIndex;
+ ext_gid_ = glyph_index_;
}
#endif
return;
}
}
face->SelectCharMap(fxge::FontEncoding::kUnicode);
- if (m_BaseEncoding == FontEncoding::kBuiltin) {
- m_BaseEncoding = FontEncoding::kStandard;
+ if (base_encoding_ == FontEncoding::kBuiltin) {
+ base_encoding_ = FontEncoding::kStandard;
}
for (uint32_t charcode = 0; charcode < kInternalTableSize; charcode++) {
const char* name =
- GetAdobeCharName(m_BaseEncoding, m_CharNames, charcode);
+ GetAdobeCharName(base_encoding_, char_names_, charcode);
if (!name) {
continue;
}
- m_Encoding.SetUnicode(charcode, UnicodeFromAdobeName(name));
- m_GlyphIndex[charcode] =
- face->GetCharIndex(m_Encoding.UnicodeFromCharCode(charcode));
+ encoding_.SetUnicode(charcode, UnicodeFromAdobeName(name));
+ glyph_index_[charcode] =
+ face->GetCharIndex(encoding_.UnicodeFromCharCode(charcode));
#if BUILDFLAG(IS_APPLE)
CalcExtGID(charcode);
#endif
- if (m_GlyphIndex[charcode] == 0 &&
+ if (glyph_index_[charcode] == 0 &&
UNSAFE_TODO(strcmp(name, kNotDef)) == 0) {
- m_Encoding.SetUnicode(charcode, 0x20);
- m_GlyphIndex[charcode] = face->GetCharIndex(0x20);
+ encoding_.SetUnicode(charcode, 0x20);
+ glyph_index_[charcode] = face->GetCharIndex(0x20);
#if BUILDFLAG(IS_APPLE)
CalcExtGID(charcode);
#endif
@@ -209,7 +209,7 @@
}
#if BUILDFLAG(IS_APPLE)
if (!bCoreText) {
- m_ExtGID = m_GlyphIndex;
+ ext_gid_ = glyph_index_;
}
#endif
return;
@@ -217,21 +217,21 @@
UseType1Charmap(face);
#if BUILDFLAG(IS_APPLE)
if (bCoreText) {
- if (FontStyleIsSymbolic(m_Flags)) {
+ if (FontStyleIsSymbolic(flags_)) {
for (uint32_t charcode = 0; charcode < kInternalTableSize; charcode++) {
const char* name =
- GetAdobeCharName(m_BaseEncoding, m_CharNames, charcode);
+ GetAdobeCharName(base_encoding_, char_names_, charcode);
if (name) {
- m_Encoding.SetUnicode(charcode, UnicodeFromAdobeName(name));
- m_GlyphIndex[charcode] = m_Font.GetFace()->GetNameIndex(name);
+ encoding_.SetUnicode(charcode, UnicodeFromAdobeName(name));
+ glyph_index_[charcode] = font_.GetFace()->GetNameIndex(name);
SetExtGID(name, charcode);
} else {
- m_GlyphIndex[charcode] = face->GetCharIndex(charcode);
- ByteString glyph_name = face->GetGlyphName(m_GlyphIndex[charcode]);
+ glyph_index_[charcode] = face->GetCharIndex(charcode);
+ ByteString glyph_name = face->GetGlyphName(glyph_index_[charcode]);
const wchar_t unicode =
glyph_name.IsEmpty() ? 0
: UnicodeFromAdobeName(glyph_name.c_str());
- m_Encoding.SetUnicode(charcode, unicode);
+ encoding_.SetUnicode(charcode, unicode);
SetExtGID(glyph_name.c_str(), charcode);
}
}
@@ -241,59 +241,59 @@
bool bUnicode = face->SelectCharMap(fxge::FontEncoding::kUnicode);
for (uint32_t charcode = 0; charcode < kInternalTableSize; charcode++) {
const char* name =
- GetAdobeCharName(m_BaseEncoding, m_CharNames, charcode);
+ GetAdobeCharName(base_encoding_, char_names_, charcode);
if (!name) {
continue;
}
- m_Encoding.SetUnicode(charcode, UnicodeFromAdobeName(name));
+ encoding_.SetUnicode(charcode, UnicodeFromAdobeName(name));
const char* pStrUnicode = GlyphNameRemap(name);
- int name_index = m_Font.GetFace()->GetNameIndex(name);
+ int name_index = font_.GetFace()->GetNameIndex(name);
if (pStrUnicode && name_index == 0) {
name = pStrUnicode;
}
- m_GlyphIndex[charcode] = name_index;
+ glyph_index_[charcode] = name_index;
SetExtGID(name, charcode);
- if (m_GlyphIndex[charcode] != 0) {
+ if (glyph_index_[charcode] != 0) {
continue;
}
if (UNSAFE_TODO(strcmp(name, kNotDef)) != 0 &&
UNSAFE_TODO(strcmp(name, kSpace)) != 0) {
- m_GlyphIndex[charcode] = face->GetCharIndex(
- bUnicode ? m_Encoding.UnicodeFromCharCode(charcode) : charcode);
+ glyph_index_[charcode] = face->GetCharIndex(
+ bUnicode ? encoding_.UnicodeFromCharCode(charcode) : charcode);
CalcExtGID(charcode);
} else {
- m_Encoding.SetUnicode(charcode, 0x20);
- m_GlyphIndex[charcode] = bUnicode ? face->GetCharIndex(0x20) : 0xffff;
+ encoding_.SetUnicode(charcode, 0x20);
+ glyph_index_[charcode] = bUnicode ? face->GetCharIndex(0x20) : 0xffff;
CalcExtGID(charcode);
}
}
return;
}
#endif // BUILDFLAG(IS_APPLE)
- if (FontStyleIsSymbolic(m_Flags)) {
+ if (FontStyleIsSymbolic(flags_)) {
for (size_t charcode = 0; charcode < kInternalTableSize; charcode++) {
- const char* name = GetAdobeCharName(m_BaseEncoding, m_CharNames,
+ const char* name = GetAdobeCharName(base_encoding_, char_names_,
static_cast<uint32_t>(charcode));
if (name) {
- m_Encoding.SetUnicode(charcode, UnicodeFromAdobeName(name));
- m_GlyphIndex[charcode] = m_Font.GetFace()->GetNameIndex(name);
+ encoding_.SetUnicode(charcode, UnicodeFromAdobeName(name));
+ glyph_index_[charcode] = font_.GetFace()->GetNameIndex(name);
} else {
- m_GlyphIndex[charcode] =
+ glyph_index_[charcode] =
face->GetCharIndex(static_cast<uint32_t>(charcode));
- if (m_GlyphIndex[charcode]) {
- ByteString glyph_name = face->GetGlyphName(m_GlyphIndex[charcode]);
+ if (glyph_index_[charcode]) {
+ ByteString glyph_name = face->GetGlyphName(glyph_index_[charcode]);
const wchar_t unicode =
glyph_name.IsEmpty() ? 0
: UnicodeFromAdobeName(glyph_name.c_str());
- m_Encoding.SetUnicode(charcode, unicode);
+ encoding_.SetUnicode(charcode, unicode);
}
}
}
#if BUILDFLAG(IS_APPLE)
if (!bCoreText) {
- m_ExtGID = m_GlyphIndex;
+ ext_gid_ = glyph_index_;
}
#endif
return;
@@ -301,59 +301,58 @@
bool bUnicode = face->SelectCharMap(fxge::FontEncoding::kUnicode);
for (size_t charcode = 0; charcode < kInternalTableSize; charcode++) {
- const char* name = GetAdobeCharName(m_BaseEncoding, m_CharNames,
+ const char* name = GetAdobeCharName(base_encoding_, char_names_,
static_cast<uint32_t>(charcode));
if (!name) {
continue;
}
- m_Encoding.SetUnicode(charcode, UnicodeFromAdobeName(name));
- m_GlyphIndex[charcode] = m_Font.GetFace()->GetNameIndex(name);
- if (m_GlyphIndex[charcode] != 0) {
+ encoding_.SetUnicode(charcode, UnicodeFromAdobeName(name));
+ glyph_index_[charcode] = font_.GetFace()->GetNameIndex(name);
+ if (glyph_index_[charcode] != 0) {
continue;
}
if (UNSAFE_TODO(strcmp(name, kNotDef)) != 0 &&
UNSAFE_TODO(strcmp(name, kSpace)) != 0) {
- m_GlyphIndex[charcode] =
- face->GetCharIndex(bUnicode ? m_Encoding.UnicodeFromCharCode(charcode)
+ glyph_index_[charcode] =
+ face->GetCharIndex(bUnicode ? encoding_.UnicodeFromCharCode(charcode)
: static_cast<uint32_t>(charcode));
} else {
- m_Encoding.SetUnicode(charcode, 0x20);
- m_GlyphIndex[charcode] = 0xffff;
+ encoding_.SetUnicode(charcode, 0x20);
+ glyph_index_[charcode] = 0xffff;
}
}
#if BUILDFLAG(IS_APPLE)
if (!bCoreText) {
- m_ExtGID = m_GlyphIndex;
+ ext_gid_ = glyph_index_;
}
#endif
}
bool CPDF_Type1Font::IsSymbolicFont() const {
- return m_Base14Font.has_value() &&
- CFX_FontMapper::IsSymbolicFont(m_Base14Font.value());
+ return base14_font_.has_value() &&
+ CFX_FontMapper::IsSymbolicFont(base14_font_.value());
}
bool CPDF_Type1Font::IsFixedFont() const {
- return m_Base14Font.has_value() &&
- CFX_FontMapper::IsFixedFont(m_Base14Font.value());
+ return base14_font_.has_value() &&
+ CFX_FontMapper::IsFixedFont(base14_font_.value());
}
#if BUILDFLAG(IS_APPLE)
void CPDF_Type1Font::SetExtGID(const char* name, uint32_t charcode) {
CFStringRef name_ct = CFStringCreateWithCStringNoCopy(
kCFAllocatorDefault, name, kCFStringEncodingASCII, kCFAllocatorNull);
- m_ExtGID[charcode] =
- CGFontGetGlyphWithGlyphName((CGFontRef)m_Font.GetPlatformFont(), name_ct);
+ ext_gid_[charcode] =
+ CGFontGetGlyphWithGlyphName((CGFontRef)font_.GetPlatformFont(), name_ct);
if (name_ct) {
CFRelease(name_ct);
}
}
void CPDF_Type1Font::CalcExtGID(uint32_t charcode) {
- ByteString glyph_name =
- m_Font.GetFace()->GetGlyphName(m_GlyphIndex[charcode]);
+ ByteString glyph_name = font_.GetFace()->GetGlyphName(glyph_index_[charcode]);
SetExtGID(glyph_name.c_str(), charcode);
}
#endif // BUILDFLAG(IS_APPLE)
diff --git a/core/fpdfapi/font/cpdf_type1font.h b/core/fpdfapi/font/cpdf_type1font.h
index c9ad6a2..c0ffc6b 100644
--- a/core/fpdfapi/font/cpdf_type1font.h
+++ b/core/fpdfapi/font/cpdf_type1font.h
@@ -29,7 +29,7 @@
int GlyphFromCharCodeExt(uint32_t charcode) override;
#endif
- bool IsBase14Font() const { return m_Base14Font.has_value(); }
+ bool IsBase14Font() const { return base14_font_.has_value(); }
private:
CPDF_Type1Font(CPDF_Document* pDocument,
@@ -48,10 +48,10 @@
void SetExtGID(const char* name, uint32_t charcode);
void CalcExtGID(uint32_t charcode);
- std::array<uint16_t, kInternalTableSize> m_ExtGID;
+ std::array<uint16_t, kInternalTableSize> ext_gid_;
#endif
- std::optional<CFX_FontMapper::StandardFont> m_Base14Font;
+ std::optional<CFX_FontMapper::StandardFont> base14_font_;
};
#endif // CORE_FPDFAPI_FONT_CPDF_TYPE1FONT_H_
diff --git a/core/fpdfapi/font/cpdf_type3char.cpp b/core/fpdfapi/font/cpdf_type3char.cpp
index 2e7874b..daf4764 100644
--- a/core/fpdfapi/font/cpdf_type3char.cpp
+++ b/core/fpdfapi/font/cpdf_type3char.cpp
@@ -33,58 +33,58 @@
}
bool CPDF_Type3Char::LoadBitmapFromSoleImageOfForm() {
- if (m_pBitmap || !m_pForm) {
+ if (bitmap_ || !form_) {
return true;
}
- if (m_bColored) {
+ if (colored_) {
return false;
}
- auto result = m_pForm->GetBitmapAndMatrixFromSoleImageOfForm();
+ auto result = form_->GetBitmapAndMatrixFromSoleImageOfForm();
if (!result.has_value()) {
return false;
}
- std::tie(m_pBitmap, m_ImageMatrix) = result.value();
- m_pForm.reset();
+ std::tie(bitmap_, image_matrix_) = result.value();
+ form_.reset();
return true;
}
void CPDF_Type3Char::InitializeFromStreamData(bool bColored,
pdfium::span<const float> pData) {
- m_bColored = bColored;
- m_Width = FXSYS_roundf(TextUnitToGlyphUnit(pData[0]));
- m_BBox.left = FXSYS_roundf(TextUnitToGlyphUnit(pData[2]));
- m_BBox.bottom = FXSYS_roundf(TextUnitToGlyphUnit(pData[3]));
- m_BBox.right = FXSYS_roundf(TextUnitToGlyphUnit(pData[4]));
- m_BBox.top = FXSYS_roundf(TextUnitToGlyphUnit(pData[5]));
+ colored_ = bColored;
+ width_ = FXSYS_roundf(TextUnitToGlyphUnit(pData[0]));
+ bbox_.left = FXSYS_roundf(TextUnitToGlyphUnit(pData[2]));
+ bbox_.bottom = FXSYS_roundf(TextUnitToGlyphUnit(pData[3]));
+ bbox_.right = FXSYS_roundf(TextUnitToGlyphUnit(pData[4]));
+ bbox_.top = FXSYS_roundf(TextUnitToGlyphUnit(pData[5]));
}
void CPDF_Type3Char::WillBeDestroyed() {
// Break cycles.
- m_pForm.reset();
+ form_.reset();
}
void CPDF_Type3Char::Transform(CPDF_Font::FormIface* pForm,
const CFX_Matrix& matrix) {
- m_Width = m_Width * matrix.GetXUnit() + 0.5f;
+ width_ = width_ * matrix.GetXUnit() + 0.5f;
CFX_FloatRect char_rect;
- if (m_BBox.right <= m_BBox.left || m_BBox.bottom >= m_BBox.top) {
+ if (bbox_.right <= bbox_.left || bbox_.bottom >= bbox_.top) {
char_rect = pForm->CalcBoundingBox();
TextUnitRectToGlyphUnitRect(&char_rect);
} else {
- char_rect = CFX_FloatRect(m_BBox);
+ char_rect = CFX_FloatRect(bbox_);
}
- m_BBox = matrix.TransformRect(char_rect).ToRoundedFxRect();
+ bbox_ = matrix.TransformRect(char_rect).ToRoundedFxRect();
}
void CPDF_Type3Char::SetForm(std::unique_ptr<CPDF_Font::FormIface> pForm) {
- m_pForm = std::move(pForm);
+ form_ = std::move(pForm);
}
RetainPtr<CFX_DIBitmap> CPDF_Type3Char::GetBitmap() {
- return m_pBitmap;
+ return bitmap_;
}
diff --git a/core/fpdfapi/font/cpdf_type3char.h b/core/fpdfapi/font/cpdf_type3char.h
index 1056d9f..f11eb73 100644
--- a/core/fpdfapi/font/cpdf_type3char.h
+++ b/core/fpdfapi/font/cpdf_type3char.h
@@ -33,21 +33,21 @@
RetainPtr<CFX_DIBitmap> GetBitmap();
- bool colored() const { return m_bColored; }
- int width() const { return m_Width; }
- const CFX_Matrix& matrix() const { return m_ImageMatrix; }
- const FX_RECT& bbox() const { return m_BBox; }
+ bool colored() const { return colored_; }
+ int width() const { return width_; }
+ const CFX_Matrix& matrix() const { return image_matrix_; }
+ const FX_RECT& bbox() const { return bbox_; }
- const CPDF_Font::FormIface* form() const { return m_pForm.get(); }
+ const CPDF_Font::FormIface* form() const { return form_.get(); }
void SetForm(std::unique_ptr<CPDF_Font::FormIface> pForm);
private:
- std::unique_ptr<CPDF_Font::FormIface> m_pForm;
- RetainPtr<CFX_DIBitmap> m_pBitmap;
- bool m_bColored = false;
- int m_Width = 0;
- CFX_Matrix m_ImageMatrix;
- FX_RECT m_BBox;
+ std::unique_ptr<CPDF_Font::FormIface> form_;
+ RetainPtr<CFX_DIBitmap> bitmap_;
+ bool colored_ = false;
+ int width_ = 0;
+ CFX_Matrix image_matrix_;
+ FX_RECT bbox_;
};
#endif // CORE_FPDFAPI_FONT_CPDF_TYPE3CHAR_H_
diff --git a/core/fpdfapi/font/cpdf_type3font.cpp b/core/fpdfapi/font/cpdf_type3font.cpp
index dfb0ff7..0fd3963 100644
--- a/core/fpdfapi/font/cpdf_type3font.cpp
+++ b/core/fpdfapi/font/cpdf_type3font.cpp
@@ -29,7 +29,7 @@
RetainPtr<CPDF_Dictionary> pFontDict,
FormFactoryIface* pFormFactory)
: CPDF_SimpleFont(pDocument, std::move(pFontDict)),
- m_pFormFactory(pFormFactory) {
+ form_factory_(pFormFactory) {
DCHECK(GetDocument());
}
@@ -48,11 +48,11 @@
}
void CPDF_Type3Font::WillBeDestroyed() {
- m_bWillBeDestroyed = true;
+ will_be_destroyed_ = true;
// Last reference to |this| may be through one of its CPDF_Type3Chars.
RetainPtr<CPDF_Font> protector(this);
- for (const auto& item : m_CacheMap) {
+ for (const auto& item : cache_map_) {
if (item.second) {
item.second->WillBeDestroyed();
}
@@ -60,42 +60,41 @@
}
bool CPDF_Type3Font::Load() {
- m_pFontResources = m_pFontDict->GetMutableDictFor("Resources");
- RetainPtr<const CPDF_Array> pMatrix = m_pFontDict->GetArrayFor("FontMatrix");
+ font_resources_ = font_dict_->GetMutableDictFor("Resources");
+ RetainPtr<const CPDF_Array> pMatrix = font_dict_->GetArrayFor("FontMatrix");
float xscale = 1.0f;
float yscale = 1.0f;
if (pMatrix) {
- m_FontMatrix = pMatrix->GetMatrix();
- xscale = m_FontMatrix.a;
- yscale = m_FontMatrix.d;
+ font_matrix_ = pMatrix->GetMatrix();
+ xscale = font_matrix_.a;
+ yscale = font_matrix_.d;
}
- RetainPtr<const CPDF_Array> pBBox = m_pFontDict->GetArrayFor("FontBBox");
+ RetainPtr<const CPDF_Array> pBBox = font_dict_->GetArrayFor("FontBBox");
if (pBBox) {
CFX_FloatRect box(
pBBox->GetFloatAt(0) * xscale, pBBox->GetFloatAt(1) * yscale,
pBBox->GetFloatAt(2) * xscale, pBBox->GetFloatAt(3) * yscale);
CPDF_Type3Char::TextUnitRectToGlyphUnitRect(&box);
- m_FontBBox = box.ToFxRect();
+ font_bbox_ = box.ToFxRect();
}
- const size_t kCharLimit = m_CharWidthL.size();
- int StartChar = m_pFontDict->GetIntegerFor("FirstChar");
+ const size_t kCharLimit = char_width_l_.size();
+ int StartChar = font_dict_->GetIntegerFor("FirstChar");
if (StartChar >= 0 && static_cast<size_t>(StartChar) < kCharLimit) {
- RetainPtr<const CPDF_Array> pWidthArray =
- m_pFontDict->GetArrayFor("Widths");
+ RetainPtr<const CPDF_Array> pWidthArray = font_dict_->GetArrayFor("Widths");
if (pWidthArray) {
size_t count = std::min(pWidthArray->size(), kCharLimit);
count = std::min(count, kCharLimit - StartChar);
for (size_t i = 0; i < count; i++) {
- m_CharWidthL[StartChar + i] =
+ char_width_l_[StartChar + i] =
FXSYS_roundf(CPDF_Type3Char::TextUnitToGlyphUnit(
pWidthArray->GetFloatAt(i) * xscale));
}
}
}
- m_pCharProcs = m_pFontDict->GetMutableDictFor("CharProcs");
- if (m_pFontDict->GetDirectObjectFor("Encoding")) {
+ char_procs_ = font_dict_->GetMutableDictFor("CharProcs");
+ if (font_dict_->GetDirectObjectFor("Encoding")) {
LoadPDFEncoding(false, false);
}
return true;
@@ -108,66 +107,65 @@
}
CPDF_Type3Char* CPDF_Type3Font::LoadChar(uint32_t charcode) {
- if (m_CharLoadingDepth >= kMaxType3FormLevel) {
+ if (char_loading_depth_ >= kMaxType3FormLevel) {
return nullptr;
}
- auto it = m_CacheMap.find(charcode);
- if (it != m_CacheMap.end()) {
+ auto it = cache_map_.find(charcode);
+ if (it != cache_map_.end()) {
return it->second.get();
}
- const char* name = GetAdobeCharName(m_BaseEncoding, m_CharNames, charcode);
+ const char* name = GetAdobeCharName(base_encoding_, char_names_, charcode);
if (!name) {
return nullptr;
}
- if (!m_pCharProcs) {
+ if (!char_procs_) {
return nullptr;
}
RetainPtr<CPDF_Stream> pStream =
- ToStream(m_pCharProcs->GetMutableDirectObjectFor(name));
+ ToStream(char_procs_->GetMutableDirectObjectFor(name));
if (!pStream) {
return nullptr;
}
- std::unique_ptr<CPDF_Font::FormIface> pForm = m_pFormFactory->CreateForm(
- m_pDocument, m_pFontResources ? m_pFontResources : m_pPageResources,
- pStream);
+ std::unique_ptr<CPDF_Font::FormIface> pForm = form_factory_->CreateForm(
+ document_, font_resources_ ? font_resources_ : page_resources_, pStream);
auto pNewChar = std::make_unique<CPDF_Type3Char>();
- // This can trigger recursion into this method. The content of |m_CacheMap|
+ // This can trigger recursion into this method. The content of |cache_map_|
// can change as a result. Thus after it returns, check the cache again for
// a cache hit.
{
- AutoRestorer<int> restorer(&m_CharLoadingDepth);
- m_CharLoadingDepth++;
+ AutoRestorer<int> restorer(&char_loading_depth_);
+ char_loading_depth_++;
pForm->ParseContentForType3Char(pNewChar.get());
}
- it = m_CacheMap.find(charcode);
- if (it != m_CacheMap.end()) {
+ it = cache_map_.find(charcode);
+ if (it != cache_map_.end()) {
return it->second.get();
}
- pNewChar->Transform(pForm.get(), m_FontMatrix);
+ pNewChar->Transform(pForm.get(), font_matrix_);
if (pForm->HasPageObjects()) {
pNewChar->SetForm(std::move(pForm));
}
CPDF_Type3Char* pCachedChar = pNewChar.get();
- m_CacheMap[charcode] = std::move(pNewChar);
+ cache_map_[charcode] = std::move(pNewChar);
return pCachedChar;
}
int CPDF_Type3Font::GetCharWidthF(uint32_t charcode) {
- if (charcode >= std::size(m_CharWidthL)) {
+ if (charcode >= std::size(char_width_l_)) {
charcode = 0;
}
- if (m_CharWidthL[charcode]) {
- return m_CharWidthL[charcode];
+ if (char_width_l_[charcode]) {
+ return char_width_l_[charcode];
}
const CPDF_Type3Char* pChar = LoadChar(charcode);
diff --git a/core/fpdfapi/font/cpdf_type3font.h b/core/fpdfapi/font/cpdf_type3font.h
index 89ad928..d001a46 100644
--- a/core/fpdfapi/font/cpdf_type3font.h
+++ b/core/fpdfapi/font/cpdf_type3font.h
@@ -36,12 +36,12 @@
FX_RECT GetCharBBox(uint32_t charcode) override;
void SetPageResources(CPDF_Dictionary* pResources) {
- m_pPageResources.Reset(pResources);
+ page_resources_.Reset(pResources);
}
CPDF_Type3Char* LoadChar(uint32_t charcode);
void CheckType3FontMetrics();
- CFX_Matrix& GetFontMatrix() { return m_FontMatrix; }
+ CFX_Matrix& GetFontMatrix() { return font_matrix_; }
private:
CPDF_Type3Font(CPDF_Document* pDocument,
@@ -55,14 +55,14 @@
void LoadGlyphMap() override;
// The depth char loading is in, to avoid recurive calling LoadChar().
- int m_CharLoadingDepth = 0;
- CFX_Matrix m_FontMatrix;
- UnownedPtr<FormFactoryIface> const m_pFormFactory;
- RetainPtr<CPDF_Dictionary> m_pCharProcs;
- RetainPtr<CPDF_Dictionary> m_pPageResources;
- RetainPtr<CPDF_Dictionary> m_pFontResources;
- std::map<uint32_t, std::unique_ptr<CPDF_Type3Char>> m_CacheMap;
- std::array<int, 256> m_CharWidthL = {};
+ int char_loading_depth_ = 0;
+ CFX_Matrix font_matrix_;
+ UnownedPtr<FormFactoryIface> const form_factory_;
+ RetainPtr<CPDF_Dictionary> char_procs_;
+ RetainPtr<CPDF_Dictionary> page_resources_;
+ RetainPtr<CPDF_Dictionary> font_resources_;
+ std::map<uint32_t, std::unique_ptr<CPDF_Type3Char>> cache_map_;
+ std::array<int, 256> char_width_l_ = {};
};
#endif // CORE_FPDFAPI_FONT_CPDF_TYPE3FONT_H_