Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(283)

Side by Side Diff: core/src/fxge/ge/fx_ge_fontmap.cpp

Issue 1252613002: FX_BOOL considered harmful. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Manual edits. Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « core/src/fxge/ge/fx_ge_font.cpp ('k') | core/src/fxge/ge/fx_ge_linux.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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
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 FX_BOOL bExact; 595 int iExact;
596 hFont = m_pFontInfo->MapFont(0, 0, FXFONT_DEFAULT_CHARSET, 0, name, bExact); 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 }
600 } 600 }
601 CFX_ByteString new_name = GetPSNameFromTT(hFont); 601 CFX_ByteString new_name = GetPSNameFromTT(hFont);
602 if (!new_name.IsEmpty()) { 602 if (!new_name.IsEmpty()) {
603 new_name.Insert(0, ' '); 603 new_name.Insert(0, ' ');
604 m_InstalledTTFonts.Add(new_name); 604 m_InstalledTTFonts.Add(new_name);
605 } 605 }
606 m_pFontInfo->DeleteFont(hFont); 606 m_pFontInfo->DeleteFont(hFont);
607 } 607 }
608 m_InstalledTTFonts.Add(name); 608 m_InstalledTTFonts.Add(name);
609 m_LastFamily = name; 609 m_LastFamily = name;
610 } 610 }
611 void CFX_FontMapper::LoadInstalledFonts() 611 void CFX_FontMapper::LoadInstalledFonts()
612 { 612 {
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 205 matching lines...) Expand 10 before | Expand all | Expand 10 after
839 } 839 }
840 while (iIndex < iLen) { 840 while (iIndex < iLen) {
841 if (pStyle[iIndex] == ',') { 841 if (pStyle[iIndex] == ',') {
842 break; 842 break;
843 } 843 }
844 buf.AppendChar(pStyle[iIndex]); 844 buf.AppendChar(pStyle[iIndex]);
845 ++iIndex; 845 ++iIndex;
846 } 846 }
847 return buf.GetByteString(); 847 return buf.GetByteString();
848 } 848 }
849 int32_t GetStyleType(const CFX_ByteString &bsStyle, FX_BOOL bRevert) 849 int32_t GetStyleType(const CFX_ByteString &bsStyle, bool bRevert)
850 { 850 {
851 int32_t iLen = bsStyle.GetLength(); 851 int32_t iLen = bsStyle.GetLength();
852 if (!iLen) { 852 if (!iLen) {
853 return -1; 853 return -1;
854 } 854 }
855 int iSize = sizeof(g_FontStyles) / sizeof(FX_FontStyle); 855 int iSize = sizeof(g_FontStyles) / sizeof(FX_FontStyle);
856 const FX_FontStyle *pStyle = NULL; 856 const FX_FontStyle *pStyle = NULL;
857 for (int i = iSize - 1; i >= 0; --i) { 857 for (int i = iSize - 1; i >= 0; --i) {
858 pStyle = g_FontStyles + i; 858 pStyle = g_FontStyles + i;
859 if (!pStyle || pStyle->len > iLen) { 859 if (!pStyle || pStyle->len > iLen) {
860 continue; 860 continue;
861 } 861 }
862 if (!bRevert) { 862 if (!bRevert) {
863 if (bsStyle.Left(pStyle->len).Compare(pStyle->style) == 0) { 863 if (bsStyle.Left(pStyle->len).Compare(pStyle->style) == 0) {
864 return i; 864 return i;
865 } 865 }
866 } else { 866 } else {
867 if (bsStyle.Right(pStyle->len).Compare(pStyle->style) == 0) { 867 if (bsStyle.Right(pStyle->len).Compare(pStyle->style) == 0) {
868 return i; 868 return i;
869 } 869 }
870 } 870 }
871 } 871 }
872 return -1; 872 return -1;
873 } 873 }
874 FX_BOOL CheckSupportThirdPartFont(CFX_ByteString name, int &PitchFamily) 874 bool CheckSupportThirdPartFont(CFX_ByteString name, int &PitchFamily)
875 { 875 {
876 if (name == FX_BSTRC("MyriadPro")) { 876 if (name == FX_BSTRC("MyriadPro")) {
877 PitchFamily &= ~FXFONT_FF_ROMAN; 877 PitchFamily &= ~FXFONT_FF_ROMAN;
878 return TRUE; 878 return true;
879 } 879 }
880 return FALSE; 880 return false;
881 } 881 }
882 FXFT_Face CFX_FontMapper::FindSubstFont(const CFX_ByteString& name, FX_BOOL bTru eType, FX_DWORD flags, 882 FXFT_Face CFX_FontMapper::FindSubstFont(const CFX_ByteString& name, bool bTrueTy pe, FX_DWORD flags,
883 int weight, int italic_angle, int Window CP, CFX_SubstFont* pSubstFont) 883 int weight, int italic_angle, int Window CP, CFX_SubstFont* pSubstFont)
884 { 884 {
885 if (!(flags & FXFONT_USEEXTERNATTR)) { 885 if (!(flags & FXFONT_USEEXTERNATTR)) {
886 weight = FXFONT_FW_NORMAL; 886 weight = FXFONT_FW_NORMAL;
887 italic_angle = 0; 887 italic_angle = 0;
888 } 888 }
889 CFX_ByteString SubstName = name; 889 CFX_ByteString SubstName = name;
890 SubstName.Remove(0x20); 890 SubstName.Remove(0x20);
891 if (bTrueType) { 891 if (bTrueType) {
892 if (name[0] == '@') { 892 if (name[0] == '@') {
(...skipping 22 matching lines...) Expand all
915 return m_FoxitFaces[13]; 915 return m_FoxitFaces[13];
916 } 916 }
917 const uint8_t* pFontData = NULL; 917 const uint8_t* pFontData = NULL;
918 FX_DWORD size = 0; 918 FX_DWORD size = 0;
919 m_pFontMgr->GetStandardFont(pFontData, size, 13); 919 m_pFontMgr->GetStandardFont(pFontData, size, 13);
920 m_FoxitFaces[13] = m_pFontMgr->GetFixedFace(pFontData, size, 0); 920 m_FoxitFaces[13] = m_pFontMgr->GetFixedFace(pFontData, size, 0);
921 return m_FoxitFaces[13]; 921 return m_FoxitFaces[13];
922 } 922 }
923 int iBaseFont = 0; 923 int iBaseFont = 0;
924 CFX_ByteString family, style; 924 CFX_ByteString family, style;
925 FX_BOOL» bHasComma = FALSE; 925 bool» bHasComma = false;
926 FX_BOOL bHasHypen = FALSE; 926 bool bHasHypen = false;
927 int find = SubstName.Find(FX_BSTRC(","), 0); 927 int find = SubstName.Find(FX_BSTRC(","), 0);
928 if (find >= 0) { 928 if (find >= 0) {
929 family = SubstName.Left(find); 929 family = SubstName.Left(find);
930 _PDF_GetStandardFontName(family); 930 _PDF_GetStandardFontName(family);
931 style = SubstName.Mid(find + 1); 931 style = SubstName.Mid(find + 1);
932 bHasComma = TRUE; 932 bHasComma = true;
933 } else { 933 } else {
934 family = SubstName; 934 family = SubstName;
935 } 935 }
936 for (; iBaseFont < 12; iBaseFont ++) 936 for (; iBaseFont < 12; iBaseFont ++)
937 if (family == CFX_ByteStringC(g_Base14FontNames[iBaseFont])) { 937 if (family == CFX_ByteStringC(g_Base14FontNames[iBaseFont])) {
938 break; 938 break;
939 } 939 }
940 int PitchFamily = 0; 940 int PitchFamily = 0;
941 FX_BOOL bItalic = FALSE; 941 bool bItalic = false;
942 FX_DWORD nStyle = 0; 942 FX_DWORD nStyle = 0;
943 FX_BOOL bStyleAvail = FALSE; 943 bool bStyleAvail = false;
944 if (iBaseFont < 12) { 944 if (iBaseFont < 12) {
945 family = g_Base14FontNames[iBaseFont]; 945 family = g_Base14FontNames[iBaseFont];
946 if ((iBaseFont % 4) == 1 || (iBaseFont % 4) == 2) { 946 if ((iBaseFont % 4) == 1 || (iBaseFont % 4) == 2) {
947 nStyle |= FX_FONT_STYLE_Bold; 947 nStyle |= FX_FONT_STYLE_Bold;
948 } 948 }
949 if ((iBaseFont % 4) / 2) { 949 if ((iBaseFont % 4) / 2) {
950 nStyle |= FX_FONT_STYLE_Italic; 950 nStyle |= FX_FONT_STYLE_Italic;
951 } 951 }
952 if (iBaseFont < 4) { 952 if (iBaseFont < 4) {
953 PitchFamily |= FXFONT_FF_FIXEDPITCH; 953 PitchFamily |= FXFONT_FF_FIXEDPITCH;
954 } 954 }
955 if (iBaseFont >= 8) { 955 if (iBaseFont >= 8) {
956 PitchFamily |= FXFONT_FF_ROMAN; 956 PitchFamily |= FXFONT_FF_ROMAN;
957 } 957 }
958 } else { 958 } else {
959 if (!bHasComma) { 959 if (!bHasComma) {
960 find = family.ReverseFind('-'); 960 find = family.ReverseFind('-');
961 if (find >= 0) { 961 if (find >= 0) {
962 style = family.Mid(find + 1); 962 style = family.Mid(find + 1);
963 family = family.Left(find); 963 family = family.Left(find);
964 bHasHypen = TRUE; 964 bHasHypen = true;
965 } 965 }
966 } 966 }
967 if (!bHasHypen) { 967 if (!bHasHypen) {
968 int nLen = family.GetLength(); 968 int nLen = family.GetLength();
969 int32_t nRet = GetStyleType(family, TRUE); 969 int32_t nRet = GetStyleType(family, true);
970 if (nRet > -1) { 970 if (nRet > -1) {
971 family = family.Left(nLen - g_FontStyles[nRet].len); 971 family = family.Left(nLen - g_FontStyles[nRet].len);
972 if (nRet == 0) { 972 if (nRet == 0) {
973 nStyle |= FX_FONT_STYLE_Bold; 973 nStyle |= FX_FONT_STYLE_Bold;
974 } 974 }
975 if (nRet == 1) { 975 if (nRet == 1) {
976 nStyle |= FX_FONT_STYLE_Italic; 976 nStyle |= FX_FONT_STYLE_Italic;
977 } 977 }
978 if (nRet == 2) { 978 if (nRet == 2) {
979 nStyle |= (FX_FONT_STYLE_Bold | FX_FONT_STYLE_Italic); 979 nStyle |= (FX_FONT_STYLE_Bold | FX_FONT_STYLE_Italic);
980 } 980 }
981 } 981 }
982 } 982 }
983 if (flags & FXFONT_SERIF) { 983 if (flags & FXFONT_SERIF) {
984 PitchFamily |= FXFONT_FF_ROMAN; 984 PitchFamily |= FXFONT_FF_ROMAN;
985 } 985 }
986 if (flags & FXFONT_SCRIPT) { 986 if (flags & FXFONT_SCRIPT) {
987 PitchFamily |= FXFONT_FF_SCRIPT; 987 PitchFamily |= FXFONT_FF_SCRIPT;
988 } 988 }
989 if (flags & FXFONT_FIXED_PITCH) { 989 if (flags & FXFONT_FIXED_PITCH) {
990 PitchFamily |= FXFONT_FF_FIXEDPITCH; 990 PitchFamily |= FXFONT_FF_FIXEDPITCH;
991 } 991 }
992 } 992 }
993 if (!style.IsEmpty()) { 993 if (!style.IsEmpty()) {
994 int nLen = style.GetLength(); 994 int nLen = style.GetLength();
995 const FX_CHAR* pStyle = style; 995 const FX_CHAR* pStyle = style;
996 int i = 0; 996 int i = 0;
997 FX_BOOL bFirstItem = TRUE; 997 bool bFirstItem = true;
998 CFX_ByteString buf; 998 CFX_ByteString buf;
999 while (i < nLen) { 999 while (i < nLen) {
1000 buf = ParseStyle(pStyle, nLen, i); 1000 buf = ParseStyle(pStyle, nLen, i);
1001 int32_t nRet = GetStyleType(buf, FALSE); 1001 int32_t nRet = GetStyleType(buf, false);
1002 if ((i && !bStyleAvail) || (!i && nRet < 0)) { 1002 if ((i && !bStyleAvail) || (!i && nRet < 0)) {
1003 family = SubstName; 1003 family = SubstName;
1004 iBaseFont = 12; 1004 iBaseFont = 12;
1005 break; 1005 break;
1006 } else if (nRet >= 0) { 1006 } else if (nRet >= 0) {
1007 bStyleAvail = TRUE; 1007 bStyleAvail = true;
1008 } 1008 }
1009 if (nRet == 0) { 1009 if (nRet == 0) {
1010 if (nStyle & FX_FONT_STYLE_Bold) { 1010 if (nStyle & FX_FONT_STYLE_Bold) {
1011 nStyle |= FX_FONT_STYLE_BoldBold; 1011 nStyle |= FX_FONT_STYLE_BoldBold;
1012 } else { 1012 } else {
1013 nStyle |= FX_FONT_STYLE_Bold; 1013 nStyle |= FX_FONT_STYLE_Bold;
1014 } 1014 }
1015 bFirstItem = FALSE; 1015 bFirstItem = false;
1016 } 1016 }
1017 if (nRet == 1) { 1017 if (nRet == 1) {
1018 if (bFirstItem) { 1018 if (bFirstItem) {
1019 nStyle |= FX_FONT_STYLE_Italic; 1019 nStyle |= FX_FONT_STYLE_Italic;
1020 } else { 1020 } else {
1021 family = SubstName; 1021 family = SubstName;
1022 iBaseFont = 12; 1022 iBaseFont = 12;
1023 } 1023 }
1024 break; 1024 break;
1025 } 1025 }
1026 if (nRet == 2) { 1026 if (nRet == 2) {
1027 nStyle |= FX_FONT_STYLE_Italic; 1027 nStyle |= FX_FONT_STYLE_Italic;
1028 if (nStyle & FX_FONT_STYLE_Bold) { 1028 if (nStyle & FX_FONT_STYLE_Bold) {
1029 nStyle |= FX_FONT_STYLE_BoldBold; 1029 nStyle |= FX_FONT_STYLE_BoldBold;
1030 } else { 1030 } else {
1031 nStyle |= FX_FONT_STYLE_Bold; 1031 nStyle |= FX_FONT_STYLE_Bold;
1032 } 1032 }
1033 bFirstItem = FALSE; 1033 bFirstItem = false;
1034 } 1034 }
1035 i += buf.GetLength() + 1; 1035 i += buf.GetLength() + 1;
1036 } 1036 }
1037 } 1037 }
1038 weight = weight ? weight : FXFONT_FW_NORMAL; 1038 weight = weight ? weight : FXFONT_FW_NORMAL;
1039 int old_weight = weight; 1039 int old_weight = weight;
1040 if (nStyle) { 1040 if (nStyle) {
1041 weight = nStyle & FX_FONT_STYLE_BoldBold ? 900 : (nStyle & FX_FONT_STYLE _Bold ? FXFONT_FW_BOLD : FXFONT_FW_NORMAL); 1041 weight = nStyle & FX_FONT_STYLE_BoldBold ? 900 : (nStyle & FX_FONT_STYLE _Bold ? FXFONT_FW_BOLD : FXFONT_FW_NORMAL);
1042 } 1042 }
1043 if (nStyle & FX_FONT_STYLE_Italic) { 1043 if (nStyle & FX_FONT_STYLE_Italic) {
1044 bItalic = TRUE; 1044 bItalic = true;
1045 } 1045 }
1046 FX_BOOL bCJK = FALSE; 1046 bool bCJK = false;
1047 FX_BOOL bExact = FALSE; 1047 int iExact = 0;
1048 int Charset = FXFONT_ANSI_CHARSET; 1048 int Charset = FXFONT_ANSI_CHARSET;
1049 if (WindowCP) { 1049 if (WindowCP) {
1050 Charset = _GetCharsetFromCodePage(WindowCP); 1050 Charset = _GetCharsetFromCodePage(WindowCP);
1051 } else if (iBaseFont == 12 && (flags & FXFONT_SYMBOLIC)) { 1051 } else if (iBaseFont == 12 && (flags & FXFONT_SYMBOLIC)) {
1052 Charset = FXFONT_SYMBOL_CHARSET; 1052 Charset = FXFONT_SYMBOL_CHARSET;
1053 } 1053 }
1054 if (Charset == FXFONT_SHIFTJIS_CHARSET || Charset == FXFONT_GB2312_CHARSET | | 1054 if (Charset == FXFONT_SHIFTJIS_CHARSET || Charset == FXFONT_GB2312_CHARSET | |
1055 Charset == FXFONT_HANGEUL_CHARSET || Charset == FXFONT_CHINESEBIG5_C HARSET) { 1055 Charset == FXFONT_HANGEUL_CHARSET || Charset == FXFONT_CHINESEBIG5_C HARSET) {
1056 bCJK = TRUE; 1056 bCJK = true;
1057 } 1057 }
1058 if (m_pFontInfo == NULL) { 1058 if (m_pFontInfo == NULL) {
1059 pSubstFont->m_SubstFlags |= FXFONT_SUBST_STANDARD; 1059 pSubstFont->m_SubstFlags |= FXFONT_SUBST_STANDARD;
1060 return UseInternalSubst(pSubstFont, iBaseFont, italic_angle, old_weight, PitchFamily); 1060 return UseInternalSubst(pSubstFont, iBaseFont, italic_angle, old_weight, PitchFamily);
1061 } 1061 }
1062 family = _GetFontFamily(family, nStyle); 1062 family = _GetFontFamily(family, nStyle);
1063 CFX_ByteString match = MatchInstalledFonts(_TT_NormalizeName(family)); 1063 CFX_ByteString match = MatchInstalledFonts(_TT_NormalizeName(family));
1064 if (match.IsEmpty() && family != SubstName && (!bHasComma && (!bHasHypen || (bHasHypen && !bStyleAvail)))) { 1064 if (match.IsEmpty() && family != SubstName && (!bHasComma && (!bHasHypen || (bHasHypen && !bStyleAvail)))) {
1065 match = MatchInstalledFonts(_TT_NormalizeName(SubstName)); 1065 match = MatchInstalledFonts(_TT_NormalizeName(SubstName));
1066 } 1066 }
1067 if (match.IsEmpty() && iBaseFont >= 12) { 1067 if (match.IsEmpty() && iBaseFont >= 12) {
1068 if (!bCJK) { 1068 if (!bCJK) {
1069 if (!CheckSupportThirdPartFont(family, PitchFamily)) { 1069 if (!CheckSupportThirdPartFont(family, PitchFamily)) {
1070 if (italic_angle != 0) { 1070 if (italic_angle != 0) {
1071 bItalic = TRUE; 1071 bItalic = true;
1072 } else { 1072 } else {
1073 bItalic = FALSE; 1073 bItalic = false;
1074 } 1074 }
1075 weight = old_weight; 1075 weight = old_weight;
1076 } 1076 }
1077 } else { 1077 } else {
1078 pSubstFont->m_bSubstOfCJK = TRUE; 1078 pSubstFont->m_bSubstOfCJK = true;
1079 if (nStyle) { 1079 if (nStyle) {
1080 pSubstFont->m_WeightCJK = weight; 1080 pSubstFont->m_WeightCJK = weight;
1081 } else { 1081 } else {
1082 pSubstFont->m_WeightCJK = FXFONT_FW_NORMAL; 1082 pSubstFont->m_WeightCJK = FXFONT_FW_NORMAL;
1083 } 1083 }
1084 if (nStyle & FX_FONT_STYLE_Italic) { 1084 if (nStyle & FX_FONT_STYLE_Italic) {
1085 pSubstFont->m_bItlicCJK = TRUE; 1085 pSubstFont->m_bItlicCJK = true;
1086 } 1086 }
1087 } 1087 }
1088 } else { 1088 } else {
1089 italic_angle = 0; 1089 italic_angle = 0;
1090 weight = nStyle & FX_FONT_STYLE_BoldBold ? 900 : (nStyle & FX_FONT_STYLE _Bold ? FXFONT_FW_BOLD : FXFONT_FW_NORMAL); 1090 weight = nStyle & FX_FONT_STYLE_BoldBold ? 900 : (nStyle & FX_FONT_STYLE _Bold ? FXFONT_FW_BOLD : FXFONT_FW_NORMAL);
1091 } 1091 }
1092 if (!match.IsEmpty() || iBaseFont < 12) { 1092 if (!match.IsEmpty() || iBaseFont < 12) {
1093 pSubstFont->m_SubstFlags |= FXFONT_SUBST_EXACT; 1093 pSubstFont->m_SubstFlags |= FXFONT_SUBST_EXACT;
1094 if (!match.IsEmpty()) { 1094 if (!match.IsEmpty()) {
1095 family = match; 1095 family = match;
(...skipping 19 matching lines...) Expand all
1115 if (m_FoxitFaces[iBaseFont]) { 1115 if (m_FoxitFaces[iBaseFont]) {
1116 return m_FoxitFaces[iBaseFont]; 1116 return m_FoxitFaces[iBaseFont];
1117 } 1117 }
1118 } else { 1118 } else {
1119 family = g_Base14FontNames[iBaseFont]; 1119 family = g_Base14FontNames[iBaseFont];
1120 } 1120 }
1121 pSubstFont->m_SubstFlags |= FXFONT_SUBST_STANDARD; 1121 pSubstFont->m_SubstFlags |= FXFONT_SUBST_STANDARD;
1122 } 1122 }
1123 } else { 1123 } else {
1124 if (flags & FXFONT_ITALIC) { 1124 if (flags & FXFONT_ITALIC) {
1125 bItalic = TRUE; 1125 bItalic = true;
1126 } 1126 }
1127 } 1127 }
1128 bExact = !match.IsEmpty(); 1128 iExact = !match.IsEmpty();
1129 void* hFont = m_pFontInfo->MapFont(weight, bItalic, Charset, PitchFamily, fa mily, bExact); 1129 void* hFont = m_pFontInfo->MapFont(weight, bItalic, Charset, PitchFamily, fa mily, iExact);
1130 if (bExact) { 1130 if (iExact) {
1131 pSubstFont->m_SubstFlags |= FXFONT_SUBST_EXACT; 1131 pSubstFont->m_SubstFlags |= FXFONT_SUBST_EXACT;
1132 } 1132 }
1133 if (hFont == NULL) { 1133 if (hFont == NULL) {
1134 if (bCJK) { 1134 if (bCJK) {
1135 if (italic_angle != 0) { 1135 if (italic_angle != 0) {
1136 bItalic = TRUE; 1136 bItalic = true;
1137 } else { 1137 } else {
1138 bItalic = FALSE; 1138 bItalic = false;
1139 } 1139 }
1140 weight = old_weight; 1140 weight = old_weight;
1141 } 1141 }
1142 if (!match.IsEmpty()) { 1142 if (!match.IsEmpty()) {
1143 hFont = m_pFontInfo->GetFont(match); 1143 hFont = m_pFontInfo->GetFont(match);
1144 if (hFont == NULL) { 1144 if (hFont == NULL) {
1145 return UseInternalSubst(pSubstFont, iBaseFont, italic_angle, old _weight, PitchFamily); 1145 return UseInternalSubst(pSubstFont, iBaseFont, italic_angle, old _weight, PitchFamily);
1146 } 1146 }
1147 } else { 1147 } else {
1148 if (Charset == FXFONT_SYMBOL_CHARSET) { 1148 if (Charset == FXFONT_SYMBOL_CHARSET) {
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
1218 m_pFontInfo->GetFontData(hFont, 0, pFontData, font_size); 1218 m_pFontInfo->GetFontData(hFont, 0, pFontData, font_size);
1219 face = m_pFontMgr->AddCachedFace(SubstName, weight, bItalic, pFontDa ta, font_size, m_pFontInfo->GetFaceIndex(hFont)); 1219 face = m_pFontMgr->AddCachedFace(SubstName, weight, bItalic, pFontDa ta, font_size, m_pFontInfo->GetFaceIndex(hFont));
1220 } 1220 }
1221 } 1221 }
1222 if (face == NULL) { 1222 if (face == NULL) {
1223 m_pFontInfo->DeleteFont(hFont); 1223 m_pFontInfo->DeleteFont(hFont);
1224 return NULL; 1224 return NULL;
1225 } 1225 }
1226 pSubstFont->m_Family = SubstName; 1226 pSubstFont->m_Family = SubstName;
1227 pSubstFont->m_Charset = Charset; 1227 pSubstFont->m_Charset = Charset;
1228 FX_BOOL bNeedUpdateWeight = FALSE; 1228 bool bNeedUpdateWeight = false;
1229 if (FXFT_Is_Face_Bold(face)) { 1229 if (FXFT_Is_Face_Bold(face)) {
1230 if (weight == FXFONT_FW_BOLD) { 1230 if (weight == FXFONT_FW_BOLD) {
1231 bNeedUpdateWeight = FALSE; 1231 bNeedUpdateWeight = false;
1232 } else { 1232 } else {
1233 bNeedUpdateWeight = TRUE; 1233 bNeedUpdateWeight = true;
1234 } 1234 }
1235 } else { 1235 } else {
1236 if (weight == FXFONT_FW_NORMAL) { 1236 if (weight == FXFONT_FW_NORMAL) {
1237 bNeedUpdateWeight = FALSE; 1237 bNeedUpdateWeight = false;
1238 } else { 1238 } else {
1239 bNeedUpdateWeight = TRUE; 1239 bNeedUpdateWeight = true;
1240 } 1240 }
1241 } 1241 }
1242 if (bNeedUpdateWeight) { 1242 if (bNeedUpdateWeight) {
1243 pSubstFont->m_Weight = weight; 1243 pSubstFont->m_Weight = weight;
1244 } 1244 }
1245 if (bItalic && !FXFT_Is_Face_Italic(face)) { 1245 if (bItalic && !FXFT_Is_Face_Italic(face)) {
1246 if (italic_angle == 0) { 1246 if (italic_angle == 0) {
1247 italic_angle = -12; 1247 italic_angle = -12;
1248 } else if (FXSYS_abs(italic_angle) < 5) { 1248 } else if (FXSYS_abs(italic_angle) < 5) {
1249 italic_angle = 0; 1249 italic_angle = 0;
1250 } 1250 }
1251 pSubstFont->m_ItalicAngle = italic_angle; 1251 pSubstFont->m_ItalicAngle = italic_angle;
1252 } 1252 }
1253 m_pFontInfo->DeleteFont(hFont); 1253 m_pFontInfo->DeleteFont(hFont);
1254 return face; 1254 return face;
1255 } 1255 }
1256 extern "C" { 1256 extern "C" {
1257 unsigned long _FTStreamRead(FXFT_Stream stream, unsigned long offset, 1257 unsigned long _FTStreamRead(FXFT_Stream stream, unsigned long offset,
1258 unsigned char* buffer, unsigned long count); 1258 unsigned char* buffer, unsigned long count);
1259 void _FTStreamClose(FXFT_Stream stream); 1259 void _FTStreamClose(FXFT_Stream stream);
1260 }; 1260 };
1261 CFontFileFaceInfo::CFontFileFaceInfo() 1261 CFontFileFaceInfo::CFontFileFaceInfo()
1262 { 1262 {
1263 m_pFile = NULL; 1263 m_pFile = NULL;
1264 m_Face = NULL; 1264 m_Face = NULL;
1265 m_Charsets = 0; 1265 m_Charsets = 0;
1266 m_FileSize = 0; 1266 m_FileSize = 0;
1267 m_FontOffset = 0; 1267 m_FontOffset = 0;
1268 m_Weight = 0; 1268 m_Weight = 0;
1269 m_bItalic = FALSE; 1269 m_bItalic = false;
1270 m_PitchFamily = 0; 1270 m_PitchFamily = 0;
1271 } 1271 }
1272 CFontFileFaceInfo::~CFontFileFaceInfo() 1272 CFontFileFaceInfo::~CFontFileFaceInfo()
1273 { 1273 {
1274 if (m_Face) { 1274 if (m_Face) {
1275 FXFT_Done_Face(m_Face); 1275 FXFT_Done_Face(m_Face);
1276 } 1276 }
1277 m_Face = NULL; 1277 m_Face = NULL;
1278 } 1278 }
1279 extern FX_BOOL _LoadFile(FXFT_Library library, FXFT_Face* Face, IFX_FileRead* pF ile, FXFT_Stream* stream); 1279 extern bool _LoadFile(FXFT_Library library, FXFT_Face* Face, IFX_FileRead* pFile , FXFT_Stream* stream);
1280 #if _FX_OS_ == _FX_ANDROID_ 1280 #if _FX_OS_ == _FX_ANDROID_
1281 IFX_SystemFontInfo* IFX_SystemFontInfo::CreateDefault() 1281 IFX_SystemFontInfo* IFX_SystemFontInfo::CreateDefault()
1282 { 1282 {
1283 return NULL; 1283 return NULL;
1284 } 1284 }
1285 #endif 1285 #endif
1286 CFX_FolderFontInfo::CFX_FolderFontInfo() 1286 CFX_FolderFontInfo::CFX_FolderFontInfo()
1287 { 1287 {
1288 } 1288 }
1289 CFX_FolderFontInfo::~CFX_FolderFontInfo() 1289 CFX_FolderFontInfo::~CFX_FolderFontInfo()
1290 { 1290 {
1291 FX_POSITION pos = m_FontList.GetStartPosition(); 1291 FX_POSITION pos = m_FontList.GetStartPosition();
1292 while (pos) { 1292 while (pos) {
1293 CFX_ByteString key; 1293 CFX_ByteString key;
1294 void* value; 1294 void* value;
1295 m_FontList.GetNextAssoc(pos, key, value); 1295 m_FontList.GetNextAssoc(pos, key, value);
1296 delete (CFontFaceInfo*)value; 1296 delete (CFontFaceInfo*)value;
1297 } 1297 }
1298 } 1298 }
1299 void CFX_FolderFontInfo::AddPath(const CFX_ByteStringC& path) 1299 void CFX_FolderFontInfo::AddPath(const CFX_ByteStringC& path)
1300 { 1300 {
1301 m_PathList.Add(path); 1301 m_PathList.Add(path);
1302 } 1302 }
1303 void CFX_FolderFontInfo::Release() 1303 void CFX_FolderFontInfo::Release()
1304 { 1304 {
1305 delete this; 1305 delete this;
1306 } 1306 }
1307 FX_BOOL CFX_FolderFontInfo::EnumFontList(CFX_FontMapper* pMapper) 1307 bool CFX_FolderFontInfo::EnumFontList(CFX_FontMapper* pMapper)
1308 { 1308 {
1309 m_pMapper = pMapper; 1309 m_pMapper = pMapper;
1310 for (int i = 0; i < m_PathList.GetSize(); i ++) { 1310 for (int i = 0; i < m_PathList.GetSize(); i ++) {
1311 ScanPath(m_PathList[i]); 1311 ScanPath(m_PathList[i]);
1312 } 1312 }
1313 return TRUE; 1313 return true;
1314 } 1314 }
1315 void CFX_FolderFontInfo::ScanPath(CFX_ByteString& path) 1315 void CFX_FolderFontInfo::ScanPath(CFX_ByteString& path)
1316 { 1316 {
1317 void* handle = FX_OpenFolder(path); 1317 void* handle = FX_OpenFolder(path);
1318 if (handle == NULL) { 1318 if (handle == NULL) {
1319 return; 1319 return;
1320 } 1320 }
1321 CFX_ByteString filename; 1321 CFX_ByteString filename;
1322 FX_BOOL bFolder; 1322 bool bFolder;
1323 while (FX_GetNextFile(handle, filename, bFolder)) { 1323 while (FX_GetNextFile(handle, filename, bFolder)) {
1324 if (bFolder) { 1324 if (bFolder) {
1325 if (filename == "." || filename == "..") { 1325 if (filename == "." || filename == "..") {
1326 continue; 1326 continue;
1327 } 1327 }
1328 } else { 1328 } else {
1329 CFX_ByteString ext = filename.Right(4); 1329 CFX_ByteString ext = filename.Right(4);
1330 ext.MakeUpper(); 1330 ext.MakeUpper();
1331 if (ext != ".TTF" && ext != ".OTF" && ext != ".TTC") { 1331 if (ext != ".TTF" && ext != ".OTF" && ext != ".TTC") {
1332 continue; 1332 continue;
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
1448 pInfo->m_Styles |= FXFONT_BOLD; 1448 pInfo->m_Styles |= FXFONT_BOLD;
1449 } 1449 }
1450 if (style.Find(FX_BSTRC("Italic")) > -1 || style.Find(FX_BSTRC("Oblique")) > -1) { 1450 if (style.Find(FX_BSTRC("Italic")) > -1 || style.Find(FX_BSTRC("Oblique")) > -1) {
1451 pInfo->m_Styles |= FXFONT_ITALIC; 1451 pInfo->m_Styles |= FXFONT_ITALIC;
1452 } 1452 }
1453 if (facename.Find(FX_BSTRC("Serif")) > -1) { 1453 if (facename.Find(FX_BSTRC("Serif")) > -1) {
1454 pInfo->m_Styles |= FXFONT_SERIF; 1454 pInfo->m_Styles |= FXFONT_SERIF;
1455 } 1455 }
1456 m_FontList.SetAt(facename, pInfo); 1456 m_FontList.SetAt(facename, pInfo);
1457 } 1457 }
1458 void* CFX_FolderFontInfo::MapFont(int weight, FX_BOOL bItalic, int charset, int pitch_family, const FX_CHAR* family, FX_BOOL& bExact) 1458 void* CFX_FolderFontInfo::MapFont(int weight, bool bItalic, int charset, int pit ch_family, const FX_CHAR* family, bool& bExact)
1459 { 1459 {
1460 return NULL; 1460 return NULL;
1461 } 1461 }
1462 void* CFX_FolderFontInfo::GetFont(const FX_CHAR* face) 1462 void* CFX_FolderFontInfo::GetFont(const FX_CHAR* face)
1463 { 1463 {
1464 void* p; 1464 void* p;
1465 if (!m_FontList.Lookup(face, p)) { 1465 if (!m_FontList.Lookup(face, p)) {
1466 return NULL; 1466 return NULL;
1467 } 1467 }
1468 return p; 1468 return p;
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
1503 FXSYS_fread(buffer, datasize, 1, pFile); 1503 FXSYS_fread(buffer, datasize, 1, pFile);
1504 } 1504 }
1505 if (pFile) { 1505 if (pFile) {
1506 FXSYS_fclose(pFile); 1506 FXSYS_fclose(pFile);
1507 } 1507 }
1508 return datasize; 1508 return datasize;
1509 } 1509 }
1510 void CFX_FolderFontInfo::DeleteFont(void* hFont) 1510 void CFX_FolderFontInfo::DeleteFont(void* hFont)
1511 { 1511 {
1512 } 1512 }
1513 FX_BOOL CFX_FolderFontInfo::GetFaceName(void* hFont, CFX_ByteString& name) 1513 bool CFX_FolderFontInfo::GetFaceName(void* hFont, CFX_ByteString& name)
1514 { 1514 {
1515 if (hFont == NULL) { 1515 if (hFont == NULL) {
1516 return FALSE; 1516 return false;
1517 } 1517 }
1518 CFontFaceInfo* pFont = (CFontFaceInfo*)hFont; 1518 CFontFaceInfo* pFont = (CFontFaceInfo*)hFont;
1519 name = pFont->m_FaceName; 1519 name = pFont->m_FaceName;
1520 return TRUE; 1520 return true;
1521 } 1521 }
1522 FX_BOOL CFX_FolderFontInfo::GetFontCharset(void* hFont, int& charset) 1522 bool CFX_FolderFontInfo::GetFontCharset(void* hFont, int& charset)
1523 { 1523 {
1524 return FALSE; 1524 return false;
1525 } 1525 }
OLDNEW
« no previous file with comments | « core/src/fxge/ge/fx_ge_font.cpp ('k') | core/src/fxge/ge/fx_ge_linux.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698