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

Side by Side Diff: core/src/fpdfapi/fpdf_font/fpdf_font.cpp

Issue 1520063002: Get rid of most instance of 'foo == NULL' (Closed) Base URL: https://pdfium.googlesource.com/pdfium@bstr_isnull
Patch Set: rebase Created 5 years 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
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 "font_int.h" 7 #include "font_int.h"
8 8
9 #include "core/src/fpdfapi/fpdf_page/pageint.h" 9 #include "core/src/fpdfapi/fpdf_page/pageint.h"
10 #include "core/include/fpdfapi/fpdf_module.h" 10 #include "core/include/fpdfapi/fpdf_module.h"
(...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after
344 if (rect.bottom == rect.top) { 344 if (rect.bottom == rect.top) {
345 m_Descent = m_FontBBox.bottom; 345 m_Descent = m_FontBBox.bottom;
346 } else { 346 } else {
347 m_Descent = rect.bottom; 347 m_Descent = rect.bottom;
348 } 348 }
349 } 349 }
350 } 350 }
351 void CPDF_Font::LoadUnicodeMap() { 351 void CPDF_Font::LoadUnicodeMap() {
352 m_bToUnicodeLoaded = TRUE; 352 m_bToUnicodeLoaded = TRUE;
353 CPDF_Stream* pStream = m_pFontDict->GetStream("ToUnicode"); 353 CPDF_Stream* pStream = m_pFontDict->GetStream("ToUnicode");
354 if (pStream == NULL) { 354 if (!pStream) {
355 return; 355 return;
356 } 356 }
357 m_pToUnicodeMap = new CPDF_ToUnicodeMap; 357 m_pToUnicodeMap = new CPDF_ToUnicodeMap;
358 m_pToUnicodeMap->Load(pStream); 358 m_pToUnicodeMap->Load(pStream);
359 } 359 }
360 int CPDF_Font::GetStringWidth(const FX_CHAR* pString, int size) { 360 int CPDF_Font::GetStringWidth(const FX_CHAR* pString, int size) {
361 int offset = 0; 361 int offset = 0;
362 int width = 0; 362 int width = 0;
363 while (offset < size) { 363 while (offset < size) {
364 FX_DWORD charcode = GetNextChar(pString, size, offset); 364 FX_DWORD charcode = GetNextChar(pString, size, offset);
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
418 CFX_ByteString tag = basefont.Left(4); 418 CFX_ByteString tag = basefont.Left(4);
419 int i; 419 int i;
420 int count = sizeof(ChineseFontNames) / sizeof(ChineseFontNames[0]); 420 int count = sizeof(ChineseFontNames) / sizeof(ChineseFontNames[0]);
421 for (i = 0; i < count; ++i) { 421 for (i = 0; i < count; ++i) {
422 if (tag == CFX_ByteString((const FX_CHAR*)ChineseFontNames[i])) { 422 if (tag == CFX_ByteString((const FX_CHAR*)ChineseFontNames[i])) {
423 break; 423 break;
424 } 424 }
425 } 425 }
426 if (i < count) { 426 if (i < count) {
427 CPDF_Dictionary* pFontDesc = pFontDict->GetDict("FontDescriptor"); 427 CPDF_Dictionary* pFontDesc = pFontDict->GetDict("FontDescriptor");
428 if (pFontDesc == NULL || !pFontDesc->KeyExist("FontFile2")) { 428 if (!pFontDesc || !pFontDesc->KeyExist("FontFile2")) {
429 pFont = new CPDF_CIDFont; 429 pFont = new CPDF_CIDFont;
430 pFont->m_pFontDict = pFontDict; 430 pFont->m_pFontDict = pFontDict;
431 pFont->m_pDocument = pDoc; 431 pFont->m_pDocument = pDoc;
432 if (!pFont->Load()) { 432 if (!pFont->Load()) {
433 delete pFont; 433 delete pFont;
434 return NULL; 434 return NULL;
435 } 435 }
436 return pFont; 436 return pFont;
437 } 437 }
438 } 438 }
439 #endif 439 #endif
440 } 440 }
441 pFont = new CPDF_TrueTypeFont; 441 pFont = new CPDF_TrueTypeFont;
442 } else if (type == "Type3") { 442 } else if (type == "Type3") {
443 pFont = new CPDF_Type3Font; 443 pFont = new CPDF_Type3Font;
444 } else if (type == "Type0") { 444 } else if (type == "Type0") {
445 pFont = new CPDF_CIDFont; 445 pFont = new CPDF_CIDFont;
446 } else { 446 } else {
447 pFont = new CPDF_Type1Font; 447 pFont = new CPDF_Type1Font;
448 } 448 }
449 pFont->m_pFontDict = pFontDict; 449 pFont->m_pFontDict = pFontDict;
450 pFont->m_pDocument = pDoc; 450 pFont->m_pDocument = pDoc;
451 if (!pFont->Load()) { 451 if (!pFont->Load()) {
452 delete pFont; 452 delete pFont;
453 return NULL; 453 return NULL;
454 } 454 }
455 return pFont; 455 return pFont;
456 } 456 }
457 FX_BOOL CPDF_Font::Load() { 457 FX_BOOL CPDF_Font::Load() {
458 if (m_pFontDict == NULL) { 458 if (!m_pFontDict) {
459 return FALSE; 459 return FALSE;
460 } 460 }
461 CFX_ByteString type = m_pFontDict->GetString("Subtype"); 461 CFX_ByteString type = m_pFontDict->GetString("Subtype");
462 m_BaseFont = m_pFontDict->GetString("BaseFont"); 462 m_BaseFont = m_pFontDict->GetString("BaseFont");
463 if (type == "MMType1") { 463 if (type == "MMType1") {
464 type = "Type1"; 464 type = "Type1";
465 } 465 }
466 return _Load(); 466 return _Load();
467 } 467 }
468 static CFX_WideString _FontMap_GetWideString(CFX_CharMap* pMap, 468 static CFX_WideString _FontMap_GetWideString(CFX_CharMap* pMap,
(...skipping 12 matching lines...) Expand all
481 CFX_WideString CPDF_ToUnicodeMap::Lookup(FX_DWORD charcode) { 481 CFX_WideString CPDF_ToUnicodeMap::Lookup(FX_DWORD charcode) {
482 auto it = m_Map.find(charcode); 482 auto it = m_Map.find(charcode);
483 if (it != m_Map.end()) { 483 if (it != m_Map.end()) {
484 FX_DWORD value = it->second; 484 FX_DWORD value = it->second;
485 FX_WCHAR unicode = (FX_WCHAR)(value & 0xffff); 485 FX_WCHAR unicode = (FX_WCHAR)(value & 0xffff);
486 if (unicode != 0xffff) { 486 if (unicode != 0xffff) {
487 return unicode; 487 return unicode;
488 } 488 }
489 const FX_WCHAR* buf = m_MultiCharBuf.GetBuffer(); 489 const FX_WCHAR* buf = m_MultiCharBuf.GetBuffer();
490 FX_DWORD buf_len = m_MultiCharBuf.GetLength(); 490 FX_DWORD buf_len = m_MultiCharBuf.GetLength();
491 if (buf == NULL || buf_len == 0) { 491 if (!buf || buf_len == 0) {
492 return CFX_WideString(); 492 return CFX_WideString();
493 } 493 }
494 FX_DWORD index = value >> 16; 494 FX_DWORD index = value >> 16;
495 if (index >= buf_len) { 495 if (index >= buf_len) {
496 return CFX_WideString(); 496 return CFX_WideString();
497 } 497 }
498 FX_DWORD len = buf[index]; 498 FX_DWORD len = buf[index];
499 if (index + len < index || index + len >= buf_len) { 499 if (index + len < index || index + len >= buf_len) {
500 return CFX_WideString(); 500 return CFX_WideString();
501 } 501 }
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after
697 } else { 697 } else {
698 return FALSE; 698 return FALSE;
699 } 699 }
700 return TRUE; 700 return TRUE;
701 } 701 }
702 void CPDF_Font::LoadPDFEncoding(CPDF_Object* pEncoding, 702 void CPDF_Font::LoadPDFEncoding(CPDF_Object* pEncoding,
703 int& iBaseEncoding, 703 int& iBaseEncoding,
704 CFX_ByteString*& pCharNames, 704 CFX_ByteString*& pCharNames,
705 FX_BOOL bEmbedded, 705 FX_BOOL bEmbedded,
706 FX_BOOL bTrueType) { 706 FX_BOOL bTrueType) {
707 if (pEncoding == NULL) { 707 if (!pEncoding) {
708 if (m_BaseFont == "Symbol") { 708 if (m_BaseFont == "Symbol") {
709 iBaseEncoding = bTrueType ? PDFFONT_ENCODING_MS_SYMBOL 709 iBaseEncoding = bTrueType ? PDFFONT_ENCODING_MS_SYMBOL
710 : PDFFONT_ENCODING_ADOBE_SYMBOL; 710 : PDFFONT_ENCODING_ADOBE_SYMBOL;
711 } else if (!bEmbedded && iBaseEncoding == PDFFONT_ENCODING_BUILTIN) { 711 } else if (!bEmbedded && iBaseEncoding == PDFFONT_ENCODING_BUILTIN) {
712 iBaseEncoding = PDFFONT_ENCODING_WINANSI; 712 iBaseEncoding = PDFFONT_ENCODING_WINANSI;
713 } 713 }
714 return; 714 return;
715 } 715 }
716 if (pEncoding->IsName()) { 716 if (pEncoding->IsName()) {
717 if (iBaseEncoding == PDFFONT_ENCODING_ADOBE_SYMBOL || 717 if (iBaseEncoding == PDFFONT_ENCODING_ADOBE_SYMBOL ||
(...skipping 23 matching lines...) Expand all
741 CFX_ByteString bsEncoding = pDict->GetString("BaseEncoding"); 741 CFX_ByteString bsEncoding = pDict->GetString("BaseEncoding");
742 if (bsEncoding.Compare("MacExpertEncoding") == 0 && bTrueType) { 742 if (bsEncoding.Compare("MacExpertEncoding") == 0 && bTrueType) {
743 bsEncoding = "WinAnsiEncoding"; 743 bsEncoding = "WinAnsiEncoding";
744 } 744 }
745 GetPredefinedEncoding(iBaseEncoding, bsEncoding); 745 GetPredefinedEncoding(iBaseEncoding, bsEncoding);
746 } 746 }
747 if ((!bEmbedded || bTrueType) && iBaseEncoding == PDFFONT_ENCODING_BUILTIN) { 747 if ((!bEmbedded || bTrueType) && iBaseEncoding == PDFFONT_ENCODING_BUILTIN) {
748 iBaseEncoding = PDFFONT_ENCODING_STANDARD; 748 iBaseEncoding = PDFFONT_ENCODING_STANDARD;
749 } 749 }
750 CPDF_Array* pDiffs = pDict->GetArray("Differences"); 750 CPDF_Array* pDiffs = pDict->GetArray("Differences");
751 if (pDiffs == NULL) { 751 if (!pDiffs) {
752 return; 752 return;
753 } 753 }
754 pCharNames = new CFX_ByteString[256]; 754 pCharNames = new CFX_ByteString[256];
755 FX_DWORD cur_code = 0; 755 FX_DWORD cur_code = 0;
756 for (FX_DWORD i = 0; i < pDiffs->GetCount(); i++) { 756 for (FX_DWORD i = 0; i < pDiffs->GetCount(); i++) {
757 CPDF_Object* pElement = pDiffs->GetElementValue(i); 757 CPDF_Object* pElement = pDiffs->GetElementValue(i);
758 if (!pElement) 758 if (!pElement)
759 continue; 759 continue;
760 760
761 if (CPDF_Name* pName = pElement->AsName()) { 761 if (CPDF_Name* pName = pElement->AsName()) {
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
872 const CFX_ByteString* pCharNames, 872 const CFX_ByteString* pCharNames,
873 int charcode) { 873 int charcode) {
874 ASSERT(charcode >= 0 && charcode < 256); 874 ASSERT(charcode >= 0 && charcode < 256);
875 if (charcode < 0 || charcode >= 256) { 875 if (charcode < 0 || charcode >= 256) {
876 return NULL; 876 return NULL;
877 } 877 }
878 const FX_CHAR* name = NULL; 878 const FX_CHAR* name = NULL;
879 if (pCharNames) { 879 if (pCharNames) {
880 name = pCharNames[charcode]; 880 name = pCharNames[charcode];
881 } 881 }
882 if ((name == NULL || name[0] == 0) && iBaseEncoding) { 882 if ((!name || name[0] == 0) && iBaseEncoding) {
883 name = PDF_CharNameFromPredefinedCharSet(iBaseEncoding, charcode); 883 name = PDF_CharNameFromPredefinedCharSet(iBaseEncoding, charcode);
884 } 884 }
885 if (name == NULL || name[0] == 0) { 885 return name && name[0] ? name : nullptr;
886 return NULL;
887 }
888 return name;
889 } 886 }
890 FX_BOOL CPDF_SimpleFont::LoadCommon() { 887 FX_BOOL CPDF_SimpleFont::LoadCommon() {
891 CPDF_Dictionary* pFontDesc = m_pFontDict->GetDict("FontDescriptor"); 888 CPDF_Dictionary* pFontDesc = m_pFontDict->GetDict("FontDescriptor");
892 if (pFontDesc) { 889 if (pFontDesc) {
893 LoadFontDescriptor(pFontDesc); 890 LoadFontDescriptor(pFontDesc);
894 } 891 }
895 CPDF_Array* pWidthArray = m_pFontDict->GetArray("Widths"); 892 CPDF_Array* pWidthArray = m_pFontDict->GetArray("Widths");
896 int width_start = 0, width_end = -1; 893 int width_start = 0, width_end = -1;
897 m_bUseFontWidth = TRUE; 894 m_bUseFontWidth = TRUE;
898 if (pWidthArray) { 895 if (pWidthArray) {
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after
1120 return; 1117 return;
1121 } 1118 }
1122 } 1119 }
1123 FXFT_Select_Charmap(m_Font.GetFace(), FXFT_ENCODING_UNICODE); 1120 FXFT_Select_Charmap(m_Font.GetFace(), FXFT_ENCODING_UNICODE);
1124 if (m_BaseEncoding == 0) { 1121 if (m_BaseEncoding == 0) {
1125 m_BaseEncoding = PDFFONT_ENCODING_STANDARD; 1122 m_BaseEncoding = PDFFONT_ENCODING_STANDARD;
1126 } 1123 }
1127 for (int charcode = 0; charcode < 256; charcode++) { 1124 for (int charcode = 0; charcode < 256; charcode++) {
1128 const FX_CHAR* name = 1125 const FX_CHAR* name =
1129 GetAdobeCharName(m_BaseEncoding, m_pCharNames, charcode); 1126 GetAdobeCharName(m_BaseEncoding, m_pCharNames, charcode);
1130 if (name == NULL) { 1127 if (!name) {
1131 continue; 1128 continue;
1132 } 1129 }
1133 m_Encoding.m_Unicodes[charcode] = PDF_UnicodeFromAdobeName(name); 1130 m_Encoding.m_Unicodes[charcode] = PDF_UnicodeFromAdobeName(name);
1134 m_GlyphIndex[charcode] = FXFT_Get_Char_Index( 1131 m_GlyphIndex[charcode] = FXFT_Get_Char_Index(
1135 m_Font.GetFace(), m_Encoding.m_Unicodes[charcode]); 1132 m_Font.GetFace(), m_Encoding.m_Unicodes[charcode]);
1136 #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ 1133 #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_
1137 FX_CHAR name_glyph[256]; 1134 FX_CHAR name_glyph[256];
1138 FXFT_Get_Glyph_Name(m_Font.GetFace(), m_GlyphIndex[charcode], name_glyph, 1135 FXFT_Get_Glyph_Name(m_Font.GetFace(), m_GlyphIndex[charcode], name_glyph,
1139 256); 1136 256);
1140 name_glyph[255] = 0; 1137 name_glyph[255] = 0;
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
1221 } 1218 }
1222 return; 1219 return;
1223 } 1220 }
1224 FX_BOOL bUnicode = FALSE; 1221 FX_BOOL bUnicode = FALSE;
1225 if (0 == FXFT_Select_Charmap(m_Font.GetFace(), FXFT_ENCODING_UNICODE)) { 1222 if (0 == FXFT_Select_Charmap(m_Font.GetFace(), FXFT_ENCODING_UNICODE)) {
1226 bUnicode = TRUE; 1223 bUnicode = TRUE;
1227 } 1224 }
1228 for (int charcode = 0; charcode < 256; charcode++) { 1225 for (int charcode = 0; charcode < 256; charcode++) {
1229 const FX_CHAR* name = 1226 const FX_CHAR* name =
1230 GetAdobeCharName(m_BaseEncoding, m_pCharNames, charcode); 1227 GetAdobeCharName(m_BaseEncoding, m_pCharNames, charcode);
1231 if (name == NULL) { 1228 if (!name) {
1232 continue; 1229 continue;
1233 } 1230 }
1234 m_Encoding.m_Unicodes[charcode] = PDF_UnicodeFromAdobeName(name); 1231 m_Encoding.m_Unicodes[charcode] = PDF_UnicodeFromAdobeName(name);
1235 const FX_CHAR* pStrUnicode = _GlyphNameRemap(name); 1232 const FX_CHAR* pStrUnicode = _GlyphNameRemap(name);
1236 if (pStrUnicode && 1233 if (pStrUnicode &&
1237 0 == FXFT_Get_Name_Index(m_Font.GetFace(), (char*)name)) { 1234 0 == FXFT_Get_Name_Index(m_Font.GetFace(), (char*)name)) {
1238 name = pStrUnicode; 1235 name = pStrUnicode;
1239 } 1236 }
1240 m_GlyphIndex[charcode] = 1237 m_GlyphIndex[charcode] =
1241 FXFT_Get_Name_Index(m_Font.GetFace(), (char*)name); 1238 FXFT_Get_Name_Index(m_Font.GetFace(), (char*)name);
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
1321 #endif 1318 #endif
1322 return; 1319 return;
1323 } 1320 }
1324 FX_BOOL bUnicode = FALSE; 1321 FX_BOOL bUnicode = FALSE;
1325 if (0 == FXFT_Select_Charmap(m_Font.GetFace(), FXFT_ENCODING_UNICODE)) { 1322 if (0 == FXFT_Select_Charmap(m_Font.GetFace(), FXFT_ENCODING_UNICODE)) {
1326 bUnicode = TRUE; 1323 bUnicode = TRUE;
1327 } 1324 }
1328 for (int charcode = 0; charcode < 256; charcode++) { 1325 for (int charcode = 0; charcode < 256; charcode++) {
1329 const FX_CHAR* name = 1326 const FX_CHAR* name =
1330 GetAdobeCharName(m_BaseEncoding, m_pCharNames, charcode); 1327 GetAdobeCharName(m_BaseEncoding, m_pCharNames, charcode);
1331 if (name == NULL) { 1328 if (!name) {
1332 continue; 1329 continue;
1333 } 1330 }
1334 m_Encoding.m_Unicodes[charcode] = PDF_UnicodeFromAdobeName(name); 1331 m_Encoding.m_Unicodes[charcode] = PDF_UnicodeFromAdobeName(name);
1335 m_GlyphIndex[charcode] = FXFT_Get_Name_Index(m_Font.GetFace(), (char*)name); 1332 m_GlyphIndex[charcode] = FXFT_Get_Name_Index(m_Font.GetFace(), (char*)name);
1336 if (m_GlyphIndex[charcode] == 0) { 1333 if (m_GlyphIndex[charcode] == 0) {
1337 if (FXSYS_strcmp(name, ".notdef") != 0 && 1334 if (FXSYS_strcmp(name, ".notdef") != 0 &&
1338 FXSYS_strcmp(name, "space") != 0) { 1335 FXSYS_strcmp(name, "space") != 0) {
1339 m_GlyphIndex[charcode] = FXFT_Get_Char_Index( 1336 m_GlyphIndex[charcode] = FXFT_Get_Char_Index(
1340 m_Font.GetFace(), 1337 m_Font.GetFace(),
1341 bUnicode ? m_Encoding.m_Unicodes[charcode] : charcode); 1338 bUnicode ? m_Encoding.m_Unicodes[charcode] : charcode);
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
1446 if (baseEncoding == PDFFONT_ENCODING_WINANSI && !bSupportWin) { 1443 if (baseEncoding == PDFFONT_ENCODING_WINANSI && !bSupportWin) {
1447 baseEncoding = 1444 baseEncoding =
1448 bSupportMac ? PDFFONT_ENCODING_MACROMAN : PDFFONT_ENCODING_BUILTIN; 1445 bSupportMac ? PDFFONT_ENCODING_MACROMAN : PDFFONT_ENCODING_BUILTIN;
1449 } else if (baseEncoding == PDFFONT_ENCODING_MACROMAN && !bSupportMac) { 1446 } else if (baseEncoding == PDFFONT_ENCODING_MACROMAN && !bSupportMac) {
1450 baseEncoding = 1447 baseEncoding =
1451 bSupportWin ? PDFFONT_ENCODING_WINANSI : PDFFONT_ENCODING_BUILTIN; 1448 bSupportWin ? PDFFONT_ENCODING_WINANSI : PDFFONT_ENCODING_BUILTIN;
1452 } 1449 }
1453 } 1450 }
1454 if (((baseEncoding == PDFFONT_ENCODING_MACROMAN || 1451 if (((baseEncoding == PDFFONT_ENCODING_MACROMAN ||
1455 baseEncoding == PDFFONT_ENCODING_WINANSI) && 1452 baseEncoding == PDFFONT_ENCODING_WINANSI) &&
1456 m_pCharNames == NULL) || 1453 !m_pCharNames) ||
1457 (m_Flags & PDFFONT_NONSYMBOLIC)) { 1454 (m_Flags & PDFFONT_NONSYMBOLIC)) {
1458 if (!FXFT_Has_Glyph_Names(m_Font.GetFace()) && 1455 if (!FXFT_Has_Glyph_Names(m_Font.GetFace()) &&
1459 (!m_Font.GetFace()->num_charmaps || !m_Font.GetFace()->charmaps)) { 1456 (!m_Font.GetFace()->num_charmaps || !m_Font.GetFace()->charmaps)) {
1460 int nStartChar = m_pFontDict->GetInteger("FirstChar"); 1457 int nStartChar = m_pFontDict->GetInteger("FirstChar");
1461 if (nStartChar < 0 || nStartChar > 255) 1458 if (nStartChar < 0 || nStartChar > 255)
1462 return; 1459 return;
1463 1460
1464 int charcode = 0; 1461 int charcode = 0;
1465 for (; charcode < nStartChar; charcode++) { 1462 for (; charcode < nStartChar; charcode++) {
1466 m_GlyphIndex[charcode] = 0; 1463 m_GlyphIndex[charcode] = 0;
(...skipping 12 matching lines...) Expand all
1479 bMSSymbol = !bMacRoman && FT_UseTTCharmap(m_Font.GetFace(), 3, 0); 1476 bMSSymbol = !bMacRoman && FT_UseTTCharmap(m_Font.GetFace(), 3, 0);
1480 } else { 1477 } else {
1481 bMSSymbol = FT_UseTTCharmap(m_Font.GetFace(), 3, 0); 1478 bMSSymbol = FT_UseTTCharmap(m_Font.GetFace(), 3, 0);
1482 bMacRoman = !bMSSymbol && FT_UseTTCharmap(m_Font.GetFace(), 1, 0); 1479 bMacRoman = !bMSSymbol && FT_UseTTCharmap(m_Font.GetFace(), 1, 0);
1483 } 1480 }
1484 } 1481 }
1485 FX_BOOL bToUnicode = m_pFontDict->KeyExist("ToUnicode"); 1482 FX_BOOL bToUnicode = m_pFontDict->KeyExist("ToUnicode");
1486 for (int charcode = 0; charcode < 256; charcode++) { 1483 for (int charcode = 0; charcode < 256; charcode++) {
1487 const FX_CHAR* name = 1484 const FX_CHAR* name =
1488 GetAdobeCharName(baseEncoding, m_pCharNames, charcode); 1485 GetAdobeCharName(baseEncoding, m_pCharNames, charcode);
1489 if (name == NULL) { 1486 if (!name) {
1490 m_GlyphIndex[charcode] = 1487 m_GlyphIndex[charcode] =
1491 m_pFontFile ? FXFT_Get_Char_Index(m_Font.GetFace(), charcode) : -1; 1488 m_pFontFile ? FXFT_Get_Char_Index(m_Font.GetFace(), charcode) : -1;
1492 continue; 1489 continue;
1493 } 1490 }
1494 m_Encoding.m_Unicodes[charcode] = PDF_UnicodeFromAdobeName(name); 1491 m_Encoding.m_Unicodes[charcode] = PDF_UnicodeFromAdobeName(name);
1495 if (bMSSymbol) { 1492 if (bMSSymbol) {
1496 const uint8_t prefix[4] = {0x00, 0xf0, 0xf1, 0xf2}; 1493 const uint8_t prefix[4] = {0x00, 0xf0, 0xf1, 0xf2};
1497 for (int j = 0; j < 4; j++) { 1494 for (int j = 0; j < 4; j++) {
1498 FX_WORD unicode = prefix[j] * 256 + charcode; 1495 FX_WORD unicode = prefix[j] * 256 + charcode;
1499 m_GlyphIndex[charcode] = 1496 m_GlyphIndex[charcode] =
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
1555 bGotOne = TRUE; 1552 bGotOne = TRUE;
1556 break; 1553 break;
1557 } 1554 }
1558 } 1555 }
1559 } 1556 }
1560 if (bGotOne) { 1557 if (bGotOne) {
1561 if (baseEncoding != PDFFONT_ENCODING_BUILTIN) { 1558 if (baseEncoding != PDFFONT_ENCODING_BUILTIN) {
1562 for (int charcode = 0; charcode < 256; charcode++) { 1559 for (int charcode = 0; charcode < 256; charcode++) {
1563 const FX_CHAR* name = 1560 const FX_CHAR* name =
1564 GetAdobeCharName(baseEncoding, m_pCharNames, charcode); 1561 GetAdobeCharName(baseEncoding, m_pCharNames, charcode);
1565 if (name == NULL) { 1562 if (!name) {
1566 continue; 1563 continue;
1567 } 1564 }
1568 m_Encoding.m_Unicodes[charcode] = PDF_UnicodeFromAdobeName(name); 1565 m_Encoding.m_Unicodes[charcode] = PDF_UnicodeFromAdobeName(name);
1569 } 1566 }
1570 } else if (FT_UseTTCharmap(m_Font.GetFace(), 1, 0)) { 1567 } else if (FT_UseTTCharmap(m_Font.GetFace(), 1, 0)) {
1571 for (int charcode = 0; charcode < 256; charcode++) { 1568 for (int charcode = 0; charcode < 256; charcode++) {
1572 m_Encoding.m_Unicodes[charcode] = 1569 m_Encoding.m_Unicodes[charcode] =
1573 FT_UnicodeFromCharCode(FXFT_ENCODING_APPLE_ROMAN, charcode); 1570 FT_UnicodeFromCharCode(FXFT_ENCODING_APPLE_ROMAN, charcode);
1574 } 1571 }
1575 } 1572 }
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
1762 rect = pChar->m_BBox; 1759 rect = pChar->m_BBox;
1763 } 1760 }
1764 1761
1765 CPDF_Type3Char::CPDF_Type3Char(CPDF_Form* pForm) 1762 CPDF_Type3Char::CPDF_Type3Char(CPDF_Form* pForm)
1766 : m_pForm(pForm), m_pBitmap(nullptr), m_bColored(FALSE) {} 1763 : m_pForm(pForm), m_pBitmap(nullptr), m_bColored(FALSE) {}
1767 1764
1768 CPDF_Type3Char::~CPDF_Type3Char() { 1765 CPDF_Type3Char::~CPDF_Type3Char() {
1769 delete m_pForm; 1766 delete m_pForm;
1770 delete m_pBitmap; 1767 delete m_pBitmap;
1771 } 1768 }
OLDNEW
« no previous file with comments | « core/src/fpdfapi/fpdf_edit/fpdf_edit_image.cpp ('k') | core/src/fpdfapi/fpdf_font/fpdf_font_cid.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698