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

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

Issue 1171733003: Remove typdefs for pointer types in fx_system.h (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Manual fixes. Created 5 years, 6 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
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 "../../../include/fpdfapi/fpdf_module.h" 7 #include "../../../include/fpdfapi/fpdf_module.h"
8 #include "../../../include/fpdfapi/fpdf_page.h" 8 #include "../../../include/fpdfapi/fpdf_page.h"
9 #include "font_int.h" 9 #include "font_int.h"
10 #include "../fpdf_cmaps/cmap_int.h" 10 #include "../fpdf_cmaps/cmap_int.h"
11 #include "../../../include/fxge/fx_ge.h" 11 #include "../../../include/fxge/fx_ge.h"
12 #include "../../../include/fxge/fx_freetype.h" 12 #include "../../../include/fxge/fx_freetype.h"
13 extern FX_DWORD FT_CharCodeFromUnicode(int encoding, FX_WCHAR unicode); 13 extern FX_DWORD FT_CharCodeFromUnicode(int encoding, FX_WCHAR unicode);
14 extern short TT2PDF(int m, FXFT_Face face); 14 extern short TT2PDF(int m, FXFT_Face face);
15 extern FX_BOOL FT_UseTTCharmap(FXFT_Face face, int platform_id, int encoding_id) ; 15 extern FX_BOOL FT_UseTTCharmap(FXFT_Face face, int platform_id, int encoding_id) ;
16 extern FX_LPCSTR GetAdobeCharName(int iBaseEncoding, const CFX_ByteString* pChar Names, int charcode); 16 extern const FX_CHAR* GetAdobeCharName(int iBaseEncoding, const CFX_ByteString* pCharNames, int charcode);
17 CPDF_CMapManager::CPDF_CMapManager() 17 CPDF_CMapManager::CPDF_CMapManager()
18 { 18 {
19 m_bPrompted = FALSE; 19 m_bPrompted = FALSE;
20 FXSYS_memset32(m_CID2UnicodeMaps, 0, sizeof m_CID2UnicodeMaps); 20 FXSYS_memset32(m_CID2UnicodeMaps, 0, sizeof m_CID2UnicodeMaps);
21 } 21 }
22 CPDF_CMapManager::~CPDF_CMapManager() 22 CPDF_CMapManager::~CPDF_CMapManager()
23 { 23 {
24 DropAll(FALSE); 24 DropAll(FALSE);
25 } 25 }
26 CPDF_CMap* CPDF_CMapManager::GetPredefinedCMap(const CFX_ByteString& name, FX_BO OL bPromptCJK) 26 CPDF_CMap* CPDF_CMapManager::GetPredefinedCMap(const CFX_ByteString& name, FX_BO OL bPromptCJK)
27 { 27 {
28 CPDF_CMap* pCMap; 28 CPDF_CMap* pCMap;
29 if (m_CMaps.Lookup(name, (FX_LPVOID&)pCMap)) { 29 if (m_CMaps.Lookup(name, (void*&)pCMap)) {
30 return pCMap; 30 return pCMap;
31 } 31 }
32 pCMap = LoadPredefinedCMap(name, bPromptCJK); 32 pCMap = LoadPredefinedCMap(name, bPromptCJK);
33 if (name.IsEmpty()) { 33 if (name.IsEmpty()) {
34 return pCMap; 34 return pCMap;
35 } 35 }
36 m_CMaps.SetAt(name, pCMap); 36 m_CMaps.SetAt(name, pCMap);
37 return pCMap; 37 return pCMap;
38 } 38 }
39 CPDF_CMap* CPDF_CMapManager::LoadPredefinedCMap(const CFX_ByteString& name, FX_B OOL bPromptCJK) 39 CPDF_CMap* CPDF_CMapManager::LoadPredefinedCMap(const CFX_ByteString& name, FX_B OOL bPromptCJK)
40 { 40 {
41 CPDF_CMap* pCMap = new CPDF_CMap; 41 CPDF_CMap* pCMap = new CPDF_CMap;
42 FX_LPCSTR pname = name; 42 const FX_CHAR* pname = name;
43 if (*pname == '/') { 43 if (*pname == '/') {
44 pname ++; 44 pname ++;
45 } 45 }
46 pCMap->LoadPredefined(this, pname, bPromptCJK); 46 pCMap->LoadPredefined(this, pname, bPromptCJK);
47 return pCMap; 47 return pCMap;
48 } 48 }
49 static const FX_LPCSTR g_CharsetNames[NUMBER_OF_CIDSETS] = {NULL, "GB1", "CNS1", "Japan1", "Korea1", "UCS" }; 49 static const FX_CHAR* const g_CharsetNames[NUMBER_OF_CIDSETS] = {NULL, "GB1", "C NS1", "Japan1", "Korea1", "UCS" };
50 static const int g_CharsetCPs[NUMBER_OF_CIDSETS] = {0, 936, 950, 932, 949, 1200 }; 50 static const int g_CharsetCPs[NUMBER_OF_CIDSETS] = {0, 936, 950, 932, 949, 1200 };
51 int _CharsetFromOrdering(const CFX_ByteString& Ordering) 51 int _CharsetFromOrdering(const CFX_ByteString& Ordering)
52 { 52 {
53 for (int charset = 1; charset < NUMBER_OF_CIDSETS; charset++) { 53 for (int charset = 1; charset < NUMBER_OF_CIDSETS; charset++) {
54 if (Ordering == CFX_ByteStringC(g_CharsetNames[charset])) 54 if (Ordering == CFX_ByteStringC(g_CharsetNames[charset]))
55 return charset; 55 return charset;
56 } 56 }
57 return CIDSET_UNKNOWN; 57 return CIDSET_UNKNOWN;
58 } 58 }
59 void CPDF_CMapManager::ReloadAll() 59 void CPDF_CMapManager::ReloadAll()
60 { 60 {
61 DropAll(TRUE); 61 DropAll(TRUE);
62 } 62 }
63 void CPDF_CMapManager::DropAll(FX_BOOL bReload) 63 void CPDF_CMapManager::DropAll(FX_BOOL bReload)
64 { 64 {
65 FX_POSITION pos = m_CMaps.GetStartPosition(); 65 FX_POSITION pos = m_CMaps.GetStartPosition();
66 while (pos) { 66 while (pos) {
67 CFX_ByteString name; 67 CFX_ByteString name;
68 CPDF_CMap* pCMap; 68 CPDF_CMap* pCMap;
69 m_CMaps.GetNextAssoc(pos, name, (FX_LPVOID&)pCMap); 69 m_CMaps.GetNextAssoc(pos, name, (void*&)pCMap);
70 if (pCMap == NULL) { 70 if (pCMap == NULL) {
71 continue; 71 continue;
72 } 72 }
73 if (bReload) { 73 if (bReload) {
74 pCMap->LoadPredefined(this, name, FALSE); 74 pCMap->LoadPredefined(this, name, FALSE);
75 } else { 75 } else {
76 delete pCMap; 76 delete pCMap;
77 } 77 }
78 } 78 }
79 for (int i = 0; i < sizeof m_CID2UnicodeMaps / sizeof(CPDF_CID2UnicodeMap*); i ++) { 79 for (int i = 0; i < sizeof m_CID2UnicodeMaps / sizeof(CPDF_CID2UnicodeMap*); i ++) {
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after
340 { "KSC-EUC", CIDSET_KOREA1, CIDCODING_KOREA, CPDF_CMap::MixedTwoBytes, 1, {0 xa1, 0xfe} }, 340 { "KSC-EUC", CIDSET_KOREA1, CIDCODING_KOREA, CPDF_CMap::MixedTwoBytes, 1, {0 xa1, 0xfe} },
341 { "KSCms-UHC", CIDSET_KOREA1, CIDCODING_KOREA, CPDF_CMap::MixedTwoBytes, 1, {0x81, 0xfe} }, 341 { "KSCms-UHC", CIDSET_KOREA1, CIDCODING_KOREA, CPDF_CMap::MixedTwoBytes, 1, {0x81, 0xfe} },
342 { "KSCms-UHC-HW", CIDSET_KOREA1, CIDCODING_KOREA, CPDF_CMap::MixedTwoBytes, 1, {0x81, 0xfe} }, 342 { "KSCms-UHC-HW", CIDSET_KOREA1, CIDCODING_KOREA, CPDF_CMap::MixedTwoBytes, 1, {0x81, 0xfe} },
343 { "KSCpc-EUC", CIDSET_KOREA1, CIDCODING_KOREA, CPDF_CMap::MixedTwoBytes, 1, {0xa1, 0xfd} }, 343 { "KSCpc-EUC", CIDSET_KOREA1, CIDCODING_KOREA, CPDF_CMap::MixedTwoBytes, 1, {0xa1, 0xfd} },
344 { "UniKS-UCS2", CIDSET_KOREA1, CIDCODING_UCS2, CPDF_CMap::TwoBytes }, 344 { "UniKS-UCS2", CIDSET_KOREA1, CIDCODING_UCS2, CPDF_CMap::TwoBytes },
345 { "UniKS-UTF16", CIDSET_KOREA1, CIDCODING_UTF16, CPDF_CMap::TwoBytes }, 345 { "UniKS-UTF16", CIDSET_KOREA1, CIDCODING_UTF16, CPDF_CMap::TwoBytes },
346 { NULL, 0, 0 } 346 { NULL, 0, 0 }
347 }; 347 };
348 extern void FPDFAPI_FindEmbeddedCMap(const char* name, int charset, int coding, const FXCMAP_CMap*& pMap); 348 extern void FPDFAPI_FindEmbeddedCMap(const char* name, int charset, int coding, const FXCMAP_CMap*& pMap);
349 extern FX_WORD FPDFAPI_CIDFromCharCode(const FXCMAP_CMap* pMap, FX_DWORD charcod e); 349 extern FX_WORD FPDFAPI_CIDFromCharCode(const FXCMAP_CMap* pMap, FX_DWORD charcod e);
350 FX_BOOL CPDF_CMap::LoadPredefined(CPDF_CMapManager* pMgr, FX_LPCSTR pName, FX_BO OL bPromptCJK) 350 FX_BOOL CPDF_CMap::LoadPredefined(CPDF_CMapManager* pMgr, const FX_CHAR* pName, FX_BOOL bPromptCJK)
351 { 351 {
352 m_PredefinedCMap = pName; 352 m_PredefinedCMap = pName;
353 if (m_PredefinedCMap == FX_BSTRC("Identity-H") || m_PredefinedCMap == FX_BST RC("Identity-V")) { 353 if (m_PredefinedCMap == FX_BSTRC("Identity-H") || m_PredefinedCMap == FX_BST RC("Identity-V")) {
354 m_Coding = CIDCODING_CID; 354 m_Coding = CIDCODING_CID;
355 m_bVertical = pName[9] == 'V'; 355 m_bVertical = pName[9] == 'V';
356 m_bLoaded = TRUE; 356 m_bLoaded = TRUE;
357 return TRUE; 357 return TRUE;
358 } 358 }
359 CFX_ByteString cmapid = m_PredefinedCMap; 359 CFX_ByteString cmapid = m_PredefinedCMap;
360 m_bVertical = cmapid.Right(1) == FX_BSTRC("V"); 360 m_bVertical = cmapid.Right(1) == FX_BSTRC("V");
(...skipping 28 matching lines...) Expand all
389 return TRUE; 389 return TRUE;
390 } 390 }
391 return FALSE; 391 return FALSE;
392 } 392 }
393 extern "C" { 393 extern "C" {
394 static int compare_dword(const void* data1, const void* data2) 394 static int compare_dword(const void* data1, const void* data2)
395 { 395 {
396 return (*(FX_DWORD*)data1) - (*(FX_DWORD*)data2); 396 return (*(FX_DWORD*)data1) - (*(FX_DWORD*)data2);
397 } 397 }
398 }; 398 };
399 FX_BOOL CPDF_CMap::LoadEmbedded(FX_LPCBYTE pData, FX_DWORD size) 399 FX_BOOL CPDF_CMap::LoadEmbedded(const uint8_t* pData, FX_DWORD size)
400 { 400 {
401 m_pMapping = FX_Alloc(FX_WORD, 65536); 401 m_pMapping = FX_Alloc(FX_WORD, 65536);
402 CPDF_CMapParser parser; 402 CPDF_CMapParser parser;
403 parser.Initialize(this); 403 parser.Initialize(this);
404 CPDF_SimpleParser syntax(pData, size); 404 CPDF_SimpleParser syntax(pData, size);
405 while (1) { 405 while (1) {
406 CFX_ByteStringC word = syntax.GetWord(); 406 CFX_ByteStringC word = syntax.GetWord();
407 if (word.IsEmpty()) { 407 if (word.IsEmpty()) {
408 break; 408 break;
409 } 409 }
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
455 return m_pUseMap->CIDFromCharCode(charcode); 455 return m_pUseMap->CIDFromCharCode(charcode);
456 } 456 }
457 return 0; 457 return 0;
458 } 458 }
459 FX_DWORD CID = m_pMapping[charcode]; 459 FX_DWORD CID = m_pMapping[charcode];
460 if (!CID && m_pUseMap) { 460 if (!CID && m_pUseMap) {
461 return m_pUseMap->CIDFromCharCode(charcode); 461 return m_pUseMap->CIDFromCharCode(charcode);
462 } 462 }
463 return (FX_WORD)CID; 463 return (FX_WORD)CID;
464 } 464 }
465 static int _CheckCodeRange(FX_LPBYTE codes, int size, _CMap_CodeRange* pRanges, int nRanges) 465 static int _CheckCodeRange(uint8_t* codes, int size, _CMap_CodeRange* pRanges, i nt nRanges)
466 { 466 {
467 int iSeg = nRanges - 1; 467 int iSeg = nRanges - 1;
468 while (iSeg >= 0) { 468 while (iSeg >= 0) {
469 if (pRanges[iSeg].m_CharSize < size) { 469 if (pRanges[iSeg].m_CharSize < size) {
470 iSeg --; 470 iSeg --;
471 continue; 471 continue;
472 } 472 }
473 int iChar = 0; 473 int iChar = 0;
474 while (iChar < size) { 474 while (iChar < size) {
475 if (codes[iChar] < pRanges[iSeg].m_Lower[iChar] || 475 if (codes[iChar] < pRanges[iSeg].m_Lower[iChar] ||
476 codes[iChar] > pRanges[iSeg].m_Upper[iChar]) { 476 codes[iChar] > pRanges[iSeg].m_Upper[iChar]) {
477 break; 477 break;
478 } 478 }
479 iChar ++; 479 iChar ++;
480 } 480 }
481 if (iChar == pRanges[iSeg].m_CharSize) { 481 if (iChar == pRanges[iSeg].m_CharSize) {
482 return 2; 482 return 2;
483 } 483 }
484 if (iChar) { 484 if (iChar) {
485 if (size == pRanges[iSeg].m_CharSize) { 485 if (size == pRanges[iSeg].m_CharSize) {
486 return 2; 486 return 2;
487 } 487 }
488 return 1; 488 return 1;
489 } 489 }
490 iSeg --; 490 iSeg --;
491 } 491 }
492 return 0; 492 return 0;
493 } 493 }
494 FX_DWORD CPDF_CMap::GetNextChar(FX_LPCSTR pString, int nStrLen, int& offset) con st 494 FX_DWORD CPDF_CMap::GetNextChar(const FX_CHAR* pString, int nStrLen, int& offset ) const
495 { 495 {
496 switch (m_CodingScheme) { 496 switch (m_CodingScheme) {
497 case OneByte: 497 case OneByte:
498 return ((FX_LPBYTE)pString)[offset++]; 498 return ((uint8_t*)pString)[offset++];
499 case TwoBytes: 499 case TwoBytes:
500 offset += 2; 500 offset += 2;
501 return ((FX_LPBYTE)pString)[offset - 2] * 256 + ((FX_LPBYTE)pString) [offset - 1]; 501 return ((uint8_t*)pString)[offset - 2] * 256 + ((uint8_t*)pString)[o ffset - 1];
502 case MixedTwoBytes: { 502 case MixedTwoBytes: {
503 uint8_t byte1 = ((FX_LPBYTE)pString)[offset++]; 503 uint8_t byte1 = ((uint8_t*)pString)[offset++];
504 if (!m_pLeadingBytes[byte1]) { 504 if (!m_pLeadingBytes[byte1]) {
505 return byte1; 505 return byte1;
506 } 506 }
507 uint8_t byte2 = ((FX_LPBYTE)pString)[offset++]; 507 uint8_t byte2 = ((uint8_t*)pString)[offset++];
508 return byte1 * 256 + byte2; 508 return byte1 * 256 + byte2;
509 } 509 }
510 case MixedFourBytes: { 510 case MixedFourBytes: {
511 uint8_t codes[4]; 511 uint8_t codes[4];
512 int char_size = 1; 512 int char_size = 1;
513 codes[0] = ((FX_LPBYTE)pString)[offset++]; 513 codes[0] = ((uint8_t*)pString)[offset++];
514 _CMap_CodeRange* pRanges = (_CMap_CodeRange*)m_pLeadingBytes; 514 _CMap_CodeRange* pRanges = (_CMap_CodeRange*)m_pLeadingBytes;
515 while (1) { 515 while (1) {
516 int ret = _CheckCodeRange(codes, char_size, pRanges, m_nCode Ranges); 516 int ret = _CheckCodeRange(codes, char_size, pRanges, m_nCode Ranges);
517 if (ret == 0) { 517 if (ret == 0) {
518 return 0; 518 return 0;
519 } 519 }
520 if (ret == 2) { 520 if (ret == 2) {
521 FX_DWORD charcode = 0; 521 FX_DWORD charcode = 0;
522 for (int i = 0; i < char_size; i ++) { 522 for (int i = 0; i < char_size; i ++) {
523 charcode = (charcode << 8) + codes[i]; 523 charcode = (charcode << 8) + codes[i];
524 } 524 }
525 return charcode; 525 return charcode;
526 } 526 }
527 if (char_size == 4 || offset == nStrLen) { 527 if (char_size == 4 || offset == nStrLen) {
528 return 0; 528 return 0;
529 } 529 }
530 codes[char_size ++] = ((FX_LPBYTE)pString)[offset++]; 530 codes[char_size ++] = ((uint8_t*)pString)[offset++];
531 } 531 }
532 break; 532 break;
533 } 533 }
534 } 534 }
535 return 0; 535 return 0;
536 } 536 }
537 int CPDF_CMap::GetCharSize(FX_DWORD charcode) const 537 int CPDF_CMap::GetCharSize(FX_DWORD charcode) const
538 { 538 {
539 switch (m_CodingScheme) { 539 switch (m_CodingScheme) {
540 case OneByte: 540 case OneByte:
541 return 1; 541 return 1;
542 case TwoBytes: 542 case TwoBytes:
543 return 2; 543 return 2;
544 case MixedTwoBytes: 544 case MixedTwoBytes:
545 case MixedFourBytes: 545 case MixedFourBytes:
546 if (charcode < 0x100) { 546 if (charcode < 0x100) {
547 return 1; 547 return 1;
548 } 548 }
549 if (charcode < 0x10000) { 549 if (charcode < 0x10000) {
550 return 2; 550 return 2;
551 } 551 }
552 if (charcode < 0x1000000) { 552 if (charcode < 0x1000000) {
553 return 3; 553 return 3;
554 } 554 }
555 return 4; 555 return 4;
556 } 556 }
557 return 1; 557 return 1;
558 } 558 }
559 int CPDF_CMap::CountChar(FX_LPCSTR pString, int size) const 559 int CPDF_CMap::CountChar(const FX_CHAR* pString, int size) const
560 { 560 {
561 switch (m_CodingScheme) { 561 switch (m_CodingScheme) {
562 case OneByte: 562 case OneByte:
563 return size; 563 return size;
564 case TwoBytes: 564 case TwoBytes:
565 return (size + 1) / 2; 565 return (size + 1) / 2;
566 case MixedTwoBytes: { 566 case MixedTwoBytes: {
567 int count = 0; 567 int count = 0;
568 for (int i = 0; i < size; i ++) { 568 for (int i = 0; i < size; i ++) {
569 count ++; 569 count ++;
570 if (m_pLeadingBytes[((FX_LPBYTE)pString)[i]]) { 570 if (m_pLeadingBytes[((uint8_t*)pString)[i]]) {
571 i ++; 571 i ++;
572 } 572 }
573 } 573 }
574 return count; 574 return count;
575 } 575 }
576 case MixedFourBytes: { 576 case MixedFourBytes: {
577 int count = 0, offset = 0; 577 int count = 0, offset = 0;
578 while (offset < size) { 578 while (offset < size) {
579 GetNextChar(pString, size, offset); 579 GetNextChar(pString, size, offset);
580 count ++; 580 count ++;
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
612 if (iChar == pRanges[iSeg].m_CharSize) { 612 if (iChar == pRanges[iSeg].m_CharSize) {
613 return size; 613 return size;
614 } 614 }
615 iSeg --; 615 iSeg --;
616 } 616 }
617 size --; 617 size --;
618 offset ++; 618 offset ++;
619 } 619 }
620 return 1; 620 return 1;
621 } 621 }
622 int CPDF_CMap::AppendChar(FX_LPSTR str, FX_DWORD charcode) const 622 int CPDF_CMap::AppendChar(FX_CHAR* str, FX_DWORD charcode) const
623 { 623 {
624 switch (m_CodingScheme) { 624 switch (m_CodingScheme) {
625 case OneByte: 625 case OneByte:
626 str[0] = (uint8_t)charcode; 626 str[0] = (uint8_t)charcode;
627 return 1; 627 return 1;
628 case TwoBytes: 628 case TwoBytes:
629 str[0] = (uint8_t)(charcode / 256); 629 str[0] = (uint8_t)(charcode / 256);
630 str[1] = (uint8_t)(charcode % 256); 630 str[1] = (uint8_t)(charcode % 256);
631 return 2; 631 return 2;
632 case MixedTwoBytes: 632 case MixedTwoBytes:
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
786 return m_pCID2UnicodeMap->UnicodeFromCID((FX_WORD)charcode); 786 return m_pCID2UnicodeMap->UnicodeFromCID((FX_WORD)charcode);
787 } 787 }
788 if (!m_pCMap->IsLoaded() || m_pCID2UnicodeMap == NULL || !m_pCID2UnicodeMap- >IsLoaded()) { 788 if (!m_pCMap->IsLoaded() || m_pCID2UnicodeMap == NULL || !m_pCID2UnicodeMap- >IsLoaded()) {
789 #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ 789 #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_
790 FX_WCHAR unicode; 790 FX_WCHAR unicode;
791 int charsize = 1; 791 int charsize = 1;
792 if (charcode > 255) { 792 if (charcode > 255) {
793 charcode = (charcode % 256) * 256 + (charcode / 256); 793 charcode = (charcode % 256) * 256 + (charcode / 256);
794 charsize = 2; 794 charsize = 2;
795 } 795 }
796 int ret = FXSYS_MultiByteToWideChar(g_CharsetCPs[m_pCMap->m_Coding], 0, (FX_LPCSTR)&charcode, charsize, &unicode, 1); 796 int ret = FXSYS_MultiByteToWideChar(g_CharsetCPs[m_pCMap->m_Coding], 0, (const FX_CHAR*)&charcode, charsize, &unicode, 1);
797 if (ret != 1) { 797 if (ret != 1) {
798 return 0; 798 return 0;
799 } 799 }
800 return unicode; 800 return unicode;
801 #endif 801 #endif
802 if (m_pCMap->m_pEmbedMap) { 802 if (m_pCMap->m_pEmbedMap) {
803 return _EmbeddedUnicodeFromCharcode(m_pCMap->m_pEmbedMap, m_pCMap->m _Charset, charcode); 803 return _EmbeddedUnicodeFromCharcode(m_pCMap->m_pEmbedMap, m_pCMap->m _Charset, charcode);
804 } else { 804 } else {
805 return 0; 805 return 0;
806 } 806 }
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after
1049 rect.left = TT2PDF(FXFT_Get_Glyph_HoriBearingX(face), face); 1049 rect.left = TT2PDF(FXFT_Get_Glyph_HoriBearingX(face), face);
1050 rect.right = TT2PDF(FXFT_Get_Glyph_HoriBearingX(face) + FXFT_Get _Glyph_Width(face), face); 1050 rect.right = TT2PDF(FXFT_Get_Glyph_HoriBearingX(face) + FXFT_Get _Glyph_Width(face), face);
1051 rect.top = TT2PDF(FXFT_Get_Glyph_HoriBearingY(face), face); 1051 rect.top = TT2PDF(FXFT_Get_Glyph_HoriBearingY(face), face);
1052 rect.top += rect.top / 64; 1052 rect.top += rect.top / 64;
1053 rect.bottom = TT2PDF(FXFT_Get_Glyph_HoriBearingY(face) - FXFT_Ge t_Glyph_Height(face), face); 1053 rect.bottom = TT2PDF(FXFT_Get_Glyph_HoriBearingY(face) - FXFT_Ge t_Glyph_Height(face), face);
1054 } 1054 }
1055 } 1055 }
1056 } 1056 }
1057 if (m_pFontFile == NULL && m_Charset == CIDSET_JAPAN1) { 1057 if (m_pFontFile == NULL && m_Charset == CIDSET_JAPAN1) {
1058 FX_WORD CID = CIDFromCharCode(charcode); 1058 FX_WORD CID = CIDFromCharCode(charcode);
1059 FX_LPCBYTE pTransform = GetCIDTransform(CID); 1059 const uint8_t* pTransform = GetCIDTransform(CID);
1060 if (pTransform && !bVert) { 1060 if (pTransform && !bVert) {
1061 CFX_AffineMatrix matrix(_CIDTransformToFloat(pTransform[0]), _CIDTra nsformToFloat(pTransform[1]), 1061 CFX_AffineMatrix matrix(_CIDTransformToFloat(pTransform[0]), _CIDTra nsformToFloat(pTransform[1]),
1062 _CIDTransformToFloat(pTransform[2]), _CIDTra nsformToFloat(pTransform[3]), 1062 _CIDTransformToFloat(pTransform[2]), _CIDTra nsformToFloat(pTransform[3]),
1063 _CIDTransformToFloat(pTransform[4]) * 1000 , _CIDTransformToFloat(pTransform[5]) * 1000); 1063 _CIDTransformToFloat(pTransform[4]) * 1000 , _CIDTransformToFloat(pTransform[5]) * 1000);
1064 CFX_FloatRect rect_f(rect); 1064 CFX_FloatRect rect_f(rect);
1065 rect_f.Transform(&matrix); 1065 rect_f.Transform(&matrix);
1066 rect = rect_f.GetOutterRect(); 1066 rect = rect_f.GetOutterRect();
1067 } 1067 }
1068 } 1068 }
1069 if (charcode < 256) { 1069 if (charcode < 256) {
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
1215 FX_BOOL bMacRoman = FALSE; 1215 FX_BOOL bMacRoman = FALSE;
1216 if (!bMSUnicode) { 1216 if (!bMSUnicode) {
1217 bMacRoman = FT_UseTTCharmap(m_Font.m_Face, 1, 0); 1217 bMacRoman = FT_UseTTCharmap(m_Font.m_Face, 1, 0);
1218 } 1218 }
1219 iBaseEncoding = PDFFONT_ENCODING_STANDARD; 1219 iBaseEncoding = PDFFONT_ENCODING_STANDARD;
1220 if (bMSUnicode) { 1220 if (bMSUnicode) {
1221 iBaseEncoding = PDFFONT_ENCODING_WINANSI; 1221 iBaseEncoding = PDFFONT_ENCODING_WINANSI;
1222 } else if (bMacRoman) { 1222 } else if (bMacRoman) {
1223 iBaseEncoding = PDFFONT_ENCODING_MACROMAN; 1223 iBaseEncoding = PDFFONT_ENCODING_MACROMAN;
1224 } 1224 }
1225 FX_LPCSTR name = GetAdobeCharName(iBaseEncoding, NULL, charcode); 1225 const FX_CHAR* name = GetAdobeCharName(iBaseEncoding, NULL, charcode );
1226 if (name == NULL) { 1226 if (name == NULL) {
1227 return charcode == 0 ? -1 : (int)charcode; 1227 return charcode == 0 ? -1 : (int)charcode;
1228 } 1228 }
1229 FX_WORD unicode = PDF_UnicodeFromAdobeName(name); 1229 FX_WORD unicode = PDF_UnicodeFromAdobeName(name);
1230 if (unicode) { 1230 if (unicode) {
1231 if (bMSUnicode) { 1231 if (bMSUnicode) {
1232 index = FXFT_Get_Char_Index(m_Font.m_Face, unicode); 1232 index = FXFT_Get_Char_Index(m_Font.m_Face, unicode);
1233 } else if (bMacRoman) { 1233 } else if (bMacRoman) {
1234 FX_DWORD maccode = FT_CharCodeFromUnicode(FXFT_ENCODING_APPL E_ROMAN, unicode); 1234 FX_DWORD maccode = FT_CharCodeFromUnicode(FXFT_ENCODING_APPL E_ROMAN, unicode);
1235 index = !maccode ? FXFT_Get_Name_Index(m_Font.m_Face, (char *)name) : FXFT_Get_Char_Index(m_Font.m_Face, maccode); 1235 index = !maccode ? FXFT_Get_Name_Index(m_Font.m_Face, (char *)name) : FXFT_Get_Char_Index(m_Font.m_Face, maccode);
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
1307 } 1307 }
1308 charcode = unicode_str.GetAt(0); 1308 charcode = unicode_str.GetAt(0);
1309 } 1309 }
1310 return GetGlyphIndex(charcode, pVertGlyph); 1310 return GetGlyphIndex(charcode, pVertGlyph);
1311 } 1311 }
1312 } 1312 }
1313 FX_DWORD byte_pos = cid * 2; 1313 FX_DWORD byte_pos = cid * 2;
1314 if (byte_pos + 2 > m_pCIDToGIDMap->GetSize()) { 1314 if (byte_pos + 2 > m_pCIDToGIDMap->GetSize()) {
1315 return -1; 1315 return -1;
1316 } 1316 }
1317 FX_LPCBYTE pdata = m_pCIDToGIDMap->GetData() + byte_pos; 1317 const uint8_t* pdata = m_pCIDToGIDMap->GetData() + byte_pos;
1318 return pdata[0] * 256 + pdata[1]; 1318 return pdata[0] * 256 + pdata[1];
1319 } 1319 }
1320 FX_DWORD CPDF_CIDFont::GetNextChar(FX_LPCSTR pString, int nStrLen, int& offset) const 1320 FX_DWORD CPDF_CIDFont::GetNextChar(const FX_CHAR* pString, int nStrLen, int& off set) const
1321 { 1321 {
1322 return m_pCMap->GetNextChar(pString, nStrLen, offset); 1322 return m_pCMap->GetNextChar(pString, nStrLen, offset);
1323 } 1323 }
1324 int CPDF_CIDFont::GetCharSize(FX_DWORD charcode) const 1324 int CPDF_CIDFont::GetCharSize(FX_DWORD charcode) const
1325 { 1325 {
1326 return m_pCMap->GetCharSize(charcode); 1326 return m_pCMap->GetCharSize(charcode);
1327 } 1327 }
1328 int CPDF_CIDFont::CountChar(FX_LPCSTR pString, int size) const 1328 int CPDF_CIDFont::CountChar(const FX_CHAR* pString, int size) const
1329 { 1329 {
1330 return m_pCMap->CountChar(pString, size); 1330 return m_pCMap->CountChar(pString, size);
1331 } 1331 }
1332 int CPDF_CIDFont::AppendChar(FX_LPSTR str, FX_DWORD charcode) const 1332 int CPDF_CIDFont::AppendChar(FX_CHAR* str, FX_DWORD charcode) const
1333 { 1333 {
1334 return m_pCMap->AppendChar(str, charcode); 1334 return m_pCMap->AppendChar(str, charcode);
1335 } 1335 }
1336 FX_BOOL CPDF_CIDFont::IsUnicodeCompatible() const 1336 FX_BOOL CPDF_CIDFont::IsUnicodeCompatible() const
1337 { 1337 {
1338 if (!m_pCMap->IsLoaded() || m_pCID2UnicodeMap == NULL || !m_pCID2UnicodeMap- >IsLoaded()) { 1338 if (!m_pCMap->IsLoaded() || m_pCID2UnicodeMap == NULL || !m_pCID2UnicodeMap- >IsLoaded()) {
1339 return m_pCMap->m_Coding != CIDCODING_UNKNOWN; 1339 return m_pCMap->m_Coding != CIDCODING_UNKNOWN;
1340 } 1340 }
1341 return TRUE; 1341 return TRUE;
1342 } 1342 }
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after
1572 {8811, 0, 129, 127, 0, 19, 114}, 1572 {8811, 0, 129, 127, 0, 19, 114},
1573 {8812, 0, 129, 127, 0, 19, 102}, 1573 {8812, 0, 129, 127, 0, 19, 102},
1574 {8813, 0, 129, 127, 0, 19, 114}, 1574 {8813, 0, 129, 127, 0, 19, 114},
1575 {8814, 0, 129, 127, 0, 76, 102}, 1575 {8814, 0, 129, 127, 0, 76, 102},
1576 {8815, 0, 129, 127, 0, 13, 121}, 1576 {8815, 0, 129, 127, 0, 13, 121},
1577 {8816, 0, 129, 127, 0, 19, 114}, 1577 {8816, 0, 129, 127, 0, 19, 114},
1578 {8817, 0, 129, 127, 0, 19, 127}, 1578 {8817, 0, 129, 127, 0, 19, 127},
1579 {8818, 0, 129, 127, 0, 19, 114}, 1579 {8818, 0, 129, 127, 0, 19, 114},
1580 {8819, 0, 129, 127, 0, 218, 108}, 1580 {8819, 0, 129, 127, 0, 218, 108},
1581 }; 1581 };
1582 FX_LPCBYTE CPDF_CIDFont::GetCIDTransform(FX_WORD CID) const 1582 const uint8_t* CPDF_CIDFont::GetCIDTransform(FX_WORD CID) const
1583 { 1583 {
1584 if (m_Charset != CIDSET_JAPAN1 || m_pFontFile != NULL) { 1584 if (m_Charset != CIDSET_JAPAN1 || m_pFontFile != NULL) {
1585 return NULL; 1585 return NULL;
1586 } 1586 }
1587 int begin = 0; 1587 int begin = 0;
1588 int end = sizeof Japan1_VertCIDs / sizeof(struct _CIDTransform) - 1; 1588 int end = sizeof Japan1_VertCIDs / sizeof(struct _CIDTransform) - 1;
1589 while (begin <= end) { 1589 while (begin <= end) {
1590 int middle = (begin + end) / 2; 1590 int middle = (begin + end) / 2;
1591 FX_WORD middlecode = Japan1_VertCIDs[middle].CID; 1591 FX_WORD middlecode = Japan1_VertCIDs[middle].CID;
1592 if (middlecode > CID) { 1592 if (middlecode > CID) {
1593 end = middle - 1; 1593 end = middle - 1;
1594 } else if (middlecode < CID) { 1594 } else if (middlecode < CID) {
1595 begin = middle + 1; 1595 begin = middle + 1;
1596 } else { 1596 } else {
1597 return &Japan1_VertCIDs[middle].a; 1597 return &Japan1_VertCIDs[middle].a;
1598 } 1598 }
1599 } 1599 }
1600 return NULL; 1600 return NULL;
1601 } 1601 }
OLDNEW
« no previous file with comments | « core/src/fpdfapi/fpdf_font/fpdf_font_charset.cpp ('k') | core/src/fpdfapi/fpdf_font/ttgsubtable.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698