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/fxge/fx_ge.h" | 7 #include "../../../include/fxge/fx_ge.h" |
8 #include "../../../include/fxge/fx_freetype.h" | 8 #include "../../../include/fxge/fx_freetype.h" |
9 #include "text_int.h" | 9 #include "text_int.h" |
10 #define GET_TT_SHORT(w) (FX_WORD)(((w)[0] << 8) | (w)[1]) | 10 #define GET_TT_SHORT(w) (FX_WORD)(((w)[0] << 8) | (w)[1]) |
(...skipping 1446 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1457 { | 1457 { |
1458 FXSYS_FILE* pFile = FXSYS_fopen(path, "rb"); | 1458 FXSYS_FILE* pFile = FXSYS_fopen(path, "rb"); |
1459 if (pFile == NULL) { | 1459 if (pFile == NULL) { |
1460 return; | 1460 return; |
1461 } | 1461 } |
1462 FXSYS_fseek(pFile, 0, FXSYS_SEEK_END); | 1462 FXSYS_fseek(pFile, 0, FXSYS_SEEK_END); |
1463 FX_DWORD filesize = FXSYS_ftell(pFile); | 1463 FX_DWORD filesize = FXSYS_ftell(pFile); |
1464 FX_BYTE buffer[16]; | 1464 FX_BYTE buffer[16]; |
1465 FXSYS_fseek(pFile, 0, FXSYS_SEEK_SET); | 1465 FXSYS_fseek(pFile, 0, FXSYS_SEEK_SET); |
1466 size_t readCnt = FXSYS_fread(buffer, 12, 1, pFile); | 1466 size_t readCnt = FXSYS_fread(buffer, 12, 1, pFile); |
| 1467 if (readCnt != 1) { |
| 1468 FXSYS_fclose(pFile); |
| 1469 return; |
| 1470 } |
| 1471 |
1467 if (GET_TT_LONG(buffer) == 0x74746366) { | 1472 if (GET_TT_LONG(buffer) == 0x74746366) { |
1468 FX_DWORD nFaces = GET_TT_LONG(buffer + 8); | 1473 FX_DWORD nFaces = GET_TT_LONG(buffer + 8); |
1469 FX_LPBYTE offsets = FX_Alloc(FX_BYTE, nFaces * 4); | 1474 if (nFaces > FX_DWORD_MAX / 4) { |
| 1475 FXSYS_fclose(pFile); |
| 1476 return; |
| 1477 } |
| 1478 FX_DWORD face_bytes = nFaces * 4; |
| 1479 FX_LPBYTE offsets = FX_Alloc(FX_BYTE, face_bytes); |
1470 if (!offsets) { | 1480 if (!offsets) { |
1471 FXSYS_fclose(pFile); | 1481 FXSYS_fclose(pFile); |
1472 return; | 1482 return; |
1473 } | 1483 } |
1474 readCnt = FXSYS_fread(offsets, nFaces * 4, 1, pFile); | 1484 readCnt = FXSYS_fread(offsets, face_bytes, 1, pFile); |
| 1485 if (readCnt != face_bytes) { |
| 1486 FX_Free(offsets); |
| 1487 FXSYS_fclose(pFile); |
| 1488 return; |
| 1489 } |
1475 for (FX_DWORD i = 0; i < nFaces; i ++) { | 1490 for (FX_DWORD i = 0; i < nFaces; i ++) { |
1476 FX_LPBYTE p = offsets + i * 4; | 1491 FX_LPBYTE p = offsets + i * 4; |
1477 ReportFace(path, pFile, filesize, GET_TT_LONG(p)); | 1492 ReportFace(path, pFile, filesize, GET_TT_LONG(p)); |
1478 } | 1493 } |
1479 FX_Free(offsets); | 1494 FX_Free(offsets); |
1480 } else { | 1495 } else { |
1481 ReportFace(path, pFile, filesize, 0); | 1496 ReportFace(path, pFile, filesize, 0); |
1482 } | 1497 } |
1483 FXSYS_fclose(pFile); | 1498 FXSYS_fclose(pFile); |
1484 } | 1499 } |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1618 return FALSE; | 1633 return FALSE; |
1619 } | 1634 } |
1620 CFontFaceInfo* pFont = (CFontFaceInfo*)hFont; | 1635 CFontFaceInfo* pFont = (CFontFaceInfo*)hFont; |
1621 name = pFont->m_FaceName; | 1636 name = pFont->m_FaceName; |
1622 return TRUE; | 1637 return TRUE; |
1623 } | 1638 } |
1624 FX_BOOL CFX_FolderFontInfo::GetFontCharset(void* hFont, int& charset) | 1639 FX_BOOL CFX_FolderFontInfo::GetFontCharset(void* hFont, int& charset) |
1625 { | 1640 { |
1626 return FALSE; | 1641 return FALSE; |
1627 } | 1642 } |
OLD | NEW |