| 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 546 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 557 } | 557 } |
| 558 CFX_ByteString CFX_FontMapper::GetPSNameFromTT(void* hFont) | 558 CFX_ByteString CFX_FontMapper::GetPSNameFromTT(void* hFont) |
| 559 { | 559 { |
| 560 if (m_pFontInfo == NULL) { | 560 if (m_pFontInfo == NULL) { |
| 561 CFX_ByteString(); | 561 CFX_ByteString(); |
| 562 } | 562 } |
| 563 CFX_ByteString result; | 563 CFX_ByteString result; |
| 564 FX_DWORD size = m_pFontInfo->GetFontData(hFont, 0x6e616d65, NULL, 0); | 564 FX_DWORD size = m_pFontInfo->GetFontData(hFont, 0x6e616d65, NULL, 0); |
| 565 if (size) { | 565 if (size) { |
| 566 FX_LPBYTE buffer = FX_Alloc(FX_BYTE, size); | 566 FX_LPBYTE buffer = FX_Alloc(FX_BYTE, size); |
| 567 if (!buffer) { | |
| 568 return result; | |
| 569 } | |
| 570 m_pFontInfo->GetFontData(hFont, 0x6e616d65, buffer, size); | 567 m_pFontInfo->GetFontData(hFont, 0x6e616d65, buffer, size); |
| 571 result = _FPDF_GetNameFromTT(buffer, 6); | 568 result = _FPDF_GetNameFromTT(buffer, 6); |
| 572 FX_Free(buffer); | 569 FX_Free(buffer); |
| 573 } | 570 } |
| 574 return result; | 571 return result; |
| 575 } | 572 } |
| 576 void CFX_FontMapper::AddInstalledFont(const CFX_ByteString& name, int charset) | 573 void CFX_FontMapper::AddInstalledFont(const CFX_ByteString& name, int charset) |
| 577 { | 574 { |
| 578 if (m_pFontInfo == NULL) { | 575 if (m_pFontInfo == NULL) { |
| 579 return; | 576 return; |
| (...skipping 622 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1202 FX_BYTE temp[1024]; | 1199 FX_BYTE temp[1024]; |
| 1203 m_pFontInfo->GetFontData(hFont, 0x74746366, temp, 1024); | 1200 m_pFontInfo->GetFontData(hFont, 0x74746366, temp, 1024); |
| 1204 FX_DWORD checksum = 0; | 1201 FX_DWORD checksum = 0; |
| 1205 for (int i = 0; i < 256; i ++) { | 1202 for (int i = 0; i < 256; i ++) { |
| 1206 checksum += ((FX_DWORD*)temp)[i]; | 1203 checksum += ((FX_DWORD*)temp)[i]; |
| 1207 } | 1204 } |
| 1208 FX_LPBYTE pFontData; | 1205 FX_LPBYTE pFontData; |
| 1209 face = m_pFontMgr->GetCachedTTCFace(ttc_size, checksum, ttc_size - font_
size, pFontData); | 1206 face = m_pFontMgr->GetCachedTTCFace(ttc_size, checksum, ttc_size - font_
size, pFontData); |
| 1210 if (face == NULL) { | 1207 if (face == NULL) { |
| 1211 pFontData = FX_Alloc(FX_BYTE, ttc_size); | 1208 pFontData = FX_Alloc(FX_BYTE, ttc_size); |
| 1212 if (pFontData) { | 1209 m_pFontInfo->GetFontData(hFont, 0x74746366, pFontData, ttc_size); |
| 1213 m_pFontInfo->GetFontData(hFont, 0x74746366, pFontData, ttc_size)
; | 1210 face = m_pFontMgr->AddCachedTTCFace(ttc_size, checksum, pFontData, t
tc_size, |
| 1214 face = m_pFontMgr->AddCachedTTCFace(ttc_size, checksum, pFontDat
a, ttc_size, | 1211 ttc_size - font_size); |
| 1215 ttc_size - font_size); | |
| 1216 } | |
| 1217 } | 1212 } |
| 1218 } else { | 1213 } else { |
| 1219 FX_LPBYTE pFontData; | 1214 FX_LPBYTE pFontData; |
| 1220 face = m_pFontMgr->GetCachedFace(SubstName, weight, bItalic, pFontData); | 1215 face = m_pFontMgr->GetCachedFace(SubstName, weight, bItalic, pFontData); |
| 1221 if (face == NULL) { | 1216 if (face == NULL) { |
| 1222 pFontData = FX_Alloc(FX_BYTE, font_size); | 1217 pFontData = FX_Alloc(FX_BYTE, font_size); |
| 1223 if (!pFontData) { | |
| 1224 m_pFontInfo->DeleteFont(hFont); | |
| 1225 return NULL; | |
| 1226 } | |
| 1227 m_pFontInfo->GetFontData(hFont, 0, pFontData, font_size); | 1218 m_pFontInfo->GetFontData(hFont, 0, pFontData, font_size); |
| 1228 face = m_pFontMgr->AddCachedFace(SubstName, weight, bItalic, pFontDa
ta, font_size, m_pFontInfo->GetFaceIndex(hFont)); | 1219 face = m_pFontMgr->AddCachedFace(SubstName, weight, bItalic, pFontDa
ta, font_size, m_pFontInfo->GetFaceIndex(hFont)); |
| 1229 } | 1220 } |
| 1230 } | 1221 } |
| 1231 if (face == NULL) { | 1222 if (face == NULL) { |
| 1232 m_pFontInfo->DeleteFont(hFont); | 1223 m_pFontInfo->DeleteFont(hFont); |
| 1233 return NULL; | 1224 return NULL; |
| 1234 } | 1225 } |
| 1235 pSubstFont->m_Family = SubstName; | 1226 pSubstFont->m_Family = SubstName; |
| 1236 pSubstFont->m_Charset = Charset; | 1227 pSubstFont->m_Charset = Charset; |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1373 } | 1364 } |
| 1374 | 1365 |
| 1375 if (GET_TT_LONG(buffer) == 0x74746366) { | 1366 if (GET_TT_LONG(buffer) == 0x74746366) { |
| 1376 FX_DWORD nFaces = GET_TT_LONG(buffer + 8); | 1367 FX_DWORD nFaces = GET_TT_LONG(buffer + 8); |
| 1377 if (nFaces > FX_DWORD_MAX / 4) { | 1368 if (nFaces > FX_DWORD_MAX / 4) { |
| 1378 FXSYS_fclose(pFile); | 1369 FXSYS_fclose(pFile); |
| 1379 return; | 1370 return; |
| 1380 } | 1371 } |
| 1381 FX_DWORD face_bytes = nFaces * 4; | 1372 FX_DWORD face_bytes = nFaces * 4; |
| 1382 FX_LPBYTE offsets = FX_Alloc(FX_BYTE, face_bytes); | 1373 FX_LPBYTE offsets = FX_Alloc(FX_BYTE, face_bytes); |
| 1383 if (!offsets) { | |
| 1384 FXSYS_fclose(pFile); | |
| 1385 return; | |
| 1386 } | |
| 1387 readCnt = FXSYS_fread(offsets, face_bytes, 1, pFile); | 1374 readCnt = FXSYS_fread(offsets, face_bytes, 1, pFile); |
| 1388 if (readCnt != face_bytes) { | 1375 if (readCnt != face_bytes) { |
| 1389 FX_Free(offsets); | 1376 FX_Free(offsets); |
| 1390 FXSYS_fclose(pFile); | 1377 FXSYS_fclose(pFile); |
| 1391 return; | 1378 return; |
| 1392 } | 1379 } |
| 1393 for (FX_DWORD i = 0; i < nFaces; i ++) { | 1380 for (FX_DWORD i = 0; i < nFaces; i ++) { |
| 1394 FX_LPBYTE p = offsets + i * 4; | 1381 FX_LPBYTE p = offsets + i * 4; |
| 1395 ReportFace(path, pFile, filesize, GET_TT_LONG(p)); | 1382 ReportFace(path, pFile, filesize, GET_TT_LONG(p)); |
| 1396 } | 1383 } |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1529 return FALSE; | 1516 return FALSE; |
| 1530 } | 1517 } |
| 1531 CFontFaceInfo* pFont = (CFontFaceInfo*)hFont; | 1518 CFontFaceInfo* pFont = (CFontFaceInfo*)hFont; |
| 1532 name = pFont->m_FaceName; | 1519 name = pFont->m_FaceName; |
| 1533 return TRUE; | 1520 return TRUE; |
| 1534 } | 1521 } |
| 1535 FX_BOOL CFX_FolderFontInfo::GetFontCharset(void* hFont, int& charset) | 1522 FX_BOOL CFX_FolderFontInfo::GetFontCharset(void* hFont, int& charset) |
| 1536 { | 1523 { |
| 1537 return FALSE; | 1524 return FALSE; |
| 1538 } | 1525 } |
| OLD | NEW |