diff options
Diffstat (limited to 'core/fpdfapi/font')
-rw-r--r-- | core/fpdfapi/font/cpdf_cidfont.cpp | 22 | ||||
-rw-r--r-- | core/fpdfapi/font/cpdf_cidfont.h | 2 | ||||
-rw-r--r-- | core/fpdfapi/font/cpdf_cmap.cpp | 8 | ||||
-rw-r--r-- | core/fpdfapi/font/cpdf_cmap.h | 4 | ||||
-rw-r--r-- | core/fpdfapi/font/cpdf_cmapmanager.cpp | 4 | ||||
-rw-r--r-- | core/fpdfapi/font/cpdf_cmapmanager.h | 8 | ||||
-rw-r--r-- | core/fpdfapi/font/cpdf_cmapparser.cpp | 16 | ||||
-rw-r--r-- | core/fpdfapi/font/cpdf_cmapparser.h | 12 | ||||
-rw-r--r-- | core/fpdfapi/font/cpdf_font.cpp | 30 | ||||
-rw-r--r-- | core/fpdfapi/font/cpdf_font.h | 14 | ||||
-rw-r--r-- | core/fpdfapi/font/cpdf_fontencoding.cpp | 6 | ||||
-rw-r--r-- | core/fpdfapi/font/cpdf_fontencoding.h | 4 | ||||
-rw-r--r-- | core/fpdfapi/font/cpdf_simplefont.cpp | 6 | ||||
-rw-r--r-- | core/fpdfapi/font/cpdf_simplefont.h | 4 | ||||
-rw-r--r-- | core/fpdfapi/font/cpdf_tounicodemap.cpp | 47 | ||||
-rw-r--r-- | core/fpdfapi/font/cpdf_tounicodemap.h | 6 | ||||
-rw-r--r-- | core/fpdfapi/font/cpdf_tounicodemap_unittest.cpp | 2 | ||||
-rw-r--r-- | core/fpdfapi/font/cpdf_truetypefont.cpp | 2 |
18 files changed, 98 insertions, 99 deletions
diff --git a/core/fpdfapi/font/cpdf_cidfont.cpp b/core/fpdfapi/font/cpdf_cidfont.cpp index a67abd29ac..9b326f5c4f 100644 --- a/core/fpdfapi/font/cpdf_cidfont.cpp +++ b/core/fpdfapi/font/cpdf_cidfont.cpp @@ -239,12 +239,12 @@ bool CPDF_CIDFont::IsVertWriting() const { return m_pCMap && m_pCMap->IsVertWriting(); } -CFX_WideString CPDF_CIDFont::UnicodeFromCharCode(uint32_t charcode) const { - CFX_WideString str = CPDF_Font::UnicodeFromCharCode(charcode); +WideString CPDF_CIDFont::UnicodeFromCharCode(uint32_t charcode) const { + WideString str = CPDF_Font::UnicodeFromCharCode(charcode); if (!str.IsEmpty()) return str; wchar_t ret = GetUnicodeFromCharCode(charcode); - return ret ? ret : CFX_WideString(); + return ret ? ret : WideString(); } wchar_t CPDF_CIDFont::GetUnicodeFromCharCode(uint32_t charcode) const { @@ -356,12 +356,12 @@ bool CPDF_CIDFont::Load() { if (!pEncoding) return false; - CFX_ByteString subtype = pCIDFontDict->GetStringFor("Subtype"); + ByteString subtype = pCIDFontDict->GetStringFor("Subtype"); m_bType1 = (subtype == "CIDFontType0"); CPDF_CMapManager& manager = GetFontGlobals()->m_CMapManager; if (pEncoding->IsName()) { - CFX_ByteString cmap = pEncoding->GetString(); + ByteString cmap = pEncoding->GetString(); bool bPromptCJK = m_pFontFile && m_bType1; m_pCMap = manager.GetPredefinedCMap(cmap, bPromptCJK); if (!m_pCMap) @@ -380,7 +380,7 @@ bool CPDF_CIDFont::Load() { CPDF_Dictionary* pCIDInfo = pCIDFontDict->GetDictFor("CIDSystemInfo"); if (pCIDInfo) { m_Charset = CPDF_CMapParser::CharsetFromOrdering( - pCIDInfo->GetStringFor("Ordering").AsStringC()); + pCIDInfo->GetStringFor("Ordering").AsStringView()); } } if (m_Charset != CIDSET_UNKNOWN) { @@ -621,7 +621,7 @@ int CPDF_CIDFont::GlyphFromCharCode(uint32_t charcode, bool* pVertGlyph) { if (m_Flags & FXFONT_SYMBOLIC) return cid; - CFX_WideString uni_str = UnicodeFromCharCode(charcode); + WideString uni_str = UnicodeFromCharCode(charcode); if (uni_str.IsEmpty()) return cid; @@ -633,7 +633,7 @@ int CPDF_CIDFont::GlyphFromCharCode(uint32_t charcode, bool* pVertGlyph) { if (unicode == 0) unicode = GetUnicodeFromCharCode(charcode); if (unicode == 0) { - CFX_WideString unicode_str = UnicodeFromCharCode(charcode); + WideString unicode_str = UnicodeFromCharCode(charcode); if (!unicode_str.IsEmpty()) unicode = unicode_str[0]; } @@ -651,8 +651,8 @@ int CPDF_CIDFont::GlyphFromCharCode(uint32_t charcode, bool* pVertGlyph) { iBaseEncoding = PDFFONT_ENCODING_WINANSI; else if (bMacRoman) iBaseEncoding = PDFFONT_ENCODING_MACROMAN; - const char* name = GetAdobeCharName( - iBaseEncoding, std::vector<CFX_ByteString>(), charcode); + const char* name = + GetAdobeCharName(iBaseEncoding, std::vector<ByteString>(), charcode); if (!name) return charcode ? static_cast<int>(charcode) : -1; @@ -729,7 +729,7 @@ int CPDF_CIDFont::GlyphFromCharCode(uint32_t charcode, bool* pVertGlyph) { } if (FXFT_Get_Charmap_Encoding(FXFT_Get_Face_Charmap(m_Font.GetFace())) == FXFT_ENCODING_UNICODE) { - CFX_WideString unicode_str = UnicodeFromCharCode(charcode); + WideString unicode_str = UnicodeFromCharCode(charcode); if (unicode_str.IsEmpty()) return -1; diff --git a/core/fpdfapi/font/cpdf_cidfont.h b/core/fpdfapi/font/cpdf_cidfont.h index 07982a418f..f4ddcfd577 100644 --- a/core/fpdfapi/font/cpdf_cidfont.h +++ b/core/fpdfapi/font/cpdf_cidfont.h @@ -54,7 +54,7 @@ class CPDF_CIDFont : public CPDF_Font { bool IsVertWriting() const override; bool IsUnicodeCompatible() const override; bool Load() override; - CFX_WideString UnicodeFromCharCode(uint32_t charcode) const override; + WideString UnicodeFromCharCode(uint32_t charcode) const override; uint32_t CharCodeFromUnicode(wchar_t Unicode) const override; uint16_t CIDFromCharCode(uint32_t charcode) const; diff --git a/core/fpdfapi/font/cpdf_cmap.cpp b/core/fpdfapi/font/cpdf_cmap.cpp index 0d3745e44a..54f7b34ca0 100644 --- a/core/fpdfapi/font/cpdf_cmap.cpp +++ b/core/fpdfapi/font/cpdf_cmap.cpp @@ -248,7 +248,7 @@ CPDF_CMap::CPDF_CMap() CPDF_CMap::~CPDF_CMap() {} void CPDF_CMap::LoadPredefined(CPDF_CMapManager* pMgr, - const CFX_ByteString& bsName, + const ByteString& bsName, bool bPromptCJK) { m_PredefinedCMap = bsName; if (m_PredefinedCMap == "Identity-H" || m_PredefinedCMap == "Identity-V") { @@ -257,14 +257,14 @@ void CPDF_CMap::LoadPredefined(CPDF_CMapManager* pMgr, m_bLoaded = true; return; } - CFX_ByteString cmapid = m_PredefinedCMap; + ByteString cmapid = m_PredefinedCMap; m_bVertical = cmapid.Last() == 'V'; if (cmapid.GetLength() > 2) { cmapid = cmapid.Left(cmapid.GetLength() - 2); } const PredefinedCMap* map = nullptr; for (size_t i = 0; i < FX_ArraySize(g_PredefinedCMaps); ++i) { - if (cmapid == CFX_ByteStringC(g_PredefinedCMaps[i].m_pName)) { + if (cmapid == ByteStringView(g_PredefinedCMaps[i].m_pName)) { map = &g_PredefinedCMaps[i]; break; } @@ -295,7 +295,7 @@ void CPDF_CMap::LoadEmbedded(const uint8_t* pData, uint32_t size) { CPDF_CMapParser parser(this); CPDF_SimpleParser syntax(pData, size); while (1) { - CFX_ByteStringC word = syntax.GetWord(); + ByteStringView word = syntax.GetWord(); if (word.IsEmpty()) { break; } diff --git a/core/fpdfapi/font/cpdf_cmap.h b/core/fpdfapi/font/cpdf_cmap.h index f4d6ca9113..3e23d03a01 100644 --- a/core/fpdfapi/font/cpdf_cmap.h +++ b/core/fpdfapi/font/cpdf_cmap.h @@ -51,7 +51,7 @@ class CPDF_CMap : public CFX_Retainable { friend CFX_RetainPtr<T> pdfium::MakeRetain(Args&&... args); void LoadPredefined(CPDF_CMapManager* pMgr, - const CFX_ByteString& name, + const ByteString& name, bool bPromptCJK); void LoadEmbedded(const uint8_t* pData, uint32_t dwSize); @@ -70,7 +70,7 @@ class CPDF_CMap : public CFX_Retainable { CPDF_CMap(); ~CPDF_CMap() override; - CFX_ByteString m_PredefinedCMap; + ByteString m_PredefinedCMap; bool m_bLoaded; bool m_bVertical; CIDSet m_Charset; diff --git a/core/fpdfapi/font/cpdf_cmapmanager.cpp b/core/fpdfapi/font/cpdf_cmapmanager.cpp index 040af5556a..a449db6a45 100644 --- a/core/fpdfapi/font/cpdf_cmapmanager.cpp +++ b/core/fpdfapi/font/cpdf_cmapmanager.cpp @@ -17,7 +17,7 @@ CPDF_CMapManager::CPDF_CMapManager() {} CPDF_CMapManager::~CPDF_CMapManager() {} CFX_RetainPtr<CPDF_CMap> CPDF_CMapManager::GetPredefinedCMap( - const CFX_ByteString& name, + const ByteString& name, bool bPromptCJK) { auto it = m_CMaps.find(name); if (it != m_CMaps.end()) @@ -31,7 +31,7 @@ CFX_RetainPtr<CPDF_CMap> CPDF_CMapManager::GetPredefinedCMap( } CFX_RetainPtr<CPDF_CMap> CPDF_CMapManager::LoadPredefinedCMap( - const CFX_ByteString& name, + const ByteString& name, bool bPromptCJK) { const char* pname = name.c_str(); if (*pname == '/') diff --git a/core/fpdfapi/font/cpdf_cmapmanager.h b/core/fpdfapi/font/cpdf_cmapmanager.h index 1bc1c6f839..6a860e6859 100644 --- a/core/fpdfapi/font/cpdf_cmapmanager.h +++ b/core/fpdfapi/font/cpdf_cmapmanager.h @@ -11,7 +11,7 @@ #include <memory> #include "core/fpdfapi/font/cpdf_cidfont.h" -#include "core/fxcrt/cfx_bytestring.h" +#include "core/fxcrt/bytestring.h" #include "core/fxcrt/cfx_retain_ptr.h" class CPDF_CMapManager { @@ -19,17 +19,17 @@ class CPDF_CMapManager { CPDF_CMapManager(); ~CPDF_CMapManager(); - CFX_RetainPtr<CPDF_CMap> GetPredefinedCMap(const CFX_ByteString& name, + CFX_RetainPtr<CPDF_CMap> GetPredefinedCMap(const ByteString& name, bool bPromptCJK); CPDF_CID2UnicodeMap* GetCID2UnicodeMap(CIDSet charset, bool bPromptCJK); private: - CFX_RetainPtr<CPDF_CMap> LoadPredefinedCMap(const CFX_ByteString& name, + CFX_RetainPtr<CPDF_CMap> LoadPredefinedCMap(const ByteString& name, bool bPromptCJK); std::unique_ptr<CPDF_CID2UnicodeMap> LoadCID2UnicodeMap(CIDSet charset, bool bPromptCJK); - std::map<CFX_ByteString, CFX_RetainPtr<CPDF_CMap>> m_CMaps; + std::map<ByteString, CFX_RetainPtr<CPDF_CMap>> m_CMaps; std::unique_ptr<CPDF_CID2UnicodeMap> m_CID2UnicodeMaps[6]; }; diff --git a/core/fpdfapi/font/cpdf_cmapparser.cpp b/core/fpdfapi/font/cpdf_cmapparser.cpp index 101ae5f0c8..f7d4dc1c33 100644 --- a/core/fpdfapi/font/cpdf_cmapparser.cpp +++ b/core/fpdfapi/font/cpdf_cmapparser.cpp @@ -32,9 +32,9 @@ CIDSet CIDSetFromSizeT(size_t index) { return static_cast<CIDSet>(index); } -CFX_ByteStringC CMap_GetString(const CFX_ByteStringC& word) { +ByteStringView CMap_GetString(const ByteStringView& word) { if (word.GetLength() <= 2) - return CFX_ByteStringC(); + return ByteStringView(); return word.Right(word.GetLength() - 2); } @@ -45,7 +45,7 @@ CPDF_CMapParser::CPDF_CMapParser(CPDF_CMap* pCMap) CPDF_CMapParser::~CPDF_CMapParser() {} -void CPDF_CMapParser::ParseWord(const CFX_ByteStringC& word) { +void CPDF_CMapParser::ParseWord(const ByteStringView& word) { if (word.IsEmpty()) { return; } @@ -126,7 +126,7 @@ void CPDF_CMapParser::ParseWord(const CFX_ByteStringC& word) { } if (m_CodeSeq % 2) { CPDF_CMap::CodeRange range; - if (CMap_GetCodeRange(range, m_LastWord.AsStringC(), word)) + if (CMap_GetCodeRange(range, m_LastWord.AsStringView(), word)) m_CodeRanges.push_back(range); } m_CodeSeq++; @@ -136,7 +136,7 @@ void CPDF_CMapParser::ParseWord(const CFX_ByteStringC& word) { } // Static. -uint32_t CPDF_CMapParser::CMap_GetCode(const CFX_ByteStringC& word) { +uint32_t CPDF_CMapParser::CMap_GetCode(const ByteStringView& word) { if (word.IsEmpty()) return 0; pdfium::base::CheckedNumeric<uint32_t> num = 0; @@ -160,8 +160,8 @@ uint32_t CPDF_CMapParser::CMap_GetCode(const CFX_ByteStringC& word) { // Static. bool CPDF_CMapParser::CMap_GetCodeRange(CPDF_CMap::CodeRange& range, - const CFX_ByteStringC& first, - const CFX_ByteStringC& second) { + const ByteStringView& first, + const ByteStringView& second) { if (first.GetLength() == 0 || first[0] != '<') return false; @@ -193,7 +193,7 @@ bool CPDF_CMapParser::CMap_GetCodeRange(CPDF_CMap::CodeRange& range, } // static -CIDSet CPDF_CMapParser::CharsetFromOrdering(const CFX_ByteStringC& ordering) { +CIDSet CPDF_CMapParser::CharsetFromOrdering(const ByteStringView& ordering) { for (size_t charset = 1; charset < FX_ArraySize(g_CharsetNames); ++charset) { if (ordering == g_CharsetNames[charset]) return CIDSetFromSizeT(charset); diff --git a/core/fpdfapi/font/cpdf_cmapparser.h b/core/fpdfapi/font/cpdf_cmapparser.h index b0a0ced30f..b3c8326b98 100644 --- a/core/fpdfapi/font/cpdf_cmapparser.h +++ b/core/fpdfapi/font/cpdf_cmapparser.h @@ -20,7 +20,7 @@ class CPDF_CMapParser { explicit CPDF_CMapParser(CPDF_CMap* pMap); ~CPDF_CMapParser(); - void ParseWord(const CFX_ByteStringC& str); + void ParseWord(const ByteStringView& str); bool HasAdditionalMappings() const { return !m_AdditionalCharcodeToCIDMappings.empty(); } @@ -28,16 +28,16 @@ class CPDF_CMapParser { return std::move(m_AdditionalCharcodeToCIDMappings); } - static CIDSet CharsetFromOrdering(const CFX_ByteStringC& ordering); + static CIDSet CharsetFromOrdering(const ByteStringView& ordering); private: friend class cpdf_cmapparser_CMap_GetCode_Test; friend class cpdf_cmapparser_CMap_GetCodeRange_Test; - static uint32_t CMap_GetCode(const CFX_ByteStringC& word); + static uint32_t CMap_GetCode(const ByteStringView& word); static bool CMap_GetCodeRange(CPDF_CMap::CodeRange& range, - const CFX_ByteStringC& first, - const CFX_ByteStringC& second); + const ByteStringView& first, + const ByteStringView& second); CFX_UnownedPtr<CPDF_CMap> const m_pCMap; int m_Status; @@ -45,7 +45,7 @@ class CPDF_CMapParser { uint32_t m_CodePoints[4]; std::vector<CPDF_CMap::CodeRange> m_CodeRanges; std::vector<CPDF_CMap::CIDRange> m_AdditionalCharcodeToCIDMappings; - CFX_ByteString m_LastWord; + ByteString m_LastWord; }; #endif // CORE_FPDFAPI_FONT_CPDF_CMAPPARSER_H_ diff --git a/core/fpdfapi/font/cpdf_font.cpp b/core/fpdfapi/font/cpdf_font.cpp index 0fd8b45326..9aaaa27b2e 100644 --- a/core/fpdfapi/font/cpdf_font.cpp +++ b/core/fpdfapi/font/cpdf_font.cpp @@ -37,7 +37,7 @@ const uint8_t kChineseFontNames[][5] = {{0xCB, 0xCE, 0xCC, 0xE5, 0x00}, {0xB7, 0xC2, 0xCB, 0xCE, 0x00}, {0xD0, 0xC2, 0xCB, 0xCE, 0x00}}; -void GetPredefinedEncoding(const CFX_ByteString& value, int* basemap) { +void GetPredefinedEncoding(const ByteString& value, int* basemap) { if (value == "WinAnsiEncoding") *basemap = PDFFONT_ENCODING_WINANSI; else if (value == "MacRomanEncoding") @@ -140,17 +140,17 @@ int CPDF_Font::AppendChar(char* buf, uint32_t charcode) const { return 1; } -void CPDF_Font::AppendChar(CFX_ByteString* str, uint32_t charcode) const { +void CPDF_Font::AppendChar(ByteString* str, uint32_t charcode) const { char buf[4]; int len = AppendChar(buf, charcode); - *str += CFX_ByteStringC(buf, len); + *str += ByteStringView(buf, len); } -CFX_WideString CPDF_Font::UnicodeFromCharCode(uint32_t charcode) const { +WideString CPDF_Font::UnicodeFromCharCode(uint32_t charcode) const { if (!m_bToUnicodeLoaded) LoadUnicodeMap(); - return m_pToUnicodeMap ? m_pToUnicodeMap->Lookup(charcode) : CFX_WideString(); + return m_pToUnicodeMap ? m_pToUnicodeMap->Lookup(charcode) : WideString(); } uint32_t CPDF_Font::CharCodeFromUnicode(wchar_t unicode) const { @@ -297,8 +297,8 @@ int CPDF_Font::GetStringWidth(const char* pString, int size) { // static CPDF_Font* CPDF_Font::GetStockFont(CPDF_Document* pDoc, - const CFX_ByteStringC& name) { - CFX_ByteString fontname(name); + const ByteStringView& name) { + ByteString fontname(name); int font_id = PDF_GetStandardFontName(&fontname); if (font_id < 0) return nullptr; @@ -319,12 +319,12 @@ CPDF_Font* CPDF_Font::GetStockFont(CPDF_Document* pDoc, std::unique_ptr<CPDF_Font> CPDF_Font::Create(CPDF_Document* pDoc, CPDF_Dictionary* pFontDict) { - CFX_ByteString type = pFontDict->GetStringFor("Subtype"); + ByteString type = pFontDict->GetStringFor("Subtype"); std::unique_ptr<CPDF_Font> pFont; if (type == "TrueType") { - CFX_ByteString tag = pFontDict->GetStringFor("BaseFont").Left(4); + ByteString tag = pFontDict->GetStringFor("BaseFont").Left(4); for (size_t i = 0; i < FX_ArraySize(kChineseFontNames); ++i) { - if (tag == CFX_ByteString(kChineseFontNames[i], 4)) { + if (tag == ByteString(kChineseFontNames[i], 4)) { CPDF_Dictionary* pFontDesc = pFontDict->GetDictFor("FontDescriptor"); if (!pFontDesc || !pFontDesc->KeyExist("FontFile2")) pFont = pdfium::MakeUnique<CPDF_CIDFont>(); @@ -358,7 +358,7 @@ uint32_t CPDF_Font::GetNextChar(const char* pString, void CPDF_Font::LoadPDFEncoding(CPDF_Object* pEncoding, int& iBaseEncoding, - std::vector<CFX_ByteString>* pCharNames, + std::vector<ByteString>* pCharNames, bool bEmbedded, bool bTrueType) { if (!pEncoding) { @@ -380,7 +380,7 @@ void CPDF_Font::LoadPDFEncoding(CPDF_Object* pEncoding, iBaseEncoding = PDFFONT_ENCODING_ADOBE_SYMBOL; return; } - CFX_ByteString bsEncoding = pEncoding->GetString(); + ByteString bsEncoding = pEncoding->GetString(); if (bsEncoding.Compare("MacExpertEncoding") == 0) { bsEncoding = "WinAnsiEncoding"; } @@ -394,7 +394,7 @@ void CPDF_Font::LoadPDFEncoding(CPDF_Object* pEncoding, if (iBaseEncoding != PDFFONT_ENCODING_ADOBE_SYMBOL && iBaseEncoding != PDFFONT_ENCODING_ZAPFDINGBATS) { - CFX_ByteString bsEncoding = pDict->GetStringFor("BaseEncoding"); + ByteString bsEncoding = pDict->GetStringFor("BaseEncoding"); if (bsEncoding.Compare("MacExpertEncoding") == 0 && bTrueType) { bsEncoding = "WinAnsiEncoding"; } @@ -436,7 +436,7 @@ bool CPDF_Font::IsStandardFont() const { const char* CPDF_Font::GetAdobeCharName( int iBaseEncoding, - const std::vector<CFX_ByteString>& charnames, + const std::vector<ByteString>& charnames, int charcode) { if (charcode < 0 || charcode >= 256) { NOTREACHED(); @@ -466,7 +466,7 @@ int CPDF_Font::FallbackGlyphFromCharcode(int fallbackFont, uint32_t charcode) { if (!pdfium::IndexInBounds(m_FontFallbacks, fallbackFont)) return -1; - CFX_WideString str = UnicodeFromCharCode(charcode); + WideString str = UnicodeFromCharCode(charcode); uint32_t unicode = !str.IsEmpty() ? str[0] : charcode; int glyph = FXFT_Get_Char_Index(m_FontFallbacks[fallbackFont]->GetFace(), unicode); diff --git a/core/fpdfapi/font/cpdf_font.h b/core/fpdfapi/font/cpdf_font.h index f70542223c..e92e2f24e5 100644 --- a/core/fpdfapi/font/cpdf_font.h +++ b/core/fpdfapi/font/cpdf_font.h @@ -32,7 +32,7 @@ class CPDF_Font { static std::unique_ptr<CPDF_Font> Create(CPDF_Document* pDoc, CPDF_Dictionary* pFontDict); static CPDF_Font* GetStockFont(CPDF_Document* pDoc, - const CFX_ByteStringC& fontname); + const ByteStringView& fontname); static const uint32_t kInvalidCharCode = static_cast<uint32_t>(-1); virtual ~CPDF_Font(); @@ -59,17 +59,17 @@ class CPDF_Font { virtual int AppendChar(char* buf, uint32_t charcode) const; virtual int GlyphFromCharCode(uint32_t charcode, bool* pVertGlyph) = 0; virtual int GlyphFromCharCodeExt(uint32_t charcode); - virtual CFX_WideString UnicodeFromCharCode(uint32_t charcode) const; + virtual WideString UnicodeFromCharCode(uint32_t charcode) const; virtual uint32_t CharCodeFromUnicode(wchar_t Unicode) const; virtual bool HasFontWidths() const; - const CFX_ByteString& GetBaseFont() const { return m_BaseFont; } + const ByteString& GetBaseFont() const { return m_BaseFont; } CFX_SubstFont* GetSubstFont() const { return m_Font.GetSubstFont(); } bool IsEmbedded() const { return IsType3Font() || m_pFontFile != nullptr; } CPDF_Dictionary* GetFontDict() const { return m_pFontDict; } bool IsStandardFont() const; FXFT_Face GetFace() const { return m_Font.GetFace(); } - void AppendChar(CFX_ByteString* str, uint32_t charcode) const; + void AppendChar(ByteString* str, uint32_t charcode) const; void GetFontBBox(FX_RECT& rect) const { rect = m_FontBBox; } int GetTypeAscent() const { return m_Ascent; } @@ -97,20 +97,20 @@ class CPDF_Font { void LoadUnicodeMap() const; // logically const only. void LoadPDFEncoding(CPDF_Object* pEncoding, int& iBaseEncoding, - std::vector<CFX_ByteString>* pCharNames, + std::vector<ByteString>* pCharNames, bool bEmbedded, bool bTrueType); void LoadFontDescriptor(CPDF_Dictionary* pDict); void CheckFontMetrics(); const char* GetAdobeCharName(int iBaseEncoding, - const std::vector<CFX_ByteString>& charnames, + const std::vector<ByteString>& charnames, int charcode); CFX_UnownedPtr<CPDF_Document> m_pDocument; CFX_Font m_Font; std::vector<std::unique_ptr<CFX_Font>> m_FontFallbacks; - CFX_ByteString m_BaseFont; + ByteString m_BaseFont; CFX_RetainPtr<CPDF_StreamAcc> m_pFontFile; CPDF_Dictionary* m_pFontDict; mutable std::unique_ptr<CPDF_ToUnicodeMap> m_pToUnicodeMap; diff --git a/core/fpdfapi/font/cpdf_fontencoding.cpp b/core/fpdfapi/font/cpdf_fontencoding.cpp index 2cc6445ab2..6290f20f5e 100644 --- a/core/fpdfapi/font/cpdf_fontencoding.cpp +++ b/core/fpdfapi/font/cpdf_fontencoding.cpp @@ -1672,7 +1672,7 @@ bool CPDF_FontEncoding::IsIdentical(CPDF_FontEncoding* pAnother) const { } std::unique_ptr<CPDF_Object> CPDF_FontEncoding::Realize( - CFX_WeakPtr<CFX_ByteStringPool> pPool) { + CFX_WeakPtr<ByteStringPool> pPool) { int predefined = 0; for (int cs = PDFFONT_ENCODING_WINANSI; cs < PDFFONT_ENCODING_ZAPFDINGBATS; cs++) { @@ -1761,10 +1761,10 @@ wchar_t PDF_UnicodeFromAdobeName(const char* name) { return (wchar_t)(FXFT_unicode_from_adobe_name(name) & 0x7FFFFFFF); } -CFX_ByteString PDF_AdobeNameFromUnicode(wchar_t unicode) { +ByteString PDF_AdobeNameFromUnicode(wchar_t unicode) { char glyph_name[64]; FXFT_adobe_name_from_unicode(glyph_name, unicode); - return CFX_ByteString(glyph_name); + return ByteString(glyph_name); } const char* PDF_CharNameFromPredefinedCharSet(int encoding, uint8_t charcode) { diff --git a/core/fpdfapi/font/cpdf_fontencoding.h b/core/fpdfapi/font/cpdf_fontencoding.h index 7a94db9f0e..075cc04c7c 100644 --- a/core/fpdfapi/font/cpdf_fontencoding.h +++ b/core/fpdfapi/font/cpdf_fontencoding.h @@ -28,7 +28,7 @@ uint32_t FT_CharCodeFromUnicode(int encoding, wchar_t unicode); wchar_t FT_UnicodeFromCharCode(int encoding, uint32_t charcode); wchar_t PDF_UnicodeFromAdobeName(const char* name); -CFX_ByteString PDF_AdobeNameFromUnicode(wchar_t unicode); +ByteString PDF_AdobeNameFromUnicode(wchar_t unicode); const uint16_t* PDF_UnicodesForPredefinedCharSet(int encoding); const char* PDF_CharNameFromPredefinedCharSet(int encoding, uint8_t charcode); @@ -53,7 +53,7 @@ class CPDF_FontEncoding { m_Unicodes[charcode] = unicode; } - std::unique_ptr<CPDF_Object> Realize(CFX_WeakPtr<CFX_ByteStringPool> pPool); + std::unique_ptr<CPDF_Object> Realize(CFX_WeakPtr<ByteStringPool> pPool); public: wchar_t m_Unicodes[256]; diff --git a/core/fpdfapi/font/cpdf_simplefont.cpp b/core/fpdfapi/font/cpdf_simplefont.cpp index 56a4b13cb3..ccf514db07 100644 --- a/core/fpdfapi/font/cpdf_simplefont.cpp +++ b/core/fpdfapi/font/cpdf_simplefont.cpp @@ -196,13 +196,13 @@ bool CPDF_SimpleFont::IsUnicodeCompatible() const { m_BaseEncoding != PDFFONT_ENCODING_ZAPFDINGBATS; } -CFX_WideString CPDF_SimpleFont::UnicodeFromCharCode(uint32_t charcode) const { - CFX_WideString unicode = CPDF_Font::UnicodeFromCharCode(charcode); +WideString CPDF_SimpleFont::UnicodeFromCharCode(uint32_t charcode) const { + WideString unicode = CPDF_Font::UnicodeFromCharCode(charcode); if (!unicode.IsEmpty()) return unicode; wchar_t ret = m_Encoding.UnicodeFromCharCode((uint8_t)charcode); if (ret == 0) - return CFX_WideString(); + return WideString(); return ret; } diff --git a/core/fpdfapi/font/cpdf_simplefont.h b/core/fpdfapi/font/cpdf_simplefont.h index 6a22f46966..5291211b24 100644 --- a/core/fpdfapi/font/cpdf_simplefont.h +++ b/core/fpdfapi/font/cpdf_simplefont.h @@ -24,7 +24,7 @@ class CPDF_SimpleFont : public CPDF_Font { FX_RECT GetCharBBox(uint32_t charcode) override; int GlyphFromCharCode(uint32_t charcode, bool* pVertGlyph) override; bool IsUnicodeCompatible() const override; - CFX_WideString UnicodeFromCharCode(uint32_t charcode) const override; + WideString UnicodeFromCharCode(uint32_t charcode) const override; uint32_t CharCodeFromUnicode(wchar_t Unicode) const override; CPDF_FontEncoding* GetEncoding() { return &m_Encoding; } @@ -41,7 +41,7 @@ class CPDF_SimpleFont : public CPDF_Font { CPDF_FontEncoding m_Encoding; uint16_t m_GlyphIndex[256]; uint16_t m_ExtGID[256]; - std::vector<CFX_ByteString> m_CharNames; + std::vector<ByteString> m_CharNames; int m_BaseEncoding; uint16_t m_CharWidth[256]; FX_RECT m_CharBBox[256]; diff --git a/core/fpdfapi/font/cpdf_tounicodemap.cpp b/core/fpdfapi/font/cpdf_tounicodemap.cpp index 9076f4a737..354f5061c3 100644 --- a/core/fpdfapi/font/cpdf_tounicodemap.cpp +++ b/core/fpdfapi/font/cpdf_tounicodemap.cpp @@ -14,7 +14,7 @@ #include "core/fxcrt/fx_safe_types.h" #include "third_party/base/numerics/safe_conversions.h" -CFX_WideString CPDF_ToUnicodeMap::Lookup(uint32_t charcode) const { +WideString CPDF_ToUnicodeMap::Lookup(uint32_t charcode) const { auto it = m_Map.find(charcode); if (it != m_Map.end()) { uint32_t value = it->second; @@ -25,22 +25,22 @@ CFX_WideString CPDF_ToUnicodeMap::Lookup(uint32_t charcode) const { const wchar_t* buf = m_MultiCharBuf.GetBuffer(); uint32_t buf_len = m_MultiCharBuf.GetLength(); if (!buf || buf_len == 0) { - return CFX_WideString(); + return WideString(); } uint32_t index = value >> 16; if (index >= buf_len) { - return CFX_WideString(); + return WideString(); } uint32_t len = buf[index]; if (index + len < index || index + len >= buf_len) { - return CFX_WideString(); + return WideString(); } - return CFX_WideString(buf + index + 1, len); + return WideString(buf + index + 1, len); } if (m_pBaseMap) { return m_pBaseMap->UnicodeFromCID((uint16_t)charcode); } - return CFX_WideString(); + return WideString(); } uint32_t CPDF_ToUnicodeMap::ReverseLookup(wchar_t unicode) const { @@ -52,7 +52,7 @@ uint32_t CPDF_ToUnicodeMap::ReverseLookup(wchar_t unicode) const { } // Static. -uint32_t CPDF_ToUnicodeMap::StringToCode(const CFX_ByteStringC& str) { +uint32_t CPDF_ToUnicodeMap::StringToCode(const ByteStringView& str) { int len = str.GetLength(); if (len == 0) return 0; @@ -70,8 +70,8 @@ uint32_t CPDF_ToUnicodeMap::StringToCode(const CFX_ByteStringC& str) { return result; } -static CFX_WideString StringDataAdd(CFX_WideString str) { - CFX_WideString ret; +static WideString StringDataAdd(WideString str) { + WideString ret; int len = str.GetLength(); wchar_t value = 1; for (int i = len - 1; i >= 0; --i) { @@ -89,13 +89,12 @@ static CFX_WideString StringDataAdd(CFX_WideString str) { } // Static. -CFX_WideString CPDF_ToUnicodeMap::StringToWideString( - const CFX_ByteStringC& str) { +WideString CPDF_ToUnicodeMap::StringToWideString(const ByteStringView& str) { int len = str.GetLength(); if (len == 0) - return CFX_WideString(); + return WideString(); - CFX_WideString result; + WideString result; if (str[0] == '<') { int byte_pos = 0; wchar_t ch = 0; @@ -129,7 +128,7 @@ void CPDF_ToUnicodeMap::Load(CPDF_Stream* pStream) { pAcc->LoadAllData(false); CPDF_SimpleParser parser(pAcc->GetData(), pAcc->GetSize()); while (1) { - CFX_ByteStringC word = parser.GetWord(); + ByteStringView word = parser.GetWord(); if (word.IsEmpty()) { break; } @@ -141,7 +140,7 @@ void CPDF_ToUnicodeMap::Load(CPDF_Stream* pStream) { } uint32_t srccode = StringToCode(word); word = parser.GetWord(); - CFX_WideString destcode = StringToWideString(word); + WideString destcode = StringToWideString(word); int len = destcode.GetLength(); if (len == 0) { continue; @@ -156,23 +155,23 @@ void CPDF_ToUnicodeMap::Load(CPDF_Stream* pStream) { } } else if (word == "beginbfrange") { while (1) { - CFX_ByteString low, high; + ByteString low, high; low = parser.GetWord(); if (low.IsEmpty() || low == "endbfrange") { break; } high = parser.GetWord(); - uint32_t lowcode = StringToCode(low.AsStringC()); + uint32_t lowcode = StringToCode(low.AsStringView()); uint32_t highcode = - (lowcode & 0xffffff00) | (StringToCode(high.AsStringC()) & 0xff); + (lowcode & 0xffffff00) | (StringToCode(high.AsStringView()) & 0xff); if (highcode == (uint32_t)-1) { break; } - CFX_ByteString start(parser.GetWord()); + ByteString start(parser.GetWord()); if (start == "[") { for (uint32_t code = lowcode; code <= highcode; code++) { - CFX_ByteString dest(parser.GetWord()); - CFX_WideString destcode = StringToWideString(dest.AsStringC()); + ByteString dest(parser.GetWord()); + WideString destcode = StringToWideString(dest.AsStringView()); int len = destcode.GetLength(); if (len == 0) { continue; @@ -187,17 +186,17 @@ void CPDF_ToUnicodeMap::Load(CPDF_Stream* pStream) { } parser.GetWord(); } else { - CFX_WideString destcode = StringToWideString(start.AsStringC()); + WideString destcode = StringToWideString(start.AsStringView()); int len = destcode.GetLength(); uint32_t value = 0; if (len == 1) { - value = StringToCode(start.AsStringC()); + value = StringToCode(start.AsStringView()); for (uint32_t code = lowcode; code <= highcode; code++) { m_Map[code] = value++; } } else { for (uint32_t code = lowcode; code <= highcode; code++) { - CFX_WideString retcode; + WideString retcode; if (code == lowcode) { retcode = destcode; } else { diff --git a/core/fpdfapi/font/cpdf_tounicodemap.h b/core/fpdfapi/font/cpdf_tounicodemap.h index 90a2638462..4e11140e75 100644 --- a/core/fpdfapi/font/cpdf_tounicodemap.h +++ b/core/fpdfapi/font/cpdf_tounicodemap.h @@ -22,15 +22,15 @@ class CPDF_ToUnicodeMap { void Load(CPDF_Stream* pStream); - CFX_WideString Lookup(uint32_t charcode) const; + WideString Lookup(uint32_t charcode) const; uint32_t ReverseLookup(wchar_t unicode) const; private: friend class cpdf_tounicodemap_StringToCode_Test; friend class cpdf_tounicodemap_StringToWideString_Test; - static uint32_t StringToCode(const CFX_ByteStringC& str); - static CFX_WideString StringToWideString(const CFX_ByteStringC& str); + static uint32_t StringToCode(const ByteStringView& str); + static WideString StringToWideString(const ByteStringView& str); uint32_t GetUnicode(); diff --git a/core/fpdfapi/font/cpdf_tounicodemap_unittest.cpp b/core/fpdfapi/font/cpdf_tounicodemap_unittest.cpp index 299f4d9b1e..4a5dc25a4c 100644 --- a/core/fpdfapi/font/cpdf_tounicodemap_unittest.cpp +++ b/core/fpdfapi/font/cpdf_tounicodemap_unittest.cpp @@ -21,7 +21,7 @@ TEST(cpdf_tounicodemap, StringToWideString) { EXPECT_EQ(L"", CPDF_ToUnicodeMap::StringToWideString("<c2")); - CFX_WideString res = L"\xc2ab"; + WideString res = L"\xc2ab"; EXPECT_EQ(res, CPDF_ToUnicodeMap::StringToWideString("<c2ab")); EXPECT_EQ(res, CPDF_ToUnicodeMap::StringToWideString("<c2abab")); EXPECT_EQ(res, CPDF_ToUnicodeMap::StringToWideString("<c2ab 1234")); diff --git a/core/fpdfapi/font/cpdf_truetypefont.cpp b/core/fpdfapi/font/cpdf_truetypefont.cpp index 5fde64693a..a0542ecba4 100644 --- a/core/fpdfapi/font/cpdf_truetypefont.cpp +++ b/core/fpdfapi/font/cpdf_truetypefont.cpp @@ -137,7 +137,7 @@ void CPDF_TrueTypeFont::LoadGlyphMap() { if (m_GlyphIndex[charcode] != 0 || !bToUnicode) continue; - CFX_WideString wsUnicode = UnicodeFromCharCode(charcode); + WideString wsUnicode = UnicodeFromCharCode(charcode); if (!wsUnicode.IsEmpty()) { m_GlyphIndex[charcode] = FXFT_Get_Char_Index(m_Font.GetFace(), wsUnicode[0]); |