summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/fpdfapi/fpdf_font/cpdf_cidfont.cpp8
-rw-r--r--core/fpdfapi/fpdf_font/cpdf_font.cpp40
-rw-r--r--core/fpdfapi/fpdf_font/cpdf_simplefont.cpp32
-rw-r--r--core/fpdfapi/fpdf_font/cpdf_simplefont.h4
-rw-r--r--core/fpdfapi/fpdf_font/cpdf_truetypefont.cpp66
-rw-r--r--core/fpdfapi/fpdf_font/cpdf_type1font.cpp16
-rw-r--r--core/fpdfapi/fpdf_font/cpdf_type3font.cpp11
-rw-r--r--core/fpdfapi/fpdf_font/font_int.h6
-rw-r--r--core/fpdfapi/fpdf_font/fpdf_font.cpp31
-rw-r--r--core/fpdfapi/fpdf_font/include/cpdf_font.h5
10 files changed, 110 insertions, 109 deletions
diff --git a/core/fpdfapi/fpdf_font/cpdf_cidfont.cpp b/core/fpdfapi/fpdf_font/cpdf_cidfont.cpp
index 8de2c98a84..0dcbf48be2 100644
--- a/core/fpdfapi/fpdf_font/cpdf_cidfont.cpp
+++ b/core/fpdfapi/fpdf_font/cpdf_cidfont.cpp
@@ -7,6 +7,7 @@
#include "core/fpdfapi/fpdf_font/cpdf_cidfont.h"
#include <algorithm>
+#include <vector>
#include "core/fpdfapi/fpdf_cmaps/cmap_int.h"
#include "core/fpdfapi/fpdf_font/font_int.h"
@@ -627,15 +628,16 @@ int CPDF_CIDFont::GlyphFromCharCode(uint32_t charcode, bool* pVertGlyph) {
return charcode ? static_cast<int>(charcode) : -1;
charcode += 31;
- FX_BOOL bMSUnicode = FT_UseTTCharmap(face, 3, 1);
- FX_BOOL bMacRoman = bMSUnicode ? FALSE : FT_UseTTCharmap(face, 1, 0);
+ bool bMSUnicode = FT_UseTTCharmap(face, 3, 1);
+ bool bMacRoman = !bMSUnicode && FT_UseTTCharmap(face, 1, 0);
int iBaseEncoding = PDFFONT_ENCODING_STANDARD;
if (bMSUnicode) {
iBaseEncoding = PDFFONT_ENCODING_WINANSI;
} else if (bMacRoman) {
iBaseEncoding = PDFFONT_ENCODING_MACROMAN;
}
- const FX_CHAR* name = GetAdobeCharName(iBaseEncoding, nullptr, charcode);
+ const FX_CHAR* name = GetAdobeCharName(
+ iBaseEncoding, std::vector<CFX_ByteString>(), charcode);
if (!name)
return charcode ? static_cast<int>(charcode) : -1;
diff --git a/core/fpdfapi/fpdf_font/cpdf_font.cpp b/core/fpdfapi/fpdf_font/cpdf_font.cpp
index 59a4aeca94..8101bd49a6 100644
--- a/core/fpdfapi/fpdf_font/cpdf_font.cpp
+++ b/core/fpdfapi/fpdf_font/cpdf_font.cpp
@@ -7,6 +7,7 @@
#include "core/fpdfapi/fpdf_font/include/cpdf_font.h"
#include <memory>
+#include <vector>
#include "core/fpdfapi/fpdf_font/cpdf_truetypefont.h"
#include "core/fpdfapi/fpdf_font/cpdf_type1font.h"
@@ -31,15 +32,15 @@ const uint8_t kChineseFontNames[][5] = {{0xCB, 0xCE, 0xCC, 0xE5, 0x00},
{0xB7, 0xC2, 0xCB, 0xCE, 0x00},
{0xD0, 0xC2, 0xCB, 0xCE, 0x00}};
-void GetPredefinedEncoding(int& basemap, const CFX_ByteString& value) {
+void GetPredefinedEncoding(const CFX_ByteString& value, int* basemap) {
if (value == "WinAnsiEncoding")
- basemap = PDFFONT_ENCODING_WINANSI;
+ *basemap = PDFFONT_ENCODING_WINANSI;
else if (value == "MacRomanEncoding")
- basemap = PDFFONT_ENCODING_MACROMAN;
+ *basemap = PDFFONT_ENCODING_MACROMAN;
else if (value == "MacExpertEncoding")
- basemap = PDFFONT_ENCODING_MACEXPERT;
+ *basemap = PDFFONT_ENCODING_MACEXPERT;
else if (value == "PDFDocEncoding")
- basemap = PDFFONT_ENCODING_PDFDOC;
+ *basemap = PDFFONT_ENCODING_PDFDOC;
}
} // namespace
@@ -356,7 +357,7 @@ uint32_t CPDF_Font::GetNextChar(const FX_CHAR* pString,
void CPDF_Font::LoadPDFEncoding(CPDF_Object* pEncoding,
int& iBaseEncoding,
- CFX_ByteString*& pCharNames,
+ std::vector<CFX_ByteString>* pCharNames,
FX_BOOL bEmbedded,
FX_BOOL bTrueType) {
if (!pEncoding) {
@@ -383,7 +384,7 @@ void CPDF_Font::LoadPDFEncoding(CPDF_Object* pEncoding,
if (bsEncoding.Compare("MacExpertEncoding") == 0) {
bsEncoding = "WinAnsiEncoding";
}
- GetPredefinedEncoding(iBaseEncoding, bsEncoding);
+ GetPredefinedEncoding(bsEncoding, &iBaseEncoding);
return;
}
@@ -397,16 +398,16 @@ void CPDF_Font::LoadPDFEncoding(CPDF_Object* pEncoding,
if (bsEncoding.Compare("MacExpertEncoding") == 0 && bTrueType) {
bsEncoding = "WinAnsiEncoding";
}
- GetPredefinedEncoding(iBaseEncoding, bsEncoding);
+ GetPredefinedEncoding(bsEncoding, &iBaseEncoding);
}
- if ((!bEmbedded || bTrueType) && iBaseEncoding == PDFFONT_ENCODING_BUILTIN) {
+ if ((!bEmbedded || bTrueType) && iBaseEncoding == PDFFONT_ENCODING_BUILTIN)
iBaseEncoding = PDFFONT_ENCODING_STANDARD;
- }
+
CPDF_Array* pDiffs = pDict->GetArrayBy("Differences");
- if (!pDiffs) {
+ if (!pDiffs)
return;
- }
- pCharNames = new CFX_ByteString[256];
+
+ pCharNames->resize(256);
uint32_t cur_code = 0;
for (uint32_t i = 0; i < pDiffs->GetCount(); i++) {
CPDF_Object* pElement = pDiffs->GetDirectObjectAt(i);
@@ -415,7 +416,7 @@ void CPDF_Font::LoadPDFEncoding(CPDF_Object* pEncoding,
if (CPDF_Name* pName = pElement->AsName()) {
if (cur_code < 256)
- pCharNames[cur_code] = pName->GetString();
+ (*pCharNames)[cur_code] = pName->GetString();
cur_code++;
} else {
cur_code = pElement->GetInteger();
@@ -433,16 +434,17 @@ FX_BOOL CPDF_Font::IsStandardFont() const {
return TRUE;
}
-const FX_CHAR* CPDF_Font::GetAdobeCharName(int iBaseEncoding,
- const CFX_ByteString* pCharNames,
- int charcode) {
+const FX_CHAR* CPDF_Font::GetAdobeCharName(
+ int iBaseEncoding,
+ const std::vector<CFX_ByteString>& charnames,
+ int charcode) {
if (charcode < 0 || charcode >= 256) {
ASSERT(false);
return nullptr;
}
- if (pCharNames && !pCharNames[charcode].IsEmpty())
- return pCharNames[charcode].c_str();
+ if (!charnames.empty() && !charnames[charcode].IsEmpty())
+ return charnames[charcode].c_str();
const FX_CHAR* name = nullptr;
if (iBaseEncoding)
diff --git a/core/fpdfapi/fpdf_font/cpdf_simplefont.cpp b/core/fpdfapi/fpdf_font/cpdf_simplefont.cpp
index 0eb7e2c057..65f4a5a235 100644
--- a/core/fpdfapi/fpdf_font/cpdf_simplefont.cpp
+++ b/core/fpdfapi/fpdf_font/cpdf_simplefont.cpp
@@ -11,16 +11,13 @@
#include "core/fpdfapi/fpdf_parser/include/cpdf_dictionary.h"
#include "core/fxge/include/fx_freetype.h"
-CPDF_SimpleFont::CPDF_SimpleFont()
- : m_pCharNames(nullptr), m_BaseEncoding(PDFFONT_ENCODING_BUILTIN) {
+CPDF_SimpleFont::CPDF_SimpleFont() : m_BaseEncoding(PDFFONT_ENCODING_BUILTIN) {
FXSYS_memset(m_CharWidth, 0xff, sizeof(m_CharWidth));
FXSYS_memset(m_GlyphIndex, 0xff, sizeof(m_GlyphIndex));
FXSYS_memset(m_ExtGID, 0xff, sizeof(m_ExtGID));
}
-CPDF_SimpleFont::~CPDF_SimpleFont() {
- delete[] m_pCharNames;
-}
+CPDF_SimpleFont::~CPDF_SimpleFont() {}
int CPDF_SimpleFont::GlyphFromCharCode(uint32_t charcode, bool* pVertGlyph) {
if (pVertGlyph)
@@ -139,25 +136,26 @@ FX_BOOL CPDF_SimpleFont::LoadCommon() {
m_BaseEncoding = PDFFONT_ENCODING_STANDARD;
}
CPDF_Object* pEncoding = m_pFontDict->GetDirectObjectBy("Encoding");
- LoadPDFEncoding(pEncoding, m_BaseEncoding, m_pCharNames, !!m_pFontFile,
+ LoadPDFEncoding(pEncoding, m_BaseEncoding, &m_CharNames, !!m_pFontFile,
m_Font.IsTTFont());
LoadGlyphMap();
- delete[] m_pCharNames;
- m_pCharNames = nullptr;
+ m_CharNames.clear();
if (!m_Font.GetFace())
return TRUE;
if (m_Flags & PDFFONT_ALLCAP) {
- unsigned char lowercases[] = {'a', 'z', 0xe0, 0xf6, 0xf8, 0xfd};
- for (size_t range = 0; range < sizeof lowercases / 2; range++) {
- for (int i = lowercases[range * 2]; i <= lowercases[range * 2 + 1]; i++) {
- if (m_GlyphIndex[i] != 0xffff && m_pFontFile) {
+ unsigned char kLowercases[][2] = {{'a', 'z'}, {0xe0, 0xf6}, {0xf8, 0xfd}};
+ for (size_t range = 0; range < FX_ArraySize(kLowercases); ++range) {
+ const auto& lower = kLowercases[range];
+ for (int i = lower[0]; i <= lower[1]; ++i) {
+ if (m_GlyphIndex[i] != 0xffff && m_pFontFile)
continue;
- }
- m_GlyphIndex[i] = m_GlyphIndex[i - 32];
- if (m_CharWidth[i - 32]) {
- m_CharWidth[i] = m_CharWidth[i - 32];
- m_CharBBox[i] = m_CharBBox[i - 32];
+
+ 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];
}
}
}
diff --git a/core/fpdfapi/fpdf_font/cpdf_simplefont.h b/core/fpdfapi/fpdf_font/cpdf_simplefont.h
index 3cc81cfe11..9000850ca3 100644
--- a/core/fpdfapi/fpdf_font/cpdf_simplefont.h
+++ b/core/fpdfapi/fpdf_font/cpdf_simplefont.h
@@ -7,6 +7,8 @@
#ifndef CORE_FPDFAPI_FPDF_FONT_CPDF_SIMPLEFONT_H_
#define CORE_FPDFAPI_FPDF_FONT_CPDF_SIMPLEFONT_H_
+#include <vector>
+
#include "core/fpdfapi/fpdf_font/include/cpdf_font.h"
#include "core/fpdfapi/fpdf_font/include/cpdf_fontencoding.h"
#include "core/fxcrt/include/fx_string.h"
@@ -37,7 +39,7 @@ class CPDF_SimpleFont : public CPDF_Font {
CPDF_FontEncoding m_Encoding;
uint16_t m_GlyphIndex[256];
uint16_t m_ExtGID[256];
- CFX_ByteString* m_pCharNames;
+ std::vector<CFX_ByteString> m_CharNames;
int m_BaseEncoding;
uint16_t m_CharWidth[256];
FX_SMALL_RECT m_CharBBox[256];
diff --git a/core/fpdfapi/fpdf_font/cpdf_truetypefont.cpp b/core/fpdfapi/fpdf_font/cpdf_truetypefont.cpp
index 576b00550e..25baf45d02 100644
--- a/core/fpdfapi/fpdf_font/cpdf_truetypefont.cpp
+++ b/core/fpdfapi/fpdf_font/cpdf_truetypefont.cpp
@@ -10,6 +10,12 @@
#include "core/fpdfapi/fpdf_parser/include/cpdf_dictionary.h"
#include "core/fxge/include/fx_font.h"
+namespace {
+
+const uint8_t kPrefix[4] = {0x00, 0xf0, 0xf1, 0xf2};
+
+} // namespace
+
CPDF_TrueTypeFont::CPDF_TrueTypeFont() {}
bool CPDF_TrueTypeFont::IsTrueTypeFont() const {
@@ -58,7 +64,7 @@ void CPDF_TrueTypeFont::LoadGlyphMap() {
}
if (((baseEncoding == PDFFONT_ENCODING_MACROMAN ||
baseEncoding == PDFFONT_ENCODING_WINANSI) &&
- !m_pCharNames) ||
+ m_CharNames.empty()) ||
(m_Flags & PDFFONT_NONSYMBOLIC)) {
if (!FXFT_Has_Glyph_Names(m_Font.GetFace()) &&
(!m_Font.GetFace()->num_charmaps || !m_Font.GetFace()->charmaps)) {
@@ -76,8 +82,9 @@ void CPDF_TrueTypeFont::LoadGlyphMap() {
}
return;
}
- FX_BOOL bMSUnicode = FT_UseTTCharmap(m_Font.GetFace(), 3, 1);
- FX_BOOL bMacRoman = FALSE, bMSSymbol = FALSE;
+ bool bMSUnicode = FT_UseTTCharmap(m_Font.GetFace(), 3, 1);
+ bool bMacRoman = false;
+ bool bMSSymbol = false;
if (!bMSUnicode) {
if (m_Flags & PDFFONT_NONSYMBOLIC) {
bMacRoman = FT_UseTTCharmap(m_Font.GetFace(), 1, 0);
@@ -90,7 +97,7 @@ void CPDF_TrueTypeFont::LoadGlyphMap() {
FX_BOOL bToUnicode = m_pFontDict->KeyExist("ToUnicode");
for (int charcode = 0; charcode < 256; charcode++) {
const FX_CHAR* name =
- GetAdobeCharName(baseEncoding, m_pCharNames, charcode);
+ GetAdobeCharName(baseEncoding, m_CharNames, charcode);
if (!name) {
m_GlyphIndex[charcode] =
m_pFontFile ? FXFT_Get_Char_Index(m_Font.GetFace(), charcode) : -1;
@@ -98,9 +105,8 @@ void CPDF_TrueTypeFont::LoadGlyphMap() {
}
m_Encoding.m_Unicodes[charcode] = PDF_UnicodeFromAdobeName(name);
if (bMSSymbol) {
- const uint8_t prefix[4] = {0x00, 0xf0, 0xf1, 0xf2};
- for (int j = 0; j < 4; j++) {
- uint16_t unicode = prefix[j] * 256 + charcode;
+ for (size_t j = 0; j < FX_ArraySize(kPrefix); j++) {
+ uint16_t unicode = kPrefix[j] * 256 + charcode;
m_GlyphIndex[charcode] =
FXFT_Get_Char_Index(m_Font.GetFace(), unicode);
if (m_GlyphIndex[charcode]) {
@@ -150,27 +156,24 @@ void CPDF_TrueTypeFont::LoadGlyphMap() {
return;
}
if (FT_UseTTCharmap(m_Font.GetFace(), 3, 0)) {
- const uint8_t prefix[4] = {0x00, 0xf0, 0xf1, 0xf2};
- FX_BOOL bGotOne = FALSE;
+ bool bFound = false;
for (int charcode = 0; charcode < 256; charcode++) {
- for (int j = 0; j < 4; j++) {
- uint16_t unicode = prefix[j] * 256 + charcode;
+ for (size_t j = 0; j < FX_ArraySize(kPrefix); j++) {
+ uint16_t unicode = kPrefix[j] * 256 + charcode;
m_GlyphIndex[charcode] = FXFT_Get_Char_Index(m_Font.GetFace(), unicode);
if (m_GlyphIndex[charcode]) {
- bGotOne = TRUE;
+ bFound = true;
break;
}
}
}
- if (bGotOne) {
+ if (bFound) {
if (baseEncoding != PDFFONT_ENCODING_BUILTIN) {
for (int charcode = 0; charcode < 256; charcode++) {
const FX_CHAR* name =
- GetAdobeCharName(baseEncoding, m_pCharNames, charcode);
- if (!name) {
- continue;
- }
- m_Encoding.m_Unicodes[charcode] = PDF_UnicodeFromAdobeName(name);
+ GetAdobeCharName(baseEncoding, m_CharNames, charcode);
+ if (name)
+ m_Encoding.m_Unicodes[charcode] = PDF_UnicodeFromAdobeName(name);
}
} else if (FT_UseTTCharmap(m_Font.GetFace(), 1, 0)) {
for (int charcode = 0; charcode < 256; charcode++) {
@@ -182,44 +185,39 @@ void CPDF_TrueTypeFont::LoadGlyphMap() {
}
}
if (FT_UseTTCharmap(m_Font.GetFace(), 1, 0)) {
- FX_BOOL bGotOne = FALSE;
+ bool bFound = false;
for (int charcode = 0; charcode < 256; charcode++) {
m_GlyphIndex[charcode] = FXFT_Get_Char_Index(m_Font.GetFace(), charcode);
m_Encoding.m_Unicodes[charcode] =
FT_UnicodeFromCharCode(FXFT_ENCODING_APPLE_ROMAN, charcode);
if (m_GlyphIndex[charcode]) {
- bGotOne = TRUE;
+ bFound = true;
}
}
- if (m_pFontFile || bGotOne) {
+ if (m_pFontFile || bFound)
return;
- }
}
if (FXFT_Select_Charmap(m_Font.GetFace(), FXFT_ENCODING_UNICODE) == 0) {
- FX_BOOL bGotOne = FALSE;
+ bool bFound = false;
const uint16_t* pUnicodes = PDF_UnicodesForPredefinedCharSet(baseEncoding);
for (int charcode = 0; charcode < 256; charcode++) {
if (m_pFontFile) {
m_Encoding.m_Unicodes[charcode] = charcode;
} else {
- const FX_CHAR* name = GetAdobeCharName(0, m_pCharNames, charcode);
- if (name) {
+ const FX_CHAR* name = GetAdobeCharName(0, m_CharNames, charcode);
+ if (name)
m_Encoding.m_Unicodes[charcode] = PDF_UnicodeFromAdobeName(name);
- } else if (pUnicodes) {
+ else if (pUnicodes)
m_Encoding.m_Unicodes[charcode] = pUnicodes[charcode];
- }
}
m_GlyphIndex[charcode] = FXFT_Get_Char_Index(
m_Font.GetFace(), m_Encoding.m_Unicodes[charcode]);
- if (m_GlyphIndex[charcode]) {
- bGotOne = TRUE;
- }
+ if (m_GlyphIndex[charcode])
+ bFound = true;
}
- if (bGotOne) {
+ if (bFound)
return;
- }
}
- for (int charcode = 0; charcode < 256; charcode++) {
+ for (int charcode = 0; charcode < 256; charcode++)
m_GlyphIndex[charcode] = charcode;
- }
}
diff --git a/core/fpdfapi/fpdf_font/cpdf_type1font.cpp b/core/fpdfapi/fpdf_font/cpdf_type1font.cpp
index 5f6eb1f662..c316d8d424 100644
--- a/core/fpdfapi/fpdf_font/cpdf_type1font.cpp
+++ b/core/fpdfapi/fpdf_font/cpdf_type1font.cpp
@@ -173,10 +173,10 @@ void CPDF_Type1Font::LoadGlyphMap() {
}
for (int charcode = 0; charcode < 256; charcode++) {
const FX_CHAR* name =
- GetAdobeCharName(m_BaseEncoding, m_pCharNames, charcode);
- if (!name) {
+ GetAdobeCharName(m_BaseEncoding, m_CharNames, charcode);
+ if (!name)
continue;
- }
+
m_Encoding.m_Unicodes[charcode] = PDF_UnicodeFromAdobeName(name);
m_GlyphIndex[charcode] = FXFT_Get_Char_Index(
m_Font.GetFace(), m_Encoding.m_Unicodes[charcode]);
@@ -225,7 +225,7 @@ void CPDF_Type1Font::LoadGlyphMap() {
if (m_Flags & PDFFONT_SYMBOLIC) {
for (int charcode = 0; charcode < 256; charcode++) {
const FX_CHAR* name =
- GetAdobeCharName(m_BaseEncoding, m_pCharNames, charcode);
+ GetAdobeCharName(m_BaseEncoding, m_CharNames, charcode);
if (name) {
m_Encoding.m_Unicodes[charcode] = PDF_UnicodeFromAdobeName(name);
m_GlyphIndex[charcode] =
@@ -273,7 +273,7 @@ void CPDF_Type1Font::LoadGlyphMap() {
}
for (int charcode = 0; charcode < 256; charcode++) {
const FX_CHAR* name =
- GetAdobeCharName(m_BaseEncoding, m_pCharNames, charcode);
+ GetAdobeCharName(m_BaseEncoding, m_CharNames, charcode);
if (!name) {
continue;
}
@@ -331,11 +331,11 @@ void CPDF_Type1Font::LoadGlyphMap() {
}
return;
}
-#endif
+#endif // _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_
if (m_Flags & PDFFONT_SYMBOLIC) {
for (int charcode = 0; charcode < 256; charcode++) {
const FX_CHAR* name =
- GetAdobeCharName(m_BaseEncoding, m_pCharNames, charcode);
+ GetAdobeCharName(m_BaseEncoding, m_CharNames, charcode);
if (name) {
m_Encoding.m_Unicodes[charcode] = PDF_UnicodeFromAdobeName(name);
m_GlyphIndex[charcode] =
@@ -373,7 +373,7 @@ void CPDF_Type1Font::LoadGlyphMap() {
}
for (int charcode = 0; charcode < 256; charcode++) {
const FX_CHAR* name =
- GetAdobeCharName(m_BaseEncoding, m_pCharNames, charcode);
+ GetAdobeCharName(m_BaseEncoding, m_CharNames, charcode);
if (!name) {
continue;
}
diff --git a/core/fpdfapi/fpdf_font/cpdf_type3font.cpp b/core/fpdfapi/fpdf_font/cpdf_type3font.cpp
index 8e4ac56884..849ad92298 100644
--- a/core/fpdfapi/fpdf_font/cpdf_type3font.cpp
+++ b/core/fpdfapi/fpdf_font/cpdf_type3font.cpp
@@ -6,6 +6,8 @@
#include "core/fpdfapi/fpdf_font/cpdf_type3font.h"
+#include <utility>
+
#include "core/fpdfapi/fpdf_font/cpdf_type3char.h"
#include "core/fpdfapi/fpdf_page/include/cpdf_form.h"
#include "core/fpdfapi/fpdf_page/pageint.h"
@@ -67,11 +69,11 @@ FX_BOOL CPDF_Type3Font::Load() {
m_pCharProcs = m_pFontDict->GetDictBy("CharProcs");
CPDF_Object* pEncoding = m_pFontDict->GetDirectObjectBy("Encoding");
if (pEncoding) {
- LoadPDFEncoding(pEncoding, m_BaseEncoding, m_pCharNames, FALSE, FALSE);
- if (m_pCharNames) {
+ LoadPDFEncoding(pEncoding, m_BaseEncoding, &m_CharNames, FALSE, FALSE);
+ if (!m_CharNames.empty()) {
for (int i = 0; i < 256; i++) {
m_Encoding.m_Unicodes[i] =
- PDF_UnicodeFromAdobeName(m_pCharNames[i].c_str());
+ PDF_UnicodeFromAdobeName(m_CharNames[i].c_str());
if (m_Encoding.m_Unicodes[i] == 0) {
m_Encoding.m_Unicodes[i] = i;
}
@@ -93,8 +95,7 @@ CPDF_Type3Char* CPDF_Type3Font::LoadChar(uint32_t charcode, int level) {
if (it != m_CacheMap.end())
return it->second.get();
- const FX_CHAR* name =
- GetAdobeCharName(m_BaseEncoding, m_pCharNames, charcode);
+ const FX_CHAR* name = GetAdobeCharName(m_BaseEncoding, m_CharNames, charcode);
if (!name)
return nullptr;
diff --git a/core/fpdfapi/fpdf_font/font_int.h b/core/fpdfapi/fpdf_font/font_int.h
index e14707f997..9854797e67 100644
--- a/core/fpdfapi/fpdf_font/font_int.h
+++ b/core/fpdfapi/fpdf_font/font_int.h
@@ -18,10 +18,10 @@ class CPDF_CMap;
class CPDF_Font;
class CPDF_Stream;
-typedef void* FXFT_Library;
+using FXFT_Library = void*;
-short TT2PDF(int m, FXFT_Face face);
-FX_BOOL FT_UseTTCharmap(FXFT_Face face, int platform_id, int encoding_id);
+int16_t TT2PDF(int m, FXFT_Face face);
+bool FT_UseTTCharmap(FXFT_Face face, int platform_id, int encoding_id);
CIDSet CharsetFromOrdering(const CFX_ByteStringC& ordering);
class CPDF_CMapManager {
diff --git a/core/fpdfapi/fpdf_font/fpdf_font.cpp b/core/fpdfapi/fpdf_font/fpdf_font.cpp
index 1735f0ba25..cb410b8d68 100644
--- a/core/fpdfapi/fpdf_font/fpdf_font.cpp
+++ b/core/fpdfapi/fpdf_font/fpdf_font.cpp
@@ -21,17 +21,23 @@
#include "core/fxge/include/fx_freetype.h"
#include "third_party/base/stl_util.h"
-FX_BOOL FT_UseTTCharmap(FXFT_Face face, int platform_id, int encoding_id) {
+int16_t TT2PDF(int m, FXFT_Face face) {
+ int upm = FXFT_Get_Face_UnitsPerEM(face);
+ if (upm == 0)
+ return static_cast<int16_t>(m);
+ return (m * 1000 + upm / 2) / upm;
+}
+
+bool FT_UseTTCharmap(FXFT_Face face, int platform_id, int encoding_id) {
+ auto* pCharMap = FXFT_Get_Face_Charmaps(face);
for (int i = 0; i < FXFT_Get_Face_CharmapCount(face); i++) {
- if (FXFT_Get_Charmap_PlatformID(FXFT_Get_Face_Charmaps(face)[i]) ==
- platform_id &&
- FXFT_Get_Charmap_EncodingID(FXFT_Get_Face_Charmaps(face)[i]) ==
- encoding_id) {
- FXFT_Set_Charmap(face, FXFT_Get_Face_Charmaps(face)[i]);
- return TRUE;
+ if (FXFT_Get_Charmap_PlatformID(pCharMap[i]) == platform_id &&
+ FXFT_Get_Charmap_EncodingID(pCharMap[i]) == encoding_id) {
+ FXFT_Set_Charmap(face, pCharMap[i]);
+ return true;
}
}
- return FALSE;
+ return false;
}
CFX_StockFontArray::CFX_StockFontArray() {}
@@ -84,15 +90,6 @@ void CPDF_FontGlobals::Clear(CPDF_Document* pDoc) {
m_StockMap.erase(pDoc);
}
-
-
-short TT2PDF(int m, FXFT_Face face) {
- int upm = FXFT_Get_Face_UnitsPerEM(face);
- if (upm == 0)
- return (short)m;
- return (m * 1000 + upm / 2) / upm;
-}
-
CFX_WideString CPDF_ToUnicodeMap::Lookup(uint32_t charcode) const {
auto it = m_Map.find(charcode);
if (it != m_Map.end()) {
diff --git a/core/fpdfapi/fpdf_font/include/cpdf_font.h b/core/fpdfapi/fpdf_font/include/cpdf_font.h
index 390a3137b6..a76a6a2573 100644
--- a/core/fpdfapi/fpdf_font/include/cpdf_font.h
+++ b/core/fpdfapi/fpdf_font/include/cpdf_font.h
@@ -8,6 +8,7 @@
#define CORE_FPDFAPI_FPDF_FONT_INCLUDE_CPDF_FONT_H_
#include <memory>
+#include <vector>
#include "core/fxcrt/include/fx_string.h"
#include "core/fxcrt/include/fx_system.h"
@@ -103,14 +104,14 @@ class CPDF_Font {
void LoadUnicodeMap() const; // logically const only.
void LoadPDFEncoding(CPDF_Object* pEncoding,
int& iBaseEncoding,
- CFX_ByteString*& pCharNames,
+ std::vector<CFX_ByteString>* pCharNames,
FX_BOOL bEmbedded,
FX_BOOL bTrueType);
void LoadFontDescriptor(CPDF_Dictionary* pDict);
void CheckFontMetrics();
const FX_CHAR* GetAdobeCharName(int iBaseEncoding,
- const CFX_ByteString* pCharNames,
+ const std::vector<CFX_ByteString>& charnames,
int charcode);
CFX_ByteString m_BaseFont;