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 <utility> |
10 #include <vector> | 11 #include <vector> |
11 | 12 |
12 #include "core/fpdfapi/cpdf_modulemgr.h" | 13 #include "core/fpdfapi/cpdf_modulemgr.h" |
13 #include "core/fpdfapi/font/cpdf_fontencoding.h" | 14 #include "core/fpdfapi/font/cpdf_fontencoding.h" |
14 #include "core/fpdfapi/font/cpdf_truetypefont.h" | 15 #include "core/fpdfapi/font/cpdf_truetypefont.h" |
15 #include "core/fpdfapi/font/cpdf_type1font.h" | 16 #include "core/fpdfapi/font/cpdf_type1font.h" |
16 #include "core/fpdfapi/font/cpdf_type3font.h" | 17 #include "core/fpdfapi/font/cpdf_type3font.h" |
17 #include "core/fpdfapi/font/font_int.h" | 18 #include "core/fpdfapi/font/font_int.h" |
18 #include "core/fpdfapi/page/cpdf_docpagedata.h" | 19 #include "core/fpdfapi/page/cpdf_docpagedata.h" |
19 #include "core/fpdfapi/page/cpdf_pagemodule.h" | 20 #include "core/fpdfapi/page/cpdf_pagemodule.h" |
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
303 if (font_id < 0) | 304 if (font_id < 0) |
304 return nullptr; | 305 return nullptr; |
305 | 306 |
306 CPDF_FontGlobals* pFontGlobals = | 307 CPDF_FontGlobals* pFontGlobals = |
307 CPDF_ModuleMgr::Get()->GetPageModule()->GetFontGlobals(); | 308 CPDF_ModuleMgr::Get()->GetPageModule()->GetFontGlobals(); |
308 CPDF_Font* pFont = pFontGlobals->Find(pDoc, font_id); | 309 CPDF_Font* pFont = pFontGlobals->Find(pDoc, font_id); |
309 if (pFont) | 310 if (pFont) |
310 return pFont; | 311 return pFont; |
311 | 312 |
312 CPDF_Dictionary* pDict = new CPDF_Dictionary(pDoc->GetByteStringPool()); | 313 CPDF_Dictionary* pDict = new CPDF_Dictionary(pDoc->GetByteStringPool()); |
313 pDict->SetNameFor("Type", "Font"); | 314 pDict->SetNewFor<CPDF_Name>("Type", "Font"); |
314 pDict->SetNameFor("Subtype", "Type1"); | 315 pDict->SetNewFor<CPDF_Name>("Subtype", "Type1"); |
315 pDict->SetNameFor("BaseFont", fontname); | 316 pDict->SetNewFor<CPDF_Name>("BaseFont", fontname); |
316 pDict->SetNameFor("Encoding", "WinAnsiEncoding"); | 317 pDict->SetNewFor<CPDF_Name>("Encoding", "WinAnsiEncoding"); |
317 return pFontGlobals->Set(pDoc, font_id, CPDF_Font::Create(nullptr, pDict)); | 318 return pFontGlobals->Set(pDoc, font_id, CPDF_Font::Create(nullptr, pDict)); |
318 } | 319 } |
319 | 320 |
320 std::unique_ptr<CPDF_Font> CPDF_Font::Create(CPDF_Document* pDoc, | 321 std::unique_ptr<CPDF_Font> CPDF_Font::Create(CPDF_Document* pDoc, |
321 CPDF_Dictionary* pFontDict) { | 322 CPDF_Dictionary* pFontDict) { |
322 CFX_ByteString type = pFontDict->GetStringFor("Subtype"); | 323 CFX_ByteString type = pFontDict->GetStringFor("Subtype"); |
323 std::unique_ptr<CPDF_Font> pFont; | 324 std::unique_ptr<CPDF_Font> pFont; |
324 if (type == "TrueType") { | 325 if (type == "TrueType") { |
325 CFX_ByteString tag = pFontDict->GetStringFor("BaseFont").Left(4); | 326 CFX_ByteString tag = pFontDict->GetStringFor("BaseFont").Left(4); |
326 for (size_t i = 0; i < FX_ArraySize(kChineseFontNames); ++i) { | 327 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 || | 468 if (fallbackFont < 0 || |
468 fallbackFont >= pdfium::CollectionSize<int>(m_FontFallbacks)) { | 469 fallbackFont >= pdfium::CollectionSize<int>(m_FontFallbacks)) { |
469 return -1; | 470 return -1; |
470 } | 471 } |
471 int glyph = | 472 int glyph = |
472 FXFT_Get_Char_Index(m_FontFallbacks[fallbackFont]->GetFace(), charcode); | 473 FXFT_Get_Char_Index(m_FontFallbacks[fallbackFont]->GetFace(), charcode); |
473 if (glyph == 0 || glyph == 0xffff) | 474 if (glyph == 0 || glyph == 0xffff) |
474 return -1; | 475 return -1; |
475 return glyph; | 476 return glyph; |
476 } | 477 } |
OLD | NEW |