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 <limits> | 7 #include <limits> |
| 8 | 8 |
| 9 #include "core/include/fxge/fx_freetype.h" | 9 #include "core/include/fxge/fx_freetype.h" |
| 10 #include "core/include/fxge/fx_ge.h" | 10 #include "core/include/fxge/fx_ge.h" |
| (...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 308 fontName = "FrenchScriptMT"; | 308 fontName = "FrenchScriptMT"; |
| 309 } else if (fontName.Find("FreeStyle") >= 0) { | 309 } else if (fontName.Find("FreeStyle") >= 0) { |
| 310 fontName = "FreeStyleScript"; | 310 fontName = "FreeStyleScript"; |
| 311 } | 311 } |
| 312 return fontName; | 312 return fontName; |
| 313 } | 313 } |
| 314 AltFontFamily* found = (AltFontFamily*)FXSYS_bsearch( | 314 AltFontFamily* found = (AltFontFamily*)FXSYS_bsearch( |
| 315 fontName.c_str(), g_AltFontFamilies, | 315 fontName.c_str(), g_AltFontFamilies, |
| 316 sizeof g_AltFontFamilies / sizeof(AltFontFamily), sizeof(AltFontFamily), | 316 sizeof g_AltFontFamilies / sizeof(AltFontFamily), sizeof(AltFontFamily), |
| 317 CompareFontFamilyString); | 317 CompareFontFamilyString); |
| 318 if (found == NULL) { | 318 return found ? CFX_ByteString(found->m_pFontFamily) : fontName; |
| 319 return fontName; | |
| 320 } | |
| 321 return found->m_pFontFamily; | |
| 322 } | 319 } |
| 323 | 320 |
| 324 CFX_ByteString ParseStyle(const FX_CHAR* pStyle, int iLen, int iIndex) { | 321 CFX_ByteString ParseStyle(const FX_CHAR* pStyle, int iLen, int iIndex) { |
| 325 CFX_ByteTextBuf buf; | 322 CFX_ByteTextBuf buf; |
| 326 if (!iLen || iLen <= iIndex) { | 323 if (!iLen || iLen <= iIndex) { |
| 327 return buf.GetByteString(); | 324 return buf.GetByteString(); |
| 328 } | 325 } |
| 329 while (iIndex < iLen) { | 326 while (iIndex < iLen) { |
| 330 if (pStyle[iIndex] == ',') { | 327 if (pStyle[iIndex] == ',') { |
| 331 break; | 328 break; |
| (...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 672 FXFT_Done_Face(m_MMFaces[0]); | 669 FXFT_Done_Face(m_MMFaces[0]); |
| 673 } | 670 } |
| 674 if (m_MMFaces[1]) { | 671 if (m_MMFaces[1]) { |
| 675 FXFT_Done_Face(m_MMFaces[1]); | 672 FXFT_Done_Face(m_MMFaces[1]); |
| 676 } | 673 } |
| 677 if (m_pFontInfo) { | 674 if (m_pFontInfo) { |
| 678 m_pFontInfo->Release(); | 675 m_pFontInfo->Release(); |
| 679 } | 676 } |
| 680 } | 677 } |
| 681 void CFX_FontMapper::SetSystemFontInfo(IFX_SystemFontInfo* pFontInfo) { | 678 void CFX_FontMapper::SetSystemFontInfo(IFX_SystemFontInfo* pFontInfo) { |
| 682 if (pFontInfo == NULL) { | 679 if (!pFontInfo) { |
| 683 return; | 680 return; |
| 684 } | 681 } |
| 685 if (m_pFontInfo) { | 682 if (m_pFontInfo) { |
| 686 m_pFontInfo->Release(); | 683 m_pFontInfo->Release(); |
| 687 } | 684 } |
| 688 m_pFontInfo = pFontInfo; | 685 m_pFontInfo = pFontInfo; |
| 689 } | 686 } |
| 690 | 687 |
| 691 CFX_ByteString GetNameFromTT(const uint8_t* name_table, FX_DWORD name_id) { | 688 CFX_ByteString GetNameFromTT(const uint8_t* name_table, FX_DWORD name_id) { |
| 692 const uint8_t* ptr = name_table + 2; | 689 const uint8_t* ptr = name_table + 2; |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 714 return CFX_ByteString(); | 711 return CFX_ByteString(); |
| 715 | 712 |
| 716 std::vector<uint8_t> buffer(size); | 713 std::vector<uint8_t> buffer(size); |
| 717 uint8_t* buffer_ptr = pdfium::vector_as_array(&buffer); | 714 uint8_t* buffer_ptr = pdfium::vector_as_array(&buffer); |
| 718 FX_DWORD bytes_read = | 715 FX_DWORD bytes_read = |
| 719 m_pFontInfo->GetFontData(hFont, kTableNAME, buffer_ptr, size); | 716 m_pFontInfo->GetFontData(hFont, kTableNAME, buffer_ptr, size); |
| 720 return (bytes_read == size) ? GetNameFromTT(buffer_ptr, 6) : CFX_ByteString(); | 717 return (bytes_read == size) ? GetNameFromTT(buffer_ptr, 6) : CFX_ByteString(); |
| 721 } | 718 } |
| 722 | 719 |
| 723 void CFX_FontMapper::AddInstalledFont(const CFX_ByteString& name, int charset) { | 720 void CFX_FontMapper::AddInstalledFont(const CFX_ByteString& name, int charset) { |
| 724 if (m_pFontInfo == NULL) { | 721 if (!m_pFontInfo) { |
| 725 return; | 722 return; |
| 726 } | 723 } |
| 727 if (m_CharsetArray.Find((FX_DWORD)charset) == -1) { | 724 if (m_CharsetArray.Find((FX_DWORD)charset) == -1) { |
| 728 m_CharsetArray.Add((FX_DWORD)charset); | 725 m_CharsetArray.Add((FX_DWORD)charset); |
| 729 m_FaceArray.Add(name); | 726 m_FaceArray.Add(name); |
| 730 } | 727 } |
| 731 if (name == m_LastFamily) { | 728 if (name == m_LastFamily) { |
| 732 return; | 729 return; |
| 733 } | 730 } |
| 734 const uint8_t* ptr = name; | 731 const uint8_t* ptr = name; |
| 735 FX_BOOL bLocalized = FALSE; | 732 FX_BOOL bLocalized = FALSE; |
| 736 for (int i = 0; i < name.GetLength(); i++) | 733 for (int i = 0; i < name.GetLength(); i++) |
| 737 if (ptr[i] > 0x80) { | 734 if (ptr[i] > 0x80) { |
| 738 bLocalized = TRUE; | 735 bLocalized = TRUE; |
| 739 break; | 736 break; |
| 740 } | 737 } |
| 741 if (bLocalized) { | 738 if (bLocalized) { |
| 742 void* hFont = m_pFontInfo->GetFont(name); | 739 void* hFont = m_pFontInfo->GetFont(name); |
| 743 if (hFont == NULL) { | 740 if (!hFont) { |
| 744 int iExact; | 741 int iExact; |
| 745 hFont = | 742 hFont = |
| 746 m_pFontInfo->MapFont(0, 0, FXFONT_DEFAULT_CHARSET, 0, name, iExact); | 743 m_pFontInfo->MapFont(0, 0, FXFONT_DEFAULT_CHARSET, 0, name, iExact); |
| 747 if (hFont == NULL) { | 744 if (!hFont) { |
| 748 return; | 745 return; |
| 749 } | 746 } |
| 750 } | 747 } |
| 751 CFX_ByteString new_name = GetPSNameFromTT(hFont); | 748 CFX_ByteString new_name = GetPSNameFromTT(hFont); |
| 752 if (!new_name.IsEmpty()) { | 749 if (!new_name.IsEmpty()) { |
| 753 new_name.Insert(0, ' '); | 750 new_name.Insert(0, ' '); |
| 754 m_InstalledTTFonts.Add(new_name); | 751 m_InstalledTTFonts.Add(new_name); |
| 755 } | 752 } |
| 756 m_pFontInfo->DeleteFont(hFont); | 753 m_pFontInfo->DeleteFont(hFont); |
| 757 } | 754 } |
| 758 m_InstalledTTFonts.Add(name); | 755 m_InstalledTTFonts.Add(name); |
| 759 m_LastFamily = name; | 756 m_LastFamily = name; |
| 760 } | 757 } |
| 761 void CFX_FontMapper::LoadInstalledFonts() { | 758 void CFX_FontMapper::LoadInstalledFonts() { |
| 762 if (m_pFontInfo == NULL) { | 759 if (!m_pFontInfo) { |
| 763 return; | 760 return; |
| 764 } | 761 } |
| 765 if (m_bListLoaded) { | 762 if (m_bListLoaded) { |
| 766 return; | 763 return; |
| 767 } | 764 } |
| 768 if (m_bListLoaded) { | 765 if (m_bListLoaded) { |
| 769 return; | 766 return; |
| 770 } | 767 } |
| 771 m_pFontInfo->EnumFontList(this); | 768 m_pFontInfo->EnumFontList(this); |
| 772 m_bListLoaded = TRUE; | 769 m_bListLoaded = TRUE; |
| (...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1012 if (WindowCP) { | 1009 if (WindowCP) { |
| 1013 Charset = GetCharsetFromCodePage(WindowCP); | 1010 Charset = GetCharsetFromCodePage(WindowCP); |
| 1014 } else if (iBaseFont == 12 && (flags & FXFONT_SYMBOLIC)) { | 1011 } else if (iBaseFont == 12 && (flags & FXFONT_SYMBOLIC)) { |
| 1015 Charset = FXFONT_SYMBOL_CHARSET; | 1012 Charset = FXFONT_SYMBOL_CHARSET; |
| 1016 } | 1013 } |
| 1017 if (Charset == FXFONT_SHIFTJIS_CHARSET || Charset == FXFONT_GB2312_CHARSET || | 1014 if (Charset == FXFONT_SHIFTJIS_CHARSET || Charset == FXFONT_GB2312_CHARSET || |
| 1018 Charset == FXFONT_HANGEUL_CHARSET || | 1015 Charset == FXFONT_HANGEUL_CHARSET || |
| 1019 Charset == FXFONT_CHINESEBIG5_CHARSET) { | 1016 Charset == FXFONT_CHINESEBIG5_CHARSET) { |
| 1020 bCJK = TRUE; | 1017 bCJK = TRUE; |
| 1021 } | 1018 } |
| 1022 if (m_pFontInfo == NULL) { | 1019 if (!m_pFontInfo) { |
| 1023 pSubstFont->m_SubstFlags |= FXFONT_SUBST_STANDARD; | 1020 pSubstFont->m_SubstFlags |= FXFONT_SUBST_STANDARD; |
| 1024 return UseInternalSubst(pSubstFont, iBaseFont, italic_angle, old_weight, | 1021 return UseInternalSubst(pSubstFont, iBaseFont, italic_angle, old_weight, |
| 1025 PitchFamily); | 1022 PitchFamily); |
| 1026 } | 1023 } |
| 1027 family = GetFontFamily(family, nStyle); | 1024 family = GetFontFamily(family, nStyle); |
| 1028 CFX_ByteString match = MatchInstalledFonts(TT_NormalizeName(family)); | 1025 CFX_ByteString match = MatchInstalledFonts(TT_NormalizeName(family)); |
| 1029 if (match.IsEmpty() && family != SubstName && | 1026 if (match.IsEmpty() && family != SubstName && |
| 1030 (!bHasComma && (!bHasHypen || (bHasHypen && !bStyleAvail)))) { | 1027 (!bHasComma && (!bHasHypen || (bHasHypen && !bStyleAvail)))) { |
| 1031 match = MatchInstalledFonts(TT_NormalizeName(SubstName)); | 1028 match = MatchInstalledFonts(TT_NormalizeName(SubstName)); |
| 1032 } | 1029 } |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1081 if (flags & FXFONT_ITALIC) { | 1078 if (flags & FXFONT_ITALIC) { |
| 1082 bItalic = TRUE; | 1079 bItalic = TRUE; |
| 1083 } | 1080 } |
| 1084 } | 1081 } |
| 1085 iExact = !match.IsEmpty(); | 1082 iExact = !match.IsEmpty(); |
| 1086 void* hFont = m_pFontInfo->MapFont(weight, bItalic, Charset, PitchFamily, | 1083 void* hFont = m_pFontInfo->MapFont(weight, bItalic, Charset, PitchFamily, |
| 1087 family, iExact); | 1084 family, iExact); |
| 1088 if (iExact) { | 1085 if (iExact) { |
| 1089 pSubstFont->m_SubstFlags |= FXFONT_SUBST_EXACT; | 1086 pSubstFont->m_SubstFlags |= FXFONT_SUBST_EXACT; |
| 1090 } | 1087 } |
| 1091 if (hFont == NULL) { | 1088 if (!hFont) { |
|
Lei Zhang
2015/12/15 02:31:56
Conflicted here.
| |
| 1092 #ifdef PDF_ENABLE_XFA | 1089 #ifdef PDF_ENABLE_XFA |
| 1093 if (flags & FXFONT_EXACTMATCH) { | 1090 if (flags & FXFONT_EXACTMATCH) { |
| 1094 return NULL; | 1091 return NULL; |
| 1095 } | 1092 } |
| 1096 #endif // PDF_ENABLE_XFA | 1093 #endif // PDF_ENABLE_XFA |
| 1097 if (bCJK) { | 1094 if (bCJK) { |
| 1098 if (italic_angle != 0) { | 1095 if (italic_angle != 0) { |
| 1099 bItalic = TRUE; | 1096 bItalic = TRUE; |
| 1100 } else { | 1097 } else { |
| 1101 bItalic = FALSE; | 1098 bItalic = FALSE; |
| 1102 } | 1099 } |
| 1103 weight = old_weight; | 1100 weight = old_weight; |
| 1104 } | 1101 } |
| 1105 if (!match.IsEmpty()) { | 1102 if (!match.IsEmpty()) { |
| 1106 hFont = m_pFontInfo->GetFont(match); | 1103 hFont = m_pFontInfo->GetFont(match); |
| 1107 if (hFont == NULL) { | 1104 if (!hFont) { |
| 1108 return UseInternalSubst(pSubstFont, iBaseFont, italic_angle, old_weight, | 1105 return UseInternalSubst(pSubstFont, iBaseFont, italic_angle, old_weight, |
| 1109 PitchFamily); | 1106 PitchFamily); |
| 1110 } | 1107 } |
| 1111 } else { | 1108 } else { |
| 1112 if (Charset == FXFONT_SYMBOL_CHARSET) { | 1109 if (Charset == FXFONT_SYMBOL_CHARSET) { |
| 1113 #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ || \ | 1110 #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ || \ |
| 1114 _FXM_PLATFORM_ == _FXM_PLATFORM_ANDROID_ | 1111 _FXM_PLATFORM_ == _FXM_PLATFORM_ANDROID_ |
| 1115 if (SubstName == "Symbol") { | 1112 if (SubstName == "Symbol") { |
| 1116 pSubstFont->m_Family = "Chrome Symbol"; | 1113 pSubstFont->m_Family = "Chrome Symbol"; |
| 1117 pSubstFont->m_SubstFlags |= FXFONT_SUBST_STANDARD; | 1114 pSubstFont->m_SubstFlags |= FXFONT_SUBST_STANDARD; |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1161 if (ttc_size) { | 1158 if (ttc_size) { |
| 1162 uint8_t temp[1024]; | 1159 uint8_t temp[1024]; |
| 1163 m_pFontInfo->GetFontData(hFont, kTableTTCF, temp, 1024); | 1160 m_pFontInfo->GetFontData(hFont, kTableTTCF, temp, 1024); |
| 1164 FX_DWORD checksum = 0; | 1161 FX_DWORD checksum = 0; |
| 1165 for (int i = 0; i < 256; i++) { | 1162 for (int i = 0; i < 256; i++) { |
| 1166 checksum += ((FX_DWORD*)temp)[i]; | 1163 checksum += ((FX_DWORD*)temp)[i]; |
| 1167 } | 1164 } |
| 1168 uint8_t* pFontData; | 1165 uint8_t* pFontData; |
| 1169 face = m_pFontMgr->GetCachedTTCFace(ttc_size, checksum, | 1166 face = m_pFontMgr->GetCachedTTCFace(ttc_size, checksum, |
| 1170 ttc_size - font_size, pFontData); | 1167 ttc_size - font_size, pFontData); |
| 1171 if (face == NULL) { | 1168 if (!face) { |
| 1172 pFontData = FX_Alloc(uint8_t, ttc_size); | 1169 pFontData = FX_Alloc(uint8_t, ttc_size); |
| 1173 m_pFontInfo->GetFontData(hFont, kTableTTCF, pFontData, ttc_size); | 1170 m_pFontInfo->GetFontData(hFont, kTableTTCF, pFontData, ttc_size); |
| 1174 face = m_pFontMgr->AddCachedTTCFace(ttc_size, checksum, pFontData, | 1171 face = m_pFontMgr->AddCachedTTCFace(ttc_size, checksum, pFontData, |
| 1175 ttc_size, ttc_size - font_size); | 1172 ttc_size, ttc_size - font_size); |
| 1176 } | 1173 } |
| 1177 } else { | 1174 } else { |
| 1178 uint8_t* pFontData; | 1175 uint8_t* pFontData; |
| 1179 face = m_pFontMgr->GetCachedFace(SubstName, weight, bItalic, pFontData); | 1176 face = m_pFontMgr->GetCachedFace(SubstName, weight, bItalic, pFontData); |
| 1180 if (face == NULL) { | 1177 if (!face) { |
| 1181 pFontData = FX_Alloc(uint8_t, font_size); | 1178 pFontData = FX_Alloc(uint8_t, font_size); |
| 1182 m_pFontInfo->GetFontData(hFont, 0, pFontData, font_size); | 1179 m_pFontInfo->GetFontData(hFont, 0, pFontData, font_size); |
| 1183 face = m_pFontMgr->AddCachedFace(SubstName, weight, bItalic, pFontData, | 1180 face = m_pFontMgr->AddCachedFace(SubstName, weight, bItalic, pFontData, |
| 1184 font_size, | 1181 font_size, |
| 1185 m_pFontInfo->GetFaceIndex(hFont)); | 1182 m_pFontInfo->GetFaceIndex(hFont)); |
| 1186 } | 1183 } |
| 1187 } | 1184 } |
| 1188 if (face == NULL) { | 1185 if (!face) { |
| 1189 m_pFontInfo->DeleteFont(hFont); | 1186 m_pFontInfo->DeleteFont(hFont); |
| 1190 return NULL; | 1187 return NULL; |
| 1191 } | 1188 } |
| 1192 pSubstFont->m_Family = SubstName; | 1189 pSubstFont->m_Family = SubstName; |
| 1193 pSubstFont->m_Charset = Charset; | 1190 pSubstFont->m_Charset = Charset; |
| 1194 FX_BOOL bNeedUpdateWeight = FALSE; | 1191 FX_BOOL bNeedUpdateWeight = FALSE; |
| 1195 if (FXFT_Is_Face_Bold(face)) { | 1192 if (FXFT_Is_Face_Bold(face)) { |
| 1196 if (weight == FXFONT_FW_BOLD) { | 1193 if (weight == FXFONT_FW_BOLD) { |
| 1197 bNeedUpdateWeight = FALSE; | 1194 bNeedUpdateWeight = FALSE; |
| 1198 } else { | 1195 } else { |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1330 } | 1327 } |
| 1331 FX_BOOL CFX_FolderFontInfo::EnumFontList(CFX_FontMapper* pMapper) { | 1328 FX_BOOL CFX_FolderFontInfo::EnumFontList(CFX_FontMapper* pMapper) { |
| 1332 m_pMapper = pMapper; | 1329 m_pMapper = pMapper; |
| 1333 for (int i = 0; i < m_PathList.GetSize(); i++) { | 1330 for (int i = 0; i < m_PathList.GetSize(); i++) { |
| 1334 ScanPath(m_PathList[i]); | 1331 ScanPath(m_PathList[i]); |
| 1335 } | 1332 } |
| 1336 return TRUE; | 1333 return TRUE; |
| 1337 } | 1334 } |
| 1338 void CFX_FolderFontInfo::ScanPath(CFX_ByteString& path) { | 1335 void CFX_FolderFontInfo::ScanPath(CFX_ByteString& path) { |
| 1339 void* handle = FX_OpenFolder(path); | 1336 void* handle = FX_OpenFolder(path); |
| 1340 if (handle == NULL) { | 1337 if (!handle) { |
| 1341 return; | 1338 return; |
| 1342 } | 1339 } |
| 1343 CFX_ByteString filename; | 1340 CFX_ByteString filename; |
| 1344 FX_BOOL bFolder; | 1341 FX_BOOL bFolder; |
| 1345 while (FX_GetNextFile(handle, filename, bFolder)) { | 1342 while (FX_GetNextFile(handle, filename, bFolder)) { |
| 1346 if (bFolder) { | 1343 if (bFolder) { |
| 1347 if (filename == "." || filename == "..") { | 1344 if (filename == "." || filename == "..") { |
| 1348 continue; | 1345 continue; |
| 1349 } | 1346 } |
| 1350 } else { | 1347 } else { |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 1364 if (bFolder) { | 1361 if (bFolder) { |
| 1365 ScanPath(fullpath); | 1362 ScanPath(fullpath); |
| 1366 } else { | 1363 } else { |
| 1367 ScanFile(fullpath); | 1364 ScanFile(fullpath); |
| 1368 } | 1365 } |
| 1369 } | 1366 } |
| 1370 FX_CloseFolder(handle); | 1367 FX_CloseFolder(handle); |
| 1371 } | 1368 } |
| 1372 void CFX_FolderFontInfo::ScanFile(CFX_ByteString& path) { | 1369 void CFX_FolderFontInfo::ScanFile(CFX_ByteString& path) { |
| 1373 FXSYS_FILE* pFile = FXSYS_fopen(path, "rb"); | 1370 FXSYS_FILE* pFile = FXSYS_fopen(path, "rb"); |
| 1374 if (pFile == NULL) { | 1371 if (!pFile) { |
| 1375 return; | 1372 return; |
| 1376 } | 1373 } |
| 1377 FXSYS_fseek(pFile, 0, FXSYS_SEEK_END); | 1374 FXSYS_fseek(pFile, 0, FXSYS_SEEK_END); |
| 1378 FX_DWORD filesize = FXSYS_ftell(pFile); | 1375 FX_DWORD filesize = FXSYS_ftell(pFile); |
| 1379 uint8_t buffer[16]; | 1376 uint8_t buffer[16]; |
| 1380 FXSYS_fseek(pFile, 0, FXSYS_SEEK_SET); | 1377 FXSYS_fseek(pFile, 0, FXSYS_SEEK_SET); |
| 1381 size_t readCnt = FXSYS_fread(buffer, 12, 1, pFile); | 1378 size_t readCnt = FXSYS_fread(buffer, 12, 1, pFile); |
| 1382 if (readCnt != 1) { | 1379 if (readCnt != 1) { |
| 1383 FXSYS_fclose(pFile); | 1380 FXSYS_fclose(pFile); |
| 1384 return; | 1381 return; |
| (...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1575 if (FXSYS_fseek(pFile, offset, FXSYS_SEEK_SET) < 0 || | 1572 if (FXSYS_fseek(pFile, offset, FXSYS_SEEK_SET) < 0 || |
| 1576 FXSYS_fread(buffer, datasize, 1, pFile) != 1) { | 1573 FXSYS_fread(buffer, datasize, 1, pFile) != 1) { |
| 1577 datasize = 0; | 1574 datasize = 0; |
| 1578 } | 1575 } |
| 1579 FXSYS_fclose(pFile); | 1576 FXSYS_fclose(pFile); |
| 1580 return datasize; | 1577 return datasize; |
| 1581 } | 1578 } |
| 1582 | 1579 |
| 1583 void CFX_FolderFontInfo::DeleteFont(void* hFont) {} | 1580 void CFX_FolderFontInfo::DeleteFont(void* hFont) {} |
| 1584 FX_BOOL CFX_FolderFontInfo::GetFaceName(void* hFont, CFX_ByteString& name) { | 1581 FX_BOOL CFX_FolderFontInfo::GetFaceName(void* hFont, CFX_ByteString& name) { |
| 1585 if (hFont == NULL) { | 1582 if (!hFont) { |
| 1586 return FALSE; | 1583 return FALSE; |
| 1587 } | 1584 } |
| 1588 CFX_FontFaceInfo* pFont = (CFX_FontFaceInfo*)hFont; | 1585 CFX_FontFaceInfo* pFont = (CFX_FontFaceInfo*)hFont; |
| 1589 name = pFont->m_FaceName; | 1586 name = pFont->m_FaceName; |
| 1590 return TRUE; | 1587 return TRUE; |
| 1591 } | 1588 } |
| 1592 FX_BOOL CFX_FolderFontInfo::GetFontCharset(void* hFont, int& charset) { | 1589 FX_BOOL CFX_FolderFontInfo::GetFontCharset(void* hFont, int& charset) { |
| 1593 return FALSE; | 1590 return FALSE; |
| 1594 } | 1591 } |
| 1595 | 1592 |
| 1596 int PDF_GetStandardFontName(CFX_ByteString* name) { | 1593 int PDF_GetStandardFontName(CFX_ByteString* name) { |
| 1597 AltFontName* found = static_cast<AltFontName*>( | 1594 AltFontName* found = static_cast<AltFontName*>( |
| 1598 FXSYS_bsearch(name->c_str(), g_AltFontNames, FX_ArraySize(g_AltFontNames), | 1595 FXSYS_bsearch(name->c_str(), g_AltFontNames, FX_ArraySize(g_AltFontNames), |
| 1599 sizeof(AltFontName), CompareString)); | 1596 sizeof(AltFontName), CompareString)); |
| 1600 if (!found) | 1597 if (!found) |
| 1601 return -1; | 1598 return -1; |
| 1602 | 1599 |
| 1603 *name = g_Base14FontNames[found->m_Index]; | 1600 *name = g_Base14FontNames[found->m_Index]; |
| 1604 return found->m_Index; | 1601 return found->m_Index; |
| 1605 } | 1602 } |
| OLD | NEW |