From c599b59f77d3a620e983fd30802a414795be470a Mon Sep 17 00:00:00 2001 From: Lei Zhang Date: Thu, 18 Feb 2016 15:39:09 -0800 Subject: Remove useless CPDF_FontCharMap. R=tsepez@chromium.org Review URL: https://codereview.chromium.org/1715583002 . --- core/include/fpdfapi/fpdf_resource.h | 8 ------ core/src/fpdfapi/fpdf_font/font_int.h | 5 ---- core/src/fpdfapi/fpdf_font/fpdf_font.cpp | 48 +------------------------------- 3 files changed, 1 insertion(+), 60 deletions(-) diff --git a/core/include/fpdfapi/fpdf_resource.h b/core/include/fpdfapi/fpdf_resource.h index bc71e7afbc..b8504337df 100644 --- a/core/include/fpdfapi/fpdf_resource.h +++ b/core/include/fpdfapi/fpdf_resource.h @@ -181,12 +181,6 @@ class CPDF_Font { FX_DWORD CharCodeFromUnicode(FX_WCHAR Unicode) const; - CFX_CharMap* GetCharMap() { return m_pCharMap; } - - CFX_ByteString EncodeString(const CFX_WideString& str) const; - - CFX_WideString DecodeString(const CFX_ByteString& str) const; - void GetFontBBox(FX_RECT& rect) const { rect = m_FontBBox; } int GetTypeAscent() const { return m_Ascent; } @@ -238,8 +232,6 @@ class CPDF_Font { void CheckFontMetrics(); - CFX_CharMap* m_pCharMap; - CFX_ByteString m_BaseFont; CPDF_StreamAcc* m_pFontFile; diff --git a/core/src/fpdfapi/fpdf_font/font_int.h b/core/src/fpdfapi/fpdf_font/font_int.h index 33fa926b2a..7ff97e5a77 100644 --- a/core/src/fpdfapi/fpdf_font/font_int.h +++ b/core/src/fpdfapi/fpdf_font/font_int.h @@ -207,11 +207,6 @@ class CPDF_ToUnicodeMap { static FX_DWORD StringToCode(const CFX_ByteStringC& str); static CFX_WideString StringToWideString(const CFX_ByteStringC& str); }; -class CPDF_FontCharMap : public CFX_CharMap { - public: - CPDF_FontCharMap(CPDF_Font* pFont); - CPDF_Font* m_pFont; -}; void FPDFAPI_LoadCID2UnicodeMap(CIDSet charset, const FX_WORD*& pMap, diff --git a/core/src/fpdfapi/fpdf_font/fpdf_font.cpp b/core/src/fpdfapi/fpdf_font/fpdf_font.cpp index 8d5a61ad13..87c95c668e 100644 --- a/core/src/fpdfapi/fpdf_font/fpdf_font.cpp +++ b/core/src/fpdfapi/fpdf_font/fpdf_font.cpp @@ -88,12 +88,8 @@ CPDF_Font::CPDF_Font(int fonttype) : m_FontType(fonttype) { m_Flags = 0; m_pToUnicodeMap = NULL; m_bToUnicodeLoaded = FALSE; - m_pCharMap = new CPDF_FontCharMap(this); } CPDF_Font::~CPDF_Font() { - delete m_pCharMap; - m_pCharMap = NULL; - delete m_pToUnicodeMap; m_pToUnicodeMap = NULL; @@ -162,36 +158,6 @@ FX_DWORD CPDF_Font::CharCodeFromUnicode(FX_WCHAR unicode) const { } return _CharCodeFromUnicode(unicode); } -CFX_WideString CPDF_Font::DecodeString(const CFX_ByteString& str) const { - CFX_WideString result; - int src_len = str.GetLength(); - result.Reserve(src_len); - const FX_CHAR* src_buf = str; - int src_pos = 0; - while (src_pos < src_len) { - FX_DWORD charcode = GetNextChar(src_buf, src_len, src_pos); - CFX_WideString unicode = UnicodeFromCharCode(charcode); - if (!unicode.IsEmpty()) { - result += unicode; - } else { - result += (FX_WCHAR)charcode; - } - } - return result; -} -CFX_ByteString CPDF_Font::EncodeString(const CFX_WideString& str) const { - CFX_ByteString result; - int src_len = str.GetLength(); - FX_CHAR* dest_buf = result.GetBuffer(src_len * 2); - const FX_WCHAR* src_buf = str.c_str(); - int dest_pos = 0; - for (int src_pos = 0; src_pos < src_len; src_pos++) { - FX_DWORD charcode = CharCodeFromUnicode(src_buf[src_pos]); - dest_pos += AppendChar(dest_buf + dest_pos, charcode); - } - result.ReleaseBuffer(dest_pos); - return result; -} void CPDF_Font::LoadFontDescriptor(CPDF_Dictionary* pFontDesc) { m_Flags = pFontDesc->GetIntegerBy("Flags", PDFFONT_NONSYMBOLIC); @@ -439,19 +405,7 @@ FX_BOOL CPDF_Font::Load() { } return _Load(); } -static CFX_WideString _FontMap_GetWideString(CFX_CharMap* pMap, - const CFX_ByteString& bytestr) { - return ((CPDF_FontCharMap*)pMap)->m_pFont->DecodeString(bytestr); -} -static CFX_ByteString _FontMap_GetByteString(CFX_CharMap* pMap, - const CFX_WideString& widestr) { - return ((CPDF_FontCharMap*)pMap)->m_pFont->EncodeString(widestr); -} -CPDF_FontCharMap::CPDF_FontCharMap(CPDF_Font* pFont) { - m_GetByteString = _FontMap_GetByteString; - m_GetWideString = _FontMap_GetWideString; - m_pFont = pFont; -} + CFX_WideString CPDF_ToUnicodeMap::Lookup(FX_DWORD charcode) { auto it = m_Map.find(charcode); if (it != m_Map.end()) { -- cgit v1.2.3