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 20 matching lines...) Expand all Loading... |
31 } else if (m_Type == 2) { | 31 } else if (m_Type == 2) { |
32 for (int i = 0; i < 16; i ++) | 32 for (int i = 0; i < 16; i ++) |
33 if (m_TTCFace.m_pFaces[i]) { | 33 if (m_TTCFace.m_pFaces[i]) { |
34 FXFT_Done_Face(m_TTCFace.m_pFaces[i]); | 34 FXFT_Done_Face(m_TTCFace.m_pFaces[i]); |
35 } | 35 } |
36 } | 36 } |
37 if (m_pFontData) { | 37 if (m_pFontData) { |
38 FX_Free(m_pFontData); | 38 FX_Free(m_pFontData); |
39 } | 39 } |
40 } | 40 } |
41 FX_INT32 CTTFontDesc::ReleaseFace(FXFT_Face face) | 41 int32_t CTTFontDesc::ReleaseFace(FXFT_Face face) |
42 { | 42 { |
43 if (m_Type == 1) { | 43 if (m_Type == 1) { |
44 if (m_SingleFace.m_pFace != face) { | 44 if (m_SingleFace.m_pFace != face) { |
45 return -1; | 45 return -1; |
46 } | 46 } |
47 } else if (m_Type == 2) { | 47 } else if (m_Type == 2) { |
48 int i; | 48 int i; |
49 for (i = 0; i < 16; i ++) | 49 for (i = 0; i < 16; i ++) |
50 if (m_TTCFace.m_pFaces[i] == face) { | 50 if (m_TTCFace.m_pFaces[i] == face) { |
51 break; | 51 break; |
(...skipping 523 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
575 return CFX_ByteString(); | 575 return CFX_ByteString(); |
576 } | 576 } |
577 CFX_ByteString CFX_FontMapper::GetPSNameFromTT(void* hFont) | 577 CFX_ByteString CFX_FontMapper::GetPSNameFromTT(void* hFont) |
578 { | 578 { |
579 if (m_pFontInfo == NULL) { | 579 if (m_pFontInfo == NULL) { |
580 CFX_ByteString(); | 580 CFX_ByteString(); |
581 } | 581 } |
582 CFX_ByteString result; | 582 CFX_ByteString result; |
583 FX_DWORD size = m_pFontInfo->GetFontData(hFont, 0x6e616d65, NULL, 0); | 583 FX_DWORD size = m_pFontInfo->GetFontData(hFont, 0x6e616d65, NULL, 0); |
584 if (size) { | 584 if (size) { |
585 FX_LPBYTE buffer = FX_Alloc(FX_BYTE, size); | 585 FX_LPBYTE buffer = FX_Alloc(uint8_t, size); |
586 m_pFontInfo->GetFontData(hFont, 0x6e616d65, buffer, size); | 586 m_pFontInfo->GetFontData(hFont, 0x6e616d65, buffer, size); |
587 result = _FPDF_GetNameFromTT(buffer, 6); | 587 result = _FPDF_GetNameFromTT(buffer, 6); |
588 FX_Free(buffer); | 588 FX_Free(buffer); |
589 } | 589 } |
590 return result; | 590 return result; |
591 } | 591 } |
592 void CFX_FontMapper::AddInstalledFont(const CFX_ByteString& name, int charset) | 592 void CFX_FontMapper::AddInstalledFont(const CFX_ByteString& name, int charset) |
593 { | 593 { |
594 if (m_pFontInfo == NULL) { | 594 if (m_pFontInfo == NULL) { |
595 return; | 595 return; |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
654 if (i < 0) { | 654 if (i < 0) { |
655 return CFX_ByteString(); | 655 return CFX_ByteString(); |
656 } | 656 } |
657 CFX_ByteString match = m_InstalledTTFonts[i]; | 657 CFX_ByteString match = m_InstalledTTFonts[i]; |
658 if (match[0] == ' ') { | 658 if (match[0] == ' ') { |
659 match = m_InstalledTTFonts[i + 1]; | 659 match = m_InstalledTTFonts[i + 1]; |
660 } | 660 } |
661 return match; | 661 return match; |
662 } | 662 } |
663 typedef struct _CHARSET_MAP_ { | 663 typedef struct _CHARSET_MAP_ { |
664 FX_BYTE charset; | 664 uint8_t charset; |
665 FX_WORD codepage; | 665 FX_WORD codepage; |
666 } CHARSET_MAP; | 666 } CHARSET_MAP; |
667 static const CHARSET_MAP g_Codepage2CharsetTable[] = { | 667 static const CHARSET_MAP g_Codepage2CharsetTable[] = { |
668 { 1 , 0 }, | 668 { 1 , 0 }, |
669 { 2 , 42 }, | 669 { 2 , 42 }, |
670 { 254, 437 }, | 670 { 254, 437 }, |
671 { 255, 850 }, | 671 { 255, 850 }, |
672 { 222, 874 }, | 672 { 222, 874 }, |
673 { 128, 932 }, | 673 { 128, 932 }, |
674 { 134, 936 }, | 674 { 134, 936 }, |
(...skipping 15 matching lines...) Expand all Loading... |
690 { 80, 10008 }, | 690 { 80, 10008 }, |
691 { 81, 10002 }, | 691 { 81, 10002 }, |
692 { 83, 10005 }, | 692 { 83, 10005 }, |
693 { 84, 10004 }, | 693 { 84, 10004 }, |
694 { 85, 10006 }, | 694 { 85, 10006 }, |
695 { 86, 10081 }, | 695 { 86, 10081 }, |
696 { 87, 10021 }, | 696 { 87, 10021 }, |
697 { 88, 10029 }, | 697 { 88, 10029 }, |
698 { 89, 10007 }, | 698 { 89, 10007 }, |
699 }; | 699 }; |
700 FX_BYTE _GetCharsetFromCodePage(FX_WORD codepage) | 700 uint8_t _GetCharsetFromCodePage(FX_WORD codepage) |
701 { | 701 { |
702 FX_INT32 iEnd = sizeof(g_Codepage2CharsetTable) / sizeof(CHARSET_MAP) - 1; | 702 int32_t iEnd = sizeof(g_Codepage2CharsetTable) / sizeof(CHARSET_MAP) - 1; |
703 FXSYS_assert(iEnd >= 0); | 703 FXSYS_assert(iEnd >= 0); |
704 FX_INT32 iStart = 0, iMid; | 704 int32_t iStart = 0, iMid; |
705 do { | 705 do { |
706 iMid = (iStart + iEnd) / 2; | 706 iMid = (iStart + iEnd) / 2; |
707 const CHARSET_MAP & cp = g_Codepage2CharsetTable[iMid]; | 707 const CHARSET_MAP & cp = g_Codepage2CharsetTable[iMid]; |
708 if (codepage == cp.codepage) { | 708 if (codepage == cp.codepage) { |
709 return cp.charset; | 709 return cp.charset; |
710 } else if (codepage < cp.codepage) { | 710 } else if (codepage < cp.codepage) { |
711 iEnd = iMid - 1; | 711 iEnd = iMid - 1; |
712 } else { | 712 } else { |
713 iStart = iMid + 1; | 713 iStart = iMid + 1; |
714 } | 714 } |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
834 } | 834 } |
835 _AltFontFamily* found = (_AltFontFamily*)FXSYS_bsearch(fontName.c_str(), g_A
ltFontFamilies, | 835 _AltFontFamily* found = (_AltFontFamily*)FXSYS_bsearch(fontName.c_str(), g_A
ltFontFamilies, |
836 sizeof g_AltFontFamilies / sizeof (_AltFontFamily),
sizeof (_AltFontFamily), compareFontFamilyString); | 836 sizeof g_AltFontFamilies / sizeof (_AltFontFamily),
sizeof (_AltFontFamily), compareFontFamilyString); |
837 if (found == NULL) { | 837 if (found == NULL) { |
838 return fontName; | 838 return fontName; |
839 } | 839 } |
840 return found->m_pFontFamily; | 840 return found->m_pFontFamily; |
841 }; | 841 }; |
842 typedef struct _FX_FontStyle { | 842 typedef struct _FX_FontStyle { |
843 FX_LPCSTR style; | 843 FX_LPCSTR style; |
844 FX_INT32 len; | 844 int32_t len; |
845 } FX_FontStyle; | 845 } FX_FontStyle; |
846 const FX_FontStyle g_FontStyles[] = { | 846 const FX_FontStyle g_FontStyles[] = { |
847 { "Bold", 4 }, | 847 { "Bold", 4 }, |
848 { "Italic", 6 }, | 848 { "Italic", 6 }, |
849 { "BoldItalic", 10 }, | 849 { "BoldItalic", 10 }, |
850 { "Reg", 3 }, | 850 { "Reg", 3 }, |
851 { "Regular", 7 }, | 851 { "Regular", 7 }, |
852 }; | 852 }; |
853 CFX_ByteString ParseStyle(FX_LPCSTR pStyle, int iLen, int iIndex) | 853 CFX_ByteString ParseStyle(FX_LPCSTR pStyle, int iLen, int iIndex) |
854 { | 854 { |
855 CFX_ByteTextBuf buf; | 855 CFX_ByteTextBuf buf; |
856 if (!iLen || iLen <= iIndex) { | 856 if (!iLen || iLen <= iIndex) { |
857 return buf.GetByteString(); | 857 return buf.GetByteString(); |
858 } | 858 } |
859 while (iIndex < iLen) { | 859 while (iIndex < iLen) { |
860 if (pStyle[iIndex] == ',') { | 860 if (pStyle[iIndex] == ',') { |
861 break; | 861 break; |
862 } | 862 } |
863 buf.AppendChar(pStyle[iIndex]); | 863 buf.AppendChar(pStyle[iIndex]); |
864 ++iIndex; | 864 ++iIndex; |
865 } | 865 } |
866 return buf.GetByteString(); | 866 return buf.GetByteString(); |
867 } | 867 } |
868 FX_INT32 GetStyleType(const CFX_ByteString &bsStyle, FX_BOOL bRevert) | 868 int32_t GetStyleType(const CFX_ByteString &bsStyle, FX_BOOL bRevert) |
869 { | 869 { |
870 FX_INT32 iLen = bsStyle.GetLength(); | 870 int32_t iLen = bsStyle.GetLength(); |
871 if (!iLen) { | 871 if (!iLen) { |
872 return -1; | 872 return -1; |
873 } | 873 } |
874 int iSize = sizeof(g_FontStyles) / sizeof(FX_FontStyle); | 874 int iSize = sizeof(g_FontStyles) / sizeof(FX_FontStyle); |
875 const FX_FontStyle *pStyle = NULL; | 875 const FX_FontStyle *pStyle = NULL; |
876 for (int i = iSize - 1; i >= 0; --i) { | 876 for (int i = iSize - 1; i >= 0; --i) { |
877 pStyle = g_FontStyles + i; | 877 pStyle = g_FontStyles + i; |
878 if (!pStyle || pStyle->len > iLen) { | 878 if (!pStyle || pStyle->len > iLen) { |
879 continue; | 879 continue; |
880 } | 880 } |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
978 if (!bHasComma) { | 978 if (!bHasComma) { |
979 find = family.ReverseFind('-'); | 979 find = family.ReverseFind('-'); |
980 if (find >= 0) { | 980 if (find >= 0) { |
981 style = family.Mid(find + 1); | 981 style = family.Mid(find + 1); |
982 family = family.Left(find); | 982 family = family.Left(find); |
983 bHasHypen = TRUE; | 983 bHasHypen = TRUE; |
984 } | 984 } |
985 } | 985 } |
986 if (!bHasHypen) { | 986 if (!bHasHypen) { |
987 int nLen = family.GetLength(); | 987 int nLen = family.GetLength(); |
988 FX_INT32 nRet = GetStyleType(family, TRUE); | 988 int32_t nRet = GetStyleType(family, TRUE); |
989 if (nRet > -1) { | 989 if (nRet > -1) { |
990 family = family.Left(nLen - g_FontStyles[nRet].len); | 990 family = family.Left(nLen - g_FontStyles[nRet].len); |
991 if (nRet == 0) { | 991 if (nRet == 0) { |
992 nStyle |= FX_FONT_STYLE_Bold; | 992 nStyle |= FX_FONT_STYLE_Bold; |
993 } | 993 } |
994 if (nRet == 1) { | 994 if (nRet == 1) { |
995 nStyle |= FX_FONT_STYLE_Italic; | 995 nStyle |= FX_FONT_STYLE_Italic; |
996 } | 996 } |
997 if (nRet == 2) { | 997 if (nRet == 2) { |
998 nStyle |= (FX_FONT_STYLE_Bold | FX_FONT_STYLE_Italic); | 998 nStyle |= (FX_FONT_STYLE_Bold | FX_FONT_STYLE_Italic); |
(...skipping 11 matching lines...) Expand all Loading... |
1010 } | 1010 } |
1011 } | 1011 } |
1012 if (!style.IsEmpty()) { | 1012 if (!style.IsEmpty()) { |
1013 int nLen = style.GetLength(); | 1013 int nLen = style.GetLength(); |
1014 FX_LPCSTR pStyle = style; | 1014 FX_LPCSTR pStyle = style; |
1015 int i = 0; | 1015 int i = 0; |
1016 FX_BOOL bFirstItem = TRUE; | 1016 FX_BOOL bFirstItem = TRUE; |
1017 CFX_ByteString buf; | 1017 CFX_ByteString buf; |
1018 while (i < nLen) { | 1018 while (i < nLen) { |
1019 buf = ParseStyle(pStyle, nLen, i); | 1019 buf = ParseStyle(pStyle, nLen, i); |
1020 FX_INT32 nRet = GetStyleType(buf, FALSE); | 1020 int32_t nRet = GetStyleType(buf, FALSE); |
1021 if ((i && !bStyleAvail) || (!i && nRet < 0)) { | 1021 if ((i && !bStyleAvail) || (!i && nRet < 0)) { |
1022 family = SubstName; | 1022 family = SubstName; |
1023 iBaseFont = 12; | 1023 iBaseFont = 12; |
1024 break; | 1024 break; |
1025 } else if (nRet >= 0) { | 1025 } else if (nRet >= 0) { |
1026 bStyleAvail = TRUE; | 1026 bStyleAvail = TRUE; |
1027 } | 1027 } |
1028 if (nRet == 0) { | 1028 if (nRet == 0) { |
1029 if (nStyle & FX_FONT_STYLE_Bold) { | 1029 if (nStyle & FX_FONT_STYLE_Bold) { |
1030 nStyle |= FX_FONT_STYLE_BoldBold; | 1030 nStyle |= FX_FONT_STYLE_BoldBold; |
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1211 m_pFontInfo->GetFontCharset(hFont, Charset); | 1211 m_pFontInfo->GetFontCharset(hFont, Charset); |
1212 } | 1212 } |
1213 FX_DWORD ttc_size = m_pFontInfo->GetFontData(hFont, 0x74746366, NULL, 0); | 1213 FX_DWORD ttc_size = m_pFontInfo->GetFontData(hFont, 0x74746366, NULL, 0); |
1214 FX_DWORD font_size = m_pFontInfo->GetFontData(hFont, 0, NULL, 0); | 1214 FX_DWORD font_size = m_pFontInfo->GetFontData(hFont, 0, NULL, 0); |
1215 if(font_size == 0 && ttc_size == 0) { | 1215 if(font_size == 0 && ttc_size == 0) { |
1216 m_pFontInfo->DeleteFont(hFont); | 1216 m_pFontInfo->DeleteFont(hFont); |
1217 return NULL; | 1217 return NULL; |
1218 } | 1218 } |
1219 FXFT_Face face = NULL; | 1219 FXFT_Face face = NULL; |
1220 if (ttc_size) { | 1220 if (ttc_size) { |
1221 FX_BYTE temp[1024]; | 1221 uint8_t temp[1024]; |
1222 m_pFontInfo->GetFontData(hFont, 0x74746366, temp, 1024); | 1222 m_pFontInfo->GetFontData(hFont, 0x74746366, temp, 1024); |
1223 FX_DWORD checksum = 0; | 1223 FX_DWORD checksum = 0; |
1224 for (int i = 0; i < 256; i ++) { | 1224 for (int i = 0; i < 256; i ++) { |
1225 checksum += ((FX_DWORD*)temp)[i]; | 1225 checksum += ((FX_DWORD*)temp)[i]; |
1226 } | 1226 } |
1227 FX_LPBYTE pFontData; | 1227 FX_LPBYTE pFontData; |
1228 face = m_pFontMgr->GetCachedTTCFace(ttc_size, checksum, ttc_size - font_
size, pFontData); | 1228 face = m_pFontMgr->GetCachedTTCFace(ttc_size, checksum, ttc_size - font_
size, pFontData); |
1229 if (face == NULL) { | 1229 if (face == NULL) { |
1230 pFontData = FX_Alloc(FX_BYTE, ttc_size); | 1230 pFontData = FX_Alloc(uint8_t, ttc_size); |
1231 m_pFontInfo->GetFontData(hFont, 0x74746366, pFontData, ttc_size); | 1231 m_pFontInfo->GetFontData(hFont, 0x74746366, pFontData, ttc_size); |
1232 face = m_pFontMgr->AddCachedTTCFace(ttc_size, checksum, pFontData, t
tc_size, | 1232 face = m_pFontMgr->AddCachedTTCFace(ttc_size, checksum, pFontData, t
tc_size, |
1233 ttc_size - font_size); | 1233 ttc_size - font_size); |
1234 } | 1234 } |
1235 } else { | 1235 } else { |
1236 FX_LPBYTE pFontData; | 1236 FX_LPBYTE pFontData; |
1237 face = m_pFontMgr->GetCachedFace(SubstName, weight, bItalic, pFontData); | 1237 face = m_pFontMgr->GetCachedFace(SubstName, weight, bItalic, pFontData); |
1238 if (face == NULL) { | 1238 if (face == NULL) { |
1239 pFontData = FX_Alloc(FX_BYTE, font_size); | 1239 pFontData = FX_Alloc(uint8_t, font_size); |
1240 m_pFontInfo->GetFontData(hFont, 0, pFontData, font_size); | 1240 m_pFontInfo->GetFontData(hFont, 0, pFontData, font_size); |
1241 face = m_pFontMgr->AddCachedFace(SubstName, weight, bItalic, pFontDa
ta, font_size, m_pFontInfo->GetFaceIndex(hFont)); | 1241 face = m_pFontMgr->AddCachedFace(SubstName, weight, bItalic, pFontDa
ta, font_size, m_pFontInfo->GetFaceIndex(hFont)); |
1242 } | 1242 } |
1243 } | 1243 } |
1244 if (face == NULL) { | 1244 if (face == NULL) { |
1245 m_pFontInfo->DeleteFont(hFont); | 1245 m_pFontInfo->DeleteFont(hFont); |
1246 return NULL; | 1246 return NULL; |
1247 } | 1247 } |
1248 pSubstFont->m_Family = SubstName; | 1248 pSubstFont->m_Family = SubstName; |
1249 pSubstFont->m_Charset = Charset; | 1249 pSubstFont->m_Charset = Charset; |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1296 return NULL; | 1296 return NULL; |
1297 } | 1297 } |
1298 FX_DWORD ttc_size = m_pFontInfo->GetFontData(hFont, 0x74746366, NULL, 0); | 1298 FX_DWORD ttc_size = m_pFontInfo->GetFontData(hFont, 0x74746366, NULL, 0); |
1299 FX_DWORD font_size = m_pFontInfo->GetFontData(hFont, 0, NULL, 0); | 1299 FX_DWORD font_size = m_pFontInfo->GetFontData(hFont, 0, NULL, 0); |
1300 if(font_size == 0 && ttc_size == 0) { | 1300 if(font_size == 0 && ttc_size == 0) { |
1301 m_pFontInfo->DeleteFont(hFont); | 1301 m_pFontInfo->DeleteFont(hFont); |
1302 return NULL; | 1302 return NULL; |
1303 } | 1303 } |
1304 FXFT_Face face = NULL; | 1304 FXFT_Face face = NULL; |
1305 if (ttc_size) { | 1305 if (ttc_size) { |
1306 FX_BYTE temp[1024]; | 1306 uint8_t temp[1024]; |
1307 m_pFontInfo->GetFontData(hFont, 0x74746366, temp, 1024); | 1307 m_pFontInfo->GetFontData(hFont, 0x74746366, temp, 1024); |
1308 FX_DWORD checksum = 0; | 1308 FX_DWORD checksum = 0; |
1309 for (int i = 0; i < 256; i ++) { | 1309 for (int i = 0; i < 256; i ++) { |
1310 checksum += ((FX_DWORD*)temp)[i]; | 1310 checksum += ((FX_DWORD*)temp)[i]; |
1311 } | 1311 } |
1312 FX_LPBYTE pFontData; | 1312 FX_LPBYTE pFontData; |
1313 face = m_pFontMgr->GetCachedTTCFace(ttc_size, checksum, ttc_size - font_
size, pFontData); | 1313 face = m_pFontMgr->GetCachedTTCFace(ttc_size, checksum, ttc_size - font_
size, pFontData); |
1314 if (face == NULL) { | 1314 if (face == NULL) { |
1315 pFontData = FX_Alloc(FX_BYTE, ttc_size); | 1315 pFontData = FX_Alloc(uint8_t, ttc_size); |
1316 if (pFontData) { | 1316 if (pFontData) { |
1317 m_pFontInfo->GetFontData(hFont, 0x74746366, pFontData, ttc_size)
; | 1317 m_pFontInfo->GetFontData(hFont, 0x74746366, pFontData, ttc_size)
; |
1318 face = m_pFontMgr->AddCachedTTCFace(ttc_size, checksum, pFontDat
a, ttc_size, | 1318 face = m_pFontMgr->AddCachedTTCFace(ttc_size, checksum, pFontDat
a, ttc_size, |
1319 ttc_size - font_size); | 1319 ttc_size - font_size); |
1320 } | 1320 } |
1321 } | 1321 } |
1322 } else { | 1322 } else { |
1323 CFX_ByteString SubstName; | 1323 CFX_ByteString SubstName; |
1324 m_pFontInfo->GetFaceName(hFont, SubstName); | 1324 m_pFontInfo->GetFaceName(hFont, SubstName); |
1325 FX_LPBYTE pFontData; | 1325 FX_LPBYTE pFontData; |
1326 face = m_pFontMgr->GetCachedFace(SubstName, weight, bItalic, pFontData); | 1326 face = m_pFontMgr->GetCachedFace(SubstName, weight, bItalic, pFontData); |
1327 if (face == NULL) { | 1327 if (face == NULL) { |
1328 pFontData = FX_Alloc(FX_BYTE, font_size); | 1328 pFontData = FX_Alloc(uint8_t, font_size); |
1329 if (!pFontData) { | 1329 if (!pFontData) { |
1330 m_pFontInfo->DeleteFont(hFont); | 1330 m_pFontInfo->DeleteFont(hFont); |
1331 return NULL; | 1331 return NULL; |
1332 } | 1332 } |
1333 m_pFontInfo->GetFontData(hFont, 0, pFontData, font_size); | 1333 m_pFontInfo->GetFontData(hFont, 0, pFontData, font_size); |
1334 face = m_pFontMgr->AddCachedFace(SubstName, weight, bItalic, pFontDa
ta, font_size, m_pFontInfo->GetFaceIndex(hFont)); | 1334 face = m_pFontMgr->AddCachedFace(SubstName, weight, bItalic, pFontDa
ta, font_size, m_pFontInfo->GetFaceIndex(hFont)); |
1335 } | 1335 } |
1336 } | 1336 } |
1337 m_pFontInfo->DeleteFont(hFont); | 1337 m_pFontInfo->DeleteFont(hFont); |
1338 return face; | 1338 return face; |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1447 FX_CloseFolder(handle); | 1447 FX_CloseFolder(handle); |
1448 } | 1448 } |
1449 void CFX_FolderFontInfo::ScanFile(CFX_ByteString& path) | 1449 void CFX_FolderFontInfo::ScanFile(CFX_ByteString& path) |
1450 { | 1450 { |
1451 FXSYS_FILE* pFile = FXSYS_fopen(path, "rb"); | 1451 FXSYS_FILE* pFile = FXSYS_fopen(path, "rb"); |
1452 if (pFile == NULL) { | 1452 if (pFile == NULL) { |
1453 return; | 1453 return; |
1454 } | 1454 } |
1455 FXSYS_fseek(pFile, 0, FXSYS_SEEK_END); | 1455 FXSYS_fseek(pFile, 0, FXSYS_SEEK_END); |
1456 FX_DWORD filesize = FXSYS_ftell(pFile); | 1456 FX_DWORD filesize = FXSYS_ftell(pFile); |
1457 FX_BYTE buffer[16]; | 1457 uint8_t buffer[16]; |
1458 FXSYS_fseek(pFile, 0, FXSYS_SEEK_SET); | 1458 FXSYS_fseek(pFile, 0, FXSYS_SEEK_SET); |
1459 size_t readCnt = FXSYS_fread(buffer, 12, 1, pFile); | 1459 size_t readCnt = FXSYS_fread(buffer, 12, 1, pFile); |
1460 if (readCnt != 1) { | 1460 if (readCnt != 1) { |
1461 FXSYS_fclose(pFile); | 1461 FXSYS_fclose(pFile); |
1462 return; | 1462 return; |
1463 } | 1463 } |
1464 | 1464 |
1465 if (GET_TT_LONG(buffer) == 0x74746366) { | 1465 if (GET_TT_LONG(buffer) == 0x74746366) { |
1466 FX_DWORD nFaces = GET_TT_LONG(buffer + 8); | 1466 FX_DWORD nFaces = GET_TT_LONG(buffer + 8); |
1467 if (nFaces > std::numeric_limits<FX_DWORD>::max() / 4) { | 1467 if (nFaces > std::numeric_limits<FX_DWORD>::max() / 4) { |
1468 FXSYS_fclose(pFile); | 1468 FXSYS_fclose(pFile); |
1469 return; | 1469 return; |
1470 } | 1470 } |
1471 FX_DWORD face_bytes = nFaces * 4; | 1471 FX_DWORD face_bytes = nFaces * 4; |
1472 FX_LPBYTE offsets = FX_Alloc(FX_BYTE, face_bytes); | 1472 FX_LPBYTE offsets = FX_Alloc(uint8_t, face_bytes); |
1473 readCnt = FXSYS_fread(offsets, face_bytes, 1, pFile); | 1473 readCnt = FXSYS_fread(offsets, face_bytes, 1, pFile); |
1474 if (readCnt != face_bytes) { | 1474 if (readCnt != face_bytes) { |
1475 FX_Free(offsets); | 1475 FX_Free(offsets); |
1476 FXSYS_fclose(pFile); | 1476 FXSYS_fclose(pFile); |
1477 return; | 1477 return; |
1478 } | 1478 } |
1479 for (FX_DWORD i = 0; i < nFaces; i ++) { | 1479 for (FX_DWORD i = 0; i < nFaces; i ++) { |
1480 FX_LPBYTE p = offsets + i * 4; | 1480 FX_LPBYTE p = offsets + i * 4; |
1481 ReportFace(path, pFile, filesize, GET_TT_LONG(p)); | 1481 ReportFace(path, pFile, filesize, GET_TT_LONG(p)); |
1482 } | 1482 } |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1622 return FALSE; | 1622 return FALSE; |
1623 } | 1623 } |
1624 CFontFaceInfo* pFont = (CFontFaceInfo*)hFont; | 1624 CFontFaceInfo* pFont = (CFontFaceInfo*)hFont; |
1625 name = pFont->m_FaceName; | 1625 name = pFont->m_FaceName; |
1626 return TRUE; | 1626 return TRUE; |
1627 } | 1627 } |
1628 FX_BOOL CFX_FolderFontInfo::GetFontCharset(void* hFont, int& charset) | 1628 FX_BOOL CFX_FolderFontInfo::GetFontCharset(void* hFont, int& charset) |
1629 { | 1629 { |
1630 return FALSE; | 1630 return FALSE; |
1631 } | 1631 } |
OLD | NEW |