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 <limits> | 7 #include <limits> |
8 | 8 |
9 #include "../../../include/fxge/fx_ge.h" | 9 #include "../../../include/fxge/fx_ge.h" |
10 #include "../../../include/fxge/fx_freetype.h" | 10 #include "../../../include/fxge/fx_freetype.h" |
(...skipping 1491 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1502 } else { | 1502 } else { |
1503 FX_DWORD nTables = pFont->m_FontTables.GetLength() / 16; | 1503 FX_DWORD nTables = pFont->m_FontTables.GetLength() / 16; |
1504 for (FX_DWORD i = 0; i < nTables; i++) { | 1504 for (FX_DWORD i = 0; i < nTables; i++) { |
1505 const uint8_t* p = (const uint8_t*)pFont->m_FontTables + i * 16; | 1505 const uint8_t* p = (const uint8_t*)pFont->m_FontTables + i * 16; |
1506 if (GET_TT_LONG(p) == table) { | 1506 if (GET_TT_LONG(p) == table) { |
1507 offset = GET_TT_LONG(p + 8); | 1507 offset = GET_TT_LONG(p + 8); |
1508 datasize = GET_TT_LONG(p + 12); | 1508 datasize = GET_TT_LONG(p + 12); |
1509 } | 1509 } |
1510 } | 1510 } |
1511 } | 1511 } |
1512 if (datasize && size >= datasize && pFile) { | 1512 if (datasize && size >= datasize && pFile) { |
Nico
2015/11/02 19:55:43
From how I understood the code, this check was sup
Lei Zhang
2015/11/02 19:59:09
Just because the buffer is big enough, and |pFile|
| |
1513 FXSYS_fseek(pFile, offset, FXSYS_SEEK_SET); | 1513 if (FXSYS_fseek(pFile, offset, FXSYS_SEEK_SET) < 0 || |
1514 FXSYS_fread(buffer, datasize, 1, pFile); | 1514 FXSYS_fread(buffer, datasize, 1, pFile) != 1) { |
1515 datasize = 0; | |
1516 } | |
1515 } | 1517 } |
1516 if (pFile) { | 1518 if (pFile) { |
1517 FXSYS_fclose(pFile); | 1519 FXSYS_fclose(pFile); |
1518 } | 1520 } |
1519 return datasize; | 1521 return datasize; |
1520 } | 1522 } |
1521 void CFX_FolderFontInfo::DeleteFont(void* hFont) {} | 1523 void CFX_FolderFontInfo::DeleteFont(void* hFont) {} |
1522 FX_BOOL CFX_FolderFontInfo::GetFaceName(void* hFont, CFX_ByteString& name) { | 1524 FX_BOOL CFX_FolderFontInfo::GetFaceName(void* hFont, CFX_ByteString& name) { |
1523 if (hFont == NULL) { | 1525 if (hFont == NULL) { |
1524 return FALSE; | 1526 return FALSE; |
1525 } | 1527 } |
1526 CFX_FontFaceInfo* pFont = (CFX_FontFaceInfo*)hFont; | 1528 CFX_FontFaceInfo* pFont = (CFX_FontFaceInfo*)hFont; |
1527 name = pFont->m_FaceName; | 1529 name = pFont->m_FaceName; |
1528 return TRUE; | 1530 return TRUE; |
1529 } | 1531 } |
1530 FX_BOOL CFX_FolderFontInfo::GetFontCharset(void* hFont, int& charset) { | 1532 FX_BOOL CFX_FolderFontInfo::GetFontCharset(void* hFont, int& charset) { |
1531 return FALSE; | 1533 return FALSE; |
1532 } | 1534 } |
1533 | 1535 |
1534 int PDF_GetStandardFontName(CFX_ByteString* name) { | 1536 int PDF_GetStandardFontName(CFX_ByteString* name) { |
1535 AltFontName* found = static_cast<AltFontName*>( | 1537 AltFontName* found = static_cast<AltFontName*>( |
1536 FXSYS_bsearch(name->c_str(), g_AltFontNames, FX_ArraySize(g_AltFontNames), | 1538 FXSYS_bsearch(name->c_str(), g_AltFontNames, FX_ArraySize(g_AltFontNames), |
1537 sizeof(AltFontName), compareString)); | 1539 sizeof(AltFontName), compareString)); |
1538 if (!found) | 1540 if (!found) |
1539 return -1; | 1541 return -1; |
1540 | 1542 |
1541 *name = g_Base14FontNames[found->m_Index]; | 1543 *name = g_Base14FontNames[found->m_Index]; |
1542 return found->m_Index; | 1544 return found->m_Index; |
1543 } | 1545 } |
OLD | NEW |