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 480 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 501 } | 502 } |
| 502 return CFX_WideString(); | 503 return CFX_WideString(); |
| 503 } | 504 } |
| 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) { |
|
Tom Sepez
2015/10/29 19:28:31
test, or test caller.
dsinclair
2015/11/03 15:59:02
https://codereview.chromium.org/1428593005
| |
| 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; i++) { |
| 520 int digit; | 521 if (!std::isxdigit(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; | 522 break; |
| 529 } | 523 result = result * 16 + HexCharToDigit(buf[i]); |
| 530 result = result * 16 + digit; | |
| 531 } | 524 } |
| 532 return result; | 525 return result; |
| 533 } | 526 } |
| 527 | |
| 534 for (int i = 0; i < len; i++) { | 528 for (int i = 0; i < len; i++) { |
| 535 if (buf[i] < '0' || buf[i] > '9') { | 529 if (!std::isdigit(buf[i])) |
| 536 break; | 530 break; |
| 537 } | |
| 538 result = result * 10 + buf[i] - '0'; | 531 result = result * 10 + buf[i] - '0'; |
| 539 } | 532 } |
| 533 | |
| 540 return result; | 534 return result; |
| 541 } | 535 } |
| 542 static CFX_WideString _StringDataAdd(CFX_WideString str) { | 536 static CFX_WideString _StringDataAdd(CFX_WideString str) { |
| 543 CFX_WideString ret; | 537 CFX_WideString ret; |
| 544 int len = str.GetLength(); | 538 int len = str.GetLength(); |
| 545 FX_WCHAR value = 1; | 539 FX_WCHAR value = 1; |
| 546 for (int i = len - 1; i >= 0; --i) { | 540 for (int i = len - 1; i >= 0; --i) { |
| 547 FX_WCHAR ch = str[i] + value; | 541 FX_WCHAR ch = str[i] + value; |
| 548 if (ch < str[i]) { | 542 if (ch < str[i]) { |
| 549 ret.Insert(0, 0); | 543 ret.Insert(0, 0); |
| 550 } else { | 544 } else { |
| 551 ret.Insert(0, ch); | 545 ret.Insert(0, ch); |
| 552 value = 0; | 546 value = 0; |
| 553 } | 547 } |
| 554 } | 548 } |
| 555 if (value) { | 549 if (value) { |
| 556 ret.Insert(0, value); | 550 ret.Insert(0, value); |
| 557 } | 551 } |
| 558 return ret; | 552 return ret; |
| 559 } | 553 } |
| 560 static CFX_WideString _StringToWideString(const CFX_ByteStringC& str) { | 554 static CFX_WideString _StringToWideString(const CFX_ByteStringC& str) { |
|
Tom Sepez
2015/10/29 19:28:31
test, or test caller.
dsinclair
2015/11/03 15:59:01
https://codereview.chromium.org/1428593005
| |
| 561 const FX_CHAR* buf = str.GetCStr(); | 555 const FX_CHAR* buf = str.GetCStr(); |
| 562 int len = str.GetLength(); | 556 int len = str.GetLength(); |
| 563 if (len == 0) { | 557 if (len == 0) |
| 564 return CFX_WideString(); | 558 return CFX_WideString(); |
| 565 } | 559 |
| 566 CFX_WideString result; | 560 CFX_WideString result; |
| 567 if (buf[0] == '<') { | 561 if (buf[0] == '<') { |
| 568 int byte_pos = 0; | 562 int byte_pos = 0; |
| 569 FX_WCHAR ch = 0; | 563 FX_WCHAR ch = 0; |
| 570 for (int i = 1; i < len; i++) { | 564 for (int i = 1; i < len; i++) { |
| 571 int digit; | 565 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; | 566 break; |
| 580 } | 567 |
| 581 ch = ch * 16 + digit; | 568 ch = ch * 16 + HexCharToDigit(buf[i]); |
| 582 byte_pos++; | 569 byte_pos++; |
| 583 if (byte_pos == 4) { | 570 if (byte_pos == 4) { |
| 584 result += ch; | 571 result += ch; |
| 585 byte_pos = 0; | 572 byte_pos = 0; |
| 586 ch = 0; | 573 ch = 0; |
| 587 } | 574 } |
| 588 } | 575 } |
| 589 return result; | 576 return result; |
| 590 } | 577 } |
| 591 if (buf[0] == '(') { | |
| 592 } | |
| 593 return result; | 578 return result; |
| 594 } | 579 } |
| 595 void CPDF_ToUnicodeMap::Load(CPDF_Stream* pStream) { | 580 void CPDF_ToUnicodeMap::Load(CPDF_Stream* pStream) { |
| 596 CIDSet cid_set = CIDSET_UNKNOWN; | 581 CIDSet cid_set = CIDSET_UNKNOWN; |
| 597 CPDF_StreamAcc stream; | 582 CPDF_StreamAcc stream; |
| 598 stream.LoadAllData(pStream, FALSE); | 583 stream.LoadAllData(pStream, FALSE); |
| 599 CPDF_SimpleParser parser(stream.GetData(), stream.GetSize()); | 584 CPDF_SimpleParser parser(stream.GetData(), stream.GetSize()); |
| 600 while (1) { | 585 while (1) { |
| 601 CFX_ByteStringC word = parser.GetWord(); | 586 CFX_ByteStringC word = parser.GetWord(); |
| 602 if (word.IsEmpty()) { | 587 if (word.IsEmpty()) { |
| (...skipping 1178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1781 CPDF_Type3Char::CPDF_Type3Char() { | 1766 CPDF_Type3Char::CPDF_Type3Char() { |
| 1782 m_pForm = NULL; | 1767 m_pForm = NULL; |
| 1783 m_pBitmap = NULL; | 1768 m_pBitmap = NULL; |
| 1784 m_bPageRequired = FALSE; | 1769 m_bPageRequired = FALSE; |
| 1785 m_bColored = FALSE; | 1770 m_bColored = FALSE; |
| 1786 } | 1771 } |
| 1787 CPDF_Type3Char::~CPDF_Type3Char() { | 1772 CPDF_Type3Char::~CPDF_Type3Char() { |
| 1788 delete m_pForm; | 1773 delete m_pForm; |
| 1789 delete m_pBitmap; | 1774 delete m_pBitmap; |
| 1790 } | 1775 } |
| OLD | NEW |