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 <algorithm> | 7 #include <algorithm> |
8 #include <limits> | 8 #include <limits> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 663 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
674 } | 674 } |
675 void CFX_FontMapper::SetSystemFontInfo(IFX_SystemFontInfo* pFontInfo) { | 675 void CFX_FontMapper::SetSystemFontInfo(IFX_SystemFontInfo* pFontInfo) { |
676 if (!pFontInfo) { | 676 if (!pFontInfo) { |
677 return; | 677 return; |
678 } | 678 } |
679 if (m_pFontInfo) { | 679 if (m_pFontInfo) { |
680 m_pFontInfo->Release(); | 680 m_pFontInfo->Release(); |
681 } | 681 } |
682 m_pFontInfo = pFontInfo; | 682 m_pFontInfo = pFontInfo; |
683 } | 683 } |
| 684 |
684 static CFX_ByteString GetStringFromTable(const uint8_t* string_ptr, | 685 static CFX_ByteString GetStringFromTable(const uint8_t* string_ptr, |
685 uint32_t string_ptr_length, | 686 uint32_t string_ptr_length, |
686 uint16_t offset, | 687 uint16_t offset, |
687 uint16_t length) { | 688 uint16_t length) { |
688 if (string_ptr_length < offset + length) { | 689 if (string_ptr_length < static_cast<uint32_t>(offset + length)) { |
689 return CFX_ByteString(); | 690 return CFX_ByteString(); |
690 } | 691 } |
691 return CFX_ByteStringC(string_ptr + offset, length); | 692 return CFX_ByteStringC(string_ptr + offset, length); |
692 } | 693 } |
| 694 |
693 CFX_ByteString GetNameFromTT(const uint8_t* name_table, | 695 CFX_ByteString GetNameFromTT(const uint8_t* name_table, |
694 uint32_t name_table_size, | 696 uint32_t name_table_size, |
695 uint32_t name_id) { | 697 uint32_t name_id) { |
696 if (!name_table || name_table_size < 6) { | 698 if (!name_table || name_table_size < 6) { |
697 return CFX_ByteString(); | 699 return CFX_ByteString(); |
698 } | 700 } |
699 uint32_t name_count = GET_TT_SHORT(name_table + 2); | 701 uint32_t name_count = GET_TT_SHORT(name_table + 2); |
700 uint32_t string_offset = GET_TT_SHORT(name_table + 4); | 702 uint32_t string_offset = GET_TT_SHORT(name_table + 4); |
701 // We will ignore the possibility of overlap of structures and | 703 // We will ignore the possibility of overlap of structures and |
702 // string table as if it's all corrupt there's not a lot we can do. | 704 // string table as if it's all corrupt there's not a lot we can do. |
(...skipping 939 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1642 int PDF_GetStandardFontName(CFX_ByteString* name) { | 1644 int PDF_GetStandardFontName(CFX_ByteString* name) { |
1643 AltFontName* found = static_cast<AltFontName*>( | 1645 AltFontName* found = static_cast<AltFontName*>( |
1644 FXSYS_bsearch(name->c_str(), g_AltFontNames, FX_ArraySize(g_AltFontNames), | 1646 FXSYS_bsearch(name->c_str(), g_AltFontNames, FX_ArraySize(g_AltFontNames), |
1645 sizeof(AltFontName), CompareString)); | 1647 sizeof(AltFontName), CompareString)); |
1646 if (!found) | 1648 if (!found) |
1647 return -1; | 1649 return -1; |
1648 | 1650 |
1649 *name = g_Base14FontNames[found->m_Index]; | 1651 *name = g_Base14FontNames[found->m_Index]; |
1650 return found->m_Index; | 1652 return found->m_Index; |
1651 } | 1653 } |
OLD | NEW |