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_cidfont.h" | 7 #include "core/fpdfapi/font/cpdf_cidfont.h" |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <vector> | 10 #include <vector> |
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
193 FXFT_Set_Charmap(face, *FXFT_Get_Face_Charmaps(face)); | 193 FXFT_Set_Charmap(face, *FXFT_Get_Face_Charmaps(face)); |
194 } | 194 } |
195 | 195 |
196 bool IsMetricForCID(const uint32_t* pEntry, uint16_t CID) { | 196 bool IsMetricForCID(const uint32_t* pEntry, uint16_t CID) { |
197 return pEntry[0] <= CID && pEntry[1] >= CID; | 197 return pEntry[0] <= CID && pEntry[1] >= CID; |
198 } | 198 } |
199 | 199 |
200 } // namespace | 200 } // namespace |
201 | 201 |
202 CPDF_CIDFont::CPDF_CIDFont() | 202 CPDF_CIDFont::CPDF_CIDFont() |
203 : m_pCMap(nullptr), | 203 : m_pCID2UnicodeMap(nullptr), |
204 m_pCID2UnicodeMap(nullptr), | |
205 m_bCIDIsGID(false), | 204 m_bCIDIsGID(false), |
206 m_bAnsiWidthsFixed(false), | 205 m_bAnsiWidthsFixed(false), |
207 m_bAdobeCourierStd(false) { | 206 m_bAdobeCourierStd(false) { |
208 for (size_t i = 0; i < FX_ArraySize(m_CharBBox); ++i) | 207 for (size_t i = 0; i < FX_ArraySize(m_CharBBox); ++i) |
209 m_CharBBox[i] = FX_RECT(-1, -1, -1, -1); | 208 m_CharBBox[i] = FX_RECT(-1, -1, -1, -1); |
210 } | 209 } |
211 | 210 |
212 CPDF_CIDFont::~CPDF_CIDFont() {} | 211 CPDF_CIDFont::~CPDF_CIDFont() {} |
213 | 212 |
214 bool CPDF_CIDFont::IsCIDFont() const { | 213 bool CPDF_CIDFont::IsCIDFont() const { |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
353 m_bType1 = (subtype == "CIDFontType0"); | 352 m_bType1 = (subtype == "CIDFontType0"); |
354 | 353 |
355 CPDF_CMapManager& manager = GetFontGlobals()->m_CMapManager; | 354 CPDF_CMapManager& manager = GetFontGlobals()->m_CMapManager; |
356 if (pEncoding->IsName()) { | 355 if (pEncoding->IsName()) { |
357 CFX_ByteString cmap = pEncoding->GetString(); | 356 CFX_ByteString cmap = pEncoding->GetString(); |
358 bool bPromptCJK = m_pFontFile && m_bType1; | 357 bool bPromptCJK = m_pFontFile && m_bType1; |
359 m_pCMap = manager.GetPredefinedCMap(cmap, bPromptCJK); | 358 m_pCMap = manager.GetPredefinedCMap(cmap, bPromptCJK); |
360 if (!m_pCMap) | 359 if (!m_pCMap) |
361 return false; | 360 return false; |
362 } else if (CPDF_Stream* pStream = pEncoding->AsStream()) { | 361 } else if (CPDF_Stream* pStream = pEncoding->AsStream()) { |
363 m_pCMap = new CPDF_CMap; | 362 m_pCMap = pdfium::MakeUnique<CPDF_CMap>(); |
364 m_pAllocatedCMap.reset(m_pCMap); | |
365 CPDF_StreamAcc acc; | 363 CPDF_StreamAcc acc; |
366 acc.LoadAllData(pStream, false); | 364 acc.LoadAllData(pStream, false); |
367 m_pCMap->LoadEmbedded(acc.GetData(), acc.GetSize()); | 365 m_pCMap->LoadEmbedded(acc.GetData(), acc.GetSize()); |
368 } else { | 366 } else { |
369 return false; | 367 return false; |
370 } | 368 } |
371 | 369 |
372 m_Charset = m_pCMap->m_Charset; | 370 m_Charset = m_pCMap->m_Charset; |
373 if (m_Charset == CIDSET_UNKNOWN) { | 371 if (m_Charset == CIDSET_UNKNOWN) { |
374 CPDF_Dictionary* pCIDInfo = pCIDFontDict->GetDictFor("CIDSystemInfo"); | 372 CPDF_Dictionary* pCIDInfo = pCIDFontDict->GetDictFor("CIDSystemInfo"); |
(...skipping 469 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
844 if (m_Charset != CIDSET_JAPAN1 || m_pFontFile) | 842 if (m_Charset != CIDSET_JAPAN1 || m_pFontFile) |
845 return nullptr; | 843 return nullptr; |
846 | 844 |
847 const auto* pEnd = g_Japan1_VertCIDs + FX_ArraySize(g_Japan1_VertCIDs); | 845 const auto* pEnd = g_Japan1_VertCIDs + FX_ArraySize(g_Japan1_VertCIDs); |
848 const auto* pTransform = std::lower_bound( | 846 const auto* pTransform = std::lower_bound( |
849 g_Japan1_VertCIDs, pEnd, CID, | 847 g_Japan1_VertCIDs, pEnd, CID, |
850 [](const CIDTransform& entry, uint16_t cid) { return entry.cid < cid; }); | 848 [](const CIDTransform& entry, uint16_t cid) { return entry.cid < cid; }); |
851 return (pTransform < pEnd && CID == pTransform->cid) ? &pTransform->a | 849 return (pTransform < pEnd && CID == pTransform->cid) ? &pTransform->a |
852 : nullptr; | 850 : nullptr; |
853 } | 851 } |
OLD | NEW |