Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 PDFium Authors. All rights reserved. | 1 // Copyright 2014 PDFium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
| 6 | 6 |
| 7 #include <limits> | 7 #include <limits> |
| 8 | 8 |
| 9 #include "../../../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 | |
| 12 #define GET_TT_SHORT(w) (FX_WORD)(((w)[0] << 8) | (w)[1]) | 13 #define GET_TT_SHORT(w) (FX_WORD)(((w)[0] << 8) | (w)[1]) |
| 13 #define GET_TT_LONG(w) \ | 14 #define GET_TT_LONG(w) \ |
| 14 (FX_DWORD)(((w)[0] << 24) | ((w)[1] << 16) | ((w)[2] << 8) | (w)[3]) | 15 (FX_DWORD)(((w)[0] << 24) | ((w)[1] << 16) | ((w)[2] << 8) | (w)[3]) |
| 16 | |
| 17 namespace { | |
| 18 | |
| 19 CFX_ByteString KeyNameFromFace(const CFX_ByteString& face_name, | |
| 20 int weight, | |
| 21 FX_BOOL bItalic) { | |
| 22 CFX_ByteString key(face_name); | |
| 23 key += ','; | |
| 24 key += CFX_ByteString::FormatInteger(weight); | |
| 25 key += bItalic ? 'I' : 'N'; | |
| 26 return key; | |
| 27 } | |
| 28 | |
| 29 CFX_ByteString KeyNameFromSize(int ttc_size, FX_DWORD checksum) { | |
| 30 CFX_ByteString key; | |
| 31 key.Format("%d:%d", ttc_size, checksum); | |
| 32 return key; | |
| 33 } | |
| 34 | |
| 35 } // namespace | |
| 36 | |
| 15 CFX_SubstFont::CFX_SubstFont() { | 37 CFX_SubstFont::CFX_SubstFont() { |
| 16 m_ExtHandle = NULL; | 38 m_ExtHandle = NULL; |
| 17 m_Charset = 0; | 39 m_Charset = 0; |
| 18 m_SubstFlags = 0; | 40 m_SubstFlags = 0; |
| 19 m_Weight = 0; | 41 m_Weight = 0; |
| 20 m_ItalicAngle = 0; | 42 m_ItalicAngle = 0; |
| 21 m_bSubstOfCJK = FALSE; | 43 m_bSubstOfCJK = FALSE; |
| 22 m_WeightCJK = 0; | 44 m_WeightCJK = 0; |
| 23 m_bItlicCJK = FALSE; | 45 m_bItlicCJK = FALSE; |
| 24 } | 46 } |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 69 if (m_FTLibrary) { | 91 if (m_FTLibrary) { |
| 70 FXFT_Done_FreeType(m_FTLibrary); | 92 FXFT_Done_FreeType(m_FTLibrary); |
| 71 } | 93 } |
| 72 } | 94 } |
| 73 void CFX_FontMgr::InitFTLibrary() { | 95 void CFX_FontMgr::InitFTLibrary() { |
| 74 if (m_FTLibrary == NULL) { | 96 if (m_FTLibrary == NULL) { |
| 75 FXFT_Init_FreeType(&m_FTLibrary); | 97 FXFT_Init_FreeType(&m_FTLibrary); |
| 76 } | 98 } |
| 77 } | 99 } |
| 78 void CFX_FontMgr::FreeCache() { | 100 void CFX_FontMgr::FreeCache() { |
| 79 FX_POSITION pos = m_FaceMap.GetStartPosition(); | 101 auto it = m_FaceMap.begin(); |
| 80 while (pos) { | 102 while (it != m_FaceMap.end()) { |
|
Lei Zhang
2015/08/15 00:47:33
Range-Based For Loop?
Tom Sepez
2015/08/17 20:15:26
Done.
| |
| 81 CFX_ByteString Key; | 103 auto temp = it++; |
| 82 CTTFontDesc* face; | 104 delete temp->second; |
| 83 m_FaceMap.GetNextAssoc(pos, Key, (void*&)face); | 105 m_FaceMap.erase(temp); |
| 84 delete face; | |
| 85 } | 106 } |
| 86 m_FaceMap.RemoveAll(); | |
| 87 } | 107 } |
| 88 void CFX_FontMgr::SetSystemFontInfo(IFX_SystemFontInfo* pFontInfo) { | 108 void CFX_FontMgr::SetSystemFontInfo(IFX_SystemFontInfo* pFontInfo) { |
| 89 m_pBuiltinMapper->SetSystemFontInfo(pFontInfo); | 109 m_pBuiltinMapper->SetSystemFontInfo(pFontInfo); |
| 90 } | 110 } |
| 91 FXFT_Face CFX_FontMgr::FindSubstFont(const CFX_ByteString& face_name, | 111 FXFT_Face CFX_FontMgr::FindSubstFont(const CFX_ByteString& face_name, |
| 92 FX_BOOL bTrueType, | 112 FX_BOOL bTrueType, |
| 93 FX_DWORD flags, | 113 FX_DWORD flags, |
| 94 int weight, | 114 int weight, |
| 95 int italic_angle, | 115 int italic_angle, |
| 96 int CharsetCP, | 116 int CharsetCP, |
| 97 CFX_SubstFont* pSubstFont) { | 117 CFX_SubstFont* pSubstFont) { |
| 98 if (!m_FTLibrary) { | 118 if (!m_FTLibrary) { |
| 99 FXFT_Init_FreeType(&m_FTLibrary); | 119 FXFT_Init_FreeType(&m_FTLibrary); |
| 100 } | 120 } |
| 101 return m_pBuiltinMapper->FindSubstFont(face_name, bTrueType, flags, weight, | 121 return m_pBuiltinMapper->FindSubstFont(face_name, bTrueType, flags, weight, |
| 102 italic_angle, CharsetCP, pSubstFont); | 122 italic_angle, CharsetCP, pSubstFont); |
| 103 } | 123 } |
| 104 FXFT_Face CFX_FontMgr::GetCachedFace(const CFX_ByteString& face_name, | 124 FXFT_Face CFX_FontMgr::GetCachedFace(const CFX_ByteString& face_name, |
| 105 int weight, | 125 int weight, |
| 106 FX_BOOL bItalic, | 126 FX_BOOL bItalic, |
| 107 uint8_t*& pFontData) { | 127 uint8_t*& pFontData) { |
| 108 CFX_ByteString key(face_name); | 128 auto it = m_FaceMap.find(KeyNameFromFace(face_name, weight, bItalic)); |
| 109 key += ','; | 129 if (it == m_FaceMap.end()) |
| 110 key += CFX_ByteString::FormatInteger(weight); | 130 return nullptr; |
| 111 key += bItalic ? 'I' : 'N'; | 131 |
| 112 CTTFontDesc* pFontDesc = NULL; | 132 CTTFontDesc* pFontDesc = it->second; |
| 113 m_FaceMap.Lookup(key, (void*&)pFontDesc); | 133 pFontData = pFontDesc->m_pFontData; |
| 114 if (pFontDesc) { | 134 pFontDesc->m_RefCount++; |
| 115 pFontData = pFontDesc->m_pFontData; | 135 return pFontDesc->m_SingleFace.m_pFace; |
| 116 pFontDesc->m_RefCount++; | |
| 117 return pFontDesc->m_SingleFace.m_pFace; | |
| 118 } | |
| 119 return NULL; | |
| 120 } | 136 } |
| 121 FXFT_Face CFX_FontMgr::AddCachedFace(const CFX_ByteString& face_name, | 137 FXFT_Face CFX_FontMgr::AddCachedFace(const CFX_ByteString& face_name, |
| 122 int weight, | 138 int weight, |
| 123 FX_BOOL bItalic, | 139 FX_BOOL bItalic, |
| 124 uint8_t* pData, | 140 uint8_t* pData, |
| 125 FX_DWORD size, | 141 FX_DWORD size, |
| 126 int face_index) { | 142 int face_index) { |
| 127 CTTFontDesc* pFontDesc = new CTTFontDesc; | 143 CTTFontDesc* pFontDesc = new CTTFontDesc; |
| 128 pFontDesc->m_Type = 1; | 144 pFontDesc->m_Type = 1; |
| 129 pFontDesc->m_SingleFace.m_pFace = NULL; | 145 pFontDesc->m_SingleFace.m_pFace = NULL; |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 140 &pFontDesc->m_SingleFace.m_pFace); | 156 &pFontDesc->m_SingleFace.m_pFace); |
| 141 if (ret) { | 157 if (ret) { |
| 142 delete pFontDesc; | 158 delete pFontDesc; |
| 143 return NULL; | 159 return NULL; |
| 144 } | 160 } |
| 145 ret = FXFT_Set_Pixel_Sizes(pFontDesc->m_SingleFace.m_pFace, 64, 64); | 161 ret = FXFT_Set_Pixel_Sizes(pFontDesc->m_SingleFace.m_pFace, 64, 64); |
| 146 if (ret) { | 162 if (ret) { |
| 147 delete pFontDesc; | 163 delete pFontDesc; |
| 148 return NULL; | 164 return NULL; |
| 149 } | 165 } |
| 150 CFX_ByteString key(face_name); | 166 m_FaceMap[KeyNameFromFace(face_name, weight, bItalic)] = pFontDesc; |
| 151 key += ','; | |
| 152 key += CFX_ByteString::FormatInteger(weight); | |
| 153 key += bItalic ? 'I' : 'N'; | |
| 154 m_FaceMap.SetAt(key, pFontDesc); | |
| 155 return pFontDesc->m_SingleFace.m_pFace; | 167 return pFontDesc->m_SingleFace.m_pFace; |
| 156 } | 168 } |
| 157 const FX_CHAR* const g_Base14FontNames[14] = { | 169 const FX_CHAR* const g_Base14FontNames[14] = { |
| 158 "Courier", | 170 "Courier", |
| 159 "Courier-Bold", | 171 "Courier-Bold", |
| 160 "Courier-BoldOblique", | 172 "Courier-BoldOblique", |
| 161 "Courier-Oblique", | 173 "Courier-Oblique", |
| 162 "Helvetica", | 174 "Helvetica", |
| 163 "Helvetica-Bold", | 175 "Helvetica-Bold", |
| 164 "Helvetica-BoldOblique", | 176 "Helvetica-BoldOblique", |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 297 face_index = 0; | 309 face_index = 0; |
| 298 } else { | 310 } else { |
| 299 face_index = index; | 311 face_index = index; |
| 300 } | 312 } |
| 301 return face_index; | 313 return face_index; |
| 302 } | 314 } |
| 303 FXFT_Face CFX_FontMgr::GetCachedTTCFace(int ttc_size, | 315 FXFT_Face CFX_FontMgr::GetCachedTTCFace(int ttc_size, |
| 304 FX_DWORD checksum, | 316 FX_DWORD checksum, |
| 305 int font_offset, | 317 int font_offset, |
| 306 uint8_t*& pFontData) { | 318 uint8_t*& pFontData) { |
| 307 CFX_ByteString key; | 319 auto it = m_FaceMap.find(KeyNameFromSize(ttc_size, checksum)); |
| 308 key.Format("%d:%d", ttc_size, checksum); | 320 if (it == m_FaceMap.end()) |
| 309 CTTFontDesc* pFontDesc = NULL; | 321 return nullptr; |
| 310 m_FaceMap.Lookup(key, (void*&)pFontDesc); | 322 |
| 311 if (pFontDesc == NULL) { | 323 CTTFontDesc* pFontDesc = it->second; |
| 312 return NULL; | |
| 313 } | |
| 314 pFontData = pFontDesc->m_pFontData; | 324 pFontData = pFontDesc->m_pFontData; |
| 315 pFontDesc->m_RefCount++; | 325 pFontDesc->m_RefCount++; |
| 316 int face_index = GetTTCIndex(pFontDesc->m_pFontData, ttc_size, font_offset); | 326 int face_index = GetTTCIndex(pFontDesc->m_pFontData, ttc_size, font_offset); |
| 317 if (pFontDesc->m_TTCFace.m_pFaces[face_index] == NULL) { | 327 if (!pFontDesc->m_TTCFace.m_pFaces[face_index]) { |
| 318 pFontDesc->m_TTCFace.m_pFaces[face_index] = | 328 pFontDesc->m_TTCFace.m_pFaces[face_index] = |
| 319 GetFixedFace(pFontDesc->m_pFontData, ttc_size, face_index); | 329 GetFixedFace(pFontDesc->m_pFontData, ttc_size, face_index); |
| 320 } | 330 } |
| 321 return pFontDesc->m_TTCFace.m_pFaces[face_index]; | 331 return pFontDesc->m_TTCFace.m_pFaces[face_index]; |
| 322 } | 332 } |
| 323 FXFT_Face CFX_FontMgr::AddCachedTTCFace(int ttc_size, | 333 FXFT_Face CFX_FontMgr::AddCachedTTCFace(int ttc_size, |
| 324 FX_DWORD checksum, | 334 FX_DWORD checksum, |
| 325 uint8_t* pData, | 335 uint8_t* pData, |
| 326 FX_DWORD size, | 336 FX_DWORD size, |
| 327 int font_offset) { | 337 int font_offset) { |
| 328 CFX_ByteString key; | |
| 329 key.Format("%d:%d", ttc_size, checksum); | |
| 330 CTTFontDesc* pFontDesc = new CTTFontDesc; | 338 CTTFontDesc* pFontDesc = new CTTFontDesc; |
| 331 pFontDesc->m_Type = 2; | 339 pFontDesc->m_Type = 2; |
| 332 pFontDesc->m_pFontData = pData; | 340 pFontDesc->m_pFontData = pData; |
| 333 for (int i = 0; i < 16; i++) { | 341 for (int i = 0; i < 16; i++) { |
| 334 pFontDesc->m_TTCFace.m_pFaces[i] = NULL; | 342 pFontDesc->m_TTCFace.m_pFaces[i] = NULL; |
| 335 } | 343 } |
| 336 pFontDesc->m_RefCount++; | 344 pFontDesc->m_RefCount++; |
| 337 key.Format("%d:%d", ttc_size, checksum); | 345 m_FaceMap[KeyNameFromSize(ttc_size, checksum)] = pFontDesc; |
| 338 m_FaceMap.SetAt(key, pFontDesc); | |
| 339 int face_index = GetTTCIndex(pFontDesc->m_pFontData, ttc_size, font_offset); | 346 int face_index = GetTTCIndex(pFontDesc->m_pFontData, ttc_size, font_offset); |
| 340 pFontDesc->m_TTCFace.m_pFaces[face_index] = | 347 pFontDesc->m_TTCFace.m_pFaces[face_index] = |
| 341 GetFixedFace(pFontDesc->m_pFontData, ttc_size, face_index); | 348 GetFixedFace(pFontDesc->m_pFontData, ttc_size, face_index); |
| 342 return pFontDesc->m_TTCFace.m_pFaces[face_index]; | 349 return pFontDesc->m_TTCFace.m_pFaces[face_index]; |
| 343 } | 350 } |
| 344 FXFT_Face CFX_FontMgr::GetFixedFace(const uint8_t* pData, | 351 FXFT_Face CFX_FontMgr::GetFixedFace(const uint8_t* pData, |
| 345 FX_DWORD size, | 352 FX_DWORD size, |
| 346 int face_index) { | 353 int face_index) { |
| 347 FXFT_Library library; | 354 FXFT_Library library; |
| 348 if (m_FTLibrary == NULL) { | 355 if (m_FTLibrary == NULL) { |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 371 if (ret) { | 378 if (ret) { |
| 372 return NULL; | 379 return NULL; |
| 373 } | 380 } |
| 374 ret = FXFT_Set_Pixel_Sizes(face, 64, 64); | 381 ret = FXFT_Set_Pixel_Sizes(face, 64, 64); |
| 375 if (ret) { | 382 if (ret) { |
| 376 return NULL; | 383 return NULL; |
| 377 } | 384 } |
| 378 return face; | 385 return face; |
| 379 } | 386 } |
| 380 void CFX_FontMgr::ReleaseFace(FXFT_Face face) { | 387 void CFX_FontMgr::ReleaseFace(FXFT_Face face) { |
| 381 if (face == NULL) { | 388 if (!face) { |
| 382 return; | 389 return; |
| 383 } | 390 } |
| 384 FX_POSITION pos = m_FaceMap.GetStartPosition(); | 391 auto it = m_FaceMap.begin(); |
| 385 while (pos) { | 392 while (it != m_FaceMap.end()) { |
| 386 CFX_ByteString Key; | 393 auto temp = it++; |
| 387 CTTFontDesc* ttface; | 394 if (temp->second->ReleaseFace(face)) { |
| 388 m_FaceMap.GetNextAssoc(pos, Key, (void*&)ttface); | 395 m_FaceMap.erase(temp); |
| 389 if (ttface->ReleaseFace(face)) { | |
| 390 m_FaceMap.RemoveKey(Key); | |
| 391 } | 396 } |
| 392 } | 397 } |
| 393 } | 398 } |
| 394 extern "C" { | 399 extern "C" { |
| 395 extern const unsigned char g_FoxitFixedItalicFontData[18746]; | 400 extern const unsigned char g_FoxitFixedItalicFontData[18746]; |
| 396 extern const unsigned char g_FoxitFixedFontData[17597]; | 401 extern const unsigned char g_FoxitFixedFontData[17597]; |
| 397 extern const unsigned char g_FoxitSansItalicFontData[16339]; | 402 extern const unsigned char g_FoxitSansItalicFontData[16339]; |
| 398 extern const unsigned char g_FoxitSansFontData[15025]; | 403 extern const unsigned char g_FoxitSansFontData[15025]; |
| 399 extern const unsigned char g_FoxitSerifItalicFontData[21227]; | 404 extern const unsigned char g_FoxitSerifItalicFontData[21227]; |
| 400 extern const unsigned char g_FoxitSerifFontData[19469]; | 405 extern const unsigned char g_FoxitSerifFontData[19469]; |
| (...skipping 868 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1269 FXFT_Face* Face, | 1274 FXFT_Face* Face, |
| 1270 IFX_FileRead* pFile, | 1275 IFX_FileRead* pFile, |
| 1271 FXFT_Stream* stream); | 1276 FXFT_Stream* stream); |
| 1272 #if _FX_OS_ == _FX_ANDROID_ | 1277 #if _FX_OS_ == _FX_ANDROID_ |
| 1273 IFX_SystemFontInfo* IFX_SystemFontInfo::CreateDefault(const char** pUnused) { | 1278 IFX_SystemFontInfo* IFX_SystemFontInfo::CreateDefault(const char** pUnused) { |
| 1274 return NULL; | 1279 return NULL; |
| 1275 } | 1280 } |
| 1276 #endif | 1281 #endif |
| 1277 CFX_FolderFontInfo::CFX_FolderFontInfo() {} | 1282 CFX_FolderFontInfo::CFX_FolderFontInfo() {} |
| 1278 CFX_FolderFontInfo::~CFX_FolderFontInfo() { | 1283 CFX_FolderFontInfo::~CFX_FolderFontInfo() { |
| 1279 FX_POSITION pos = m_FontList.GetStartPosition(); | 1284 for (auto& pair : m_FontList) { |
| 1280 while (pos) { | 1285 delete pair.second; |
| 1281 CFX_ByteString key; | |
| 1282 void* value; | |
| 1283 m_FontList.GetNextAssoc(pos, key, value); | |
| 1284 delete (CFX_FontFaceInfo*)value; | |
| 1285 } | 1286 } |
| 1286 } | 1287 } |
| 1287 void CFX_FolderFontInfo::AddPath(const CFX_ByteStringC& path) { | 1288 void CFX_FolderFontInfo::AddPath(const CFX_ByteStringC& path) { |
| 1288 m_PathList.Add(path); | 1289 m_PathList.Add(path); |
| 1289 } | 1290 } |
| 1290 void CFX_FolderFontInfo::Release() { | 1291 void CFX_FolderFontInfo::Release() { |
| 1291 delete this; | 1292 delete this; |
| 1292 } | 1293 } |
| 1293 FX_BOOL CFX_FolderFontInfo::EnumFontList(CFX_FontMapper* pMapper) { | 1294 FX_BOOL CFX_FolderFontInfo::EnumFontList(CFX_FontMapper* pMapper) { |
| 1294 m_pMapper = pMapper; | 1295 m_pMapper = pMapper; |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1384 if (tables.IsEmpty()) { | 1385 if (tables.IsEmpty()) { |
| 1385 return; | 1386 return; |
| 1386 } | 1387 } |
| 1387 CFX_ByteString names = | 1388 CFX_ByteString names = |
| 1388 _FPDF_LoadTableFromTT(pFile, tables, nTables, 0x6e616d65); | 1389 _FPDF_LoadTableFromTT(pFile, tables, nTables, 0x6e616d65); |
| 1389 CFX_ByteString facename = _FPDF_GetNameFromTT(names, 1); | 1390 CFX_ByteString facename = _FPDF_GetNameFromTT(names, 1); |
| 1390 CFX_ByteString style = _FPDF_GetNameFromTT(names, 2); | 1391 CFX_ByteString style = _FPDF_GetNameFromTT(names, 2); |
| 1391 if (style != "Regular") { | 1392 if (style != "Regular") { |
| 1392 facename += " " + style; | 1393 facename += " " + style; |
| 1393 } | 1394 } |
| 1394 void* p; | 1395 if (m_FontList.find(facename) != m_FontList.end()) { |
| 1395 if (m_FontList.Lookup(facename, p)) { | |
| 1396 return; | 1396 return; |
| 1397 } | 1397 } |
| 1398 CFX_FontFaceInfo* pInfo = | 1398 CFX_FontFaceInfo* pInfo = |
| 1399 new CFX_FontFaceInfo(path, facename, tables, offset, filesize); | 1399 new CFX_FontFaceInfo(path, facename, tables, offset, filesize); |
| 1400 CFX_ByteString os2 = | 1400 CFX_ByteString os2 = |
| 1401 _FPDF_LoadTableFromTT(pFile, tables, nTables, 0x4f532f32); | 1401 _FPDF_LoadTableFromTT(pFile, tables, nTables, 0x4f532f32); |
| 1402 if (os2.GetLength() >= 86) { | 1402 if (os2.GetLength() >= 86) { |
| 1403 const uint8_t* p = (const uint8_t*)os2 + 78; | 1403 const uint8_t* p = (const uint8_t*)os2 + 78; |
| 1404 FX_DWORD codepages = GET_TT_LONG(p); | 1404 FX_DWORD codepages = GET_TT_LONG(p); |
| 1405 if (codepages & (1 << 17)) { | 1405 if (codepages & (1 << 17)) { |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 1429 if (style.Find(FX_BSTRC("Bold")) > -1) { | 1429 if (style.Find(FX_BSTRC("Bold")) > -1) { |
| 1430 pInfo->m_Styles |= FXFONT_BOLD; | 1430 pInfo->m_Styles |= FXFONT_BOLD; |
| 1431 } | 1431 } |
| 1432 if (style.Find(FX_BSTRC("Italic")) > -1 || | 1432 if (style.Find(FX_BSTRC("Italic")) > -1 || |
| 1433 style.Find(FX_BSTRC("Oblique")) > -1) { | 1433 style.Find(FX_BSTRC("Oblique")) > -1) { |
| 1434 pInfo->m_Styles |= FXFONT_ITALIC; | 1434 pInfo->m_Styles |= FXFONT_ITALIC; |
| 1435 } | 1435 } |
| 1436 if (facename.Find(FX_BSTRC("Serif")) > -1) { | 1436 if (facename.Find(FX_BSTRC("Serif")) > -1) { |
| 1437 pInfo->m_Styles |= FXFONT_SERIF; | 1437 pInfo->m_Styles |= FXFONT_SERIF; |
| 1438 } | 1438 } |
| 1439 m_FontList.SetAt(facename, pInfo); | 1439 m_FontList[facename] = pInfo; |
| 1440 } | 1440 } |
| 1441 void* CFX_FolderFontInfo::MapFont(int weight, | 1441 void* CFX_FolderFontInfo::MapFont(int weight, |
| 1442 FX_BOOL bItalic, | 1442 FX_BOOL bItalic, |
| 1443 int charset, | 1443 int charset, |
| 1444 int pitch_family, | 1444 int pitch_family, |
| 1445 const FX_CHAR* family, | 1445 const FX_CHAR* family, |
| 1446 int& iExact) { | 1446 int& iExact) { |
| 1447 return NULL; | 1447 return NULL; |
| 1448 } | 1448 } |
| 1449 void* CFX_FolderFontInfo::GetFont(const FX_CHAR* face) { | 1449 void* CFX_FolderFontInfo::GetFont(const FX_CHAR* face) { |
| 1450 void* p; | 1450 auto it = m_FontList.find(face); |
| 1451 if (!m_FontList.Lookup(face, p)) { | 1451 return it != m_FontList.end() ? it->second : nullptr; |
| 1452 return NULL; | |
| 1453 } | |
| 1454 return p; | |
| 1455 } | 1452 } |
| 1456 FX_DWORD CFX_FolderFontInfo::GetFontData(void* hFont, | 1453 FX_DWORD CFX_FolderFontInfo::GetFontData(void* hFont, |
| 1457 FX_DWORD table, | 1454 FX_DWORD table, |
| 1458 uint8_t* buffer, | 1455 uint8_t* buffer, |
| 1459 FX_DWORD size) { | 1456 FX_DWORD size) { |
| 1460 if (hFont == NULL) { | 1457 if (hFont == NULL) { |
| 1461 return 0; | 1458 return 0; |
| 1462 } | 1459 } |
| 1463 CFX_FontFaceInfo* pFont = (CFX_FontFaceInfo*)hFont; | 1460 CFX_FontFaceInfo* pFont = (CFX_FontFaceInfo*)hFont; |
| 1464 FXSYS_FILE* pFile = NULL; | 1461 FXSYS_FILE* pFile = NULL; |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1500 if (hFont == NULL) { | 1497 if (hFont == NULL) { |
| 1501 return FALSE; | 1498 return FALSE; |
| 1502 } | 1499 } |
| 1503 CFX_FontFaceInfo* pFont = (CFX_FontFaceInfo*)hFont; | 1500 CFX_FontFaceInfo* pFont = (CFX_FontFaceInfo*)hFont; |
| 1504 name = pFont->m_FaceName; | 1501 name = pFont->m_FaceName; |
| 1505 return TRUE; | 1502 return TRUE; |
| 1506 } | 1503 } |
| 1507 FX_BOOL CFX_FolderFontInfo::GetFontCharset(void* hFont, int& charset) { | 1504 FX_BOOL CFX_FolderFontInfo::GetFontCharset(void* hFont, int& charset) { |
| 1508 return FALSE; | 1505 return FALSE; |
| 1509 } | 1506 } |
| OLD | NEW |