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

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

Issue 2386273004: Add ptr_util.h from base until std::make_unique<> available (Closed)
Patch Set: 2016 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
« no previous file with comments | « no previous file | core/fpdfapi/fpdf_page/fpdf_page_parser.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/fpdf_font/cpdf_font.h" 7 #include "core/fpdfapi/fpdf_font/cpdf_font.h"
8 8
9 #include <memory> 9 #include <memory>
10 #include <vector> 10 #include <vector>
11 11
12 #include "core/fpdfapi/cpdf_modulemgr.h" 12 #include "core/fpdfapi/cpdf_modulemgr.h"
13 #include "core/fpdfapi/fpdf_font/cpdf_fontencoding.h" 13 #include "core/fpdfapi/fpdf_font/cpdf_fontencoding.h"
14 #include "core/fpdfapi/fpdf_font/cpdf_truetypefont.h" 14 #include "core/fpdfapi/fpdf_font/cpdf_truetypefont.h"
15 #include "core/fpdfapi/fpdf_font/cpdf_type1font.h" 15 #include "core/fpdfapi/fpdf_font/cpdf_type1font.h"
16 #include "core/fpdfapi/fpdf_font/cpdf_type3font.h" 16 #include "core/fpdfapi/fpdf_font/cpdf_type3font.h"
17 #include "core/fpdfapi/fpdf_font/font_int.h" 17 #include "core/fpdfapi/fpdf_font/font_int.h"
18 #include "core/fpdfapi/fpdf_page/cpdf_pagemodule.h" 18 #include "core/fpdfapi/fpdf_page/cpdf_pagemodule.h"
19 #include "core/fpdfapi/fpdf_page/pageint.h" 19 #include "core/fpdfapi/fpdf_page/pageint.h"
20 #include "core/fpdfapi/fpdf_parser/cpdf_array.h" 20 #include "core/fpdfapi/fpdf_parser/cpdf_array.h"
21 #include "core/fpdfapi/fpdf_parser/cpdf_dictionary.h" 21 #include "core/fpdfapi/fpdf_parser/cpdf_dictionary.h"
22 #include "core/fpdfapi/fpdf_parser/cpdf_document.h" 22 #include "core/fpdfapi/fpdf_parser/cpdf_document.h"
23 #include "core/fpdfapi/fpdf_parser/cpdf_name.h" 23 #include "core/fpdfapi/fpdf_parser/cpdf_name.h"
24 #include "core/fpdfapi/fpdf_parser/cpdf_stream_acc.h" 24 #include "core/fpdfapi/fpdf_parser/cpdf_stream_acc.h"
25 #include "core/fxcrt/fx_memory.h" 25 #include "core/fxcrt/fx_memory.h"
26 #include "core/fxge/fx_freetype.h" 26 #include "core/fxge/fx_freetype.h"
27 #include "third_party/base/ptr_util.h"
27 #include "third_party/base/stl_util.h" 28 #include "third_party/base/stl_util.h"
28 29
29 namespace { 30 namespace {
30 31
31 const uint8_t kChineseFontNames[][5] = {{0xCB, 0xCE, 0xCC, 0xE5, 0x00}, 32 const uint8_t kChineseFontNames[][5] = {{0xCB, 0xCE, 0xCC, 0xE5, 0x00},
32 {0xBF, 0xAC, 0xCC, 0xE5, 0x00}, 33 {0xBF, 0xAC, 0xCC, 0xE5, 0x00},
33 {0xBA, 0xDA, 0xCC, 0xE5, 0x00}, 34 {0xBA, 0xDA, 0xCC, 0xE5, 0x00},
34 {0xB7, 0xC2, 0xCB, 0xCE, 0x00}, 35 {0xB7, 0xC2, 0xCB, 0xCE, 0x00},
35 {0xD0, 0xC2, 0xCB, 0xCE, 0x00}}; 36 {0xD0, 0xC2, 0xCB, 0xCE, 0x00}};
36 37
(...skipping 410 matching lines...) Expand 10 before | Expand all | Expand 10 after
447 return charnames[charcode].c_str(); 448 return charnames[charcode].c_str();
448 449
449 const FX_CHAR* name = nullptr; 450 const FX_CHAR* name = nullptr;
450 if (iBaseEncoding) 451 if (iBaseEncoding)
451 name = PDF_CharNameFromPredefinedCharSet(iBaseEncoding, charcode); 452 name = PDF_CharNameFromPredefinedCharSet(iBaseEncoding, charcode);
452 return name && name[0] ? name : nullptr; 453 return name && name[0] ? name : nullptr;
453 } 454 }
454 455
455 uint32_t CPDF_Font::FallbackFontFromCharcode(uint32_t charcode) { 456 uint32_t CPDF_Font::FallbackFontFromCharcode(uint32_t charcode) {
456 if (m_FontFallbacks.empty()) { 457 if (m_FontFallbacks.empty()) {
457 m_FontFallbacks.push_back(WrapUnique(new CFX_Font())); 458 m_FontFallbacks.push_back(pdfium::MakeUnique<CFX_Font>());
458 m_FontFallbacks[0]->LoadSubst("Arial", IsTrueTypeFont(), m_Flags, 459 m_FontFallbacks[0]->LoadSubst("Arial", IsTrueTypeFont(), m_Flags,
459 m_StemV * 5, m_ItalicAngle, 0, 460 m_StemV * 5, m_ItalicAngle, 0,
460 IsVertWriting()); 461 IsVertWriting());
461 } 462 }
462 return 0; 463 return 0;
463 } 464 }
464 465
465 int CPDF_Font::FallbackGlyphFromCharcode(int fallbackFont, uint32_t charcode) { 466 int CPDF_Font::FallbackGlyphFromCharcode(int fallbackFont, uint32_t charcode) {
466 if (fallbackFont < 0 || 467 if (fallbackFont < 0 ||
467 fallbackFont >= pdfium::CollectionSize<int>(m_FontFallbacks)) { 468 fallbackFont >= pdfium::CollectionSize<int>(m_FontFallbacks)) {
468 return -1; 469 return -1;
469 } 470 }
470 int glyph = 471 int glyph =
471 FXFT_Get_Char_Index(m_FontFallbacks[fallbackFont]->GetFace(), charcode); 472 FXFT_Get_Char_Index(m_FontFallbacks[fallbackFont]->GetFace(), charcode);
472 if (glyph == 0 || glyph == 0xffff) 473 if (glyph == 0 || glyph == 0xffff)
473 return -1; 474 return -1;
474 return glyph; 475 return glyph;
475 } 476 }
OLDNEW
« no previous file with comments | « no previous file | core/fpdfapi/fpdf_page/fpdf_page_parser.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698