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

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

Issue 2345063002: Use string pools in some dictionaries (Closed)
Patch Set: Remove default ctor Created 4 years, 3 months 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
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/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
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);
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 pFont = CPDF_Font::CreateFontF(nullptr, pDict); 316 pFont = CPDF_Font::CreateFontF(nullptr, pDict);
317 pFontGlobals->Set(pDoc, font_id, pFont); 317 pFontGlobals->Set(pDoc, font_id, pFont);
318 return pFont; 318 return pFont;
319 } 319 }
320 320
321 CPDF_Font* CPDF_Font::CreateFontF(CPDF_Document* pDoc, 321 CPDF_Font* CPDF_Font::CreateFontF(CPDF_Document* pDoc,
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
468 if (fallbackFont < 0 || 468 if (fallbackFont < 0 ||
469 fallbackFont >= pdfium::CollectionSize<int>(m_FontFallbacks)) { 469 fallbackFont >= pdfium::CollectionSize<int>(m_FontFallbacks)) {
470 return -1; 470 return -1;
471 } 471 }
472 int glyph = 472 int glyph =
473 FXFT_Get_Char_Index(m_FontFallbacks[fallbackFont]->GetFace(), charcode); 473 FXFT_Get_Char_Index(m_FontFallbacks[fallbackFont]->GetFace(), charcode);
474 if (glyph == 0 || glyph == 0xffff) 474 if (glyph == 0 || glyph == 0xffff)
475 return -1; 475 return -1;
476 return glyph; 476 return glyph;
477 } 477 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698