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

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

Issue 2248453002: Use a std::vector in fpdf_font code. (Closed) Base URL: https://pdfium.googlesource.com/pdfium@master
Patch Set: nits Created 4 years, 4 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/cpdf_font.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/cpdf_cidfont.h" 7 #include "core/fpdfapi/fpdf_font/cpdf_cidfont.h"
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <vector>
10 11
11 #include "core/fpdfapi/fpdf_cmaps/cmap_int.h" 12 #include "core/fpdfapi/fpdf_cmaps/cmap_int.h"
12 #include "core/fpdfapi/fpdf_font/font_int.h" 13 #include "core/fpdfapi/fpdf_font/font_int.h"
13 #include "core/fpdfapi/fpdf_font/include/cpdf_fontencoding.h" 14 #include "core/fpdfapi/fpdf_font/include/cpdf_fontencoding.h"
14 #include "core/fpdfapi/fpdf_font/ttgsubtable.h" 15 #include "core/fpdfapi/fpdf_font/ttgsubtable.h"
15 #include "core/fpdfapi/fpdf_page/cpdf_pagemodule.h" 16 #include "core/fpdfapi/fpdf_page/cpdf_pagemodule.h"
16 #include "core/fpdfapi/fpdf_parser/include/cpdf_array.h" 17 #include "core/fpdfapi/fpdf_parser/include/cpdf_array.h"
17 #include "core/fpdfapi/fpdf_parser/include/cpdf_dictionary.h" 18 #include "core/fpdfapi/fpdf_parser/include/cpdf_dictionary.h"
18 #include "core/fpdfapi/fpdf_parser/include/cpdf_stream_acc.h" 19 #include "core/fpdfapi/fpdf_parser/include/cpdf_stream_acc.h"
19 #include "core/fpdfapi/include/cpdf_modulemgr.h" 20 #include "core/fpdfapi/include/cpdf_modulemgr.h"
(...skipping 600 matching lines...) Expand 10 before | Expand all | Expand 10 after
620 unicode = GetUnicodeFromCharCode(charcode); 621 unicode = GetUnicodeFromCharCode(charcode);
621 if (unicode == 0 && !(m_Flags & PDFFONT_SYMBOLIC)) 622 if (unicode == 0 && !(m_Flags & PDFFONT_SYMBOLIC))
622 unicode = UnicodeFromCharCode(charcode).GetAt(0); 623 unicode = UnicodeFromCharCode(charcode).GetAt(0);
623 } 624 }
624 FXFT_Face face = m_Font.GetFace(); 625 FXFT_Face face = m_Font.GetFace();
625 if (unicode == 0) { 626 if (unicode == 0) {
626 if (!m_bAdobeCourierStd) 627 if (!m_bAdobeCourierStd)
627 return charcode ? static_cast<int>(charcode) : -1; 628 return charcode ? static_cast<int>(charcode) : -1;
628 629
629 charcode += 31; 630 charcode += 31;
630 FX_BOOL bMSUnicode = FT_UseTTCharmap(face, 3, 1); 631 bool bMSUnicode = FT_UseTTCharmap(face, 3, 1);
631 FX_BOOL bMacRoman = bMSUnicode ? FALSE : FT_UseTTCharmap(face, 1, 0); 632 bool bMacRoman = !bMSUnicode && FT_UseTTCharmap(face, 1, 0);
632 int iBaseEncoding = PDFFONT_ENCODING_STANDARD; 633 int iBaseEncoding = PDFFONT_ENCODING_STANDARD;
633 if (bMSUnicode) { 634 if (bMSUnicode) {
634 iBaseEncoding = PDFFONT_ENCODING_WINANSI; 635 iBaseEncoding = PDFFONT_ENCODING_WINANSI;
635 } else if (bMacRoman) { 636 } else if (bMacRoman) {
636 iBaseEncoding = PDFFONT_ENCODING_MACROMAN; 637 iBaseEncoding = PDFFONT_ENCODING_MACROMAN;
637 } 638 }
638 const FX_CHAR* name = GetAdobeCharName(iBaseEncoding, nullptr, charcode); 639 const FX_CHAR* name = GetAdobeCharName(
640 iBaseEncoding, std::vector<CFX_ByteString>(), charcode);
639 if (!name) 641 if (!name)
640 return charcode ? static_cast<int>(charcode) : -1; 642 return charcode ? static_cast<int>(charcode) : -1;
641 643
642 int index = 0; 644 int index = 0;
643 uint16_t name_unicode = PDF_UnicodeFromAdobeName(name); 645 uint16_t name_unicode = PDF_UnicodeFromAdobeName(name);
644 if (!name_unicode) 646 if (!name_unicode)
645 return charcode ? static_cast<int>(charcode) : -1; 647 return charcode ? static_cast<int>(charcode) : -1;
646 648
647 if (iBaseEncoding == PDFFONT_ENCODING_STANDARD) 649 if (iBaseEncoding == PDFFONT_ENCODING_STANDARD)
648 return FXFT_Get_Char_Index(face, name_unicode); 650 return FXFT_Get_Char_Index(face, name_unicode);
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
833 const uint8_t* CPDF_CIDFont::GetCIDTransform(uint16_t CID) const { 835 const uint8_t* CPDF_CIDFont::GetCIDTransform(uint16_t CID) const {
834 if (m_Charset != CIDSET_JAPAN1 || m_pFontFile) 836 if (m_Charset != CIDSET_JAPAN1 || m_pFontFile)
835 return nullptr; 837 return nullptr;
836 838
837 const auto* pEnd = g_Japan1_VertCIDs + FX_ArraySize(g_Japan1_VertCIDs); 839 const auto* pEnd = g_Japan1_VertCIDs + FX_ArraySize(g_Japan1_VertCIDs);
838 const auto* pTransform = std::lower_bound( 840 const auto* pTransform = std::lower_bound(
839 g_Japan1_VertCIDs, pEnd, CID, 841 g_Japan1_VertCIDs, pEnd, CID,
840 [](const CIDTransform& entry, uint16_t cid) { return entry.cid < cid; }); 842 [](const CIDTransform& entry, uint16_t cid) { return entry.cid < cid; });
841 return pTransform < pEnd && CID == pTransform->cid ? &pTransform->a : nullptr; 843 return pTransform < pEnd && CID == pTransform->cid ? &pTransform->a : nullptr;
842 } 844 }
OLDNEW
« no previous file with comments | « no previous file | core/fpdfapi/fpdf_font/cpdf_font.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698