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 <algorithm> | 7 #include <algorithm> |
8 #include <limits> | 8 #include <limits> |
9 #include <utility> | 9 #include <utility> |
10 #include <vector> | 10 #include <vector> |
(...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
329 } | 329 } |
330 return buf.MakeString(); | 330 return buf.MakeString(); |
331 } | 331 } |
332 | 332 |
333 int32_t GetStyleType(const CFX_ByteString& bsStyle, FX_BOOL bRevert) { | 333 int32_t GetStyleType(const CFX_ByteString& bsStyle, FX_BOOL bRevert) { |
334 int32_t iLen = bsStyle.GetLength(); | 334 int32_t iLen = bsStyle.GetLength(); |
335 if (!iLen) { | 335 if (!iLen) { |
336 return -1; | 336 return -1; |
337 } | 337 } |
338 int iSize = sizeof(g_FontStyles) / sizeof(FX_FontStyle); | 338 int iSize = sizeof(g_FontStyles) / sizeof(FX_FontStyle); |
339 const FX_FontStyle* pStyle = NULL; | 339 const FX_FontStyle* pStyle = nullptr; |
340 for (int i = iSize - 1; i >= 0; --i) { | 340 for (int i = iSize - 1; i >= 0; --i) { |
341 pStyle = g_FontStyles + i; | 341 pStyle = g_FontStyles + i; |
342 if (!pStyle || pStyle->len > iLen) { | 342 if (!pStyle || pStyle->len > iLen) { |
343 continue; | 343 continue; |
344 } | 344 } |
345 if (!bRevert) { | 345 if (!bRevert) { |
346 if (bsStyle.Left(pStyle->len).Compare(pStyle->style) == 0) { | 346 if (bsStyle.Left(pStyle->len).Compare(pStyle->style) == 0) { |
347 return i; | 347 return i; |
348 } | 348 } |
349 } else { | 349 } else { |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
403 if (!!(style & FXFONT_FIXED_PITCH) == | 403 if (!!(style & FXFONT_FIXED_PITCH) == |
404 !!(pitch_family & FXFONT_FF_FIXEDPITCH)) { | 404 !!(pitch_family & FXFONT_FF_FIXEDPITCH)) { |
405 iSimilarValue += 8; | 405 iSimilarValue += 8; |
406 } | 406 } |
407 return iSimilarValue; | 407 return iSimilarValue; |
408 } | 408 } |
409 | 409 |
410 } // namespace | 410 } // namespace |
411 | 411 |
412 CFX_SubstFont::CFX_SubstFont() { | 412 CFX_SubstFont::CFX_SubstFont() { |
413 m_ExtHandle = NULL; | 413 m_ExtHandle = nullptr; |
414 m_Charset = 0; | 414 m_Charset = 0; |
415 m_SubstFlags = 0; | 415 m_SubstFlags = 0; |
416 m_Weight = 0; | 416 m_Weight = 0; |
417 m_ItalicAngle = 0; | 417 m_ItalicAngle = 0; |
418 m_bSubstOfCJK = FALSE; | 418 m_bSubstOfCJK = FALSE; |
419 m_WeightCJK = 0; | 419 m_WeightCJK = 0; |
420 m_bItlicCJK = FALSE; | 420 m_bItlicCJK = FALSE; |
421 } | 421 } |
422 CTTFontDesc::~CTTFontDesc() { | 422 CTTFontDesc::~CTTFontDesc() { |
423 if (m_Type == 1) { | 423 if (m_Type == 1) { |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
510 return pFontDesc->m_SingleFace.m_pFace; | 510 return pFontDesc->m_SingleFace.m_pFace; |
511 } | 511 } |
512 FXFT_Face CFX_FontMgr::AddCachedFace(const CFX_ByteString& face_name, | 512 FXFT_Face CFX_FontMgr::AddCachedFace(const CFX_ByteString& face_name, |
513 int weight, | 513 int weight, |
514 FX_BOOL bItalic, | 514 FX_BOOL bItalic, |
515 uint8_t* pData, | 515 uint8_t* pData, |
516 uint32_t size, | 516 uint32_t size, |
517 int face_index) { | 517 int face_index) { |
518 CTTFontDesc* pFontDesc = new CTTFontDesc; | 518 CTTFontDesc* pFontDesc = new CTTFontDesc; |
519 pFontDesc->m_Type = 1; | 519 pFontDesc->m_Type = 1; |
520 pFontDesc->m_SingleFace.m_pFace = NULL; | 520 pFontDesc->m_SingleFace.m_pFace = nullptr; |
521 pFontDesc->m_SingleFace.m_bBold = weight; | 521 pFontDesc->m_SingleFace.m_bBold = weight; |
522 pFontDesc->m_SingleFace.m_bItalic = bItalic; | 522 pFontDesc->m_SingleFace.m_bItalic = bItalic; |
523 pFontDesc->m_pFontData = pData; | 523 pFontDesc->m_pFontData = pData; |
524 pFontDesc->m_RefCount = 1; | 524 pFontDesc->m_RefCount = 1; |
525 | 525 |
526 InitFTLibrary(); | 526 InitFTLibrary(); |
527 FXFT_Library library = m_FTLibrary; | 527 FXFT_Library library = m_FTLibrary; |
528 int ret = FXFT_New_Memory_Face(library, pData, size, face_index, | 528 int ret = FXFT_New_Memory_Face(library, pData, size, face_index, |
529 &pFontDesc->m_SingleFace.m_pFace); | 529 &pFontDesc->m_SingleFace.m_pFace); |
530 if (ret) { | 530 if (ret) { |
531 delete pFontDesc; | 531 delete pFontDesc; |
532 return NULL; | 532 return nullptr; |
533 } | 533 } |
534 ret = FXFT_Set_Pixel_Sizes(pFontDesc->m_SingleFace.m_pFace, 64, 64); | 534 ret = FXFT_Set_Pixel_Sizes(pFontDesc->m_SingleFace.m_pFace, 64, 64); |
535 if (ret) { | 535 if (ret) { |
536 delete pFontDesc; | 536 delete pFontDesc; |
537 return NULL; | 537 return nullptr; |
538 } | 538 } |
539 m_FaceMap[KeyNameFromFace(face_name, weight, bItalic)] = pFontDesc; | 539 m_FaceMap[KeyNameFromFace(face_name, weight, bItalic)] = pFontDesc; |
540 return pFontDesc->m_SingleFace.m_pFace; | 540 return pFontDesc->m_SingleFace.m_pFace; |
541 } | 541 } |
542 | 542 |
543 int GetTTCIndex(const uint8_t* pFontData, | 543 int GetTTCIndex(const uint8_t* pFontData, |
544 uint32_t ttc_size, | 544 uint32_t ttc_size, |
545 uint32_t font_offset) { | 545 uint32_t font_offset) { |
546 int face_index = 0; | 546 int face_index = 0; |
547 const uint8_t* p = pFontData + 8; | 547 const uint8_t* p = pFontData + 8; |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
580 } | 580 } |
581 FXFT_Face CFX_FontMgr::AddCachedTTCFace(int ttc_size, | 581 FXFT_Face CFX_FontMgr::AddCachedTTCFace(int ttc_size, |
582 uint32_t checksum, | 582 uint32_t checksum, |
583 uint8_t* pData, | 583 uint8_t* pData, |
584 uint32_t size, | 584 uint32_t size, |
585 int font_offset) { | 585 int font_offset) { |
586 CTTFontDesc* pFontDesc = new CTTFontDesc; | 586 CTTFontDesc* pFontDesc = new CTTFontDesc; |
587 pFontDesc->m_Type = 2; | 587 pFontDesc->m_Type = 2; |
588 pFontDesc->m_pFontData = pData; | 588 pFontDesc->m_pFontData = pData; |
589 for (int i = 0; i < 16; i++) { | 589 for (int i = 0; i < 16; i++) { |
590 pFontDesc->m_TTCFace.m_pFaces[i] = NULL; | 590 pFontDesc->m_TTCFace.m_pFaces[i] = nullptr; |
591 } | 591 } |
592 pFontDesc->m_RefCount++; | 592 pFontDesc->m_RefCount++; |
593 m_FaceMap[KeyNameFromSize(ttc_size, checksum)] = pFontDesc; | 593 m_FaceMap[KeyNameFromSize(ttc_size, checksum)] = pFontDesc; |
594 int face_index = GetTTCIndex(pFontDesc->m_pFontData, ttc_size, font_offset); | 594 int face_index = GetTTCIndex(pFontDesc->m_pFontData, ttc_size, font_offset); |
595 pFontDesc->m_TTCFace.m_pFaces[face_index] = | 595 pFontDesc->m_TTCFace.m_pFaces[face_index] = |
596 GetFixedFace(pFontDesc->m_pFontData, ttc_size, face_index); | 596 GetFixedFace(pFontDesc->m_pFontData, ttc_size, face_index); |
597 return pFontDesc->m_TTCFace.m_pFaces[face_index]; | 597 return pFontDesc->m_TTCFace.m_pFaces[face_index]; |
598 } | 598 } |
599 | 599 |
600 FXFT_Face CFX_FontMgr::GetFixedFace(const uint8_t* pData, | 600 FXFT_Face CFX_FontMgr::GetFixedFace(const uint8_t* pData, |
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
808 | 808 |
809 FXFT_Face CFX_FontMapper::UseInternalSubst(CFX_SubstFont* pSubstFont, | 809 FXFT_Face CFX_FontMapper::UseInternalSubst(CFX_SubstFont* pSubstFont, |
810 int iBaseFont, | 810 int iBaseFont, |
811 int italic_angle, | 811 int italic_angle, |
812 int weight, | 812 int weight, |
813 int picthfamily) { | 813 int picthfamily) { |
814 if (iBaseFont < 12) { | 814 if (iBaseFont < 12) { |
815 if (m_FoxitFaces[iBaseFont]) { | 815 if (m_FoxitFaces[iBaseFont]) { |
816 return m_FoxitFaces[iBaseFont]; | 816 return m_FoxitFaces[iBaseFont]; |
817 } | 817 } |
818 const uint8_t* pFontData = NULL; | 818 const uint8_t* pFontData = nullptr; |
819 uint32_t size = 0; | 819 uint32_t size = 0; |
820 if (m_pFontMgr->GetBuiltinFont(iBaseFont, &pFontData, &size)) { | 820 if (m_pFontMgr->GetBuiltinFont(iBaseFont, &pFontData, &size)) { |
821 m_FoxitFaces[iBaseFont] = m_pFontMgr->GetFixedFace(pFontData, size, 0); | 821 m_FoxitFaces[iBaseFont] = m_pFontMgr->GetFixedFace(pFontData, size, 0); |
822 return m_FoxitFaces[iBaseFont]; | 822 return m_FoxitFaces[iBaseFont]; |
823 } | 823 } |
824 } | 824 } |
825 pSubstFont->m_SubstFlags |= FXFONT_SUBST_MM; | 825 pSubstFont->m_SubstFlags |= FXFONT_SUBST_MM; |
826 pSubstFont->m_ItalicAngle = italic_angle; | 826 pSubstFont->m_ItalicAngle = italic_angle; |
827 if (weight) { | 827 if (weight) { |
828 pSubstFont->m_Weight = weight; | 828 pSubstFont->m_Weight = weight; |
829 } | 829 } |
830 if (picthfamily & FXFONT_FF_ROMAN) { | 830 if (picthfamily & FXFONT_FF_ROMAN) { |
831 pSubstFont->m_Weight = pSubstFont->m_Weight * 4 / 5; | 831 pSubstFont->m_Weight = pSubstFont->m_Weight * 4 / 5; |
832 pSubstFont->m_Family = "Chrome Serif"; | 832 pSubstFont->m_Family = "Chrome Serif"; |
833 if (m_MMFaces[1]) { | 833 if (m_MMFaces[1]) { |
834 return m_MMFaces[1]; | 834 return m_MMFaces[1]; |
835 } | 835 } |
836 const uint8_t* pFontData = NULL; | 836 const uint8_t* pFontData = nullptr; |
837 uint32_t size = 0; | 837 uint32_t size = 0; |
838 m_pFontMgr->GetBuiltinFont(14, &pFontData, &size); | 838 m_pFontMgr->GetBuiltinFont(14, &pFontData, &size); |
839 m_MMFaces[1] = m_pFontMgr->GetFixedFace(pFontData, size, 0); | 839 m_MMFaces[1] = m_pFontMgr->GetFixedFace(pFontData, size, 0); |
840 return m_MMFaces[1]; | 840 return m_MMFaces[1]; |
841 } | 841 } |
842 pSubstFont->m_Family = "Chrome Sans"; | 842 pSubstFont->m_Family = "Chrome Sans"; |
843 if (m_MMFaces[0]) { | 843 if (m_MMFaces[0]) { |
844 return m_MMFaces[0]; | 844 return m_MMFaces[0]; |
845 } | 845 } |
846 const uint8_t* pFontData = NULL; | 846 const uint8_t* pFontData = nullptr; |
847 uint32_t size = 0; | 847 uint32_t size = 0; |
848 m_pFontMgr->GetBuiltinFont(15, &pFontData, &size); | 848 m_pFontMgr->GetBuiltinFont(15, &pFontData, &size); |
849 m_MMFaces[0] = m_pFontMgr->GetFixedFace(pFontData, size, 0); | 849 m_MMFaces[0] = m_pFontMgr->GetFixedFace(pFontData, size, 0); |
850 return m_MMFaces[0]; | 850 return m_MMFaces[0]; |
851 } | 851 } |
852 | 852 |
853 FXFT_Face CFX_FontMapper::FindSubstFont(const CFX_ByteString& name, | 853 FXFT_Face CFX_FontMapper::FindSubstFont(const CFX_ByteString& name, |
854 FX_BOOL bTrueType, | 854 FX_BOOL bTrueType, |
855 uint32_t flags, | 855 uint32_t flags, |
856 int weight, | 856 int weight, |
(...skipping 12 matching lines...) Expand all Loading... |
869 } | 869 } |
870 } | 870 } |
871 PDF_GetStandardFontName(&SubstName); | 871 PDF_GetStandardFontName(&SubstName); |
872 if (SubstName == "Symbol" && !bTrueType) { | 872 if (SubstName == "Symbol" && !bTrueType) { |
873 pSubstFont->m_Family = "Chrome Symbol"; | 873 pSubstFont->m_Family = "Chrome Symbol"; |
874 pSubstFont->m_Charset = FXFONT_SYMBOL_CHARSET; | 874 pSubstFont->m_Charset = FXFONT_SYMBOL_CHARSET; |
875 pSubstFont->m_SubstFlags |= FXFONT_SUBST_STANDARD; | 875 pSubstFont->m_SubstFlags |= FXFONT_SUBST_STANDARD; |
876 if (m_FoxitFaces[12]) { | 876 if (m_FoxitFaces[12]) { |
877 return m_FoxitFaces[12]; | 877 return m_FoxitFaces[12]; |
878 } | 878 } |
879 const uint8_t* pFontData = NULL; | 879 const uint8_t* pFontData = nullptr; |
880 uint32_t size = 0; | 880 uint32_t size = 0; |
881 m_pFontMgr->GetBuiltinFont(12, &pFontData, &size); | 881 m_pFontMgr->GetBuiltinFont(12, &pFontData, &size); |
882 m_FoxitFaces[12] = m_pFontMgr->GetFixedFace(pFontData, size, 0); | 882 m_FoxitFaces[12] = m_pFontMgr->GetFixedFace(pFontData, size, 0); |
883 return m_FoxitFaces[12]; | 883 return m_FoxitFaces[12]; |
884 } | 884 } |
885 if (SubstName == "ZapfDingbats") { | 885 if (SubstName == "ZapfDingbats") { |
886 pSubstFont->m_Family = "Chrome Dingbats"; | 886 pSubstFont->m_Family = "Chrome Dingbats"; |
887 pSubstFont->m_Charset = FXFONT_SYMBOL_CHARSET; | 887 pSubstFont->m_Charset = FXFONT_SYMBOL_CHARSET; |
888 pSubstFont->m_SubstFlags |= FXFONT_SUBST_STANDARD; | 888 pSubstFont->m_SubstFlags |= FXFONT_SUBST_STANDARD; |
889 if (m_FoxitFaces[13]) { | 889 if (m_FoxitFaces[13]) { |
890 return m_FoxitFaces[13]; | 890 return m_FoxitFaces[13]; |
891 } | 891 } |
892 const uint8_t* pFontData = NULL; | 892 const uint8_t* pFontData = nullptr; |
893 uint32_t size = 0; | 893 uint32_t size = 0; |
894 m_pFontMgr->GetBuiltinFont(13, &pFontData, &size); | 894 m_pFontMgr->GetBuiltinFont(13, &pFontData, &size); |
895 m_FoxitFaces[13] = m_pFontMgr->GetFixedFace(pFontData, size, 0); | 895 m_FoxitFaces[13] = m_pFontMgr->GetFixedFace(pFontData, size, 0); |
896 return m_FoxitFaces[13]; | 896 return m_FoxitFaces[13]; |
897 } | 897 } |
898 int iBaseFont = 0; | 898 int iBaseFont = 0; |
899 CFX_ByteString family, style; | 899 CFX_ByteString family, style; |
900 FX_BOOL bHasComma = FALSE; | 900 FX_BOOL bHasComma = FALSE; |
901 FX_BOOL bHasHypen = FALSE; | 901 FX_BOOL bHasHypen = FALSE; |
902 int find = SubstName.Find(",", 0); | 902 int find = SubstName.Find(",", 0); |
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1099 } | 1099 } |
1100 iExact = !match.IsEmpty(); | 1100 iExact = !match.IsEmpty(); |
1101 void* hFont = m_pFontInfo->MapFont(weight, bItalic, Charset, PitchFamily, | 1101 void* hFont = m_pFontInfo->MapFont(weight, bItalic, Charset, PitchFamily, |
1102 family.c_str(), iExact); | 1102 family.c_str(), iExact); |
1103 if (iExact) { | 1103 if (iExact) { |
1104 pSubstFont->m_SubstFlags |= FXFONT_SUBST_EXACT; | 1104 pSubstFont->m_SubstFlags |= FXFONT_SUBST_EXACT; |
1105 } | 1105 } |
1106 if (!hFont) { | 1106 if (!hFont) { |
1107 #ifdef PDF_ENABLE_XFA | 1107 #ifdef PDF_ENABLE_XFA |
1108 if (flags & FXFONT_EXACTMATCH) { | 1108 if (flags & FXFONT_EXACTMATCH) { |
1109 return NULL; | 1109 return nullptr; |
1110 } | 1110 } |
1111 #endif // PDF_ENABLE_XFA | 1111 #endif // PDF_ENABLE_XFA |
1112 if (bCJK) { | 1112 if (bCJK) { |
1113 if (italic_angle != 0) { | 1113 if (italic_angle != 0) { |
1114 bItalic = TRUE; | 1114 bItalic = TRUE; |
1115 } else { | 1115 } else { |
1116 bItalic = FALSE; | 1116 bItalic = FALSE; |
1117 } | 1117 } |
1118 weight = old_weight; | 1118 weight = old_weight; |
1119 } | 1119 } |
1120 if (!match.IsEmpty()) { | 1120 if (!match.IsEmpty()) { |
1121 hFont = m_pFontInfo->GetFont(match.c_str()); | 1121 hFont = m_pFontInfo->GetFont(match.c_str()); |
1122 if (!hFont) { | 1122 if (!hFont) { |
1123 return UseInternalSubst(pSubstFont, iBaseFont, italic_angle, old_weight, | 1123 return UseInternalSubst(pSubstFont, iBaseFont, italic_angle, old_weight, |
1124 PitchFamily); | 1124 PitchFamily); |
1125 } | 1125 } |
1126 } else { | 1126 } else { |
1127 if (Charset == FXFONT_SYMBOL_CHARSET) { | 1127 if (Charset == FXFONT_SYMBOL_CHARSET) { |
1128 #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ || \ | 1128 #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ || \ |
1129 _FXM_PLATFORM_ == _FXM_PLATFORM_ANDROID_ | 1129 _FXM_PLATFORM_ == _FXM_PLATFORM_ANDROID_ |
1130 if (SubstName == "Symbol") { | 1130 if (SubstName == "Symbol") { |
1131 pSubstFont->m_Family = "Chrome Symbol"; | 1131 pSubstFont->m_Family = "Chrome Symbol"; |
1132 pSubstFont->m_SubstFlags |= FXFONT_SUBST_STANDARD; | 1132 pSubstFont->m_SubstFlags |= FXFONT_SUBST_STANDARD; |
1133 pSubstFont->m_Charset = FXFONT_SYMBOL_CHARSET; | 1133 pSubstFont->m_Charset = FXFONT_SYMBOL_CHARSET; |
1134 if (m_FoxitFaces[12]) { | 1134 if (m_FoxitFaces[12]) { |
1135 return m_FoxitFaces[12]; | 1135 return m_FoxitFaces[12]; |
1136 } | 1136 } |
1137 const uint8_t* pFontData = NULL; | 1137 const uint8_t* pFontData = nullptr; |
1138 uint32_t size = 0; | 1138 uint32_t size = 0; |
1139 m_pFontMgr->GetBuiltinFont(12, &pFontData, &size); | 1139 m_pFontMgr->GetBuiltinFont(12, &pFontData, &size); |
1140 m_FoxitFaces[12] = m_pFontMgr->GetFixedFace(pFontData, size, 0); | 1140 m_FoxitFaces[12] = m_pFontMgr->GetFixedFace(pFontData, size, 0); |
1141 return m_FoxitFaces[12]; | 1141 return m_FoxitFaces[12]; |
1142 } | 1142 } |
1143 #endif | 1143 #endif |
1144 pSubstFont->m_SubstFlags |= FXFONT_SUBST_NONSYMBOL; | 1144 pSubstFont->m_SubstFlags |= FXFONT_SUBST_NONSYMBOL; |
1145 return FindSubstFont(family, bTrueType, flags & ~FXFONT_SYMBOLIC, | 1145 return FindSubstFont(family, bTrueType, flags & ~FXFONT_SYMBOLIC, |
1146 weight, italic_angle, 0, pSubstFont); | 1146 weight, italic_angle, 0, pSubstFont); |
1147 } | 1147 } |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1200 if (!face) { | 1200 if (!face) { |
1201 pFontData = FX_Alloc(uint8_t, font_size); | 1201 pFontData = FX_Alloc(uint8_t, font_size); |
1202 m_pFontInfo->GetFontData(hFont, 0, pFontData, font_size); | 1202 m_pFontInfo->GetFontData(hFont, 0, pFontData, font_size); |
1203 face = m_pFontMgr->AddCachedFace(SubstName, weight, bItalic, pFontData, | 1203 face = m_pFontMgr->AddCachedFace(SubstName, weight, bItalic, pFontData, |
1204 font_size, | 1204 font_size, |
1205 m_pFontInfo->GetFaceIndex(hFont)); | 1205 m_pFontInfo->GetFaceIndex(hFont)); |
1206 } | 1206 } |
1207 } | 1207 } |
1208 if (!face) { | 1208 if (!face) { |
1209 m_pFontInfo->DeleteFont(hFont); | 1209 m_pFontInfo->DeleteFont(hFont); |
1210 return NULL; | 1210 return nullptr; |
1211 } | 1211 } |
1212 pSubstFont->m_Family = SubstName; | 1212 pSubstFont->m_Family = SubstName; |
1213 pSubstFont->m_Charset = Charset; | 1213 pSubstFont->m_Charset = Charset; |
1214 FX_BOOL bNeedUpdateWeight = FALSE; | 1214 FX_BOOL bNeedUpdateWeight = FALSE; |
1215 if (FXFT_Is_Face_Bold(face)) { | 1215 if (FXFT_Is_Face_Bold(face)) { |
1216 if (weight == FXFONT_FW_BOLD) { | 1216 if (weight == FXFONT_FW_BOLD) { |
1217 bNeedUpdateWeight = FALSE; | 1217 bNeedUpdateWeight = FALSE; |
1218 } else { | 1218 } else { |
1219 bNeedUpdateWeight = TRUE; | 1219 bNeedUpdateWeight = TRUE; |
1220 } | 1220 } |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1256 PitchFamily |= FXFONT_FF_SCRIPT; | 1256 PitchFamily |= FXFONT_FF_SCRIPT; |
1257 } | 1257 } |
1258 if (flags & FXFONT_FIXED_PITCH) { | 1258 if (flags & FXFONT_FIXED_PITCH) { |
1259 PitchFamily |= FXFONT_FF_FIXEDPITCH; | 1259 PitchFamily |= FXFONT_FF_FIXEDPITCH; |
1260 } | 1260 } |
1261 void* hFont = | 1261 void* hFont = |
1262 m_pFontInfo->MapFontByUnicode(dwUnicode, weight, bItalic, PitchFamily); | 1262 m_pFontInfo->MapFontByUnicode(dwUnicode, weight, bItalic, PitchFamily); |
1263 if (!hFont) | 1263 if (!hFont) |
1264 return nullptr; | 1264 return nullptr; |
1265 | 1265 |
1266 uint32_t ttc_size = m_pFontInfo->GetFontData(hFont, 0x74746366, NULL, 0); | 1266 uint32_t ttc_size = m_pFontInfo->GetFontData(hFont, 0x74746366, nullptr, 0); |
1267 uint32_t font_size = m_pFontInfo->GetFontData(hFont, 0, NULL, 0); | 1267 uint32_t font_size = m_pFontInfo->GetFontData(hFont, 0, nullptr, 0); |
1268 if (font_size == 0 && ttc_size == 0) { | 1268 if (font_size == 0 && ttc_size == 0) { |
1269 m_pFontInfo->DeleteFont(hFont); | 1269 m_pFontInfo->DeleteFont(hFont); |
1270 return NULL; | 1270 return nullptr; |
1271 } | 1271 } |
1272 FXFT_Face face = NULL; | 1272 FXFT_Face face = nullptr; |
1273 if (ttc_size) { | 1273 if (ttc_size) { |
1274 uint8_t temp[1024]; | 1274 uint8_t temp[1024]; |
1275 m_pFontInfo->GetFontData(hFont, 0x74746366, temp, 1024); | 1275 m_pFontInfo->GetFontData(hFont, 0x74746366, temp, 1024); |
1276 uint32_t checksum = 0; | 1276 uint32_t checksum = 0; |
1277 for (int i = 0; i < 256; i++) { | 1277 for (int i = 0; i < 256; i++) { |
1278 checksum += ((uint32_t*)temp)[i]; | 1278 checksum += ((uint32_t*)temp)[i]; |
1279 } | 1279 } |
1280 uint8_t* pFontData; | 1280 uint8_t* pFontData; |
1281 face = m_pFontMgr->GetCachedTTCFace(ttc_size, checksum, | 1281 face = m_pFontMgr->GetCachedTTCFace(ttc_size, checksum, |
1282 ttc_size - font_size, pFontData); | 1282 ttc_size - font_size, pFontData); |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1315 int pitch_family) { | 1315 int pitch_family) { |
1316 return nullptr; | 1316 return nullptr; |
1317 } | 1317 } |
1318 #endif // PDF_ENABLE_XFA | 1318 #endif // PDF_ENABLE_XFA |
1319 | 1319 |
1320 int IFX_SystemFontInfo::GetFaceIndex(void* hFont) { | 1320 int IFX_SystemFontInfo::GetFaceIndex(void* hFont) { |
1321 return 0; | 1321 return 0; |
1322 } | 1322 } |
1323 | 1323 |
1324 void* IFX_SystemFontInfo::RetainFont(void* hFont) { | 1324 void* IFX_SystemFontInfo::RetainFont(void* hFont) { |
1325 return NULL; | 1325 return nullptr; |
1326 } | 1326 } |
1327 | 1327 |
1328 int CFX_FontMapper::GetFaceSize() const { | 1328 int CFX_FontMapper::GetFaceSize() const { |
1329 return pdfium::CollectionSize<int>(m_FaceArray); | 1329 return pdfium::CollectionSize<int>(m_FaceArray); |
1330 } | 1330 } |
1331 | 1331 |
1332 FX_BOOL CFX_FontMapper::IsBuiltinFace(const FXFT_Face face) const { | 1332 FX_BOOL CFX_FontMapper::IsBuiltinFace(const FXFT_Face face) const { |
1333 for (size_t i = 0; i < MM_FACE_COUNT; ++i) { | 1333 for (size_t i = 0; i < MM_FACE_COUNT; ++i) { |
1334 if (m_MMFaces[i] == face) { | 1334 if (m_MMFaces[i] == face) { |
1335 return TRUE; | 1335 return TRUE; |
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1559 } | 1559 } |
1560 } | 1560 } |
1561 return pFind; | 1561 return pFind; |
1562 } | 1562 } |
1563 void* CFX_FolderFontInfo::MapFont(int weight, | 1563 void* CFX_FolderFontInfo::MapFont(int weight, |
1564 FX_BOOL bItalic, | 1564 FX_BOOL bItalic, |
1565 int charset, | 1565 int charset, |
1566 int pitch_family, | 1566 int pitch_family, |
1567 const FX_CHAR* family, | 1567 const FX_CHAR* family, |
1568 int& iExact) { | 1568 int& iExact) { |
1569 return NULL; | 1569 return nullptr; |
1570 } | 1570 } |
1571 | 1571 |
1572 #ifdef PDF_ENABLE_XFA | 1572 #ifdef PDF_ENABLE_XFA |
1573 void* CFX_FolderFontInfo::MapFontByUnicode(uint32_t dwUnicode, | 1573 void* CFX_FolderFontInfo::MapFontByUnicode(uint32_t dwUnicode, |
1574 int weight, | 1574 int weight, |
1575 FX_BOOL bItalic, | 1575 FX_BOOL bItalic, |
1576 int pitch_family) { | 1576 int pitch_family) { |
1577 return NULL; | 1577 return nullptr; |
1578 } | 1578 } |
1579 #endif // PDF_ENABLE_XFA | 1579 #endif // PDF_ENABLE_XFA |
1580 | 1580 |
1581 void* CFX_FolderFontInfo::GetFont(const FX_CHAR* face) { | 1581 void* CFX_FolderFontInfo::GetFont(const FX_CHAR* face) { |
1582 auto it = m_FontList.find(face); | 1582 auto it = m_FontList.find(face); |
1583 return it != m_FontList.end() ? it->second : nullptr; | 1583 return it != m_FontList.end() ? it->second : nullptr; |
1584 } | 1584 } |
1585 | 1585 |
1586 uint32_t CFX_FolderFontInfo::GetFontData(void* hFont, | 1586 uint32_t CFX_FolderFontInfo::GetFontData(void* hFont, |
1587 uint32_t table, | 1587 uint32_t table, |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1639 int PDF_GetStandardFontName(CFX_ByteString* name) { | 1639 int PDF_GetStandardFontName(CFX_ByteString* name) { |
1640 AltFontName* found = static_cast<AltFontName*>( | 1640 AltFontName* found = static_cast<AltFontName*>( |
1641 FXSYS_bsearch(name->c_str(), g_AltFontNames, FX_ArraySize(g_AltFontNames), | 1641 FXSYS_bsearch(name->c_str(), g_AltFontNames, FX_ArraySize(g_AltFontNames), |
1642 sizeof(AltFontName), CompareString)); | 1642 sizeof(AltFontName), CompareString)); |
1643 if (!found) | 1643 if (!found) |
1644 return -1; | 1644 return -1; |
1645 | 1645 |
1646 *name = g_Base14FontNames[found->m_Index]; | 1646 *name = g_Base14FontNames[found->m_Index]; |
1647 return found->m_Index; | 1647 return found->m_Index; |
1648 } | 1648 } |
OLD | NEW |