OLD | NEW |
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/font/cpdf_font.h" | 7 #include "core/fpdfapi/font/cpdf_font.h" |
8 | 8 |
9 #include <memory> | 9 #include <memory> |
10 #include <vector> | 10 #include <vector> |
(...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
336 } else if (type == "Type3") { | 336 } else if (type == "Type3") { |
337 pFont.reset(new CPDF_Type3Font); | 337 pFont.reset(new CPDF_Type3Font); |
338 } else if (type == "Type0") { | 338 } else if (type == "Type0") { |
339 pFont.reset(new CPDF_CIDFont); | 339 pFont.reset(new CPDF_CIDFont); |
340 } else { | 340 } else { |
341 pFont.reset(new CPDF_Type1Font); | 341 pFont.reset(new CPDF_Type1Font); |
342 } | 342 } |
343 pFont->m_pFontDict = pFontDict; | 343 pFont->m_pFontDict = pFontDict; |
344 pFont->m_pDocument = pDoc; | 344 pFont->m_pDocument = pDoc; |
345 pFont->m_BaseFont = pFontDict->GetStringFor("BaseFont"); | 345 pFont->m_BaseFont = pFontDict->GetStringFor("BaseFont"); |
346 return pFont->Load() ? std::move(pFont) : std::unique_ptr<CPDF_Font>(); | 346 return pFont->Load() ? std::move(pFont) : nullptr; |
347 } | 347 } |
348 | 348 |
349 uint32_t CPDF_Font::GetNextChar(const FX_CHAR* pString, | 349 uint32_t CPDF_Font::GetNextChar(const FX_CHAR* pString, |
350 int nStrLen, | 350 int nStrLen, |
351 int& offset) const { | 351 int& offset) const { |
352 if (offset < 0 || nStrLen < 1) { | 352 if (offset < 0 || nStrLen < 1) { |
353 return 0; | 353 return 0; |
354 } | 354 } |
355 uint8_t ch = offset < nStrLen ? pString[offset++] : pString[nStrLen - 1]; | 355 uint8_t ch = offset < nStrLen ? pString[offset++] : pString[nStrLen - 1]; |
356 return static_cast<uint32_t>(ch); | 356 return static_cast<uint32_t>(ch); |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
467 if (fallbackFont < 0 || | 467 if (fallbackFont < 0 || |
468 fallbackFont >= pdfium::CollectionSize<int>(m_FontFallbacks)) { | 468 fallbackFont >= pdfium::CollectionSize<int>(m_FontFallbacks)) { |
469 return -1; | 469 return -1; |
470 } | 470 } |
471 int glyph = | 471 int glyph = |
472 FXFT_Get_Char_Index(m_FontFallbacks[fallbackFont]->GetFace(), charcode); | 472 FXFT_Get_Char_Index(m_FontFallbacks[fallbackFont]->GetFace(), charcode); |
473 if (glyph == 0 || glyph == 0xffff) | 473 if (glyph == 0 || glyph == 0xffff) |
474 return -1; | 474 return -1; |
475 return glyph; | 475 return glyph; |
476 } | 476 } |
OLD | NEW |