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