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/fpdf_font/include/cpdf_font.h" | 7 #include "core/fpdfapi/fpdf_font/include/cpdf_font.h" |
8 | 8 |
9 #include <memory> | 9 #include <memory> |
10 #include <vector> | 10 #include <vector> |
(...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
301 int font_id = PDF_GetStandardFontName(&fontname); | 301 int font_id = PDF_GetStandardFontName(&fontname); |
302 if (font_id < 0) | 302 if (font_id < 0) |
303 return nullptr; | 303 return nullptr; |
304 | 304 |
305 CPDF_FontGlobals* pFontGlobals = | 305 CPDF_FontGlobals* pFontGlobals = |
306 CPDF_ModuleMgr::Get()->GetPageModule()->GetFontGlobals(); | 306 CPDF_ModuleMgr::Get()->GetPageModule()->GetFontGlobals(); |
307 CPDF_Font* pFont = pFontGlobals->Find(pDoc, font_id); | 307 CPDF_Font* pFont = pFontGlobals->Find(pDoc, font_id); |
308 if (pFont) | 308 if (pFont) |
309 return pFont; | 309 return pFont; |
310 | 310 |
311 CPDF_Dictionary* pDict = new CPDF_Dictionary; | 311 CPDF_Dictionary* pDict = new CPDF_Dictionary(pDoc->GetByteStringPool()); |
312 pDict->SetNameFor("Type", "Font"); | 312 pDict->SetNameFor("Type", "Font"); |
313 pDict->SetNameFor("Subtype", "Type1"); | 313 pDict->SetNameFor("Subtype", "Type1"); |
314 pDict->SetNameFor("BaseFont", fontname); | 314 pDict->SetNameFor("BaseFont", fontname); |
315 pDict->SetNameFor("Encoding", "WinAnsiEncoding"); | 315 pDict->SetNameFor("Encoding", "WinAnsiEncoding"); |
316 return pFontGlobals->Set(pDoc, font_id, CPDF_Font::Create(nullptr, pDict)); | 316 return pFontGlobals->Set(pDoc, font_id, CPDF_Font::Create(nullptr, pDict)); |
317 } | 317 } |
318 | 318 |
319 std::unique_ptr<CPDF_Font> CPDF_Font::Create(CPDF_Document* pDoc, | 319 std::unique_ptr<CPDF_Font> CPDF_Font::Create(CPDF_Document* pDoc, |
320 CPDF_Dictionary* pFontDict) { | 320 CPDF_Dictionary* pFontDict) { |
321 CFX_ByteString type = pFontDict->GetStringFor("Subtype"); | 321 CFX_ByteString type = pFontDict->GetStringFor("Subtype"); |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
466 if (fallbackFont < 0 || | 466 if (fallbackFont < 0 || |
467 fallbackFont >= pdfium::CollectionSize<int>(m_FontFallbacks)) { | 467 fallbackFont >= pdfium::CollectionSize<int>(m_FontFallbacks)) { |
468 return -1; | 468 return -1; |
469 } | 469 } |
470 int glyph = | 470 int glyph = |
471 FXFT_Get_Char_Index(m_FontFallbacks[fallbackFont]->GetFace(), charcode); | 471 FXFT_Get_Char_Index(m_FontFallbacks[fallbackFont]->GetFace(), charcode); |
472 if (glyph == 0 || glyph == 0xffff) | 472 if (glyph == 0 || glyph == 0xffff) |
473 return -1; | 473 return -1; |
474 return glyph; | 474 return glyph; |
475 } | 475 } |
OLD | NEW |