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

Side by Side Diff: core/fpdfapi/font/cpdf_font.cpp

Issue 2510223002: Make CPDF_Dictionary use unique pointers. (Closed)
Patch Set: rebase Created 4 years, 1 month 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
« no previous file with comments | « core/fpdfapi/edit/fpdf_edit_create.cpp ('k') | core/fpdfapi/font/cpdf_fontencoding.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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 }
OLDNEW
« no previous file with comments | « core/fpdfapi/edit/fpdf_edit_create.cpp ('k') | core/fpdfapi/font/cpdf_fontencoding.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698