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

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

Issue 1867183002: Use std::vector as internal storage for CPDF_Array (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Created 4 years, 8 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/cpdf_type3font.h" 7 #include "core/fpdfapi/fpdf_font/cpdf_type3font.h"
8 8
9 #include "core/fpdfapi/fpdf_font/cpdf_type3char.h" 9 #include "core/fpdfapi/fpdf_font/cpdf_type3char.h"
10 #include "core/fpdfapi/fpdf_page/include/cpdf_form.h" 10 #include "core/fpdfapi/fpdf_page/include/cpdf_form.h"
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 CPDF_Array* pBBox = m_pFontDict->GetArrayBy("FontBBox"); 50 CPDF_Array* pBBox = m_pFontDict->GetArrayBy("FontBBox");
51 if (pBBox) { 51 if (pBBox) {
52 m_FontBBox.left = (int32_t)(pBBox->GetNumberAt(0) * xscale * 1000); 52 m_FontBBox.left = (int32_t)(pBBox->GetNumberAt(0) * xscale * 1000);
53 m_FontBBox.bottom = (int32_t)(pBBox->GetNumberAt(1) * yscale * 1000); 53 m_FontBBox.bottom = (int32_t)(pBBox->GetNumberAt(1) * yscale * 1000);
54 m_FontBBox.right = (int32_t)(pBBox->GetNumberAt(2) * xscale * 1000); 54 m_FontBBox.right = (int32_t)(pBBox->GetNumberAt(2) * xscale * 1000);
55 m_FontBBox.top = (int32_t)(pBBox->GetNumberAt(3) * yscale * 1000); 55 m_FontBBox.top = (int32_t)(pBBox->GetNumberAt(3) * yscale * 1000);
56 } 56 }
57 int StartChar = m_pFontDict->GetIntegerBy("FirstChar"); 57 int StartChar = m_pFontDict->GetIntegerBy("FirstChar");
58 CPDF_Array* pWidthArray = m_pFontDict->GetArrayBy("Widths"); 58 CPDF_Array* pWidthArray = m_pFontDict->GetArrayBy("Widths");
59 if (pWidthArray && (StartChar >= 0 && StartChar < 256)) { 59 if (pWidthArray && (StartChar >= 0 && StartChar < 256)) {
60 uint32_t count = pWidthArray->GetCount(); 60 size_t count = pWidthArray->GetCount();
61 if (count > 256) { 61 if (count > 256)
62 count = 256; 62 count = 256;
63 } 63 if (StartChar + count > 256)
64 if (StartChar + count > 256) {
65 count = 256 - StartChar; 64 count = 256 - StartChar;
66 } 65 for (size_t i = 0; i < count; i++) {
67 for (uint32_t i = 0; i < count; i++) {
68 m_CharWidthL[StartChar + i] = 66 m_CharWidthL[StartChar + i] =
69 FXSYS_round(pWidthArray->GetNumberAt(i) * xscale * 1000); 67 FXSYS_round(pWidthArray->GetNumberAt(i) * xscale * 1000);
70 } 68 }
71 } 69 }
72 m_pCharProcs = m_pFontDict->GetDictBy("CharProcs"); 70 m_pCharProcs = m_pFontDict->GetDictBy("CharProcs");
73 CPDF_Object* pEncoding = m_pFontDict->GetDirectObjectBy("Encoding"); 71 CPDF_Object* pEncoding = m_pFontDict->GetDirectObjectBy("Encoding");
74 if (pEncoding) { 72 if (pEncoding) {
75 LoadPDFEncoding(pEncoding, m_BaseEncoding, m_pCharNames, FALSE, FALSE); 73 LoadPDFEncoding(pEncoding, m_BaseEncoding, m_pCharNames, FALSE, FALSE);
76 if (m_pCharNames) { 74 if (m_pCharNames) {
77 for (int i = 0; i < 256; i++) { 75 for (int i = 0; i < 256; i++) {
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 return m_CharWidthL[charcode]; 151 return m_CharWidthL[charcode];
154 152
155 const CPDF_Type3Char* pChar = LoadChar(charcode, level); 153 const CPDF_Type3Char* pChar = LoadChar(charcode, level);
156 return pChar ? pChar->m_Width : 0; 154 return pChar ? pChar->m_Width : 0;
157 } 155 }
158 156
159 FX_RECT CPDF_Type3Font::GetCharBBox(uint32_t charcode, int level) { 157 FX_RECT CPDF_Type3Font::GetCharBBox(uint32_t charcode, int level) {
160 const CPDF_Type3Char* pChar = LoadChar(charcode, level); 158 const CPDF_Type3Char* pChar = LoadChar(charcode, level);
161 return pChar ? pChar->m_BBox : FX_RECT(); 159 return pChar ? pChar->m_BBox : FX_RECT();
162 } 160 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698