Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(898)

Side by Side Diff: core/fpdfapi/fpdf_font/fpdf_font_cid.cpp

Issue 2340513002: Remove more strcmp/memcmp usage. (Closed)
Patch Set: Nit Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « core/fpdfapi/fpdf_font/font_int.h ('k') | fpdfsdk/fpdfppo.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 PDFium Authors. All rights reserved. 1 // Copyright 2014 PDFium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6 6
7 #include "core/fpdfapi/fpdf_font/font_int.h" 7 #include "core/fpdfapi/fpdf_font/font_int.h"
8 8
9 #include "core/fpdfapi/fpdf_cmaps/cmap_int.h" 9 #include "core/fpdfapi/fpdf_cmaps/cmap_int.h"
10 #include "core/fpdfapi/fpdf_font/ttgsubtable.h" 10 #include "core/fpdfapi/fpdf_font/ttgsubtable.h"
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after
308 CPDF_CMap* pCMap = new CPDF_CMap; 308 CPDF_CMap* pCMap = new CPDF_CMap;
309 const FX_CHAR* pname = name.c_str(); 309 const FX_CHAR* pname = name.c_str();
310 if (*pname == '/') { 310 if (*pname == '/') {
311 pname++; 311 pname++;
312 } 312 }
313 pCMap->LoadPredefined(this, pname, bPromptCJK); 313 pCMap->LoadPredefined(this, pname, bPromptCJK);
314 return pCMap; 314 return pCMap;
315 } 315 }
316 316
317 void CPDF_CMapManager::ReloadAll() { 317 void CPDF_CMapManager::ReloadAll() {
318 for (const auto& pair : m_CMaps) { 318 for (const auto& pair : m_CMaps)
319 CPDF_CMap* pCMap = pair.second; 319 pair.second->LoadPredefined(this, pair.first, FALSE);
320 pCMap->LoadPredefined(this, pair.first.c_str(), FALSE); 320
321 }
322 for (size_t i = 0; i < FX_ArraySize(m_CID2UnicodeMaps); ++i) { 321 for (size_t i = 0; i < FX_ArraySize(m_CID2UnicodeMaps); ++i) {
323 if (CPDF_CID2UnicodeMap* pMap = m_CID2UnicodeMaps[i]) { 322 if (CPDF_CID2UnicodeMap* pMap = m_CID2UnicodeMaps[i]) {
324 pMap->Load(this, CIDSetFromSizeT(i), FALSE); 323 pMap->Load(this, CIDSetFromSizeT(i), FALSE);
325 } 324 }
326 } 325 }
327 } 326 }
328 CPDF_CID2UnicodeMap* CPDF_CMapManager::GetCID2UnicodeMap(CIDSet charset, 327 CPDF_CID2UnicodeMap* CPDF_CMapManager::GetCID2UnicodeMap(CIDSet charset,
329 FX_BOOL bPromptCJK) { 328 FX_BOOL bPromptCJK) {
330 if (!m_CID2UnicodeMaps[charset]) 329 if (!m_CID2UnicodeMaps[charset])
331 m_CID2UnicodeMaps[charset] = LoadCID2UnicodeMap(charset, bPromptCJK); 330 m_CID2UnicodeMaps[charset] = LoadCID2UnicodeMap(charset, bPromptCJK);
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
521 520
522 FX_BOOL CPDF_CMap::IsLoaded() const { 521 FX_BOOL CPDF_CMap::IsLoaded() const {
523 return m_bLoaded; 522 return m_bLoaded;
524 } 523 }
525 524
526 FX_BOOL CPDF_CMap::IsVertWriting() const { 525 FX_BOOL CPDF_CMap::IsVertWriting() const {
527 return m_bVertical; 526 return m_bVertical;
528 } 527 }
529 528
530 FX_BOOL CPDF_CMap::LoadPredefined(CPDF_CMapManager* pMgr, 529 FX_BOOL CPDF_CMap::LoadPredefined(CPDF_CMapManager* pMgr,
531 const FX_CHAR* pName, 530 const CFX_ByteString& bsName,
532 FX_BOOL bPromptCJK) { 531 FX_BOOL bPromptCJK) {
533 m_PredefinedCMap = pName; 532 m_PredefinedCMap = bsName;
534 if (m_PredefinedCMap == "Identity-H" || m_PredefinedCMap == "Identity-V") { 533 if (m_PredefinedCMap == "Identity-H" || m_PredefinedCMap == "Identity-V") {
535 m_Coding = CIDCODING_CID; 534 m_Coding = CIDCODING_CID;
536 m_bVertical = pName[9] == 'V'; 535 m_bVertical = bsName[9] == 'V';
537 m_bLoaded = TRUE; 536 m_bLoaded = TRUE;
538 return TRUE; 537 return TRUE;
539 } 538 }
540 CFX_ByteString cmapid = m_PredefinedCMap; 539 CFX_ByteString cmapid = m_PredefinedCMap;
541 m_bVertical = cmapid.Right(1) == "V"; 540 m_bVertical = cmapid.Right(1) == "V";
542 if (cmapid.GetLength() > 2) { 541 if (cmapid.GetLength() > 2) {
543 cmapid = cmapid.Left(cmapid.GetLength() - 2); 542 cmapid = cmapid.Left(cmapid.GetLength() - 2);
544 } 543 }
545 const CPDF_PredefinedCMap* map = nullptr; 544 const CPDF_PredefinedCMap* map = nullptr;
546 for (size_t i = 0; i < FX_ArraySize(g_PredefinedCMaps); ++i) { 545 for (size_t i = 0; i < FX_ArraySize(g_PredefinedCMaps); ++i) {
(...skipping 10 matching lines...) Expand all
557 m_CodingScheme = map->m_CodingScheme; 556 m_CodingScheme = map->m_CodingScheme;
558 if (m_CodingScheme == MixedTwoBytes) { 557 if (m_CodingScheme == MixedTwoBytes) {
559 m_pLeadingBytes = FX_Alloc(uint8_t, 256); 558 m_pLeadingBytes = FX_Alloc(uint8_t, 256);
560 for (uint32_t i = 0; i < map->m_LeadingSegCount; ++i) { 559 for (uint32_t i = 0; i < map->m_LeadingSegCount; ++i) {
561 const uint8_t* segs = map->m_LeadingSegs; 560 const uint8_t* segs = map->m_LeadingSegs;
562 for (int b = segs[i * 2]; b <= segs[i * 2 + 1]; ++b) { 561 for (int b = segs[i * 2]; b <= segs[i * 2 + 1]; ++b) {
563 m_pLeadingBytes[b] = 1; 562 m_pLeadingBytes[b] = 1;
564 } 563 }
565 } 564 }
566 } 565 }
567 FPDFAPI_FindEmbeddedCMap(pName, m_Charset, m_Coding, m_pEmbedMap); 566 FPDFAPI_FindEmbeddedCMap(bsName, m_Charset, m_Coding, m_pEmbedMap);
568 if (m_pEmbedMap) { 567 if (!m_pEmbedMap)
569 m_bLoaded = TRUE; 568 return FALSE;
570 return TRUE; 569
571 } 570 m_bLoaded = TRUE;
572 return FALSE; 571 return TRUE;
573 } 572 }
573
574 FX_BOOL CPDF_CMap::LoadEmbedded(const uint8_t* pData, uint32_t size) { 574 FX_BOOL CPDF_CMap::LoadEmbedded(const uint8_t* pData, uint32_t size) {
575 m_pMapping = FX_Alloc(uint16_t, 65536); 575 m_pMapping = FX_Alloc(uint16_t, 65536);
576 CPDF_CMapParser parser; 576 CPDF_CMapParser parser;
577 parser.Initialize(this); 577 parser.Initialize(this);
578 CPDF_SimpleParser syntax(pData, size); 578 CPDF_SimpleParser syntax(pData, size);
579 while (1) { 579 while (1) {
580 CFX_ByteStringC word = syntax.GetWord(); 580 CFX_ByteStringC word = syntax.GetWord();
581 if (word.IsEmpty()) { 581 if (word.IsEmpty()) {
582 break; 582 break;
583 } 583 }
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
785 m_EmbeddedCount = pFontGlobals->m_EmbeddedToUnicodes[charset].m_Count; 785 m_EmbeddedCount = pFontGlobals->m_EmbeddedToUnicodes[charset].m_Count;
786 } 786 }
787 787
788 CIDSet CharsetFromOrdering(const CFX_ByteStringC& ordering) { 788 CIDSet CharsetFromOrdering(const CFX_ByteStringC& ordering) {
789 for (size_t charset = 1; charset < FX_ArraySize(g_CharsetNames); ++charset) { 789 for (size_t charset = 1; charset < FX_ArraySize(g_CharsetNames); ++charset) {
790 if (ordering == g_CharsetNames[charset]) 790 if (ordering == g_CharsetNames[charset])
791 return CIDSetFromSizeT(charset); 791 return CIDSetFromSizeT(charset);
792 } 792 }
793 return CIDSET_UNKNOWN; 793 return CIDSET_UNKNOWN;
794 } 794 }
OLDNEW
« no previous file with comments | « core/fpdfapi/fpdf_font/font_int.h ('k') | fpdfsdk/fpdfppo.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698