| OLD | NEW |
| 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 "../../../include/fpdfapi/fpdf_pageobj.h" | 9 #include "../../../include/fpdfapi/fpdf_pageobj.h" |
| 10 #include "../../../include/fpdfapi/fpdf_resource.h" | 10 #include "../../../include/fpdfapi/fpdf_resource.h" |
| 11 #include "../../../include/fxcrt/fx_ext.h" | |
| 12 #include "../../../include/fxge/fx_freetype.h" | 11 #include "../../../include/fxge/fx_freetype.h" |
| 13 #include "../fpdf_page/pageint.h" | 12 #include "../fpdf_page/pageint.h" |
| 14 #include "font_int.h" | 13 #include "font_int.h" |
| 15 | 14 |
| 16 FX_BOOL FT_UseTTCharmap(FXFT_Face face, int platform_id, int encoding_id) { | 15 FX_BOOL FT_UseTTCharmap(FXFT_Face face, int platform_id, int encoding_id) { |
| 17 for (int i = 0; i < FXFT_Get_Face_CharmapCount(face); i++) { | 16 for (int i = 0; i < FXFT_Get_Face_CharmapCount(face); i++) { |
| 18 if (FXFT_Get_Charmap_PlatformID(FXFT_Get_Face_Charmaps(face)[i]) == | 17 if (FXFT_Get_Charmap_PlatformID(FXFT_Get_Face_Charmaps(face)[i]) == |
| 19 platform_id && | 18 platform_id && |
| 20 FXFT_Get_Charmap_EncodingID(FXFT_Get_Face_Charmaps(face)[i]) == | 19 FXFT_Get_Charmap_EncodingID(FXFT_Get_Face_Charmaps(face)[i]) == |
| 21 encoding_id) { | 20 encoding_id) { |
| (...skipping 485 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 507 if (pair.second == unicode) | 506 if (pair.second == unicode) |
| 508 return pair.first; | 507 return pair.first; |
| 509 } | 508 } |
| 510 return 0; | 509 return 0; |
| 511 } | 510 } |
| 512 | 511 |
| 513 // Static. | 512 // Static. |
| 514 FX_DWORD CPDF_ToUnicodeMap::StringToCode(const CFX_ByteStringC& str) { | 513 FX_DWORD CPDF_ToUnicodeMap::StringToCode(const CFX_ByteStringC& str) { |
| 515 const FX_CHAR* buf = str.GetCStr(); | 514 const FX_CHAR* buf = str.GetCStr(); |
| 516 int len = str.GetLength(); | 515 int len = str.GetLength(); |
| 517 if (len == 0) | 516 if (len == 0) { |
| 518 return 0; | 517 return 0; |
| 519 | 518 } |
| 520 int result = 0; | 519 int result = 0; |
| 521 if (buf[0] == '<') { | 520 if (buf[0] == '<') { |
| 522 for (int i = 1; i < len && std::isxdigit(buf[i]); ++i) | 521 for (int i = 1; i < len; i++) { |
| 523 result = result * 16 + FXSYS_toHexDigit(buf[i]); | 522 int digit; |
| 523 if (buf[i] >= '0' && buf[i] <= '9') { |
| 524 digit = buf[i] - '0'; |
| 525 } else if (buf[i] >= 'a' && buf[i] <= 'f') { |
| 526 digit = buf[i] - 'a' + 10; |
| 527 } else if (buf[i] >= 'A' && buf[i] <= 'F') { |
| 528 digit = buf[i] - 'A' + 10; |
| 529 } else { |
| 530 break; |
| 531 } |
| 532 result = result * 16 + digit; |
| 533 } |
| 524 return result; | 534 return result; |
| 525 } | 535 } |
| 526 | 536 for (int i = 0; i < len; i++) { |
| 527 for (int i = 0; i < len && std::isdigit(buf[i]); ++i) | 537 if (buf[i] < '0' || buf[i] > '9') { |
| 528 result = result * 10 + FXSYS_toDecimalDigit(buf[i]); | 538 break; |
| 529 | 539 } |
| 540 result = result * 10 + buf[i] - '0'; |
| 541 } |
| 530 return result; | 542 return result; |
| 531 } | 543 } |
| 532 static CFX_WideString StringDataAdd(CFX_WideString str) { | 544 static CFX_WideString StringDataAdd(CFX_WideString str) { |
| 533 CFX_WideString ret; | 545 CFX_WideString ret; |
| 534 int len = str.GetLength(); | 546 int len = str.GetLength(); |
| 535 FX_WCHAR value = 1; | 547 FX_WCHAR value = 1; |
| 536 for (int i = len - 1; i >= 0; --i) { | 548 for (int i = len - 1; i >= 0; --i) { |
| 537 FX_WCHAR ch = str[i] + value; | 549 FX_WCHAR ch = str[i] + value; |
| 538 if (ch < str[i]) { | 550 if (ch < str[i]) { |
| 539 ret.Insert(0, 0); | 551 ret.Insert(0, 0); |
| 540 } else { | 552 } else { |
| 541 ret.Insert(0, ch); | 553 ret.Insert(0, ch); |
| 542 value = 0; | 554 value = 0; |
| 543 } | 555 } |
| 544 } | 556 } |
| 545 if (value) { | 557 if (value) { |
| 546 ret.Insert(0, value); | 558 ret.Insert(0, value); |
| 547 } | 559 } |
| 548 return ret; | 560 return ret; |
| 549 } | 561 } |
| 550 | 562 |
| 551 // Static. | 563 // Static. |
| 552 CFX_WideString CPDF_ToUnicodeMap::StringToWideString( | 564 CFX_WideString CPDF_ToUnicodeMap::StringToWideString( |
| 553 const CFX_ByteStringC& str) { | 565 const CFX_ByteStringC& str) { |
| 554 const FX_CHAR* buf = str.GetCStr(); | 566 const FX_CHAR* buf = str.GetCStr(); |
| 555 int len = str.GetLength(); | 567 int len = str.GetLength(); |
| 556 if (len == 0) | 568 if (len == 0) { |
| 557 return CFX_WideString(); | 569 return CFX_WideString(); |
| 558 | 570 } |
| 559 CFX_WideString result; | 571 CFX_WideString result; |
| 560 if (buf[0] == '<') { | 572 if (buf[0] == '<') { |
| 561 int byte_pos = 0; | 573 int byte_pos = 0; |
| 562 FX_WCHAR ch = 0; | 574 FX_WCHAR ch = 0; |
| 563 for (int i = 1; i < len && std::isxdigit(buf[i]); ++i) { | 575 for (int i = 1; i < len; i++) { |
| 564 ch = ch * 16 + FXSYS_toHexDigit(buf[i]); | 576 int digit; |
| 577 if (buf[i] >= '0' && buf[i] <= '9') { |
| 578 digit = buf[i] - '0'; |
| 579 } else if (buf[i] >= 'a' && buf[i] <= 'f') { |
| 580 digit = buf[i] - 'a' + 10; |
| 581 } else if (buf[i] >= 'A' && buf[i] <= 'F') { |
| 582 digit = buf[i] - 'A' + 10; |
| 583 } else { |
| 584 break; |
| 585 } |
| 586 ch = ch * 16 + digit; |
| 587 |
| 565 byte_pos++; | 588 byte_pos++; |
| 566 if (byte_pos == 4) { | 589 if (byte_pos == 4) { |
| 567 result += ch; | 590 result += ch; |
| 568 byte_pos = 0; | 591 byte_pos = 0; |
| 569 ch = 0; | 592 ch = 0; |
| 570 } | 593 } |
| 571 } | 594 } |
| 572 return result; | 595 return result; |
| 573 } | 596 } |
| 597 if (buf[0] == '(') { |
| 598 } |
| 574 return result; | 599 return result; |
| 575 } | 600 } |
| 576 void CPDF_ToUnicodeMap::Load(CPDF_Stream* pStream) { | 601 void CPDF_ToUnicodeMap::Load(CPDF_Stream* pStream) { |
| 577 CIDSet cid_set = CIDSET_UNKNOWN; | 602 CIDSet cid_set = CIDSET_UNKNOWN; |
| 578 CPDF_StreamAcc stream; | 603 CPDF_StreamAcc stream; |
| 579 stream.LoadAllData(pStream, FALSE); | 604 stream.LoadAllData(pStream, FALSE); |
| 580 CPDF_SimpleParser parser(stream.GetData(), stream.GetSize()); | 605 CPDF_SimpleParser parser(stream.GetData(), stream.GetSize()); |
| 581 while (1) { | 606 while (1) { |
| 582 CFX_ByteStringC word = parser.GetWord(); | 607 CFX_ByteStringC word = parser.GetWord(); |
| 583 if (word.IsEmpty()) { | 608 if (word.IsEmpty()) { |
| (...skipping 1178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1762 CPDF_Type3Char::CPDF_Type3Char() { | 1787 CPDF_Type3Char::CPDF_Type3Char() { |
| 1763 m_pForm = NULL; | 1788 m_pForm = NULL; |
| 1764 m_pBitmap = NULL; | 1789 m_pBitmap = NULL; |
| 1765 m_bPageRequired = FALSE; | 1790 m_bPageRequired = FALSE; |
| 1766 m_bColored = FALSE; | 1791 m_bColored = FALSE; |
| 1767 } | 1792 } |
| 1768 CPDF_Type3Char::~CPDF_Type3Char() { | 1793 CPDF_Type3Char::~CPDF_Type3Char() { |
| 1769 delete m_pForm; | 1794 delete m_pForm; |
| 1770 delete m_pBitmap; | 1795 delete m_pBitmap; |
| 1771 } | 1796 } |
| OLD | NEW |