summaryrefslogtreecommitdiff
path: root/core/fpdfapi/fpdf_font/cpdf_font.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'core/fpdfapi/fpdf_font/cpdf_font.cpp')
-rw-r--r--core/fpdfapi/fpdf_font/cpdf_font.cpp35
1 files changed, 11 insertions, 24 deletions
diff --git a/core/fpdfapi/fpdf_font/cpdf_font.cpp b/core/fpdfapi/fpdf_font/cpdf_font.cpp
index c15ac6b445..061b477f17 100644
--- a/core/fpdfapi/fpdf_font/cpdf_font.cpp
+++ b/core/fpdfapi/fpdf_font/cpdf_font.cpp
@@ -128,24 +128,13 @@ int CPDF_Font::GetCharSize(uint32_t charcode) const {
return 1;
}
-int CPDF_Font::GlyphFromCharCode(uint32_t charcode, FX_BOOL* pVertGlyph) {
- ASSERT(false);
- return 0;
-}
-
int CPDF_Font::GlyphFromCharCodeExt(uint32_t charcode) {
- return GlyphFromCharCode(charcode);
+ return GlyphFromCharCode(charcode, nullptr);
}
FX_BOOL CPDF_Font::IsVertWriting() const {
- FX_BOOL bVertWriting = FALSE;
const CPDF_CIDFont* pCIDFont = AsCIDFont();
- if (pCIDFont) {
- bVertWriting = pCIDFont->IsVertWriting();
- } else {
- bVertWriting = m_Font.IsVertical();
- }
- return bVertWriting;
+ return pCIDFont ? pCIDFont->IsVertWriting() : m_Font.IsVertical();
}
int CPDF_Font::AppendChar(FX_CHAR* buf, uint32_t charcode) const {
@@ -167,18 +156,14 @@ CFX_WideString CPDF_Font::UnicodeFromCharCode(uint32_t charcode) const {
if (!m_bToUnicodeLoaded)
LoadUnicodeMap();
- if (m_pToUnicodeMap)
- return m_pToUnicodeMap->Lookup(charcode);
- return CFX_WideString();
+ return m_pToUnicodeMap ? m_pToUnicodeMap->Lookup(charcode) : CFX_WideString();
}
uint32_t CPDF_Font::CharCodeFromUnicode(FX_WCHAR unicode) const {
if (!m_bToUnicodeLoaded)
LoadUnicodeMap();
- if (m_pToUnicodeMap)
- return m_pToUnicodeMap->ReverseLookup(unicode);
- return 0;
+ return m_pToUnicodeMap ? m_pToUnicodeMap->ReverseLookup(unicode) : 0;
}
void CPDF_Font::LoadFontDescriptor(CPDF_Dictionary* pFontDesc) {
@@ -458,14 +443,16 @@ FX_BOOL CPDF_Font::IsStandardFont() const {
const FX_CHAR* CPDF_Font::GetAdobeCharName(int iBaseEncoding,
const CFX_ByteString* pCharNames,
int charcode) {
- ASSERT(charcode >= 0 && charcode < 256);
- if (charcode < 0 || charcode >= 256)
+ if (charcode < 0 || charcode >= 256) {
+ ASSERT(false);
return nullptr;
+ }
+
+ if (pCharNames && !pCharNames[charcode].IsEmpty())
+ return pCharNames[charcode].c_str();
const FX_CHAR* name = nullptr;
- if (pCharNames)
- name = pCharNames[charcode].c_str();
- if ((!name || name[0] == 0) && iBaseEncoding)
+ if (iBaseEncoding)
name = PDF_CharNameFromPredefinedCharSet(iBaseEncoding, charcode);
return name && name[0] ? name : nullptr;
}