| 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 "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 372 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 383 int font_id = PDF_GetStandardFontName(&fontname); | 383 int font_id = PDF_GetStandardFontName(&fontname); |
| 384 if (font_id < 0) { | 384 if (font_id < 0) { |
| 385 return nullptr; | 385 return nullptr; |
| 386 } | 386 } |
| 387 CPDF_FontGlobals* pFontGlobals = | 387 CPDF_FontGlobals* pFontGlobals = |
| 388 CPDF_ModuleMgr::Get()->GetPageModule()->GetFontGlobals(); | 388 CPDF_ModuleMgr::Get()->GetPageModule()->GetFontGlobals(); |
| 389 CPDF_Font* pFont = pFontGlobals->Find(pDoc, font_id); | 389 CPDF_Font* pFont = pFontGlobals->Find(pDoc, font_id); |
| 390 if (pFont) { | 390 if (pFont) { |
| 391 return pFont; | 391 return pFont; |
| 392 } | 392 } |
| 393 CPDF_Dictionary* pDict = CPDF_Dictionary::Create(); | 393 CPDF_Dictionary* pDict = new CPDF_Dictionary; |
| 394 pDict->SetAtName("Type", "Font"); | 394 pDict->SetAtName("Type", "Font"); |
| 395 pDict->SetAtName("Subtype", "Type1"); | 395 pDict->SetAtName("Subtype", "Type1"); |
| 396 pDict->SetAtName("BaseFont", fontname); | 396 pDict->SetAtName("BaseFont", fontname); |
| 397 pDict->SetAtName("Encoding", "WinAnsiEncoding"); | 397 pDict->SetAtName("Encoding", "WinAnsiEncoding"); |
| 398 pFont = CPDF_Font::CreateFontF(NULL, pDict); | 398 pFont = CPDF_Font::CreateFontF(NULL, pDict); |
| 399 pFontGlobals->Set(pDoc, font_id, pFont); | 399 pFontGlobals->Set(pDoc, font_id, pFont); |
| 400 return pFont; | 400 return pFont; |
| 401 } | 401 } |
| 402 const uint8_t ChineseFontNames[][5] = {{0xCB, 0xCE, 0xCC, 0xE5, 0x00}, | 402 const uint8_t ChineseFontNames[][5] = {{0xCB, 0xCE, 0xCC, 0xE5, 0x00}, |
| 403 {0xBF, 0xAC, 0xCC, 0xE5, 0x00}, | 403 {0xBF, 0xAC, 0xCC, 0xE5, 0x00}, |
| (...skipping 980 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1384 break; | 1384 break; |
| 1385 } | 1385 } |
| 1386 } | 1386 } |
| 1387 if (match) { | 1387 if (match) { |
| 1388 predefined = cs; | 1388 predefined = cs; |
| 1389 break; | 1389 break; |
| 1390 } | 1390 } |
| 1391 } | 1391 } |
| 1392 if (predefined) { | 1392 if (predefined) { |
| 1393 if (predefined == PDFFONT_ENCODING_WINANSI) { | 1393 if (predefined == PDFFONT_ENCODING_WINANSI) { |
| 1394 return CPDF_Name::Create("WinAnsiEncoding"); | 1394 return new CPDF_Name("WinAnsiEncoding"); |
| 1395 } | 1395 } |
| 1396 if (predefined == PDFFONT_ENCODING_MACROMAN) { | 1396 if (predefined == PDFFONT_ENCODING_MACROMAN) { |
| 1397 return CPDF_Name::Create("MacRomanEncoding"); | 1397 return new CPDF_Name("MacRomanEncoding"); |
| 1398 } | 1398 } |
| 1399 if (predefined == PDFFONT_ENCODING_MACEXPERT) { | 1399 if (predefined == PDFFONT_ENCODING_MACEXPERT) { |
| 1400 return CPDF_Name::Create("MacExpertEncoding"); | 1400 return new CPDF_Name("MacExpertEncoding"); |
| 1401 } | 1401 } |
| 1402 return NULL; | 1402 return NULL; |
| 1403 } | 1403 } |
| 1404 CPDF_Dictionary* pDict = CPDF_Dictionary::Create(); | |
| 1405 pDict->SetAtName("BaseEncoding", "WinAnsiEncoding"); | |
| 1406 const FX_WORD* pStandard = | 1404 const FX_WORD* pStandard = |
| 1407 PDF_UnicodesForPredefinedCharSet(PDFFONT_ENCODING_WINANSI); | 1405 PDF_UnicodesForPredefinedCharSet(PDFFONT_ENCODING_WINANSI); |
| 1408 CPDF_Array* pDiff = CPDF_Array::Create(); | 1406 CPDF_Array* pDiff = new CPDF_Array; |
| 1409 for (int i = 0; i < 256; i++) { | 1407 for (int i = 0; i < 256; i++) { |
| 1410 if (pStandard[i] == m_Unicodes[i]) { | 1408 if (pStandard[i] == m_Unicodes[i]) { |
| 1411 continue; | 1409 continue; |
| 1412 } | 1410 } |
| 1413 pDiff->Add(CPDF_Number::Create(i)); | 1411 pDiff->Add(new CPDF_Number(i)); |
| 1414 pDiff->Add(CPDF_Name::Create(PDF_AdobeNameFromUnicode(m_Unicodes[i]))); | 1412 pDiff->Add(new CPDF_Name(PDF_AdobeNameFromUnicode(m_Unicodes[i]))); |
| 1415 } | 1413 } |
| 1414 |
| 1415 CPDF_Dictionary* pDict = new CPDF_Dictionary; |
| 1416 pDict->SetAtName("BaseEncoding", "WinAnsiEncoding"); |
| 1416 pDict->SetAt("Differences", pDiff); | 1417 pDict->SetAt("Differences", pDiff); |
| 1417 return pDict; | 1418 return pDict; |
| 1418 } | 1419 } |
| 1419 CPDF_TrueTypeFont::CPDF_TrueTypeFont() : CPDF_SimpleFont(PDFFONT_TRUETYPE) {} | 1420 CPDF_TrueTypeFont::CPDF_TrueTypeFont() : CPDF_SimpleFont(PDFFONT_TRUETYPE) {} |
| 1420 FX_BOOL CPDF_TrueTypeFont::_Load() { | 1421 FX_BOOL CPDF_TrueTypeFont::_Load() { |
| 1421 return LoadCommon(); | 1422 return LoadCommon(); |
| 1422 } | 1423 } |
| 1423 void CPDF_TrueTypeFont::LoadGlyphMap() { | 1424 void CPDF_TrueTypeFont::LoadGlyphMap() { |
| 1424 if (!m_Font.GetFace()) | 1425 if (!m_Font.GetFace()) |
| 1425 return; | 1426 return; |
| (...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1759 rect = pChar->m_BBox; | 1760 rect = pChar->m_BBox; |
| 1760 } | 1761 } |
| 1761 | 1762 |
| 1762 CPDF_Type3Char::CPDF_Type3Char(CPDF_Form* pForm) | 1763 CPDF_Type3Char::CPDF_Type3Char(CPDF_Form* pForm) |
| 1763 : m_pForm(pForm), m_pBitmap(nullptr), m_bColored(FALSE) {} | 1764 : m_pForm(pForm), m_pBitmap(nullptr), m_bColored(FALSE) {} |
| 1764 | 1765 |
| 1765 CPDF_Type3Char::~CPDF_Type3Char() { | 1766 CPDF_Type3Char::~CPDF_Type3Char() { |
| 1766 delete m_pForm; | 1767 delete m_pForm; |
| 1767 delete m_pBitmap; | 1768 delete m_pBitmap; |
| 1768 } | 1769 } |
| OLD | NEW |