From 8ea3f5176aab4d6688710d9937cf38a43c14d030 Mon Sep 17 00:00:00 2001 From: thestig Date: Mon, 27 Jun 2016 11:55:24 -0700 Subject: Clean up some CPDF_Font subclasses. Review-Url: https://codereview.chromium.org/2093313002 --- core/fpdfapi/fpdf_font/cpdf_font.cpp | 35 +++++++++++------------------------ 1 file changed, 11 insertions(+), 24 deletions(-) (limited to 'core/fpdfapi/fpdf_font/cpdf_font.cpp') 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; } -- cgit v1.2.3