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

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

Issue 2368693002: Remove FX_BOOL from cpdf_font (Closed)
Patch Set: And again 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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 *basemap = PDFFONT_ENCODING_MACEXPERT; 43 *basemap = PDFFONT_ENCODING_MACEXPERT;
44 else if (value == "PDFDocEncoding") 44 else if (value == "PDFDocEncoding")
45 *basemap = PDFFONT_ENCODING_PDFDOC; 45 *basemap = PDFFONT_ENCODING_PDFDOC;
46 } 46 }
47 47
48 } // namespace 48 } // namespace
49 49
50 CPDF_Font::CPDF_Font() 50 CPDF_Font::CPDF_Font()
51 : m_pFontFile(nullptr), 51 : m_pFontFile(nullptr),
52 m_pFontDict(nullptr), 52 m_pFontDict(nullptr),
53 m_bToUnicodeLoaded(FALSE), 53 m_bToUnicodeLoaded(false),
54 m_Flags(0), 54 m_Flags(0),
55 m_StemV(0), 55 m_StemV(0),
56 m_Ascent(0), 56 m_Ascent(0),
57 m_Descent(0), 57 m_Descent(0),
58 m_ItalicAngle(0) {} 58 m_ItalicAngle(0) {}
59 59
60 CPDF_Font::~CPDF_Font() { 60 CPDF_Font::~CPDF_Font() {
61 if (m_pFontFile) { 61 if (m_pFontFile) {
62 m_pDocument->GetPageData()->ReleaseFontFileStreamAcc( 62 m_pDocument->GetPageData()->ReleaseFontFileStreamAcc(
63 m_pFontFile->GetStream()->AsStream()); 63 m_pFontFile->GetStream()->AsStream());
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 } 105 }
106 106
107 const CPDF_CIDFont* CPDF_Font::AsCIDFont() const { 107 const CPDF_CIDFont* CPDF_Font::AsCIDFont() const {
108 return nullptr; 108 return nullptr;
109 } 109 }
110 110
111 CPDF_CIDFont* CPDF_Font::AsCIDFont() { 111 CPDF_CIDFont* CPDF_Font::AsCIDFont() {
112 return nullptr; 112 return nullptr;
113 } 113 }
114 114
115 FX_BOOL CPDF_Font::IsUnicodeCompatible() const { 115 bool CPDF_Font::IsUnicodeCompatible() const {
116 return FALSE; 116 return false;
117 } 117 }
118 118
119 int CPDF_Font::CountChar(const FX_CHAR* pString, int size) const { 119 int CPDF_Font::CountChar(const FX_CHAR* pString, int size) const {
120 return size; 120 return size;
121 } 121 }
122 122
123 int CPDF_Font::GetCharSize(uint32_t charcode) const { 123 int CPDF_Font::GetCharSize(uint32_t charcode) const {
124 return 1; 124 return 1;
125 } 125 }
126 126
127 int CPDF_Font::GlyphFromCharCodeExt(uint32_t charcode) { 127 int CPDF_Font::GlyphFromCharCodeExt(uint32_t charcode) {
128 return GlyphFromCharCode(charcode, nullptr); 128 return GlyphFromCharCode(charcode, nullptr);
129 } 129 }
130 130
131 FX_BOOL CPDF_Font::IsVertWriting() const { 131 bool CPDF_Font::IsVertWriting() const {
132 const CPDF_CIDFont* pCIDFont = AsCIDFont(); 132 const CPDF_CIDFont* pCIDFont = AsCIDFont();
133 return pCIDFont ? pCIDFont->IsVertWriting() : m_Font.IsVertical(); 133 return pCIDFont ? pCIDFont->IsVertWriting() : m_Font.IsVertical();
134 } 134 }
135 135
136 int CPDF_Font::AppendChar(FX_CHAR* buf, uint32_t charcode) const { 136 int CPDF_Font::AppendChar(FX_CHAR* buf, uint32_t charcode) const {
137 *buf = static_cast<FX_CHAR>(charcode); 137 *buf = static_cast<FX_CHAR>(charcode);
138 return 1; 138 return 1;
139 } 139 }
140 140
141 void CPDF_Font::AppendChar(CFX_ByteString& str, uint32_t charcode) const { 141 void CPDF_Font::AppendChar(CFX_ByteString& str, uint32_t charcode) const {
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
269 } 269 }
270 if (m_Ascent == 0 && m_Descent == 0) { 270 if (m_Ascent == 0 && m_Descent == 0) {
271 FX_RECT rect = GetCharBBox('A'); 271 FX_RECT rect = GetCharBBox('A');
272 m_Ascent = rect.bottom == rect.top ? m_FontBBox.top : rect.top; 272 m_Ascent = rect.bottom == rect.top ? m_FontBBox.top : rect.top;
273 rect = GetCharBBox('g'); 273 rect = GetCharBBox('g');
274 m_Descent = rect.bottom == rect.top ? m_FontBBox.bottom : rect.bottom; 274 m_Descent = rect.bottom == rect.top ? m_FontBBox.bottom : rect.bottom;
275 } 275 }
276 } 276 }
277 277
278 void CPDF_Font::LoadUnicodeMap() const { 278 void CPDF_Font::LoadUnicodeMap() const {
279 m_bToUnicodeLoaded = TRUE; 279 m_bToUnicodeLoaded = true;
280 CPDF_Stream* pStream = m_pFontDict->GetStreamFor("ToUnicode"); 280 CPDF_Stream* pStream = m_pFontDict->GetStreamFor("ToUnicode");
281 if (!pStream) { 281 if (!pStream) {
282 return; 282 return;
283 } 283 }
284 m_pToUnicodeMap.reset(new CPDF_ToUnicodeMap); 284 m_pToUnicodeMap.reset(new CPDF_ToUnicodeMap);
285 m_pToUnicodeMap->Load(pStream); 285 m_pToUnicodeMap->Load(pStream);
286 } 286 }
287 287
288 int CPDF_Font::GetStringWidth(const FX_CHAR* pString, int size) { 288 int CPDF_Font::GetStringWidth(const FX_CHAR* pString, int size) {
289 int offset = 0; 289 int offset = 0;
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
351 if (offset < 0 || nStrLen < 1) { 351 if (offset < 0 || nStrLen < 1) {
352 return 0; 352 return 0;
353 } 353 }
354 uint8_t ch = offset < nStrLen ? pString[offset++] : pString[nStrLen - 1]; 354 uint8_t ch = offset < nStrLen ? pString[offset++] : pString[nStrLen - 1];
355 return static_cast<uint32_t>(ch); 355 return static_cast<uint32_t>(ch);
356 } 356 }
357 357
358 void CPDF_Font::LoadPDFEncoding(CPDF_Object* pEncoding, 358 void CPDF_Font::LoadPDFEncoding(CPDF_Object* pEncoding,
359 int& iBaseEncoding, 359 int& iBaseEncoding,
360 std::vector<CFX_ByteString>* pCharNames, 360 std::vector<CFX_ByteString>* pCharNames,
361 FX_BOOL bEmbedded, 361 bool bEmbedded,
362 FX_BOOL bTrueType) { 362 bool bTrueType) {
363 if (!pEncoding) { 363 if (!pEncoding) {
364 if (m_BaseFont == "Symbol") { 364 if (m_BaseFont == "Symbol") {
365 iBaseEncoding = bTrueType ? PDFFONT_ENCODING_MS_SYMBOL 365 iBaseEncoding = bTrueType ? PDFFONT_ENCODING_MS_SYMBOL
366 : PDFFONT_ENCODING_ADOBE_SYMBOL; 366 : PDFFONT_ENCODING_ADOBE_SYMBOL;
367 } else if (!bEmbedded && iBaseEncoding == PDFFONT_ENCODING_BUILTIN) { 367 } else if (!bEmbedded && iBaseEncoding == PDFFONT_ENCODING_BUILTIN) {
368 iBaseEncoding = PDFFONT_ENCODING_WINANSI; 368 iBaseEncoding = PDFFONT_ENCODING_WINANSI;
369 } 369 }
370 return; 370 return;
371 } 371 }
372 if (pEncoding->IsName()) { 372 if (pEncoding->IsName()) {
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
417 if (CPDF_Name* pName = pElement->AsName()) { 417 if (CPDF_Name* pName = pElement->AsName()) {
418 if (cur_code < 256) 418 if (cur_code < 256)
419 (*pCharNames)[cur_code] = pName->GetString(); 419 (*pCharNames)[cur_code] = pName->GetString();
420 cur_code++; 420 cur_code++;
421 } else { 421 } else {
422 cur_code = pElement->GetInteger(); 422 cur_code = pElement->GetInteger();
423 } 423 }
424 } 424 }
425 } 425 }
426 426
427 FX_BOOL CPDF_Font::IsStandardFont() const { 427 bool CPDF_Font::IsStandardFont() const {
428 if (!IsType1Font()) 428 if (!IsType1Font())
429 return FALSE; 429 return false;
430 if (m_pFontFile) 430 if (m_pFontFile)
431 return FALSE; 431 return false;
432 if (AsType1Font()->GetBase14Font() < 0) 432 if (AsType1Font()->GetBase14Font() < 0)
433 return FALSE; 433 return false;
434 return TRUE; 434 return true;
435 } 435 }
436 436
437 const FX_CHAR* CPDF_Font::GetAdobeCharName( 437 const FX_CHAR* CPDF_Font::GetAdobeCharName(
438 int iBaseEncoding, 438 int iBaseEncoding,
439 const std::vector<CFX_ByteString>& charnames, 439 const std::vector<CFX_ByteString>& charnames,
440 int charcode) { 440 int charcode) {
441 if (charcode < 0 || charcode >= 256) { 441 if (charcode < 0 || charcode >= 256) {
442 ASSERT(false); 442 ASSERT(false);
443 return nullptr; 443 return nullptr;
444 } 444 }
(...skipping 21 matching lines...) Expand all
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

Powered by Google App Engine
This is Rietveld 408576698