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/fpdf_font/cpdf_cidfont.h" | 7 #include "core/fpdfapi/fpdf_font/cpdf_cidfont.h" |
8 | 8 |
9 #include "core/fpdfapi/fpdf_cmaps/cmap_int.h" | 9 #include "core/fpdfapi/fpdf_cmaps/cmap_int.h" |
10 #include "core/fpdfapi/fpdf_font/font_int.h" | 10 #include "core/fpdfapi/fpdf_font/font_int.h" |
(...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
313 if (unicode < 0x80) { | 313 if (unicode < 0x80) { |
314 return static_cast<uint32_t>(unicode); | 314 return static_cast<uint32_t>(unicode); |
315 } | 315 } |
316 if (m_pCMap->m_Coding == CIDCODING_CID) { | 316 if (m_pCMap->m_Coding == CIDCODING_CID) { |
317 return 0; | 317 return 0; |
318 } | 318 } |
319 #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ | 319 #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ |
320 uint8_t buffer[32]; | 320 uint8_t buffer[32]; |
321 int ret = | 321 int ret = |
322 FXSYS_WideCharToMultiByte(g_CharsetCPs[m_pCMap->m_Coding], 0, &unicode, 1, | 322 FXSYS_WideCharToMultiByte(g_CharsetCPs[m_pCMap->m_Coding], 0, &unicode, 1, |
323 (char*)buffer, 4, NULL, NULL); | 323 (char*)buffer, 4, nullptr, nullptr); |
324 if (ret == 1) { | 324 if (ret == 1) { |
325 return buffer[0]; | 325 return buffer[0]; |
326 } | 326 } |
327 if (ret == 2) { | 327 if (ret == 2) { |
328 return buffer[0] * 256 + buffer[1]; | 328 return buffer[0] * 256 + buffer[1]; |
329 } | 329 } |
330 #else | 330 #else |
331 if (m_pCMap->m_pEmbedMap) { | 331 if (m_pCMap->m_pEmbedMap) { |
332 return EmbeddedCharcodeFromUnicode(m_pCMap->m_pEmbedMap, m_pCMap->m_Charset, | 332 return EmbeddedCharcodeFromUnicode(m_pCMap->m_pEmbedMap, m_pCMap->m_Charset, |
333 unicode); | 333 unicode); |
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
596 index = vindex; | 596 index = vindex; |
597 if (pVertGlyph) { | 597 if (pVertGlyph) { |
598 *pVertGlyph = TRUE; | 598 *pVertGlyph = TRUE; |
599 } | 599 } |
600 } | 600 } |
601 return index; | 601 return index; |
602 } | 602 } |
603 if (!m_Font.GetSubData()) { | 603 if (!m_Font.GetSubData()) { |
604 unsigned long length = 0; | 604 unsigned long length = 0; |
605 int error = FXFT_Load_Sfnt_Table(face, FT_MAKE_TAG('G', 'S', 'U', 'B'), 0, | 605 int error = FXFT_Load_Sfnt_Table(face, FT_MAKE_TAG('G', 'S', 'U', 'B'), 0, |
606 NULL, &length); | 606 nullptr, &length); |
607 if (!error) { | 607 if (!error) { |
608 m_Font.SetSubData(FX_Alloc(uint8_t, length)); | 608 m_Font.SetSubData(FX_Alloc(uint8_t, length)); |
609 } | 609 } |
610 } | 610 } |
611 int error = FXFT_Load_Sfnt_Table(face, FT_MAKE_TAG('G', 'S', 'U', 'B'), 0, | 611 int error = FXFT_Load_Sfnt_Table(face, FT_MAKE_TAG('G', 'S', 'U', 'B'), 0, |
612 m_Font.GetSubData(), NULL); | 612 m_Font.GetSubData(), nullptr); |
613 if (!error && m_Font.GetSubData()) { | 613 if (!error && m_Font.GetSubData()) { |
614 m_pTTGSUBTable.reset(new CFX_CTTGSUBTable); | 614 m_pTTGSUBTable.reset(new CFX_CTTGSUBTable); |
615 m_pTTGSUBTable->LoadGSUBTable((FT_Bytes)m_Font.GetSubData()); | 615 m_pTTGSUBTable->LoadGSUBTable((FT_Bytes)m_Font.GetSubData()); |
616 uint32_t vindex = 0; | 616 uint32_t vindex = 0; |
617 m_pTTGSUBTable->GetVerticalGlyph(index, &vindex); | 617 m_pTTGSUBTable->GetVerticalGlyph(index, &vindex); |
618 if (vindex) { | 618 if (vindex) { |
619 index = vindex; | 619 index = vindex; |
620 if (pVertGlyph) { | 620 if (pVertGlyph) { |
621 *pVertGlyph = TRUE; | 621 *pVertGlyph = TRUE; |
622 } | 622 } |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
671 FX_BOOL bMacRoman = FALSE; | 671 FX_BOOL bMacRoman = FALSE; |
672 if (!bMSUnicode) { | 672 if (!bMSUnicode) { |
673 bMacRoman = FT_UseTTCharmap(face, 1, 0); | 673 bMacRoman = FT_UseTTCharmap(face, 1, 0); |
674 } | 674 } |
675 iBaseEncoding = PDFFONT_ENCODING_STANDARD; | 675 iBaseEncoding = PDFFONT_ENCODING_STANDARD; |
676 if (bMSUnicode) { | 676 if (bMSUnicode) { |
677 iBaseEncoding = PDFFONT_ENCODING_WINANSI; | 677 iBaseEncoding = PDFFONT_ENCODING_WINANSI; |
678 } else if (bMacRoman) { | 678 } else if (bMacRoman) { |
679 iBaseEncoding = PDFFONT_ENCODING_MACROMAN; | 679 iBaseEncoding = PDFFONT_ENCODING_MACROMAN; |
680 } | 680 } |
681 const FX_CHAR* name = GetAdobeCharName(iBaseEncoding, NULL, charcode); | 681 const FX_CHAR* name = GetAdobeCharName(iBaseEncoding, nullptr, charcode); |
682 if (!name) { | 682 if (!name) { |
683 return charcode == 0 ? -1 : (int)charcode; | 683 return charcode == 0 ? -1 : (int)charcode; |
684 } | 684 } |
685 uint16_t name_unicode = PDF_UnicodeFromAdobeName(name); | 685 uint16_t name_unicode = PDF_UnicodeFromAdobeName(name); |
686 if (name_unicode) { | 686 if (name_unicode) { |
687 if (bMSUnicode) { | 687 if (bMSUnicode) { |
688 index = FXFT_Get_Char_Index(face, name_unicode); | 688 index = FXFT_Get_Char_Index(face, name_unicode); |
689 } else if (bMacRoman) { | 689 } else if (bMacRoman) { |
690 uint32_t maccode = | 690 uint32_t maccode = |
691 FT_CharCodeFromUnicode(FXFT_ENCODING_APPLE_ROMAN, name_unicode); | 691 FT_CharCodeFromUnicode(FXFT_ENCODING_APPLE_ROMAN, name_unicode); |
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
885 | 885 |
886 const uint8_t* CPDF_CIDFont::GetCIDTransform(uint16_t CID) const { | 886 const uint8_t* CPDF_CIDFont::GetCIDTransform(uint16_t CID) const { |
887 if (m_Charset != CIDSET_JAPAN1 || m_pFontFile) | 887 if (m_Charset != CIDSET_JAPAN1 || m_pFontFile) |
888 return nullptr; | 888 return nullptr; |
889 | 889 |
890 const struct CIDTransform* found = (const struct CIDTransform*)FXSYS_bsearch( | 890 const struct CIDTransform* found = (const struct CIDTransform*)FXSYS_bsearch( |
891 &CID, g_Japan1_VertCIDs, FX_ArraySize(g_Japan1_VertCIDs), | 891 &CID, g_Japan1_VertCIDs, FX_ArraySize(g_Japan1_VertCIDs), |
892 sizeof(g_Japan1_VertCIDs[0]), CompareCIDTransform); | 892 sizeof(g_Japan1_VertCIDs[0]), CompareCIDTransform); |
893 return found ? &found->a : nullptr; | 893 return found ? &found->a : nullptr; |
894 } | 894 } |
OLD | NEW |