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

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

Issue 2119013002: Change class member variables in raw pointer type into unique_ptr (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: fix test Created 4 years, 5 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_font/font_int.h » ('j') | core/fpdfapi/fpdf_font/ttgsubtable.h » ('J')
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/include/cpdf_font.h" 7 #include "core/fpdfapi/fpdf_font/include/cpdf_font.h"
8 8
9 #include <memory>
10
11 #include "core/fpdfapi/fpdf_font/cpdf_truetypefont.h" 9 #include "core/fpdfapi/fpdf_font/cpdf_truetypefont.h"
12 #include "core/fpdfapi/fpdf_font/cpdf_type1font.h" 10 #include "core/fpdfapi/fpdf_font/cpdf_type1font.h"
13 #include "core/fpdfapi/fpdf_font/cpdf_type3font.h" 11 #include "core/fpdfapi/fpdf_font/cpdf_type3font.h"
14 #include "core/fpdfapi/fpdf_font/font_int.h" 12 #include "core/fpdfapi/fpdf_font/font_int.h"
15 #include "core/fpdfapi/fpdf_font/include/cpdf_fontencoding.h" 13 #include "core/fpdfapi/fpdf_font/include/cpdf_fontencoding.h"
16 #include "core/fpdfapi/fpdf_page/cpdf_pagemodule.h" 14 #include "core/fpdfapi/fpdf_page/cpdf_pagemodule.h"
17 #include "core/fpdfapi/fpdf_page/pageint.h" 15 #include "core/fpdfapi/fpdf_page/pageint.h"
18 #include "core/fpdfapi/fpdf_parser/include/cpdf_array.h" 16 #include "core/fpdfapi/fpdf_parser/include/cpdf_array.h"
19 #include "core/fpdfapi/fpdf_parser/include/cpdf_dictionary.h" 17 #include "core/fpdfapi/fpdf_parser/include/cpdf_dictionary.h"
20 #include "core/fpdfapi/fpdf_parser/include/cpdf_document.h" 18 #include "core/fpdfapi/fpdf_parser/include/cpdf_document.h"
(...skipping 22 matching lines...) Expand all
43 else 41 else
44 return FALSE; 42 return FALSE;
45 return TRUE; 43 return TRUE;
46 } 44 }
47 45
48 } // namespace 46 } // namespace
49 47
50 CPDF_Font::CPDF_Font() 48 CPDF_Font::CPDF_Font()
51 : m_pFontFile(nullptr), 49 : m_pFontFile(nullptr),
52 m_pFontDict(nullptr), 50 m_pFontDict(nullptr),
53 m_pToUnicodeMap(nullptr),
54 m_bToUnicodeLoaded(FALSE), 51 m_bToUnicodeLoaded(FALSE),
55 m_Flags(0), 52 m_Flags(0),
56 m_StemV(0), 53 m_StemV(0),
57 m_Ascent(0), 54 m_Ascent(0),
58 m_Descent(0), 55 m_Descent(0),
59 m_ItalicAngle(0) {} 56 m_ItalicAngle(0) {}
60 57
61 CPDF_Font::~CPDF_Font() { 58 CPDF_Font::~CPDF_Font() {
62 delete m_pToUnicodeMap;
63 m_pToUnicodeMap = nullptr;
64
65 if (m_pFontFile) { 59 if (m_pFontFile) {
66 m_pDocument->GetPageData()->ReleaseFontFileStreamAcc( 60 m_pDocument->GetPageData()->ReleaseFontFileStreamAcc(
67 const_cast<CPDF_Stream*>(m_pFontFile->GetStream()->AsStream())); 61 const_cast<CPDF_Stream*>(m_pFontFile->GetStream()->AsStream()));
68 } 62 }
69 } 63 }
70 64
71 bool CPDF_Font::IsType1Font() const { 65 bool CPDF_Font::IsType1Font() const {
72 return false; 66 return false;
73 } 67 }
74 68
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
278 m_Descent = rect.bottom == rect.top ? m_FontBBox.bottom : rect.bottom; 272 m_Descent = rect.bottom == rect.top ? m_FontBBox.bottom : rect.bottom;
279 } 273 }
280 } 274 }
281 275
282 void CPDF_Font::LoadUnicodeMap() const { 276 void CPDF_Font::LoadUnicodeMap() const {
283 m_bToUnicodeLoaded = TRUE; 277 m_bToUnicodeLoaded = TRUE;
284 CPDF_Stream* pStream = m_pFontDict->GetStreamBy("ToUnicode"); 278 CPDF_Stream* pStream = m_pFontDict->GetStreamBy("ToUnicode");
285 if (!pStream) { 279 if (!pStream) {
286 return; 280 return;
287 } 281 }
288 m_pToUnicodeMap = new CPDF_ToUnicodeMap; 282 m_pToUnicodeMap.reset(new CPDF_ToUnicodeMap);
289 m_pToUnicodeMap->Load(pStream); 283 m_pToUnicodeMap->Load(pStream);
290 } 284 }
291 285
292 int CPDF_Font::GetStringWidth(const FX_CHAR* pString, int size) { 286 int CPDF_Font::GetStringWidth(const FX_CHAR* pString, int size) {
293 int offset = 0; 287 int offset = 0;
294 int width = 0; 288 int width = 0;
295 while (offset < size) { 289 while (offset < size) {
296 uint32_t charcode = GetNextChar(pString, size, offset); 290 uint32_t charcode = GetNextChar(pString, size, offset);
297 width += GetCharWidthF(charcode); 291 width += GetCharWidthF(charcode);
298 } 292 }
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
449 } 443 }
450 444
451 if (pCharNames && !pCharNames[charcode].IsEmpty()) 445 if (pCharNames && !pCharNames[charcode].IsEmpty())
452 return pCharNames[charcode].c_str(); 446 return pCharNames[charcode].c_str();
453 447
454 const FX_CHAR* name = nullptr; 448 const FX_CHAR* name = nullptr;
455 if (iBaseEncoding) 449 if (iBaseEncoding)
456 name = PDF_CharNameFromPredefinedCharSet(iBaseEncoding, charcode); 450 name = PDF_CharNameFromPredefinedCharSet(iBaseEncoding, charcode);
457 return name && name[0] ? name : nullptr; 451 return name && name[0] ? name : nullptr;
458 } 452 }
OLDNEW
« no previous file with comments | « no previous file | core/fpdfapi/fpdf_font/font_int.h » ('j') | core/fpdfapi/fpdf_font/ttgsubtable.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698