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

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

Issue 1832173003: Remove FX_DWORD from core/ and delete definition (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
« no previous file with comments | « core/fpdfapi/fpdf_font/cpdf_cidfont.cpp ('k') | core/fpdfapi/fpdf_font/cpdf_fontencoding.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/include/cpdf_font.h" 7 #include "core/fpdfapi/fpdf_font/include/cpdf_font.h"
8 8
9 #include "core/fpdfapi/fpdf_font/cpdf_truetypefont.h" 9 #include "core/fpdfapi/fpdf_font/cpdf_truetypefont.h"
10 #include "core/fpdfapi/fpdf_font/cpdf_type1font.h" 10 #include "core/fpdfapi/fpdf_font/cpdf_type1font.h"
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 } 114 }
115 115
116 FX_BOOL CPDF_Font::IsUnicodeCompatible() const { 116 FX_BOOL CPDF_Font::IsUnicodeCompatible() const {
117 return FALSE; 117 return FALSE;
118 } 118 }
119 119
120 int CPDF_Font::CountChar(const FX_CHAR* pString, int size) const { 120 int CPDF_Font::CountChar(const FX_CHAR* pString, int size) const {
121 return size; 121 return size;
122 } 122 }
123 123
124 int CPDF_Font::GetCharSize(FX_DWORD charcode) const { 124 int CPDF_Font::GetCharSize(uint32_t charcode) const {
125 return 1; 125 return 1;
126 } 126 }
127 127
128 int CPDF_Font::GlyphFromCharCode(FX_DWORD charcode, FX_BOOL* pVertGlyph) { 128 int CPDF_Font::GlyphFromCharCode(uint32_t charcode, FX_BOOL* pVertGlyph) {
129 ASSERT(false); 129 ASSERT(false);
130 return 0; 130 return 0;
131 } 131 }
132 132
133 int CPDF_Font::GlyphFromCharCodeExt(FX_DWORD charcode) { 133 int CPDF_Font::GlyphFromCharCodeExt(uint32_t charcode) {
134 return GlyphFromCharCode(charcode); 134 return GlyphFromCharCode(charcode);
135 } 135 }
136 136
137 FX_BOOL CPDF_Font::IsVertWriting() const { 137 FX_BOOL CPDF_Font::IsVertWriting() const {
138 FX_BOOL bVertWriting = FALSE; 138 FX_BOOL bVertWriting = FALSE;
139 const CPDF_CIDFont* pCIDFont = AsCIDFont(); 139 const CPDF_CIDFont* pCIDFont = AsCIDFont();
140 if (pCIDFont) { 140 if (pCIDFont) {
141 bVertWriting = pCIDFont->IsVertWriting(); 141 bVertWriting = pCIDFont->IsVertWriting();
142 } else { 142 } else {
143 bVertWriting = m_Font.IsVertical(); 143 bVertWriting = m_Font.IsVertical();
144 } 144 }
145 return bVertWriting; 145 return bVertWriting;
146 } 146 }
147 147
148 int CPDF_Font::AppendChar(FX_CHAR* buf, FX_DWORD charcode) const { 148 int CPDF_Font::AppendChar(FX_CHAR* buf, uint32_t charcode) const {
149 *buf = (FX_CHAR)charcode; 149 *buf = (FX_CHAR)charcode;
150 return 1; 150 return 1;
151 } 151 }
152 152
153 void CPDF_Font::AppendChar(CFX_ByteString& str, FX_DWORD charcode) const { 153 void CPDF_Font::AppendChar(CFX_ByteString& str, uint32_t charcode) const {
154 char buf[4]; 154 char buf[4];
155 int len = AppendChar(buf, charcode); 155 int len = AppendChar(buf, charcode);
156 if (len == 1) { 156 if (len == 1) {
157 str += buf[0]; 157 str += buf[0];
158 } else { 158 } else {
159 str += CFX_ByteString(buf, len); 159 str += CFX_ByteString(buf, len);
160 } 160 }
161 } 161 }
162 162
163 CFX_WideString CPDF_Font::UnicodeFromCharCode(FX_DWORD charcode) const { 163 CFX_WideString CPDF_Font::UnicodeFromCharCode(uint32_t charcode) const {
164 if (!m_bToUnicodeLoaded) 164 if (!m_bToUnicodeLoaded)
165 ((CPDF_Font*)this)->LoadUnicodeMap(); 165 ((CPDF_Font*)this)->LoadUnicodeMap();
166 166
167 if (m_pToUnicodeMap) 167 if (m_pToUnicodeMap)
168 return m_pToUnicodeMap->Lookup(charcode); 168 return m_pToUnicodeMap->Lookup(charcode);
169 return CFX_WideString(); 169 return CFX_WideString();
170 } 170 }
171 171
172 FX_DWORD CPDF_Font::CharCodeFromUnicode(FX_WCHAR unicode) const { 172 uint32_t CPDF_Font::CharCodeFromUnicode(FX_WCHAR unicode) const {
173 if (!m_bToUnicodeLoaded) 173 if (!m_bToUnicodeLoaded)
174 ((CPDF_Font*)this)->LoadUnicodeMap(); 174 ((CPDF_Font*)this)->LoadUnicodeMap();
175 175
176 if (m_pToUnicodeMap) 176 if (m_pToUnicodeMap)
177 return m_pToUnicodeMap->ReverseLookup(unicode); 177 return m_pToUnicodeMap->ReverseLookup(unicode);
178 return 0; 178 return 0;
179 } 179 }
180 180
181 void CPDF_Font::LoadFontDescriptor(CPDF_Dictionary* pFontDesc) { 181 void CPDF_Font::LoadFontDescriptor(CPDF_Dictionary* pFontDesc) {
182 m_Flags = pFontDesc->GetIntegerBy("Flags", PDFFONT_NONSYMBOLIC); 182 m_Flags = pFontDesc->GetIntegerBy("Flags", PDFFONT_NONSYMBOLIC);
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
230 if (!pFontFile) 230 if (!pFontFile)
231 pFontFile = pFontDesc->GetStreamBy("FontFile3"); 231 pFontFile = pFontDesc->GetStreamBy("FontFile3");
232 if (!pFontFile) 232 if (!pFontFile)
233 return; 233 return;
234 234
235 m_pFontFile = m_pDocument->LoadFontFile(pFontFile); 235 m_pFontFile = m_pDocument->LoadFontFile(pFontFile);
236 if (!m_pFontFile) 236 if (!m_pFontFile)
237 return; 237 return;
238 238
239 const uint8_t* pFontData = m_pFontFile->GetData(); 239 const uint8_t* pFontData = m_pFontFile->GetData();
240 FX_DWORD dwFontSize = m_pFontFile->GetSize(); 240 uint32_t dwFontSize = m_pFontFile->GetSize();
241 if (!m_Font.LoadEmbedded(pFontData, dwFontSize)) { 241 if (!m_Font.LoadEmbedded(pFontData, dwFontSize)) {
242 m_pDocument->GetPageData()->ReleaseFontFileStreamAcc( 242 m_pDocument->GetPageData()->ReleaseFontFileStreamAcc(
243 const_cast<CPDF_Stream*>(m_pFontFile->GetStream()->AsStream())); 243 const_cast<CPDF_Stream*>(m_pFontFile->GetStream()->AsStream()));
244 m_pFontFile = nullptr; 244 m_pFontFile = nullptr;
245 } 245 }
246 } 246 }
247 247
248 void CPDF_Font::CheckFontMetrics() { 248 void CPDF_Font::CheckFontMetrics() {
249 if (m_FontBBox.top == 0 && m_FontBBox.bottom == 0 && m_FontBBox.left == 0 && 249 if (m_FontBBox.top == 0 && m_FontBBox.bottom == 0 && m_FontBBox.left == 0 &&
250 m_FontBBox.right == 0) { 250 m_FontBBox.right == 0) {
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
298 return; 298 return;
299 } 299 }
300 m_pToUnicodeMap = new CPDF_ToUnicodeMap; 300 m_pToUnicodeMap = new CPDF_ToUnicodeMap;
301 m_pToUnicodeMap->Load(pStream); 301 m_pToUnicodeMap->Load(pStream);
302 } 302 }
303 303
304 int CPDF_Font::GetStringWidth(const FX_CHAR* pString, int size) { 304 int CPDF_Font::GetStringWidth(const FX_CHAR* pString, int size) {
305 int offset = 0; 305 int offset = 0;
306 int width = 0; 306 int width = 0;
307 while (offset < size) { 307 while (offset < size) {
308 FX_DWORD charcode = GetNextChar(pString, size, offset); 308 uint32_t charcode = GetNextChar(pString, size, offset);
309 width += GetCharWidthF(charcode); 309 width += GetCharWidthF(charcode);
310 } 310 }
311 return width; 311 return width;
312 } 312 }
313 313
314 CPDF_Font* CPDF_Font::GetStockFont(CPDF_Document* pDoc, 314 CPDF_Font* CPDF_Font::GetStockFont(CPDF_Document* pDoc,
315 const CFX_ByteStringC& name) { 315 const CFX_ByteStringC& name) {
316 CFX_ByteString fontname(name); 316 CFX_ByteString fontname(name);
317 int font_id = PDF_GetStandardFontName(&fontname); 317 int font_id = PDF_GetStandardFontName(&fontname);
318 if (font_id < 0) { 318 if (font_id < 0) {
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
380 pFont->m_pFontDict = pFontDict; 380 pFont->m_pFontDict = pFontDict;
381 pFont->m_pDocument = pDoc; 381 pFont->m_pDocument = pDoc;
382 pFont->m_BaseFont = pFontDict->GetStringBy("BaseFont"); 382 pFont->m_BaseFont = pFontDict->GetStringBy("BaseFont");
383 if (!pFont->Load()) { 383 if (!pFont->Load()) {
384 delete pFont; 384 delete pFont;
385 return NULL; 385 return NULL;
386 } 386 }
387 return pFont; 387 return pFont;
388 } 388 }
389 389
390 FX_DWORD CPDF_Font::GetNextChar(const FX_CHAR* pString, 390 uint32_t CPDF_Font::GetNextChar(const FX_CHAR* pString,
391 int nStrLen, 391 int nStrLen,
392 int& offset) const { 392 int& offset) const {
393 if (offset < 0 || nStrLen < 1) { 393 if (offset < 0 || nStrLen < 1) {
394 return 0; 394 return 0;
395 } 395 }
396 uint8_t ch = offset < nStrLen ? pString[offset++] : pString[nStrLen - 1]; 396 uint8_t ch = offset < nStrLen ? pString[offset++] : pString[nStrLen - 1];
397 return static_cast<FX_DWORD>(ch); 397 return static_cast<uint32_t>(ch);
398 } 398 }
399 399
400 void CPDF_Font::LoadPDFEncoding(CPDF_Object* pEncoding, 400 void CPDF_Font::LoadPDFEncoding(CPDF_Object* pEncoding,
401 int& iBaseEncoding, 401 int& iBaseEncoding,
402 CFX_ByteString*& pCharNames, 402 CFX_ByteString*& pCharNames,
403 FX_BOOL bEmbedded, 403 FX_BOOL bEmbedded,
404 FX_BOOL bTrueType) { 404 FX_BOOL bTrueType) {
405 if (!pEncoding) { 405 if (!pEncoding) {
406 if (m_BaseFont == "Symbol") { 406 if (m_BaseFont == "Symbol") {
407 iBaseEncoding = bTrueType ? PDFFONT_ENCODING_MS_SYMBOL 407 iBaseEncoding = bTrueType ? PDFFONT_ENCODING_MS_SYMBOL
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
443 GetPredefinedEncoding(iBaseEncoding, bsEncoding); 443 GetPredefinedEncoding(iBaseEncoding, bsEncoding);
444 } 444 }
445 if ((!bEmbedded || bTrueType) && iBaseEncoding == PDFFONT_ENCODING_BUILTIN) { 445 if ((!bEmbedded || bTrueType) && iBaseEncoding == PDFFONT_ENCODING_BUILTIN) {
446 iBaseEncoding = PDFFONT_ENCODING_STANDARD; 446 iBaseEncoding = PDFFONT_ENCODING_STANDARD;
447 } 447 }
448 CPDF_Array* pDiffs = pDict->GetArrayBy("Differences"); 448 CPDF_Array* pDiffs = pDict->GetArrayBy("Differences");
449 if (!pDiffs) { 449 if (!pDiffs) {
450 return; 450 return;
451 } 451 }
452 pCharNames = new CFX_ByteString[256]; 452 pCharNames = new CFX_ByteString[256];
453 FX_DWORD cur_code = 0; 453 uint32_t cur_code = 0;
454 for (FX_DWORD i = 0; i < pDiffs->GetCount(); i++) { 454 for (uint32_t i = 0; i < pDiffs->GetCount(); i++) {
455 CPDF_Object* pElement = pDiffs->GetElementValue(i); 455 CPDF_Object* pElement = pDiffs->GetElementValue(i);
456 if (!pElement) 456 if (!pElement)
457 continue; 457 continue;
458 458
459 if (CPDF_Name* pName = pElement->AsName()) { 459 if (CPDF_Name* pName = pElement->AsName()) {
460 if (cur_code < 256) 460 if (cur_code < 256)
461 pCharNames[cur_code] = pName->GetString(); 461 pCharNames[cur_code] = pName->GetString();
462 cur_code++; 462 cur_code++;
463 } else { 463 } else {
464 cur_code = pElement->GetInteger(); 464 cur_code = pElement->GetInteger();
(...skipping 18 matching lines...) Expand all
483 if (charcode < 0 || charcode >= 256) 483 if (charcode < 0 || charcode >= 256)
484 return nullptr; 484 return nullptr;
485 485
486 const FX_CHAR* name = nullptr; 486 const FX_CHAR* name = nullptr;
487 if (pCharNames) 487 if (pCharNames)
488 name = pCharNames[charcode]; 488 name = pCharNames[charcode];
489 if ((!name || name[0] == 0) && iBaseEncoding) 489 if ((!name || name[0] == 0) && iBaseEncoding)
490 name = PDF_CharNameFromPredefinedCharSet(iBaseEncoding, charcode); 490 name = PDF_CharNameFromPredefinedCharSet(iBaseEncoding, charcode);
491 return name && name[0] ? name : nullptr; 491 return name && name[0] ? name : nullptr;
492 } 492 }
OLDNEW
« no previous file with comments | « core/fpdfapi/fpdf_font/cpdf_cidfont.cpp ('k') | core/fpdfapi/fpdf_font/cpdf_fontencoding.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698