Chromium Code Reviews| 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 483 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 504 FX_DWORD CPDF_ToUnicodeMap::ReverseLookup(FX_WCHAR unicode) { | 505 FX_DWORD CPDF_ToUnicodeMap::ReverseLookup(FX_WCHAR unicode) { |
| 505 for (const auto& pair : m_Map) { | 506 for (const auto& pair : m_Map) { |
| 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 static FX_DWORD _StringToCode(const CFX_ByteStringC& str) { | 512 static FX_DWORD _StringToCode(const CFX_ByteStringC& str) { |
| 512 const FX_CHAR* buf = str.GetCStr(); | 513 const FX_CHAR* buf = str.GetCStr(); |
| 513 int len = str.GetLength(); | 514 int len = str.GetLength(); |
| 514 if (len == 0) { | 515 if (len == 0) |
| 515 return 0; | 516 return 0; |
| 516 } | 517 |
| 517 int result = 0; | 518 int result = 0; |
| 518 if (buf[0] == '<') { | 519 if (buf[0] == '<') { |
| 519 for (int i = 1; i < len; i++) { | 520 for (int i = 1; i < len && !std::isxdigit(buf[i]); ++i) |
|
Tom Sepez
2015/10/29 20:44:26
I don't think you want the ! here.
dsinclair
2015/11/02 15:43:37
Done.
| |
| 520 int digit; | 521 result = result * 16 + FXSYS_toHexDigit(buf[i]); |
| 521 if (buf[i] >= '0' && buf[i] <= '9') { | |
| 522 digit = buf[i] - '0'; | |
| 523 } else if (buf[i] >= 'a' && buf[i] <= 'f') { | |
| 524 digit = buf[i] - 'a' + 10; | |
| 525 } else if (buf[i] >= 'A' && buf[i] <= 'F') { | |
| 526 digit = buf[i] - 'A' + 10; | |
| 527 } else { | |
| 528 break; | |
| 529 } | |
| 530 result = result * 16 + digit; | |
| 531 } | |
| 532 return result; | 522 return result; |
| 533 } | 523 } |
| 524 | |
| 534 for (int i = 0; i < len; i++) { | 525 for (int i = 0; i < len; i++) { |
|
Tom Sepez
2015/10/29 20:44:26
Lets make the same change here.
dsinclair
2015/11/02 15:43:37
Done.
| |
| 535 if (buf[i] < '0' || buf[i] > '9') { | 526 if (!std::isdigit(buf[i])) |
| 536 break; | 527 break; |
| 537 } | 528 result = result * 10 + FXSYS_toDecimalDigit(buf[i]); |
| 538 result = result * 10 + buf[i] - '0'; | |
| 539 } | 529 } |
| 530 | |
| 540 return result; | 531 return result; |
| 541 } | 532 } |
| 542 static CFX_WideString _StringDataAdd(CFX_WideString str) { | 533 static CFX_WideString _StringDataAdd(CFX_WideString str) { |
| 543 CFX_WideString ret; | 534 CFX_WideString ret; |
| 544 int len = str.GetLength(); | 535 int len = str.GetLength(); |
| 545 FX_WCHAR value = 1; | 536 FX_WCHAR value = 1; |
| 546 for (int i = len - 1; i >= 0; --i) { | 537 for (int i = len - 1; i >= 0; --i) { |
| 547 FX_WCHAR ch = str[i] + value; | 538 FX_WCHAR ch = str[i] + value; |
| 548 if (ch < str[i]) { | 539 if (ch < str[i]) { |
| 549 ret.Insert(0, 0); | 540 ret.Insert(0, 0); |
| 550 } else { | 541 } else { |
| 551 ret.Insert(0, ch); | 542 ret.Insert(0, ch); |
| 552 value = 0; | 543 value = 0; |
| 553 } | 544 } |
| 554 } | 545 } |
| 555 if (value) { | 546 if (value) { |
| 556 ret.Insert(0, value); | 547 ret.Insert(0, value); |
| 557 } | 548 } |
| 558 return ret; | 549 return ret; |
| 559 } | 550 } |
| 560 static CFX_WideString _StringToWideString(const CFX_ByteStringC& str) { | 551 static CFX_WideString _StringToWideString(const CFX_ByteStringC& str) { |
| 561 const FX_CHAR* buf = str.GetCStr(); | 552 const FX_CHAR* buf = str.GetCStr(); |
| 562 int len = str.GetLength(); | 553 int len = str.GetLength(); |
| 563 if (len == 0) { | 554 if (len == 0) |
| 564 return CFX_WideString(); | 555 return CFX_WideString(); |
| 565 } | 556 |
| 566 CFX_WideString result; | 557 CFX_WideString result; |
| 567 if (buf[0] == '<') { | 558 if (buf[0] == '<') { |
| 568 int byte_pos = 0; | 559 int byte_pos = 0; |
| 569 FX_WCHAR ch = 0; | 560 FX_WCHAR ch = 0; |
| 570 for (int i = 1; i < len; i++) { | 561 for (int i = 1; i < len; i++) { |
| 571 int digit; | 562 if (!std::isxdigit(buf[i])) |
| 572 if (buf[i] >= '0' && buf[i] <= '9') { | |
| 573 digit = buf[i] - '0'; | |
| 574 } else if (buf[i] >= 'a' && buf[i] <= 'f') { | |
| 575 digit = buf[i] - 'a' + 10; | |
| 576 } else if (buf[i] >= 'A' && buf[i] <= 'F') { | |
| 577 digit = buf[i] - 'A' + 10; | |
| 578 } else { | |
| 579 break; | 563 break; |
| 580 } | 564 |
| 581 ch = ch * 16 + digit; | 565 ch = ch * 16 + FXSYS_toHexDigit(buf[i]); |
| 582 byte_pos++; | 566 byte_pos++; |
| 583 if (byte_pos == 4) { | 567 if (byte_pos == 4) { |
| 584 result += ch; | 568 result += ch; |
| 585 byte_pos = 0; | 569 byte_pos = 0; |
| 586 ch = 0; | 570 ch = 0; |
| 587 } | 571 } |
| 588 } | 572 } |
| 589 return result; | 573 return result; |
| 590 } | 574 } |
| 591 if (buf[0] == '(') { | |
| 592 } | |
| 593 return result; | 575 return result; |
| 594 } | 576 } |
| 595 void CPDF_ToUnicodeMap::Load(CPDF_Stream* pStream) { | 577 void CPDF_ToUnicodeMap::Load(CPDF_Stream* pStream) { |
| 596 CIDSet cid_set = CIDSET_UNKNOWN; | 578 CIDSet cid_set = CIDSET_UNKNOWN; |
| 597 CPDF_StreamAcc stream; | 579 CPDF_StreamAcc stream; |
| 598 stream.LoadAllData(pStream, FALSE); | 580 stream.LoadAllData(pStream, FALSE); |
| 599 CPDF_SimpleParser parser(stream.GetData(), stream.GetSize()); | 581 CPDF_SimpleParser parser(stream.GetData(), stream.GetSize()); |
| 600 while (1) { | 582 while (1) { |
| 601 CFX_ByteStringC word = parser.GetWord(); | 583 CFX_ByteStringC word = parser.GetWord(); |
| 602 if (word.IsEmpty()) { | 584 if (word.IsEmpty()) { |
| (...skipping 1178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1781 CPDF_Type3Char::CPDF_Type3Char() { | 1763 CPDF_Type3Char::CPDF_Type3Char() { |
| 1782 m_pForm = NULL; | 1764 m_pForm = NULL; |
| 1783 m_pBitmap = NULL; | 1765 m_pBitmap = NULL; |
| 1784 m_bPageRequired = FALSE; | 1766 m_bPageRequired = FALSE; |
| 1785 m_bColored = FALSE; | 1767 m_bColored = FALSE; |
| 1786 } | 1768 } |
| 1787 CPDF_Type3Char::~CPDF_Type3Char() { | 1769 CPDF_Type3Char::~CPDF_Type3Char() { |
| 1788 delete m_pForm; | 1770 delete m_pForm; |
| 1789 delete m_pBitmap; | 1771 delete m_pBitmap; |
| 1790 } | 1772 } |
| OLD | NEW |