| 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" |
| 11 #include "text_int.h" | 11 #include "text_int.h" |
| 12 #define GET_TT_SHORT(w) (FX_WORD)(((w)[0] << 8) | (w)[1]) | 12 #define GET_TT_SHORT(w) (FX_WORD)(((w)[0] << 8) | (w)[1]) |
| 13 #define GET_TT_LONG(w) (FX_DWORD)(((w)[0] << 24) | ((w)[1] << 16) | ((w)[2] << 8
) | (w)[3]) | 13 #define GET_TT_LONG(w) (FX_DWORD)(((w)[0] << 24) | ((w)[1] << 16) | ((w)[2] << 8
) | (w)[3]) |
| 14 CFX_SubstFont::CFX_SubstFont() | 14 CFX_SubstFont::CFX_SubstFont() |
| 15 { | 15 { |
| 16 m_ExtHandle = NULL; | 16 m_ExtHandle = NULL; |
| 17 m_Charset = 0; | 17 m_Charset = 0; |
| 18 m_SubstFlags = 0; | 18 m_SubstFlags = 0; |
| 19 m_Weight = 0; | 19 m_Weight = 0; |
| 20 m_ItalicAngle = 0; | 20 m_ItalicAngle = 0; |
| 21 m_bSubstOfCJK = FALSE; | 21 m_bSubstOfCJK = false; |
| 22 m_WeightCJK = 0; | 22 m_WeightCJK = 0; |
| 23 m_bItlicCJK = FALSE; | 23 m_bItlicCJK = false; |
| 24 } | 24 } |
| 25 CTTFontDesc::~CTTFontDesc() | 25 CTTFontDesc::~CTTFontDesc() |
| 26 { | 26 { |
| 27 if (m_Type == 1) { | 27 if (m_Type == 1) { |
| 28 if (m_SingleFace.m_pFace) { | 28 if (m_SingleFace.m_pFace) { |
| 29 FXFT_Done_Face(m_SingleFace.m_pFace); | 29 FXFT_Done_Face(m_SingleFace.m_pFace); |
| 30 } | 30 } |
| 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_BOOL CTTFontDesc::ReleaseFace(FXFT_Face face) | 41 bool 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 FALSE; | 45 return false; |
| 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; |
| 52 } | 52 } |
| 53 if (i == 16) { | 53 if (i == 16) { |
| 54 return FALSE; | 54 return false; |
| 55 } | 55 } |
| 56 } | 56 } |
| 57 m_RefCount --; | 57 m_RefCount --; |
| 58 if (m_RefCount) { | 58 if (m_RefCount) { |
| 59 return FALSE; | 59 return false; |
| 60 } | 60 } |
| 61 delete this; | 61 delete this; |
| 62 return TRUE; | 62 return true; |
| 63 } | 63 } |
| 64 CFX_FontMgr::CFX_FontMgr() | 64 CFX_FontMgr::CFX_FontMgr() |
| 65 { | 65 { |
| 66 m_pBuiltinMapper = new CFX_FontMapper; | 66 m_pBuiltinMapper = new CFX_FontMapper; |
| 67 m_pBuiltinMapper->m_pFontMgr = this; | 67 m_pBuiltinMapper->m_pFontMgr = this; |
| 68 m_pExtMapper = NULL; | 68 m_pExtMapper = NULL; |
| 69 m_FTLibrary = NULL; | 69 m_FTLibrary = NULL; |
| 70 FXSYS_memset(m_ExternalFonts, 0, sizeof m_ExternalFonts); | 70 FXSYS_memset(m_ExternalFonts, 0, sizeof m_ExternalFonts); |
| 71 } | 71 } |
| 72 CFX_FontMgr::~CFX_FontMgr() | 72 CFX_FontMgr::~CFX_FontMgr() |
| (...skipping 18 matching lines...) Expand all Loading... |
| 91 CTTFontDesc* face; | 91 CTTFontDesc* face; |
| 92 m_FaceMap.GetNextAssoc(pos, Key, (void*&)face); | 92 m_FaceMap.GetNextAssoc(pos, Key, (void*&)face); |
| 93 delete face; | 93 delete face; |
| 94 } | 94 } |
| 95 m_FaceMap.RemoveAll(); | 95 m_FaceMap.RemoveAll(); |
| 96 } | 96 } |
| 97 void CFX_FontMgr::SetSystemFontInfo(IFX_SystemFontInfo* pFontInfo) | 97 void CFX_FontMgr::SetSystemFontInfo(IFX_SystemFontInfo* pFontInfo) |
| 98 { | 98 { |
| 99 m_pBuiltinMapper->SetSystemFontInfo(pFontInfo); | 99 m_pBuiltinMapper->SetSystemFontInfo(pFontInfo); |
| 100 } | 100 } |
| 101 FXFT_Face CFX_FontMgr::FindSubstFont(const CFX_ByteString& face_name, FX_BOOL bT
rueType, | 101 FXFT_Face CFX_FontMgr::FindSubstFont(const CFX_ByteString& face_name, bool bTrue
Type, |
| 102 FX_DWORD flags, int weight, int italic_angl
e, int CharsetCP, CFX_SubstFont* pSubstFont) | 102 FX_DWORD flags, int weight, int italic_angl
e, int CharsetCP, CFX_SubstFont* pSubstFont) |
| 103 { | 103 { |
| 104 if (m_FTLibrary == NULL) { | 104 if (m_FTLibrary == NULL) { |
| 105 FXFT_Init_FreeType(&m_FTLibrary); | 105 FXFT_Init_FreeType(&m_FTLibrary); |
| 106 } | 106 } |
| 107 if (m_pExtMapper) { | 107 if (m_pExtMapper) { |
| 108 FXFT_Face face = m_pExtMapper->FindSubstFont(face_name, bTrueType, flags
, weight, italic_angle, | 108 FXFT_Face face = m_pExtMapper->FindSubstFont(face_name, bTrueType, flags
, weight, italic_angle, |
| 109 CharsetCP, pSubstFont); | 109 CharsetCP, pSubstFont); |
| 110 if (face) { | 110 if (face) { |
| 111 return face; | 111 return face; |
| 112 } | 112 } |
| 113 } | 113 } |
| 114 return m_pBuiltinMapper->FindSubstFont(face_name, bTrueType, flags, weight,
italic_angle, | 114 return m_pBuiltinMapper->FindSubstFont(face_name, bTrueType, flags, weight,
italic_angle, |
| 115 CharsetCP, pSubstFont); | 115 CharsetCP, pSubstFont); |
| 116 } | 116 } |
| 117 FXFT_Face CFX_FontMgr::GetCachedFace(const CFX_ByteString& face_name, | 117 FXFT_Face CFX_FontMgr::GetCachedFace(const CFX_ByteString& face_name, |
| 118 int weight, FX_BOOL bItalic, uint8_t*& pFon
tData) | 118 int weight, bool bItalic, uint8_t*& pFontDa
ta) |
| 119 { | 119 { |
| 120 CFX_ByteString key(face_name); | 120 CFX_ByteString key(face_name); |
| 121 key += ','; | 121 key += ','; |
| 122 key += CFX_ByteString::FormatInteger(weight); | 122 key += CFX_ByteString::FormatInteger(weight); |
| 123 key += bItalic ? 'I' : 'N'; | 123 key += bItalic ? 'I' : 'N'; |
| 124 CTTFontDesc* pFontDesc = NULL; | 124 CTTFontDesc* pFontDesc = NULL; |
| 125 m_FaceMap.Lookup(key, (void*&)pFontDesc); | 125 m_FaceMap.Lookup(key, (void*&)pFontDesc); |
| 126 if(pFontDesc) { | 126 if(pFontDesc) { |
| 127 pFontData = pFontDesc->m_pFontData; | 127 pFontData = pFontDesc->m_pFontData; |
| 128 pFontDesc->m_RefCount ++; | 128 pFontDesc->m_RefCount ++; |
| 129 return pFontDesc->m_SingleFace.m_pFace; | 129 return pFontDesc->m_SingleFace.m_pFace; |
| 130 } | 130 } |
| 131 return NULL; | 131 return NULL; |
| 132 } | 132 } |
| 133 FXFT_Face CFX_FontMgr::AddCachedFace(const CFX_ByteString& face_name, | 133 FXFT_Face CFX_FontMgr::AddCachedFace(const CFX_ByteString& face_name, |
| 134 int weight, FX_BOOL bItalic, uint8_t* pData
, FX_DWORD size, int face_index) | 134 int weight, bool bItalic, uint8_t* pData, F
X_DWORD size, int face_index) |
| 135 { | 135 { |
| 136 CTTFontDesc* pFontDesc = new CTTFontDesc; | 136 CTTFontDesc* pFontDesc = new CTTFontDesc; |
| 137 pFontDesc->m_Type = 1; | 137 pFontDesc->m_Type = 1; |
| 138 pFontDesc->m_SingleFace.m_pFace = NULL; | 138 pFontDesc->m_SingleFace.m_pFace = NULL; |
| 139 pFontDesc->m_SingleFace.m_bBold = weight; | 139 pFontDesc->m_SingleFace.m_bBold = weight; |
| 140 pFontDesc->m_SingleFace.m_bItalic = bItalic; | 140 pFontDesc->m_SingleFace.m_bItalic = bItalic; |
| 141 pFontDesc->m_pFontData = pData; | 141 pFontDesc->m_pFontData = pData; |
| 142 pFontDesc->m_RefCount = 1; | 142 pFontDesc->m_RefCount = 1; |
| 143 FXFT_Library library; | 143 FXFT_Library library; |
| 144 if (m_FTLibrary == NULL) { | 144 if (m_FTLibrary == NULL) { |
| (...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 426 {g_FoxitSerifBoldFontData, 19395}, | 426 {g_FoxitSerifBoldFontData, 19395}, |
| 427 {g_FoxitSerifBoldItalicFontData, 20733}, | 427 {g_FoxitSerifBoldItalicFontData, 20733}, |
| 428 {g_FoxitSerifItalicFontData, 21227}, | 428 {g_FoxitSerifItalicFontData, 21227}, |
| 429 {g_FoxitSymbolFontData, 16729}, | 429 {g_FoxitSymbolFontData, 16729}, |
| 430 {g_FoxitDingbatsFontData, 29513}, | 430 {g_FoxitDingbatsFontData, 29513}, |
| 431 }; | 431 }; |
| 432 void _FPDFAPI_GetInternalFontData(int id, const uint8_t*& data, FX_DWORD& size) | 432 void _FPDFAPI_GetInternalFontData(int id, const uint8_t*& data, FX_DWORD& size) |
| 433 { | 433 { |
| 434 CFX_GEModule::Get()->GetFontMgr()->GetStandardFont(data, size, id); | 434 CFX_GEModule::Get()->GetFontMgr()->GetStandardFont(data, size, id); |
| 435 } | 435 } |
| 436 FX_BOOL CFX_FontMgr::GetStandardFont(const uint8_t*& pFontData, FX_DWORD& size,
int index) | 436 bool CFX_FontMgr::GetStandardFont(const uint8_t*& pFontData, FX_DWORD& size, int
index) |
| 437 { | 437 { |
| 438 if (index > 15 || index < 0) { | 438 if (index > 15 || index < 0) { |
| 439 return FALSE; | 439 return false; |
| 440 } | 440 } |
| 441 { | 441 { |
| 442 if (index >= 14) { | 442 if (index >= 14) { |
| 443 if (index == 14) { | 443 if (index == 14) { |
| 444 pFontData = g_FoxitSerifMMFontData; | 444 pFontData = g_FoxitSerifMMFontData; |
| 445 size = 113417; | 445 size = 113417; |
| 446 } else { | 446 } else { |
| 447 pFontData = g_FoxitSansMMFontData; | 447 pFontData = g_FoxitSansMMFontData; |
| 448 size = 66919; | 448 size = 66919; |
| 449 } | 449 } |
| 450 } else { | 450 } else { |
| 451 pFontData = g_FoxitFonts[index].m_pFontData; | 451 pFontData = g_FoxitFonts[index].m_pFontData; |
| 452 size = g_FoxitFonts[index].m_dwSize; | 452 size = g_FoxitFonts[index].m_dwSize; |
| 453 } | 453 } |
| 454 } | 454 } |
| 455 return TRUE; | 455 return true; |
| 456 } | 456 } |
| 457 CFX_FontMapper::CFX_FontMapper() | 457 CFX_FontMapper::CFX_FontMapper() |
| 458 { | 458 { |
| 459 FXSYS_memset(m_FoxitFaces, 0, sizeof m_FoxitFaces); | 459 FXSYS_memset(m_FoxitFaces, 0, sizeof m_FoxitFaces); |
| 460 m_MMFaces[0] = m_MMFaces[1] = NULL; | 460 m_MMFaces[0] = m_MMFaces[1] = NULL; |
| 461 m_pFontInfo = NULL; | 461 m_pFontInfo = NULL; |
| 462 m_bListLoaded = FALSE; | 462 m_bListLoaded = false; |
| 463 m_pFontEnumerator = NULL; | 463 m_pFontEnumerator = NULL; |
| 464 } | 464 } |
| 465 CFX_FontMapper::~CFX_FontMapper() | 465 CFX_FontMapper::~CFX_FontMapper() |
| 466 { | 466 { |
| 467 for (int i = 0; i < 14; i ++) | 467 for (int i = 0; i < 14; i ++) |
| 468 if (m_FoxitFaces[i]) { | 468 if (m_FoxitFaces[i]) { |
| 469 FXFT_Done_Face(m_FoxitFaces[i]); | 469 FXFT_Done_Face(m_FoxitFaces[i]); |
| 470 } | 470 } |
| 471 if (m_MMFaces[0]) { | 471 if (m_MMFaces[0]) { |
| 472 FXFT_Done_Face(m_MMFaces[0]); | 472 FXFT_Done_Face(m_MMFaces[0]); |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 576 return; | 576 return; |
| 577 } | 577 } |
| 578 if (m_CharsetArray.Find((FX_DWORD)charset) == -1) { | 578 if (m_CharsetArray.Find((FX_DWORD)charset) == -1) { |
| 579 m_CharsetArray.Add((FX_DWORD)charset); | 579 m_CharsetArray.Add((FX_DWORD)charset); |
| 580 m_FaceArray.Add(name); | 580 m_FaceArray.Add(name); |
| 581 } | 581 } |
| 582 if (name == m_LastFamily) { | 582 if (name == m_LastFamily) { |
| 583 return; | 583 return; |
| 584 } | 584 } |
| 585 const uint8_t* ptr = name; | 585 const uint8_t* ptr = name; |
| 586 FX_BOOL bLocalized = FALSE; | 586 bool bLocalized = false; |
| 587 for (int i = 0; i < name.GetLength(); i ++) | 587 for (int i = 0; i < name.GetLength(); i ++) |
| 588 if (ptr[i] > 0x80) { | 588 if (ptr[i] > 0x80) { |
| 589 bLocalized = TRUE; | 589 bLocalized = true; |
| 590 break; | 590 break; |
| 591 } | 591 } |
| 592 if (bLocalized) { | 592 if (bLocalized) { |
| 593 void* hFont = m_pFontInfo->GetFont(name); | 593 void* hFont = m_pFontInfo->GetFont(name); |
| 594 if (hFont == NULL) { | 594 if (hFont == NULL) { |
| 595 int iExact; | 595 int iExact; |
| 596 hFont = m_pFontInfo->MapFont(0, 0, FXFONT_DEFAULT_CHARSET, 0, name,
iExact); | 596 hFont = m_pFontInfo->MapFont(0, 0, FXFONT_DEFAULT_CHARSET, 0, name,
iExact); |
| 597 if (hFont == NULL) { | 597 if (hFont == NULL) { |
| 598 return; | 598 return; |
| 599 } | 599 } |
| (...skipping 13 matching lines...) Expand all Loading... |
| 613 if (m_pFontInfo == NULL) { | 613 if (m_pFontInfo == NULL) { |
| 614 return; | 614 return; |
| 615 } | 615 } |
| 616 if (m_bListLoaded) { | 616 if (m_bListLoaded) { |
| 617 return; | 617 return; |
| 618 } | 618 } |
| 619 if (m_bListLoaded) { | 619 if (m_bListLoaded) { |
| 620 return; | 620 return; |
| 621 } | 621 } |
| 622 m_pFontInfo->EnumFontList(this); | 622 m_pFontInfo->EnumFontList(this); |
| 623 m_bListLoaded = TRUE; | 623 m_bListLoaded = true; |
| 624 } | 624 } |
| 625 CFX_ByteString CFX_FontMapper::MatchInstalledFonts(const CFX_ByteString& norm_na
me) | 625 CFX_ByteString CFX_FontMapper::MatchInstalledFonts(const CFX_ByteString& norm_na
me) |
| 626 { | 626 { |
| 627 LoadInstalledFonts(); | 627 LoadInstalledFonts(); |
| 628 int i; | 628 int i; |
| 629 for (i = m_InstalledTTFonts.GetSize() - 1; i >= 0; i --) { | 629 for (i = m_InstalledTTFonts.GetSize() - 1; i >= 0; i --) { |
| 630 CFX_ByteString norm1 = _TT_NormalizeName(m_InstalledTTFonts[i]); | 630 CFX_ByteString norm1 = _TT_NormalizeName(m_InstalledTTFonts[i]); |
| 631 if (norm1 == norm_name) { | 631 if (norm1 == norm_name) { |
| 632 break; | 632 break; |
| 633 } | 633 } |
| (...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 840 } | 840 } |
| 841 while (iIndex < iLen) { | 841 while (iIndex < iLen) { |
| 842 if (pStyle[iIndex] == ',') { | 842 if (pStyle[iIndex] == ',') { |
| 843 break; | 843 break; |
| 844 } | 844 } |
| 845 buf.AppendChar(pStyle[iIndex]); | 845 buf.AppendChar(pStyle[iIndex]); |
| 846 ++iIndex; | 846 ++iIndex; |
| 847 } | 847 } |
| 848 return buf.GetByteString(); | 848 return buf.GetByteString(); |
| 849 } | 849 } |
| 850 int32_t GetStyleType(const CFX_ByteString &bsStyle, FX_BOOL bRevert) | 850 int32_t GetStyleType(const CFX_ByteString &bsStyle, bool bRevert) |
| 851 { | 851 { |
| 852 int32_t iLen = bsStyle.GetLength(); | 852 int32_t iLen = bsStyle.GetLength(); |
| 853 if (!iLen) { | 853 if (!iLen) { |
| 854 return -1; | 854 return -1; |
| 855 } | 855 } |
| 856 int iSize = sizeof(g_FontStyles) / sizeof(FX_FontStyle); | 856 int iSize = sizeof(g_FontStyles) / sizeof(FX_FontStyle); |
| 857 const FX_FontStyle *pStyle = NULL; | 857 const FX_FontStyle *pStyle = NULL; |
| 858 for (int i = iSize - 1; i >= 0; --i) { | 858 for (int i = iSize - 1; i >= 0; --i) { |
| 859 pStyle = g_FontStyles + i; | 859 pStyle = g_FontStyles + i; |
| 860 if (!pStyle || pStyle->len > iLen) { | 860 if (!pStyle || pStyle->len > iLen) { |
| 861 continue; | 861 continue; |
| 862 } | 862 } |
| 863 if (!bRevert) { | 863 if (!bRevert) { |
| 864 if (bsStyle.Left(pStyle->len).Compare(pStyle->style) == 0) { | 864 if (bsStyle.Left(pStyle->len).Compare(pStyle->style) == 0) { |
| 865 return i; | 865 return i; |
| 866 } | 866 } |
| 867 } else { | 867 } else { |
| 868 if (bsStyle.Right(pStyle->len).Compare(pStyle->style) == 0) { | 868 if (bsStyle.Right(pStyle->len).Compare(pStyle->style) == 0) { |
| 869 return i; | 869 return i; |
| 870 } | 870 } |
| 871 } | 871 } |
| 872 } | 872 } |
| 873 return -1; | 873 return -1; |
| 874 } | 874 } |
| 875 FX_BOOL CheckSupportThirdPartFont(CFX_ByteString name, int &PitchFamily) | 875 bool CheckSupportThirdPartFont(CFX_ByteString name, int &PitchFamily) |
| 876 { | 876 { |
| 877 if (name == FX_BSTRC("MyriadPro")) { | 877 if (name == FX_BSTRC("MyriadPro")) { |
| 878 PitchFamily &= ~FXFONT_FF_ROMAN; | 878 PitchFamily &= ~FXFONT_FF_ROMAN; |
| 879 return TRUE; | 879 return true; |
| 880 } | 880 } |
| 881 return FALSE; | 881 return false; |
| 882 } | 882 } |
| 883 FXFT_Face CFX_FontMapper::FindSubstFont(const CFX_ByteString& name, FX_BOOL bTru
eType, FX_DWORD flags, | 883 FXFT_Face CFX_FontMapper::FindSubstFont(const CFX_ByteString& name, bool bTrueTy
pe, FX_DWORD flags, |
| 884 int weight, int italic_angle, int Window
CP, CFX_SubstFont* pSubstFont) | 884 int weight, int italic_angle, int Window
CP, CFX_SubstFont* pSubstFont) |
| 885 { | 885 { |
| 886 if (!(flags & FXFONT_USEEXTERNATTR)) { | 886 if (!(flags & FXFONT_USEEXTERNATTR)) { |
| 887 weight = FXFONT_FW_NORMAL; | 887 weight = FXFONT_FW_NORMAL; |
| 888 italic_angle = 0; | 888 italic_angle = 0; |
| 889 } | 889 } |
| 890 CFX_ByteString SubstName = name; | 890 CFX_ByteString SubstName = name; |
| 891 SubstName.Remove(0x20); | 891 SubstName.Remove(0x20); |
| 892 if (bTrueType) { | 892 if (bTrueType) { |
| 893 if (name[0] == '@') { | 893 if (name[0] == '@') { |
| (...skipping 22 matching lines...) Expand all Loading... |
| 916 return m_FoxitFaces[13]; | 916 return m_FoxitFaces[13]; |
| 917 } | 917 } |
| 918 const uint8_t* pFontData = NULL; | 918 const uint8_t* pFontData = NULL; |
| 919 FX_DWORD size = 0; | 919 FX_DWORD size = 0; |
| 920 m_pFontMgr->GetStandardFont(pFontData, size, 13); | 920 m_pFontMgr->GetStandardFont(pFontData, size, 13); |
| 921 m_FoxitFaces[13] = m_pFontMgr->GetFixedFace(pFontData, size, 0); | 921 m_FoxitFaces[13] = m_pFontMgr->GetFixedFace(pFontData, size, 0); |
| 922 return m_FoxitFaces[13]; | 922 return m_FoxitFaces[13]; |
| 923 } | 923 } |
| 924 int iBaseFont = 0; | 924 int iBaseFont = 0; |
| 925 CFX_ByteString family, style; | 925 CFX_ByteString family, style; |
| 926 FX_BOOL» bHasComma = FALSE; | 926 bool» bHasComma = false; |
| 927 FX_BOOL bHasHypen = FALSE; | 927 bool bHasHypen = false; |
| 928 int find = SubstName.Find(FX_BSTRC(","), 0); | 928 int find = SubstName.Find(FX_BSTRC(","), 0); |
| 929 if (find >= 0) { | 929 if (find >= 0) { |
| 930 family = SubstName.Left(find); | 930 family = SubstName.Left(find); |
| 931 _PDF_GetStandardFontName(family); | 931 _PDF_GetStandardFontName(family); |
| 932 style = SubstName.Mid(find + 1); | 932 style = SubstName.Mid(find + 1); |
| 933 bHasComma = TRUE; | 933 bHasComma = true; |
| 934 } else { | 934 } else { |
| 935 family = SubstName; | 935 family = SubstName; |
| 936 } | 936 } |
| 937 for (; iBaseFont < 12; iBaseFont ++) | 937 for (; iBaseFont < 12; iBaseFont ++) |
| 938 if (family == CFX_ByteStringC(g_Base14FontNames[iBaseFont])) { | 938 if (family == CFX_ByteStringC(g_Base14FontNames[iBaseFont])) { |
| 939 break; | 939 break; |
| 940 } | 940 } |
| 941 int PitchFamily = 0; | 941 int PitchFamily = 0; |
| 942 FX_BOOL bItalic = FALSE; | 942 bool bItalic = false; |
| 943 FX_DWORD nStyle = 0; | 943 FX_DWORD nStyle = 0; |
| 944 FX_BOOL bStyleAvail = FALSE; | 944 bool bStyleAvail = false; |
| 945 if (iBaseFont < 12) { | 945 if (iBaseFont < 12) { |
| 946 family = g_Base14FontNames[iBaseFont]; | 946 family = g_Base14FontNames[iBaseFont]; |
| 947 if ((iBaseFont % 4) == 1 || (iBaseFont % 4) == 2) { | 947 if ((iBaseFont % 4) == 1 || (iBaseFont % 4) == 2) { |
| 948 nStyle |= FX_FONT_STYLE_Bold; | 948 nStyle |= FX_FONT_STYLE_Bold; |
| 949 } | 949 } |
| 950 if ((iBaseFont % 4) / 2) { | 950 if ((iBaseFont % 4) / 2) { |
| 951 nStyle |= FX_FONT_STYLE_Italic; | 951 nStyle |= FX_FONT_STYLE_Italic; |
| 952 } | 952 } |
| 953 if (iBaseFont < 4) { | 953 if (iBaseFont < 4) { |
| 954 PitchFamily |= FXFONT_FF_FIXEDPITCH; | 954 PitchFamily |= FXFONT_FF_FIXEDPITCH; |
| 955 } | 955 } |
| 956 if (iBaseFont >= 8) { | 956 if (iBaseFont >= 8) { |
| 957 PitchFamily |= FXFONT_FF_ROMAN; | 957 PitchFamily |= FXFONT_FF_ROMAN; |
| 958 } | 958 } |
| 959 } else { | 959 } else { |
| 960 if (!bHasComma) { | 960 if (!bHasComma) { |
| 961 find = family.ReverseFind('-'); | 961 find = family.ReverseFind('-'); |
| 962 if (find >= 0) { | 962 if (find >= 0) { |
| 963 style = family.Mid(find + 1); | 963 style = family.Mid(find + 1); |
| 964 family = family.Left(find); | 964 family = family.Left(find); |
| 965 bHasHypen = TRUE; | 965 bHasHypen = true; |
| 966 } | 966 } |
| 967 } | 967 } |
| 968 if (!bHasHypen) { | 968 if (!bHasHypen) { |
| 969 int nLen = family.GetLength(); | 969 int nLen = family.GetLength(); |
| 970 int32_t nRet = GetStyleType(family, TRUE); | 970 int32_t nRet = GetStyleType(family, true); |
| 971 if (nRet > -1) { | 971 if (nRet > -1) { |
| 972 family = family.Left(nLen - g_FontStyles[nRet].len); | 972 family = family.Left(nLen - g_FontStyles[nRet].len); |
| 973 if (nRet == 0) { | 973 if (nRet == 0) { |
| 974 nStyle |= FX_FONT_STYLE_Bold; | 974 nStyle |= FX_FONT_STYLE_Bold; |
| 975 } | 975 } |
| 976 if (nRet == 1) { | 976 if (nRet == 1) { |
| 977 nStyle |= FX_FONT_STYLE_Italic; | 977 nStyle |= FX_FONT_STYLE_Italic; |
| 978 } | 978 } |
| 979 if (nRet == 2) { | 979 if (nRet == 2) { |
| 980 nStyle |= (FX_FONT_STYLE_Bold | FX_FONT_STYLE_Italic); | 980 nStyle |= (FX_FONT_STYLE_Bold | FX_FONT_STYLE_Italic); |
| 981 } | 981 } |
| 982 } | 982 } |
| 983 } | 983 } |
| 984 if (flags & FXFONT_SERIF) { | 984 if (flags & FXFONT_SERIF) { |
| 985 PitchFamily |= FXFONT_FF_ROMAN; | 985 PitchFamily |= FXFONT_FF_ROMAN; |
| 986 } | 986 } |
| 987 if (flags & FXFONT_SCRIPT) { | 987 if (flags & FXFONT_SCRIPT) { |
| 988 PitchFamily |= FXFONT_FF_SCRIPT; | 988 PitchFamily |= FXFONT_FF_SCRIPT; |
| 989 } | 989 } |
| 990 if (flags & FXFONT_FIXED_PITCH) { | 990 if (flags & FXFONT_FIXED_PITCH) { |
| 991 PitchFamily |= FXFONT_FF_FIXEDPITCH; | 991 PitchFamily |= FXFONT_FF_FIXEDPITCH; |
| 992 } | 992 } |
| 993 } | 993 } |
| 994 if (!style.IsEmpty()) { | 994 if (!style.IsEmpty()) { |
| 995 int nLen = style.GetLength(); | 995 int nLen = style.GetLength(); |
| 996 const FX_CHAR* pStyle = style; | 996 const FX_CHAR* pStyle = style; |
| 997 int i = 0; | 997 int i = 0; |
| 998 FX_BOOL bFirstItem = TRUE; | 998 bool bFirstItem = true; |
| 999 CFX_ByteString buf; | 999 CFX_ByteString buf; |
| 1000 while (i < nLen) { | 1000 while (i < nLen) { |
| 1001 buf = ParseStyle(pStyle, nLen, i); | 1001 buf = ParseStyle(pStyle, nLen, i); |
| 1002 int32_t nRet = GetStyleType(buf, FALSE); | 1002 int32_t nRet = GetStyleType(buf, false); |
| 1003 if ((i && !bStyleAvail) || (!i && nRet < 0)) { | 1003 if ((i && !bStyleAvail) || (!i && nRet < 0)) { |
| 1004 family = SubstName; | 1004 family = SubstName; |
| 1005 iBaseFont = 12; | 1005 iBaseFont = 12; |
| 1006 break; | 1006 break; |
| 1007 } else if (nRet >= 0) { | 1007 } else if (nRet >= 0) { |
| 1008 bStyleAvail = TRUE; | 1008 bStyleAvail = true; |
| 1009 } | 1009 } |
| 1010 if (nRet == 0) { | 1010 if (nRet == 0) { |
| 1011 if (nStyle & FX_FONT_STYLE_Bold) { | 1011 if (nStyle & FX_FONT_STYLE_Bold) { |
| 1012 nStyle |= FX_FONT_STYLE_BoldBold; | 1012 nStyle |= FX_FONT_STYLE_BoldBold; |
| 1013 } else { | 1013 } else { |
| 1014 nStyle |= FX_FONT_STYLE_Bold; | 1014 nStyle |= FX_FONT_STYLE_Bold; |
| 1015 } | 1015 } |
| 1016 bFirstItem = FALSE; | 1016 bFirstItem = false; |
| 1017 } | 1017 } |
| 1018 if (nRet == 1) { | 1018 if (nRet == 1) { |
| 1019 if (bFirstItem) { | 1019 if (bFirstItem) { |
| 1020 nStyle |= FX_FONT_STYLE_Italic; | 1020 nStyle |= FX_FONT_STYLE_Italic; |
| 1021 } else { | 1021 } else { |
| 1022 family = SubstName; | 1022 family = SubstName; |
| 1023 iBaseFont = 12; | 1023 iBaseFont = 12; |
| 1024 } | 1024 } |
| 1025 break; | 1025 break; |
| 1026 } | 1026 } |
| 1027 if (nRet == 2) { | 1027 if (nRet == 2) { |
| 1028 nStyle |= FX_FONT_STYLE_Italic; | 1028 nStyle |= FX_FONT_STYLE_Italic; |
| 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; |
| 1031 } else { | 1031 } else { |
| 1032 nStyle |= FX_FONT_STYLE_Bold; | 1032 nStyle |= FX_FONT_STYLE_Bold; |
| 1033 } | 1033 } |
| 1034 bFirstItem = FALSE; | 1034 bFirstItem = false; |
| 1035 } | 1035 } |
| 1036 i += buf.GetLength() + 1; | 1036 i += buf.GetLength() + 1; |
| 1037 } | 1037 } |
| 1038 } | 1038 } |
| 1039 weight = weight ? weight : FXFONT_FW_NORMAL; | 1039 weight = weight ? weight : FXFONT_FW_NORMAL; |
| 1040 int old_weight = weight; | 1040 int old_weight = weight; |
| 1041 if (nStyle) { | 1041 if (nStyle) { |
| 1042 weight = nStyle & FX_FONT_STYLE_BoldBold ? 900 : (nStyle & FX_FONT_STYLE
_Bold ? FXFONT_FW_BOLD : FXFONT_FW_NORMAL); | 1042 weight = nStyle & FX_FONT_STYLE_BoldBold ? 900 : (nStyle & FX_FONT_STYLE
_Bold ? FXFONT_FW_BOLD : FXFONT_FW_NORMAL); |
| 1043 } | 1043 } |
| 1044 if (nStyle & FX_FONT_STYLE_Italic) { | 1044 if (nStyle & FX_FONT_STYLE_Italic) { |
| 1045 bItalic = TRUE; | 1045 bItalic = true; |
| 1046 } | 1046 } |
| 1047 FX_BOOL bCJK = FALSE; | 1047 bool bCJK = false; |
| 1048 int iExact = 0; | 1048 int iExact = 0; |
| 1049 int Charset = FXFONT_ANSI_CHARSET; | 1049 int Charset = FXFONT_ANSI_CHARSET; |
| 1050 if (WindowCP) { | 1050 if (WindowCP) { |
| 1051 Charset = _GetCharsetFromCodePage(WindowCP); | 1051 Charset = _GetCharsetFromCodePage(WindowCP); |
| 1052 } else if (iBaseFont == 12 && (flags & FXFONT_SYMBOLIC)) { | 1052 } else if (iBaseFont == 12 && (flags & FXFONT_SYMBOLIC)) { |
| 1053 Charset = FXFONT_SYMBOL_CHARSET; | 1053 Charset = FXFONT_SYMBOL_CHARSET; |
| 1054 } | 1054 } |
| 1055 if (Charset == FXFONT_SHIFTJIS_CHARSET || Charset == FXFONT_GB2312_CHARSET |
| | 1055 if (Charset == FXFONT_SHIFTJIS_CHARSET || Charset == FXFONT_GB2312_CHARSET |
| |
| 1056 Charset == FXFONT_HANGEUL_CHARSET || Charset == FXFONT_CHINESEBIG5_C
HARSET) { | 1056 Charset == FXFONT_HANGEUL_CHARSET || Charset == FXFONT_CHINESEBIG5_C
HARSET) { |
| 1057 bCJK = TRUE; | 1057 bCJK = true; |
| 1058 } | 1058 } |
| 1059 if (m_pFontInfo == NULL) { | 1059 if (m_pFontInfo == NULL) { |
| 1060 pSubstFont->m_SubstFlags |= FXFONT_SUBST_STANDARD; | 1060 pSubstFont->m_SubstFlags |= FXFONT_SUBST_STANDARD; |
| 1061 return UseInternalSubst(pSubstFont, iBaseFont, italic_angle, old_weight,
PitchFamily); | 1061 return UseInternalSubst(pSubstFont, iBaseFont, italic_angle, old_weight,
PitchFamily); |
| 1062 } | 1062 } |
| 1063 family = _GetFontFamily(family, nStyle); | 1063 family = _GetFontFamily(family, nStyle); |
| 1064 CFX_ByteString match = MatchInstalledFonts(_TT_NormalizeName(family)); | 1064 CFX_ByteString match = MatchInstalledFonts(_TT_NormalizeName(family)); |
| 1065 if (match.IsEmpty() && family != SubstName && (!bHasComma && (!bHasHypen ||
(bHasHypen && !bStyleAvail)))) { | 1065 if (match.IsEmpty() && family != SubstName && (!bHasComma && (!bHasHypen ||
(bHasHypen && !bStyleAvail)))) { |
| 1066 match = MatchInstalledFonts(_TT_NormalizeName(SubstName)); | 1066 match = MatchInstalledFonts(_TT_NormalizeName(SubstName)); |
| 1067 } | 1067 } |
| 1068 if (match.IsEmpty() && iBaseFont >= 12) { | 1068 if (match.IsEmpty() && iBaseFont >= 12) { |
| 1069 if (!bCJK) { | 1069 if (!bCJK) { |
| 1070 if (!CheckSupportThirdPartFont(family, PitchFamily)) { | 1070 if (!CheckSupportThirdPartFont(family, PitchFamily)) { |
| 1071 if (italic_angle != 0) { | 1071 if (italic_angle != 0) { |
| 1072 bItalic = TRUE; | 1072 bItalic = true; |
| 1073 } else { | 1073 } else { |
| 1074 bItalic = FALSE; | 1074 bItalic = false; |
| 1075 } | 1075 } |
| 1076 weight = old_weight; | 1076 weight = old_weight; |
| 1077 } | 1077 } |
| 1078 } else { | 1078 } else { |
| 1079 pSubstFont->m_bSubstOfCJK = TRUE; | 1079 pSubstFont->m_bSubstOfCJK = true; |
| 1080 if (nStyle) { | 1080 if (nStyle) { |
| 1081 pSubstFont->m_WeightCJK = weight; | 1081 pSubstFont->m_WeightCJK = weight; |
| 1082 } else { | 1082 } else { |
| 1083 pSubstFont->m_WeightCJK = FXFONT_FW_NORMAL; | 1083 pSubstFont->m_WeightCJK = FXFONT_FW_NORMAL; |
| 1084 } | 1084 } |
| 1085 if (nStyle & FX_FONT_STYLE_Italic) { | 1085 if (nStyle & FX_FONT_STYLE_Italic) { |
| 1086 pSubstFont->m_bItlicCJK = TRUE; | 1086 pSubstFont->m_bItlicCJK = true; |
| 1087 } | 1087 } |
| 1088 } | 1088 } |
| 1089 } else { | 1089 } else { |
| 1090 italic_angle = 0; | 1090 italic_angle = 0; |
| 1091 weight = nStyle & FX_FONT_STYLE_BoldBold ? 900 : (nStyle & FX_FONT_STYLE
_Bold ? FXFONT_FW_BOLD : FXFONT_FW_NORMAL); | 1091 weight = nStyle & FX_FONT_STYLE_BoldBold ? 900 : (nStyle & FX_FONT_STYLE
_Bold ? FXFONT_FW_BOLD : FXFONT_FW_NORMAL); |
| 1092 } | 1092 } |
| 1093 if (!match.IsEmpty() || iBaseFont < 12) { | 1093 if (!match.IsEmpty() || iBaseFont < 12) { |
| 1094 pSubstFont->m_SubstFlags |= FXFONT_SUBST_EXACT; | 1094 pSubstFont->m_SubstFlags |= FXFONT_SUBST_EXACT; |
| 1095 if (!match.IsEmpty()) { | 1095 if (!match.IsEmpty()) { |
| 1096 family = match; | 1096 family = match; |
| (...skipping 19 matching lines...) Expand all Loading... |
| 1116 if (m_FoxitFaces[iBaseFont]) { | 1116 if (m_FoxitFaces[iBaseFont]) { |
| 1117 return m_FoxitFaces[iBaseFont]; | 1117 return m_FoxitFaces[iBaseFont]; |
| 1118 } | 1118 } |
| 1119 } else { | 1119 } else { |
| 1120 family = g_Base14FontNames[iBaseFont]; | 1120 family = g_Base14FontNames[iBaseFont]; |
| 1121 } | 1121 } |
| 1122 pSubstFont->m_SubstFlags |= FXFONT_SUBST_STANDARD; | 1122 pSubstFont->m_SubstFlags |= FXFONT_SUBST_STANDARD; |
| 1123 } | 1123 } |
| 1124 } else { | 1124 } else { |
| 1125 if (flags & FXFONT_ITALIC) { | 1125 if (flags & FXFONT_ITALIC) { |
| 1126 bItalic = TRUE; | 1126 bItalic = true; |
| 1127 } | 1127 } |
| 1128 } | 1128 } |
| 1129 iExact = !match.IsEmpty(); | 1129 iExact = !match.IsEmpty(); |
| 1130 void* hFont = m_pFontInfo->MapFont(weight, bItalic, Charset, PitchFamily, fa
mily, iExact); | 1130 void* hFont = m_pFontInfo->MapFont(weight, bItalic, Charset, PitchFamily, fa
mily, iExact); |
| 1131 if (iExact) { | 1131 if (iExact) { |
| 1132 pSubstFont->m_SubstFlags |= FXFONT_SUBST_EXACT; | 1132 pSubstFont->m_SubstFlags |= FXFONT_SUBST_EXACT; |
| 1133 } | 1133 } |
| 1134 if (hFont == NULL) { | 1134 if (hFont == NULL) { |
| 1135 if (bCJK) { | 1135 if (bCJK) { |
| 1136 if (italic_angle != 0) { | 1136 if (italic_angle != 0) { |
| 1137 bItalic = TRUE; | 1137 bItalic = true; |
| 1138 } else { | 1138 } else { |
| 1139 bItalic = FALSE; | 1139 bItalic = false; |
| 1140 } | 1140 } |
| 1141 weight = old_weight; | 1141 weight = old_weight; |
| 1142 } | 1142 } |
| 1143 if (!match.IsEmpty()) { | 1143 if (!match.IsEmpty()) { |
| 1144 hFont = m_pFontInfo->GetFont(match); | 1144 hFont = m_pFontInfo->GetFont(match); |
| 1145 if (hFont == NULL) { | 1145 if (hFont == NULL) { |
| 1146 return UseInternalSubst(pSubstFont, iBaseFont, italic_angle, old
_weight, PitchFamily); | 1146 return UseInternalSubst(pSubstFont, iBaseFont, italic_angle, old
_weight, PitchFamily); |
| 1147 } | 1147 } |
| 1148 } else { | 1148 } else { |
| 1149 if (Charset == FXFONT_SYMBOL_CHARSET) { | 1149 if (Charset == FXFONT_SYMBOL_CHARSET) { |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1214 m_pFontInfo->GetFontData(hFont, 0, pFontData, font_size); | 1214 m_pFontInfo->GetFontData(hFont, 0, pFontData, font_size); |
| 1215 face = m_pFontMgr->AddCachedFace(SubstName, weight, bItalic, pFontDa
ta, font_size, m_pFontInfo->GetFaceIndex(hFont)); | 1215 face = m_pFontMgr->AddCachedFace(SubstName, weight, bItalic, pFontDa
ta, font_size, m_pFontInfo->GetFaceIndex(hFont)); |
| 1216 } | 1216 } |
| 1217 } | 1217 } |
| 1218 if (face == NULL) { | 1218 if (face == NULL) { |
| 1219 m_pFontInfo->DeleteFont(hFont); | 1219 m_pFontInfo->DeleteFont(hFont); |
| 1220 return NULL; | 1220 return NULL; |
| 1221 } | 1221 } |
| 1222 pSubstFont->m_Family = SubstName; | 1222 pSubstFont->m_Family = SubstName; |
| 1223 pSubstFont->m_Charset = Charset; | 1223 pSubstFont->m_Charset = Charset; |
| 1224 FX_BOOL bNeedUpdateWeight = FALSE; | 1224 bool bNeedUpdateWeight = false; |
| 1225 if (FXFT_Is_Face_Bold(face)) { | 1225 if (FXFT_Is_Face_Bold(face)) { |
| 1226 if (weight == FXFONT_FW_BOLD) { | 1226 if (weight == FXFONT_FW_BOLD) { |
| 1227 bNeedUpdateWeight = FALSE; | 1227 bNeedUpdateWeight = false; |
| 1228 } else { | 1228 } else { |
| 1229 bNeedUpdateWeight = TRUE; | 1229 bNeedUpdateWeight = true; |
| 1230 } | 1230 } |
| 1231 } else { | 1231 } else { |
| 1232 if (weight == FXFONT_FW_NORMAL) { | 1232 if (weight == FXFONT_FW_NORMAL) { |
| 1233 bNeedUpdateWeight = FALSE; | 1233 bNeedUpdateWeight = false; |
| 1234 } else { | 1234 } else { |
| 1235 bNeedUpdateWeight = TRUE; | 1235 bNeedUpdateWeight = true; |
| 1236 } | 1236 } |
| 1237 } | 1237 } |
| 1238 if (bNeedUpdateWeight) { | 1238 if (bNeedUpdateWeight) { |
| 1239 pSubstFont->m_Weight = weight; | 1239 pSubstFont->m_Weight = weight; |
| 1240 } | 1240 } |
| 1241 if (bItalic && !FXFT_Is_Face_Italic(face)) { | 1241 if (bItalic && !FXFT_Is_Face_Italic(face)) { |
| 1242 if (italic_angle == 0) { | 1242 if (italic_angle == 0) { |
| 1243 italic_angle = -12; | 1243 italic_angle = -12; |
| 1244 } else if (FXSYS_abs(italic_angle) < 5) { | 1244 } else if (FXSYS_abs(italic_angle) < 5) { |
| 1245 italic_angle = 0; | 1245 italic_angle = 0; |
| 1246 } | 1246 } |
| 1247 pSubstFont->m_ItalicAngle = italic_angle; | 1247 pSubstFont->m_ItalicAngle = italic_angle; |
| 1248 } | 1248 } |
| 1249 m_pFontInfo->DeleteFont(hFont); | 1249 m_pFontInfo->DeleteFont(hFont); |
| 1250 return face; | 1250 return face; |
| 1251 } | 1251 } |
| 1252 extern "C" { | 1252 extern "C" { |
| 1253 unsigned long _FTStreamRead(FXFT_Stream stream, unsigned long offset, | 1253 unsigned long _FTStreamRead(FXFT_Stream stream, unsigned long offset, |
| 1254 unsigned char* buffer, unsigned long count); | 1254 unsigned char* buffer, unsigned long count); |
| 1255 void _FTStreamClose(FXFT_Stream stream); | 1255 void _FTStreamClose(FXFT_Stream stream); |
| 1256 }; | 1256 }; |
| 1257 CFontFileFaceInfo::CFontFileFaceInfo() | 1257 CFontFileFaceInfo::CFontFileFaceInfo() |
| 1258 { | 1258 { |
| 1259 m_pFile = NULL; | 1259 m_pFile = NULL; |
| 1260 m_Face = NULL; | 1260 m_Face = NULL; |
| 1261 m_Charsets = 0; | 1261 m_Charsets = 0; |
| 1262 m_FileSize = 0; | 1262 m_FileSize = 0; |
| 1263 m_FontOffset = 0; | 1263 m_FontOffset = 0; |
| 1264 m_Weight = 0; | 1264 m_Weight = 0; |
| 1265 m_bItalic = FALSE; | 1265 m_bItalic = false; |
| 1266 m_PitchFamily = 0; | 1266 m_PitchFamily = 0; |
| 1267 } | 1267 } |
| 1268 CFontFileFaceInfo::~CFontFileFaceInfo() | 1268 CFontFileFaceInfo::~CFontFileFaceInfo() |
| 1269 { | 1269 { |
| 1270 if (m_Face) { | 1270 if (m_Face) { |
| 1271 FXFT_Done_Face(m_Face); | 1271 FXFT_Done_Face(m_Face); |
| 1272 } | 1272 } |
| 1273 m_Face = NULL; | 1273 m_Face = NULL; |
| 1274 } | 1274 } |
| 1275 extern FX_BOOL _LoadFile(FXFT_Library library, FXFT_Face* Face, IFX_FileRead* pF
ile, FXFT_Stream* stream); | 1275 extern bool _LoadFile(FXFT_Library library, FXFT_Face* Face, IFX_FileRead* pFile
, FXFT_Stream* stream); |
| 1276 #if _FX_OS_ == _FX_ANDROID_ | 1276 #if _FX_OS_ == _FX_ANDROID_ |
| 1277 IFX_SystemFontInfo* IFX_SystemFontInfo::CreateDefault() | 1277 IFX_SystemFontInfo* IFX_SystemFontInfo::CreateDefault() |
| 1278 { | 1278 { |
| 1279 return NULL; | 1279 return NULL; |
| 1280 } | 1280 } |
| 1281 #endif | 1281 #endif |
| 1282 CFX_FolderFontInfo::CFX_FolderFontInfo() | 1282 CFX_FolderFontInfo::CFX_FolderFontInfo() |
| 1283 { | 1283 { |
| 1284 } | 1284 } |
| 1285 CFX_FolderFontInfo::~CFX_FolderFontInfo() | 1285 CFX_FolderFontInfo::~CFX_FolderFontInfo() |
| 1286 { | 1286 { |
| 1287 FX_POSITION pos = m_FontList.GetStartPosition(); | 1287 FX_POSITION pos = m_FontList.GetStartPosition(); |
| 1288 while (pos) { | 1288 while (pos) { |
| 1289 CFX_ByteString key; | 1289 CFX_ByteString key; |
| 1290 void* value; | 1290 void* value; |
| 1291 m_FontList.GetNextAssoc(pos, key, value); | 1291 m_FontList.GetNextAssoc(pos, key, value); |
| 1292 delete (CFontFaceInfo*)value; | 1292 delete (CFontFaceInfo*)value; |
| 1293 } | 1293 } |
| 1294 } | 1294 } |
| 1295 void CFX_FolderFontInfo::AddPath(const CFX_ByteStringC& path) | 1295 void CFX_FolderFontInfo::AddPath(const CFX_ByteStringC& path) |
| 1296 { | 1296 { |
| 1297 m_PathList.Add(path); | 1297 m_PathList.Add(path); |
| 1298 } | 1298 } |
| 1299 void CFX_FolderFontInfo::Release() | 1299 void CFX_FolderFontInfo::Release() |
| 1300 { | 1300 { |
| 1301 delete this; | 1301 delete this; |
| 1302 } | 1302 } |
| 1303 FX_BOOL CFX_FolderFontInfo::EnumFontList(CFX_FontMapper* pMapper) | 1303 bool CFX_FolderFontInfo::EnumFontList(CFX_FontMapper* pMapper) |
| 1304 { | 1304 { |
| 1305 m_pMapper = pMapper; | 1305 m_pMapper = pMapper; |
| 1306 for (int i = 0; i < m_PathList.GetSize(); i ++) { | 1306 for (int i = 0; i < m_PathList.GetSize(); i ++) { |
| 1307 ScanPath(m_PathList[i]); | 1307 ScanPath(m_PathList[i]); |
| 1308 } | 1308 } |
| 1309 return TRUE; | 1309 return true; |
| 1310 } | 1310 } |
| 1311 void CFX_FolderFontInfo::ScanPath(CFX_ByteString& path) | 1311 void CFX_FolderFontInfo::ScanPath(CFX_ByteString& path) |
| 1312 { | 1312 { |
| 1313 void* handle = FX_OpenFolder(path); | 1313 void* handle = FX_OpenFolder(path); |
| 1314 if (handle == NULL) { | 1314 if (handle == NULL) { |
| 1315 return; | 1315 return; |
| 1316 } | 1316 } |
| 1317 CFX_ByteString filename; | 1317 CFX_ByteString filename; |
| 1318 FX_BOOL bFolder; | 1318 bool bFolder; |
| 1319 while (FX_GetNextFile(handle, filename, bFolder)) { | 1319 while (FX_GetNextFile(handle, filename, bFolder)) { |
| 1320 if (bFolder) { | 1320 if (bFolder) { |
| 1321 if (filename == "." || filename == "..") { | 1321 if (filename == "." || filename == "..") { |
| 1322 continue; | 1322 continue; |
| 1323 } | 1323 } |
| 1324 } else { | 1324 } else { |
| 1325 CFX_ByteString ext = filename.Right(4); | 1325 CFX_ByteString ext = filename.Right(4); |
| 1326 ext.MakeUpper(); | 1326 ext.MakeUpper(); |
| 1327 if (ext != ".TTF" && ext != ".OTF" && ext != ".TTC") { | 1327 if (ext != ".TTF" && ext != ".OTF" && ext != ".TTC") { |
| 1328 continue; | 1328 continue; |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1444 pInfo->m_Styles |= FXFONT_BOLD; | 1444 pInfo->m_Styles |= FXFONT_BOLD; |
| 1445 } | 1445 } |
| 1446 if (style.Find(FX_BSTRC("Italic")) > -1 || style.Find(FX_BSTRC("Oblique")) >
-1) { | 1446 if (style.Find(FX_BSTRC("Italic")) > -1 || style.Find(FX_BSTRC("Oblique")) >
-1) { |
| 1447 pInfo->m_Styles |= FXFONT_ITALIC; | 1447 pInfo->m_Styles |= FXFONT_ITALIC; |
| 1448 } | 1448 } |
| 1449 if (facename.Find(FX_BSTRC("Serif")) > -1) { | 1449 if (facename.Find(FX_BSTRC("Serif")) > -1) { |
| 1450 pInfo->m_Styles |= FXFONT_SERIF; | 1450 pInfo->m_Styles |= FXFONT_SERIF; |
| 1451 } | 1451 } |
| 1452 m_FontList.SetAt(facename, pInfo); | 1452 m_FontList.SetAt(facename, pInfo); |
| 1453 } | 1453 } |
| 1454 void* CFX_FolderFontInfo::MapFont(int weight, FX_BOOL bItalic, int charset, int
pitch_family, const FX_CHAR* family, int& iExact) | 1454 void* CFX_FolderFontInfo::MapFont(int weight, bool bItalic, int charset, int pit
ch_family, const FX_CHAR* family, int& iExact) |
| 1455 { | 1455 { |
| 1456 return NULL; | 1456 return NULL; |
| 1457 } | 1457 } |
| 1458 void* CFX_FolderFontInfo::GetFont(const FX_CHAR* face) | 1458 void* CFX_FolderFontInfo::GetFont(const FX_CHAR* face) |
| 1459 { | 1459 { |
| 1460 void* p; | 1460 void* p; |
| 1461 if (!m_FontList.Lookup(face, p)) { | 1461 if (!m_FontList.Lookup(face, p)) { |
| 1462 return NULL; | 1462 return NULL; |
| 1463 } | 1463 } |
| 1464 return p; | 1464 return p; |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1499 FXSYS_fread(buffer, datasize, 1, pFile); | 1499 FXSYS_fread(buffer, datasize, 1, pFile); |
| 1500 } | 1500 } |
| 1501 if (pFile) { | 1501 if (pFile) { |
| 1502 FXSYS_fclose(pFile); | 1502 FXSYS_fclose(pFile); |
| 1503 } | 1503 } |
| 1504 return datasize; | 1504 return datasize; |
| 1505 } | 1505 } |
| 1506 void CFX_FolderFontInfo::DeleteFont(void* hFont) | 1506 void CFX_FolderFontInfo::DeleteFont(void* hFont) |
| 1507 { | 1507 { |
| 1508 } | 1508 } |
| 1509 FX_BOOL CFX_FolderFontInfo::GetFaceName(void* hFont, CFX_ByteString& name) | 1509 bool CFX_FolderFontInfo::GetFaceName(void* hFont, CFX_ByteString& name) |
| 1510 { | 1510 { |
| 1511 if (hFont == NULL) { | 1511 if (hFont == NULL) { |
| 1512 return FALSE; | 1512 return false; |
| 1513 } | 1513 } |
| 1514 CFontFaceInfo* pFont = (CFontFaceInfo*)hFont; | 1514 CFontFaceInfo* pFont = (CFontFaceInfo*)hFont; |
| 1515 name = pFont->m_FaceName; | 1515 name = pFont->m_FaceName; |
| 1516 return TRUE; | 1516 return true; |
| 1517 } | 1517 } |
| 1518 FX_BOOL CFX_FolderFontInfo::GetFontCharset(void* hFont, int& charset) | 1518 bool CFX_FolderFontInfo::GetFontCharset(void* hFont, int& charset) |
| 1519 { | 1519 { |
| 1520 return FALSE; | 1520 return false; |
| 1521 } | 1521 } |
| OLD | NEW |