| OLD | NEW |
| 1 // Copyright 2016 PDFium Authors. All rights reserved. | 1 // Copyright 2016 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 "core/fpdfapi/font/cpdf_font.h" | 7 #include "core/fpdfapi/font/cpdf_font.h" |
| 8 | 8 |
| 9 #include <memory> | 9 #include <memory> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 303 if (font_id < 0) | 303 if (font_id < 0) |
| 304 return nullptr; | 304 return nullptr; |
| 305 | 305 |
| 306 CPDF_FontGlobals* pFontGlobals = | 306 CPDF_FontGlobals* pFontGlobals = |
| 307 CPDF_ModuleMgr::Get()->GetPageModule()->GetFontGlobals(); | 307 CPDF_ModuleMgr::Get()->GetPageModule()->GetFontGlobals(); |
| 308 CPDF_Font* pFont = pFontGlobals->Find(pDoc, font_id); | 308 CPDF_Font* pFont = pFontGlobals->Find(pDoc, font_id); |
| 309 if (pFont) | 309 if (pFont) |
| 310 return pFont; | 310 return pFont; |
| 311 | 311 |
| 312 CPDF_Dictionary* pDict = new CPDF_Dictionary(pDoc->GetByteStringPool()); | 312 CPDF_Dictionary* pDict = new CPDF_Dictionary(pDoc->GetByteStringPool()); |
| 313 pDict->SetNameFor("Type", "Font"); | 313 pDict->SetNewFor<CPDF_Name>("Type", "Font"); |
| 314 pDict->SetNameFor("Subtype", "Type1"); | 314 pDict->SetNewFor<CPDF_Name>("Subtype", "Type1"); |
| 315 pDict->SetNameFor("BaseFont", fontname); | 315 pDict->SetNewFor<CPDF_Name>("BaseFont", fontname); |
| 316 pDict->SetNameFor("Encoding", "WinAnsiEncoding"); | 316 pDict->SetNewFor<CPDF_Name>("Encoding", "WinAnsiEncoding"); |
| 317 return pFontGlobals->Set(pDoc, font_id, CPDF_Font::Create(nullptr, pDict)); | 317 return pFontGlobals->Set(pDoc, font_id, CPDF_Font::Create(nullptr, pDict)); |
| 318 } | 318 } |
| 319 | 319 |
| 320 std::unique_ptr<CPDF_Font> CPDF_Font::Create(CPDF_Document* pDoc, | 320 std::unique_ptr<CPDF_Font> CPDF_Font::Create(CPDF_Document* pDoc, |
| 321 CPDF_Dictionary* pFontDict) { | 321 CPDF_Dictionary* pFontDict) { |
| 322 CFX_ByteString type = pFontDict->GetStringFor("Subtype"); | 322 CFX_ByteString type = pFontDict->GetStringFor("Subtype"); |
| 323 std::unique_ptr<CPDF_Font> pFont; | 323 std::unique_ptr<CPDF_Font> pFont; |
| 324 if (type == "TrueType") { | 324 if (type == "TrueType") { |
| 325 CFX_ByteString tag = pFontDict->GetStringFor("BaseFont").Left(4); | 325 CFX_ByteString tag = pFontDict->GetStringFor("BaseFont").Left(4); |
| 326 for (size_t i = 0; i < FX_ArraySize(kChineseFontNames); ++i) { | 326 for (size_t i = 0; i < FX_ArraySize(kChineseFontNames); ++i) { |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 467 if (fallbackFont < 0 || | 467 if (fallbackFont < 0 || |
| 468 fallbackFont >= pdfium::CollectionSize<int>(m_FontFallbacks)) { | 468 fallbackFont >= pdfium::CollectionSize<int>(m_FontFallbacks)) { |
| 469 return -1; | 469 return -1; |
| 470 } | 470 } |
| 471 int glyph = | 471 int glyph = |
| 472 FXFT_Get_Char_Index(m_FontFallbacks[fallbackFont]->GetFace(), charcode); | 472 FXFT_Get_Char_Index(m_FontFallbacks[fallbackFont]->GetFace(), charcode); |
| 473 if (glyph == 0 || glyph == 0xffff) | 473 if (glyph == 0 || glyph == 0xffff) |
| 474 return -1; | 474 return -1; |
| 475 return glyph; | 475 return glyph; |
| 476 } | 476 } |
| OLD | NEW |