diff options
author | Lei Zhang <thestig@chromium.org> | 2015-12-14 16:58:33 -0800 |
---|---|---|
committer | Lei Zhang <thestig@chromium.org> | 2015-12-14 16:58:33 -0800 |
commit | d983b09c3ae29a97cba8e9ec9c6351545f6087ee (patch) | |
tree | 5641a4bc6eddaa8069904c29c3e3897043411646 /core/src/fpdfapi/fpdf_font | |
parent | f86d3f946e2f1977c7eaea01dcb9d7ecb3064cd1 (diff) | |
download | pdfium-d983b09c3ae29a97cba8e9ec9c6351545f6087ee.tar.xz |
Merge to XFA: Remove FX_BSTRC.
R=tsepez@chromium.org
Review URL: https://codereview.chromium.org/1521563002 .
(cherry picked from commit 1956a174020686f91cd3b34294e91f4560fe45aa)
Review URL: https://codereview.chromium.org/1526823002 .
Diffstat (limited to 'core/src/fpdfapi/fpdf_font')
-rw-r--r-- | core/src/fpdfapi/fpdf_font/fpdf_font.cpp | 154 | ||||
-rw-r--r-- | core/src/fpdfapi/fpdf_font/fpdf_font_cid.cpp | 68 |
2 files changed, 107 insertions, 115 deletions
diff --git a/core/src/fpdfapi/fpdf_font/fpdf_font.cpp b/core/src/fpdfapi/fpdf_font/fpdf_font.cpp index 64d6cdce92..b515d90a7f 100644 --- a/core/src/fpdfapi/fpdf_font/fpdf_font.cpp +++ b/core/src/fpdfapi/fpdf_font/fpdf_font.cpp @@ -141,13 +141,13 @@ FX_BOOL CPDF_Font::IsVertWriting() const { CFX_ByteString CPDF_Font::GetFontTypeName() const { switch (m_FontType) { case PDFFONT_TYPE1: - return FX_BSTRC("Type1"); + return "Type1"; case PDFFONT_TRUETYPE: - return FX_BSTRC("TrueType"); + return "TrueType"; case PDFFONT_TYPE3: - return FX_BSTRC("Type3"); + return "Type3"; case PDFFONT_CIDFONT: - return FX_BSTRC("Type0"); + return "Type0"; } return CFX_ByteString(); } @@ -220,11 +220,11 @@ CFX_ByteString CPDF_Font::EncodeString(const CFX_WideString& str) const { } void CPDF_Font::LoadFontDescriptor(CPDF_Dictionary* pFontDesc) { - m_Flags = pFontDesc->GetInteger(FX_BSTRC("Flags"), PDFFONT_NONSYMBOLIC); + m_Flags = pFontDesc->GetInteger("Flags", PDFFONT_NONSYMBOLIC); int ItalicAngle = 0; FX_BOOL bExistItalicAngle = FALSE; - if (pFontDesc->KeyExist(FX_BSTRC("ItalicAngle"))) { - ItalicAngle = pFontDesc->GetInteger(FX_BSTRC("ItalicAngle")); + if (pFontDesc->KeyExist("ItalicAngle")) { + ItalicAngle = pFontDesc->GetInteger("ItalicAngle"); bExistItalicAngle = TRUE; } if (ItalicAngle < 0) { @@ -232,22 +232,22 @@ void CPDF_Font::LoadFontDescriptor(CPDF_Dictionary* pFontDesc) { m_ItalicAngle = ItalicAngle; } FX_BOOL bExistStemV = FALSE; - if (pFontDesc->KeyExist(FX_BSTRC("StemV"))) { - m_StemV = pFontDesc->GetInteger(FX_BSTRC("StemV")); + if (pFontDesc->KeyExist("StemV")) { + m_StemV = pFontDesc->GetInteger("StemV"); bExistStemV = TRUE; } FX_BOOL bExistAscent = FALSE; - if (pFontDesc->KeyExist(FX_BSTRC("Ascent"))) { - m_Ascent = pFontDesc->GetInteger(FX_BSTRC("Ascent")); + if (pFontDesc->KeyExist("Ascent")) { + m_Ascent = pFontDesc->GetInteger("Ascent"); bExistAscent = TRUE; } FX_BOOL bExistDescent = FALSE; - if (pFontDesc->KeyExist(FX_BSTRC("Descent"))) { - m_Descent = pFontDesc->GetInteger(FX_BSTRC("Descent")); + if (pFontDesc->KeyExist("Descent")) { + m_Descent = pFontDesc->GetInteger("Descent"); bExistDescent = TRUE; } FX_BOOL bExistCapHeight = FALSE; - if (pFontDesc->KeyExist(FX_BSTRC("CapHeight"))) { + if (pFontDesc->KeyExist("CapHeight")) { bExistCapHeight = TRUE; } if (bExistItalicAngle && bExistAscent && bExistCapHeight && bExistDescent && @@ -257,7 +257,7 @@ void CPDF_Font::LoadFontDescriptor(CPDF_Dictionary* pFontDesc) { if (m_Descent > 10) { m_Descent = -m_Descent; } - CPDF_Array* pBBox = pFontDesc->GetArray(FX_BSTRC("FontBBox")); + CPDF_Array* pBBox = pFontDesc->GetArray("FontBBox"); if (pBBox) { m_FontBBox.left = pBBox->GetInteger(0); m_FontBBox.bottom = pBBox->GetInteger(1); @@ -265,11 +265,11 @@ void CPDF_Font::LoadFontDescriptor(CPDF_Dictionary* pFontDesc) { m_FontBBox.top = pBBox->GetInteger(3); } - CPDF_Stream* pFontFile = pFontDesc->GetStream(FX_BSTRC("FontFile")); + CPDF_Stream* pFontFile = pFontDesc->GetStream("FontFile"); if (!pFontFile) - pFontFile = pFontDesc->GetStream(FX_BSTRC("FontFile2")); + pFontFile = pFontDesc->GetStream("FontFile2"); if (!pFontFile) - pFontFile = pFontDesc->GetStream(FX_BSTRC("FontFile3")); + pFontFile = pFontDesc->GetStream("FontFile3"); if (!pFontFile) return; @@ -350,7 +350,7 @@ void CPDF_Font::CheckFontMetrics() { } void CPDF_Font::LoadUnicodeMap() { m_bToUnicodeLoaded = TRUE; - CPDF_Stream* pStream = m_pFontDict->GetStream(FX_BSTRC("ToUnicode")); + CPDF_Stream* pStream = m_pFontDict->GetStream("ToUnicode"); if (pStream == NULL) { return; } @@ -391,10 +391,10 @@ CPDF_Font* CPDF_Font::GetStockFont(CPDF_Document* pDoc, return pFont; } CPDF_Dictionary* pDict = CPDF_Dictionary::Create(); - pDict->SetAtName(FX_BSTRC("Type"), FX_BSTRC("Font")); - pDict->SetAtName(FX_BSTRC("Subtype"), FX_BSTRC("Type1")); - pDict->SetAtName(FX_BSTRC("BaseFont"), fontname); - pDict->SetAtName(FX_BSTRC("Encoding"), FX_BSTRC("WinAnsiEncoding")); + pDict->SetAtName("Type", "Font"); + pDict->SetAtName("Subtype", "Type1"); + pDict->SetAtName("BaseFont", fontname); + pDict->SetAtName("Encoding", "WinAnsiEncoding"); pFont = CPDF_Font::CreateFontF(NULL, pDict); pFontGlobals->Set(pDoc, font_id, pFont); return pFont; @@ -406,15 +406,15 @@ const uint8_t ChineseFontNames[][5] = {{0xCB, 0xCE, 0xCC, 0xE5, 0x00}, {0xD0, 0xC2, 0xCB, 0xCE, 0x00}}; CPDF_Font* CPDF_Font::CreateFontF(CPDF_Document* pDoc, CPDF_Dictionary* pFontDict) { - CFX_ByteString type = pFontDict->GetString(FX_BSTRC("Subtype")); + CFX_ByteString type = pFontDict->GetString("Subtype"); CPDF_Font* pFont; - if (type == FX_BSTRC("TrueType")) { + if (type == "TrueType") { { #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ || \ _FXM_PLATFORM_ == _FXM_PLATFORM_LINUX_ || \ _FXM_PLATFORM_ == _FXM_PLATFORM_ANDROID_ || \ _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ - CFX_ByteString basefont = pFontDict->GetString(FX_BSTRC("BaseFont")); + CFX_ByteString basefont = pFontDict->GetString("BaseFont"); CFX_ByteString tag = basefont.Left(4); int i; int count = sizeof(ChineseFontNames) / sizeof(ChineseFontNames[0]); @@ -424,9 +424,8 @@ CPDF_Font* CPDF_Font::CreateFontF(CPDF_Document* pDoc, } } if (i < count) { - CPDF_Dictionary* pFontDesc = - pFontDict->GetDict(FX_BSTRC("FontDescriptor")); - if (pFontDesc == NULL || !pFontDesc->KeyExist(FX_BSTRC("FontFile2"))) { + CPDF_Dictionary* pFontDesc = pFontDict->GetDict("FontDescriptor"); + if (pFontDesc == NULL || !pFontDesc->KeyExist("FontFile2")) { pFont = new CPDF_CIDFont; pFont->m_pFontDict = pFontDict; pFont->m_pDocument = pDoc; @@ -440,9 +439,9 @@ CPDF_Font* CPDF_Font::CreateFontF(CPDF_Document* pDoc, #endif } pFont = new CPDF_TrueTypeFont; - } else if (type == FX_BSTRC("Type3")) { + } else if (type == "Type3") { pFont = new CPDF_Type3Font; - } else if (type == FX_BSTRC("Type0")) { + } else if (type == "Type0") { pFont = new CPDF_CIDFont; } else { pFont = new CPDF_Type1Font; @@ -459,10 +458,10 @@ FX_BOOL CPDF_Font::Load() { if (m_pFontDict == NULL) { return FALSE; } - CFX_ByteString type = m_pFontDict->GetString(FX_BSTRC("Subtype")); - m_BaseFont = m_pFontDict->GetString(FX_BSTRC("BaseFont")); - if (type == FX_BSTRC("MMType1")) { - type = FX_BSTRC("Type1"); + CFX_ByteString type = m_pFontDict->GetString("Subtype"); + m_BaseFont = m_pFontDict->GetString("BaseFont"); + if (type == "MMType1") { + type = "Type1"; } return _Load(); } @@ -588,10 +587,10 @@ void CPDF_ToUnicodeMap::Load(CPDF_Stream* pStream) { if (word.IsEmpty()) { break; } - if (word == FX_BSTRC("beginbfchar")) { + if (word == "beginbfchar") { while (1) { word = parser.GetWord(); - if (word.IsEmpty() || word == FX_BSTRC("endbfchar")) { + if (word.IsEmpty() || word == "endbfchar") { break; } FX_DWORD srccode = StringToCode(word); @@ -609,11 +608,11 @@ void CPDF_ToUnicodeMap::Load(CPDF_Stream* pStream) { m_MultiCharBuf << destcode; } } - } else if (word == FX_BSTRC("beginbfrange")) { + } else if (word == "beginbfrange") { while (1) { CFX_ByteString low, high; low = parser.GetWord(); - if (low.IsEmpty() || low == FX_BSTRC("endbfrange")) { + if (low.IsEmpty() || low == "endbfrange") { break; } high = parser.GetWord(); @@ -624,7 +623,7 @@ void CPDF_ToUnicodeMap::Load(CPDF_Stream* pStream) { break; } CFX_ByteString start = parser.GetWord(); - if (start == FX_BSTRC("[")) { + if (start == "[") { for (FX_DWORD code = lowcode; code <= highcode; code++) { CFX_ByteString dest = parser.GetWord(); CFX_WideString destcode = StringToWideString(dest); @@ -666,13 +665,13 @@ void CPDF_ToUnicodeMap::Load(CPDF_Stream* pStream) { } } } - } else if (word == FX_BSTRC("/Adobe-Korea1-UCS2")) { + } else if (word == "/Adobe-Korea1-UCS2") { cid_set = CIDSET_KOREA1; - } else if (word == FX_BSTRC("/Adobe-Japan1-UCS2")) { + } else if (word == "/Adobe-Japan1-UCS2") { cid_set = CIDSET_JAPAN1; - } else if (word == FX_BSTRC("/Adobe-CNS1-UCS2")) { + } else if (word == "/Adobe-CNS1-UCS2") { cid_set = CIDSET_CNS1; - } else if (word == FX_BSTRC("/Adobe-GB1-UCS2")) { + } else if (word == "/Adobe-GB1-UCS2") { cid_set = CIDSET_GB1; } } @@ -687,13 +686,13 @@ void CPDF_ToUnicodeMap::Load(CPDF_Stream* pStream) { } static FX_BOOL GetPredefinedEncoding(int& basemap, const CFX_ByteString& value) { - if (value == FX_BSTRC("WinAnsiEncoding")) { + if (value == "WinAnsiEncoding") { basemap = PDFFONT_ENCODING_WINANSI; - } else if (value == FX_BSTRC("MacRomanEncoding")) { + } else if (value == "MacRomanEncoding") { basemap = PDFFONT_ENCODING_MACROMAN; - } else if (value == FX_BSTRC("MacExpertEncoding")) { + } else if (value == "MacExpertEncoding") { basemap = PDFFONT_ENCODING_MACEXPERT; - } else if (value == FX_BSTRC("PDFDocEncoding")) { + } else if (value == "PDFDocEncoding") { basemap = PDFFONT_ENCODING_PDFDOC; } else { return FALSE; @@ -706,7 +705,7 @@ void CPDF_Font::LoadPDFEncoding(CPDF_Object* pEncoding, FX_BOOL bEmbedded, FX_BOOL bTrueType) { if (pEncoding == NULL) { - if (m_BaseFont == FX_BSTRC("Symbol")) { + if (m_BaseFont == "Symbol") { iBaseEncoding = bTrueType ? PDFFONT_ENCODING_MS_SYMBOL : PDFFONT_ENCODING_ADOBE_SYMBOL; } else if (!bEmbedded && iBaseEncoding == PDFFONT_ENCODING_BUILTIN) { @@ -719,15 +718,15 @@ void CPDF_Font::LoadPDFEncoding(CPDF_Object* pEncoding, iBaseEncoding == PDFFONT_ENCODING_ZAPFDINGBATS) { return; } - if ((m_Flags & PDFFONT_SYMBOLIC) && m_BaseFont == FX_BSTRC("Symbol")) { + if ((m_Flags & PDFFONT_SYMBOLIC) && m_BaseFont == "Symbol") { if (!bTrueType) { iBaseEncoding = PDFFONT_ENCODING_ADOBE_SYMBOL; } return; } CFX_ByteString bsEncoding = pEncoding->GetString(); - if (bsEncoding.Compare(FX_BSTRC("MacExpertEncoding")) == 0) { - bsEncoding = FX_BSTRC("WinAnsiEncoding"); + if (bsEncoding.Compare("MacExpertEncoding") == 0) { + bsEncoding = "WinAnsiEncoding"; } GetPredefinedEncoding(iBaseEncoding, bsEncoding); return; @@ -739,16 +738,16 @@ void CPDF_Font::LoadPDFEncoding(CPDF_Object* pEncoding, if (iBaseEncoding != PDFFONT_ENCODING_ADOBE_SYMBOL && iBaseEncoding != PDFFONT_ENCODING_ZAPFDINGBATS) { - CFX_ByteString bsEncoding = pDict->GetString(FX_BSTRC("BaseEncoding")); - if (bsEncoding.Compare(FX_BSTRC("MacExpertEncoding")) == 0 && bTrueType) { - bsEncoding = FX_BSTRC("WinAnsiEncoding"); + CFX_ByteString bsEncoding = pDict->GetString("BaseEncoding"); + if (bsEncoding.Compare("MacExpertEncoding") == 0 && bTrueType) { + bsEncoding = "WinAnsiEncoding"; } GetPredefinedEncoding(iBaseEncoding, bsEncoding); } if ((!bEmbedded || bTrueType) && iBaseEncoding == PDFFONT_ENCODING_BUILTIN) { iBaseEncoding = PDFFONT_ENCODING_STANDARD; } - CPDF_Array* pDiffs = pDict->GetArray(FX_BSTRC("Differences")); + CPDF_Array* pDiffs = pDict->GetArray("Differences"); if (pDiffs == NULL) { return; } @@ -889,23 +888,23 @@ const FX_CHAR* GetAdobeCharName(int iBaseEncoding, return name; } FX_BOOL CPDF_SimpleFont::LoadCommon() { - CPDF_Dictionary* pFontDesc = m_pFontDict->GetDict(FX_BSTRC("FontDescriptor")); + CPDF_Dictionary* pFontDesc = m_pFontDict->GetDict("FontDescriptor"); if (pFontDesc) { LoadFontDescriptor(pFontDesc); } - CPDF_Array* pWidthArray = m_pFontDict->GetArray(FX_BSTRC("Widths")); + CPDF_Array* pWidthArray = m_pFontDict->GetArray("Widths"); int width_start = 0, width_end = -1; m_bUseFontWidth = TRUE; if (pWidthArray) { m_bUseFontWidth = FALSE; - if (pFontDesc && pFontDesc->KeyExist(FX_BSTRC("MissingWidth"))) { - int MissingWidth = pFontDesc->GetInteger(FX_BSTRC("MissingWidth")); + if (pFontDesc && pFontDesc->KeyExist("MissingWidth")) { + int MissingWidth = pFontDesc->GetInteger("MissingWidth"); for (int i = 0; i < 256; i++) { m_CharWidth[i] = MissingWidth; } } - width_start = m_pFontDict->GetInteger(FX_BSTRC("FirstChar"), 0); - width_end = m_pFontDict->GetInteger(FX_BSTRC("LastChar"), 0); + width_start = m_pFontDict->GetInteger("FirstChar", 0); + width_end = m_pFontDict->GetInteger("LastChar", 0); if (width_start >= 0 && width_start <= 255) { if (width_end <= 0 || width_end >= width_start + (int)pWidthArray->GetCount()) { @@ -929,7 +928,7 @@ FX_BOOL CPDF_SimpleFont::LoadCommon() { if (!(m_Flags & PDFFONT_SYMBOLIC)) { m_BaseEncoding = PDFFONT_ENCODING_STANDARD; } - CPDF_Object* pEncoding = m_pFontDict->GetElementValue(FX_BSTRC("Encoding")); + CPDF_Object* pEncoding = m_pFontDict->GetElementValue("Encoding"); LoadPDFEncoding(pEncoding, m_BaseEncoding, m_pCharNames, m_pFontFile != NULL, m_Font.IsTTFont()); LoadGlyphMap(); @@ -990,10 +989,9 @@ CPDF_Type1Font::CPDF_Type1Font() : CPDF_SimpleFont(PDFFONT_TYPE1) { FX_BOOL CPDF_Type1Font::_Load() { m_Base14Font = PDF_GetStandardFontName(&m_BaseFont); if (m_Base14Font >= 0) { - CPDF_Dictionary* pFontDesc = - m_pFontDict->GetDict(FX_BSTRC("FontDescriptor")); - if (pFontDesc && pFontDesc->KeyExist(FX_BSTRC("Flags"))) { - m_Flags = pFontDesc->GetInteger(FX_BSTRC("Flags")); + CPDF_Dictionary* pFontDesc = m_pFontDict->GetDict("FontDescriptor"); + if (pFontDesc && pFontDesc->KeyExist("Flags")) { + m_Flags = pFontDesc->GetInteger("Flags"); } else { m_Flags = m_Base14Font >= 12 ? PDFFONT_SYMBOLIC : PDFFONT_NONSYMBOLIC; } @@ -1407,7 +1405,7 @@ CPDF_Object* CPDF_FontEncoding::Realize() { return NULL; } CPDF_Dictionary* pDict = CPDF_Dictionary::Create(); - pDict->SetAtName(FX_BSTRC("BaseEncoding"), FX_BSTRC("WinAnsiEncoding")); + pDict->SetAtName("BaseEncoding", "WinAnsiEncoding"); const FX_WORD* pStandard = PDF_UnicodesForPredefinedCharSet(PDFFONT_ENCODING_WINANSI); CPDF_Array* pDiff = CPDF_Array::Create(); @@ -1418,7 +1416,7 @@ CPDF_Object* CPDF_FontEncoding::Realize() { pDiff->Add(CPDF_Number::Create(i)); pDiff->Add(CPDF_Name::Create(PDF_AdobeNameFromUnicode(m_Unicodes[i]))); } - pDict->SetAt(FX_BSTRC("Differences"), pDiff); + pDict->SetAt("Differences", pDiff); return pDict; } CPDF_TrueTypeFont::CPDF_TrueTypeFont() : CPDF_SimpleFont(PDFFONT_TRUETYPE) {} @@ -1459,7 +1457,7 @@ void CPDF_TrueTypeFont::LoadGlyphMap() { (m_Flags & PDFFONT_NONSYMBOLIC)) { if (!FXFT_Has_Glyph_Names(m_Font.GetFace()) && (!m_Font.GetFace()->num_charmaps || !m_Font.GetFace()->charmaps)) { - int nStartChar = m_pFontDict->GetInteger(FX_BSTRC("FirstChar")); + int nStartChar = m_pFontDict->GetInteger("FirstChar"); if (nStartChar < 0 || nStartChar > 255) return; @@ -1484,7 +1482,7 @@ void CPDF_TrueTypeFont::LoadGlyphMap() { bMacRoman = !bMSSymbol && FT_UseTTCharmap(m_Font.GetFace(), 1, 0); } } - FX_BOOL bToUnicode = m_pFontDict->KeyExist(FX_BSTRC("ToUnicode")); + FX_BOOL bToUnicode = m_pFontDict->KeyExist("ToUnicode"); for (int charcode = 0; charcode < 256; charcode++) { const FX_CHAR* name = GetAdobeCharName(baseEncoding, m_pCharNames, charcode); @@ -1635,15 +1633,15 @@ CPDF_Type3Font::~CPDF_Type3Font() { } FX_BOOL CPDF_Type3Font::_Load() { - m_pFontResources = m_pFontDict->GetDict(FX_BSTRC("Resources")); - CPDF_Array* pMatrix = m_pFontDict->GetArray(FX_BSTRC("FontMatrix")); + m_pFontResources = m_pFontDict->GetDict("Resources"); + CPDF_Array* pMatrix = m_pFontDict->GetArray("FontMatrix"); FX_FLOAT xscale = 1.0f, yscale = 1.0f; if (pMatrix) { m_FontMatrix = pMatrix->GetMatrix(); xscale = m_FontMatrix.a; yscale = m_FontMatrix.d; } - CPDF_Array* pBBox = m_pFontDict->GetArray(FX_BSTRC("FontBBox")); + CPDF_Array* pBBox = m_pFontDict->GetArray("FontBBox"); if (pBBox) { m_FontBBox.left = (int32_t)(FXSYS_Mul(pBBox->GetNumber(0), xscale) * 1000); m_FontBBox.bottom = @@ -1651,8 +1649,8 @@ FX_BOOL CPDF_Type3Font::_Load() { m_FontBBox.right = (int32_t)(FXSYS_Mul(pBBox->GetNumber(2), xscale) * 1000); m_FontBBox.top = (int32_t)(FXSYS_Mul(pBBox->GetNumber(3), yscale) * 1000); } - int StartChar = m_pFontDict->GetInteger(FX_BSTRC("FirstChar")); - CPDF_Array* pWidthArray = m_pFontDict->GetArray(FX_BSTRC("Widths")); + int StartChar = m_pFontDict->GetInteger("FirstChar"); + CPDF_Array* pWidthArray = m_pFontDict->GetArray("Widths"); if (pWidthArray && (StartChar >= 0 && StartChar < 256)) { FX_DWORD count = pWidthArray->GetCount(); if (count > 256) { @@ -1666,8 +1664,8 @@ FX_BOOL CPDF_Type3Font::_Load() { FXSYS_round(FXSYS_Mul(pWidthArray->GetNumber(i), xscale) * 1000); } } - m_pCharProcs = m_pFontDict->GetDict(FX_BSTRC("CharProcs")); - CPDF_Object* pEncoding = m_pFontDict->GetElementValue(FX_BSTRC("Encoding")); + m_pCharProcs = m_pFontDict->GetDict("CharProcs"); + CPDF_Object* pEncoding = m_pFontDict->GetElementValue("Encoding"); if (pEncoding) { LoadPDFEncoding(pEncoding, m_BaseEncoding, m_pCharNames, FALSE, FALSE); if (m_pCharNames) { diff --git a/core/src/fpdfapi/fpdf_font/fpdf_font_cid.cpp b/core/src/fpdfapi/fpdf_font/fpdf_font_cid.cpp index 1434c9d336..89004fee55 100644 --- a/core/src/fpdfapi/fpdf_font/fpdf_font_cid.cpp +++ b/core/src/fpdfapi/fpdf_font/fpdf_font_cid.cpp @@ -605,27 +605,26 @@ void CPDF_CMapParser::ParseWord(const CFX_ByteStringC& word) { if (word.IsEmpty()) { return; } - if (word == FX_BSTRC("begincidchar")) { + if (word == "begincidchar") { m_Status = 1; m_CodeSeq = 0; - } else if (word == FX_BSTRC("begincidrange")) { + } else if (word == "begincidrange") { m_Status = 2; m_CodeSeq = 0; - } else if (word == FX_BSTRC("endcidrange") || - word == FX_BSTRC("endcidchar")) { + } else if (word == "endcidrange" || word == "endcidchar") { m_Status = 0; - } else if (word == FX_BSTRC("/WMode")) { + } else if (word == "/WMode") { m_Status = 6; - } else if (word == FX_BSTRC("/Registry")) { + } else if (word == "/Registry") { m_Status = 3; - } else if (word == FX_BSTRC("/Ordering")) { + } else if (word == "/Ordering") { m_Status = 4; - } else if (word == FX_BSTRC("/Supplement")) { + } else if (word == "/Supplement") { m_Status = 5; - } else if (word == FX_BSTRC("begincodespacerange")) { + } else if (word == "begincodespacerange") { m_Status = 7; m_CodeSeq = 0; - } else if (word == FX_BSTRC("usecmap")) { + } else if (word == "usecmap") { } else if (m_Status == 1 || m_Status == 2) { m_CodePoints[m_CodeSeq] = CMap_GetCode(word); m_CodeSeq++; @@ -669,7 +668,7 @@ void CPDF_CMapParser::ParseWord(const CFX_ByteStringC& word) { m_pCMap->m_bVertical = CMap_GetCode(word); m_Status = 0; } else if (m_Status == 7) { - if (word == FX_BSTRC("endcodespacerange")) { + if (word == "endcodespacerange") { int nSegs = m_CodeRanges.GetSize(); if (nSegs > 1) { m_pCMap->m_CodingScheme = CPDF_CMap::MixedFourBytes; @@ -779,15 +778,14 @@ FX_BOOL CPDF_CMap::LoadPredefined(CPDF_CMapManager* pMgr, const FX_CHAR* pName, FX_BOOL bPromptCJK) { m_PredefinedCMap = pName; - if (m_PredefinedCMap == FX_BSTRC("Identity-H") || - m_PredefinedCMap == FX_BSTRC("Identity-V")) { + if (m_PredefinedCMap == "Identity-H" || m_PredefinedCMap == "Identity-V") { m_Coding = CIDCODING_CID; m_bVertical = pName[9] == 'V'; m_bLoaded = TRUE; return TRUE; } CFX_ByteString cmapid = m_PredefinedCMap; - m_bVertical = cmapid.Right(1) == FX_BSTRC("V"); + m_bVertical = cmapid.Right(1) == "V"; if (cmapid.GetLength() > 2) { cmapid = cmapid.Left(cmapid.GetLength() - 2); } @@ -1155,10 +1153,10 @@ FX_DWORD CPDF_CIDFont::_CharCodeFromUnicode(FX_WCHAR unicode) const { } FX_BOOL CPDF_CIDFont::_Load() { - if (m_pFontDict->GetString(FX_BSTRC("Subtype")) == FX_BSTRC("TrueType")) { + if (m_pFontDict->GetString("Subtype") == "TrueType") { return LoadGB2312(); } - CPDF_Array* pFonts = m_pFontDict->GetArray(FX_BSTRC("DescendantFonts")); + CPDF_Array* pFonts = m_pFontDict->GetArray("DescendantFonts"); if (pFonts == NULL) { return FALSE; } @@ -1169,7 +1167,7 @@ FX_BOOL CPDF_CIDFont::_Load() { if (pCIDFontDict == NULL) { return FALSE; } - m_BaseFont = pCIDFontDict->GetString(FX_BSTRC("BaseFont")); + m_BaseFont = pCIDFontDict->GetString("BaseFont"); if ((m_BaseFont.Compare("CourierStd") == 0 || m_BaseFont.Compare("CourierStd-Bold") == 0 || m_BaseFont.Compare("CourierStd-BoldOblique") == 0 || @@ -1177,17 +1175,16 @@ FX_BOOL CPDF_CIDFont::_Load() { !IsEmbedded()) { m_bAdobeCourierStd = TRUE; } - CPDF_Dictionary* pFontDesc = - pCIDFontDict->GetDict(FX_BSTRC("FontDescriptor")); + CPDF_Dictionary* pFontDesc = pCIDFontDict->GetDict("FontDescriptor"); if (pFontDesc) { LoadFontDescriptor(pFontDesc); } - CPDF_Object* pEncoding = m_pFontDict->GetElementValue(FX_BSTRC("Encoding")); + CPDF_Object* pEncoding = m_pFontDict->GetElementValue("Encoding"); if (pEncoding == NULL) { return FALSE; } - CFX_ByteString subtype = pCIDFontDict->GetString(FX_BSTRC("Subtype")); - m_bType1 = (subtype == FX_BSTRC("CIDFontType0")); + CFX_ByteString subtype = pCIDFontDict->GetString("Subtype"); + m_bType1 = (subtype == "CIDFontType0"); if (pEncoding->IsName()) { CFX_ByteString cmap = pEncoding->GetString(); @@ -1209,11 +1206,9 @@ FX_BOOL CPDF_CIDFont::_Load() { } m_Charset = m_pCMap->m_Charset; if (m_Charset == CIDSET_UNKNOWN) { - CPDF_Dictionary* pCIDInfo = - pCIDFontDict->GetDict(FX_BSTRC("CIDSystemInfo")); + CPDF_Dictionary* pCIDInfo = pCIDFontDict->GetDict("CIDSystemInfo"); if (pCIDInfo) { - m_Charset = - CharsetFromOrdering(pCIDInfo->GetString(FX_BSTRC("Ordering"))); + m_Charset = CharsetFromOrdering(pCIDInfo->GetString("Ordering")); } } if (m_Charset != CIDSET_UNKNOWN) @@ -1224,7 +1219,7 @@ FX_BOOL CPDF_CIDFont::_Load() { ->m_CMapManager.GetCID2UnicodeMap( m_Charset, m_pFontFile == NULL && (m_pCMap->m_Coding == CIDCODING_CID || - pCIDFontDict->KeyExist(FX_BSTRC("W")))); + pCIDFontDict->KeyExist("W"))); if (m_Font.GetFace()) { if (m_bType1) { FXFT_Select_Charmap(m_Font.GetFace(), FXFT_ENCODING_UNICODE); @@ -1232,8 +1227,8 @@ FX_BOOL CPDF_CIDFont::_Load() { FT_UseCIDCharmap(m_Font.GetFace(), m_pCMap->m_Coding); } } - m_DefaultWidth = pCIDFontDict->GetInteger(FX_BSTRC("DW"), 1000); - CPDF_Array* pWidthArray = pCIDFontDict->GetArray(FX_BSTRC("W")); + m_DefaultWidth = pCIDFontDict->GetInteger("DW", 1000); + CPDF_Array* pWidthArray = pCIDFontDict->GetArray("W"); if (pWidthArray) { LoadMetricsArray(pWidthArray, m_WidthList, 1); } @@ -1242,13 +1237,12 @@ FX_BOOL CPDF_CIDFont::_Load() { } if (1) { if (m_pFontFile || (GetSubstFont()->m_SubstFlags & FXFONT_SUBST_EXACT)) { - CPDF_Object* pmap = - pCIDFontDict->GetElementValue(FX_BSTRC("CIDToGIDMap")); + CPDF_Object* pmap = pCIDFontDict->GetElementValue("CIDToGIDMap"); if (pmap) { if (CPDF_Stream* pStream = pmap->AsStream()) { m_pCIDToGIDMap = new CPDF_StreamAcc; m_pCIDToGIDMap->LoadAllData(pStream, FALSE); - } else if (pmap->GetString() == FX_BSTRC("Identity")) { + } else if (pmap->GetString() == "Identity") { #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ if (m_pFontFile) { m_bCIDIsGID = TRUE; @@ -1262,11 +1256,11 @@ FX_BOOL CPDF_CIDFont::_Load() { } CheckFontMetrics(); if (IsVertWriting()) { - pWidthArray = pCIDFontDict->GetArray(FX_BSTRC("W2")); + pWidthArray = pCIDFontDict->GetArray("W2"); if (pWidthArray) { LoadMetricsArray(pWidthArray, m_VertMetrics, 3); } - CPDF_Array* pDefaultArray = pCIDFontDict->GetArray(FX_BSTRC("DW2")); + CPDF_Array* pDefaultArray = pCIDFontDict->GetArray("DW2"); if (pDefaultArray) { m_DefaultVY = pDefaultArray->GetInteger(0); m_DefaultW1 = pDefaultArray->GetInteger(1); @@ -1693,8 +1687,8 @@ FX_FLOAT CPDF_CIDFont::CIDTransformToFloat(uint8_t ch) { } FX_BOOL CPDF_CIDFont::LoadGB2312() { - m_BaseFont = m_pFontDict->GetString(FX_BSTRC("BaseFont")); - CPDF_Dictionary* pFontDesc = m_pFontDict->GetDict(FX_BSTRC("FontDescriptor")); + m_BaseFont = m_pFontDict->GetString("BaseFont"); + CPDF_Dictionary* pFontDesc = m_pFontDict->GetDict("FontDescriptor"); if (pFontDesc) { LoadFontDescriptor(pFontDesc); } @@ -1703,7 +1697,7 @@ FX_BOOL CPDF_CIDFont::LoadGB2312() { m_pCMap = CPDF_ModuleMgr::Get() ->GetPageModule() ->GetFontGlobals() - ->m_CMapManager.GetPredefinedCMap(FX_BSTRC("GBK-EUC-H"), FALSE); + ->m_CMapManager.GetPredefinedCMap("GBK-EUC-H", FALSE); m_pCID2UnicodeMap = CPDF_ModuleMgr::Get() ->GetPageModule() ->GetFontGlobals() |