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

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

Issue 2345063002: Use string pools in some dictionaries (Closed)
Patch Set: windows compile Created 4 years, 2 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->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
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 }
OLDNEW
« no previous file with comments | « core/fpdfapi/fpdf_edit/cpdf_pagecontentgenerator.cpp ('k') | core/fpdfapi/fpdf_font/cpdf_fontencoding.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698