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

Side by Side Diff: core/src/fpdfapi/fpdf_font/fpdf_font_cid.cpp

Issue 1243883003: Fix else-after-returns throughout pdfium. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Rebase, Address comments. Created 5 years, 5 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 | « core/src/fpdfapi/fpdf_font/fpdf_font.cpp ('k') | core/src/fpdfapi/fpdf_page/fpdf_page.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 2014 PDFium Authors. All rights reserved. 1 // Copyright 2014 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 "../../../include/fpdfapi/fpdf_module.h" 7 #include "../../../include/fpdfapi/fpdf_module.h"
8 #include "../../../include/fpdfapi/fpdf_page.h" 8 #include "../../../include/fpdfapi/fpdf_page.h"
9 #include "../../../include/fpdfapi/fpdf_resource.h" 9 #include "../../../include/fpdfapi/fpdf_resource.h"
10 #include "../../../include/fxge/fx_freetype.h" 10 #include "../../../include/fxge/fx_freetype.h"
(...skipping 623 matching lines...) Expand 10 before | Expand all | Expand 10 after
634 _CMap_CodeRange* pRanges = (_CMap_CodeRange*)m_pLeadingBytes; 634 _CMap_CodeRange* pRanges = (_CMap_CodeRange*)m_pLeadingBytes;
635 int iSize = _GetCharSize(charcode, pRanges, m_nCodeRanges); 635 int iSize = _GetCharSize(charcode, pRanges, m_nCodeRanges);
636 if (iSize == 0) { 636 if (iSize == 0) {
637 iSize = 1; 637 iSize = 1;
638 } 638 }
639 if (iSize > 1) { 639 if (iSize > 1) {
640 FXSYS_memset(str, 0, sizeof(uint8_t) * iSize); 640 FXSYS_memset(str, 0, sizeof(uint8_t) * iSize);
641 } 641 }
642 str[iSize - 1] = (uint8_t)charcode; 642 str[iSize - 1] = (uint8_t)charcode;
643 return iSize; 643 return iSize;
644 } else if (charcode < 0x10000) { 644 }
645 if (charcode < 0x10000) {
645 str[0] = (uint8_t)(charcode >> 8); 646 str[0] = (uint8_t)(charcode >> 8);
646 str[1] = (uint8_t)charcode; 647 str[1] = (uint8_t)charcode;
647 return 2; 648 return 2;
648 } else if (charcode < 0x1000000) { 649 }
650 if (charcode < 0x1000000) {
649 str[0] = (uint8_t)(charcode >> 16); 651 str[0] = (uint8_t)(charcode >> 16);
650 str[1] = (uint8_t)(charcode >> 8); 652 str[1] = (uint8_t)(charcode >> 8);
651 str[2] = (uint8_t)charcode; 653 str[2] = (uint8_t)charcode;
652 return 3; 654 return 3;
653 } else {
654 str[0] = (uint8_t)(charcode >> 24);
655 str[1] = (uint8_t)(charcode >> 16);
656 str[2] = (uint8_t)(charcode >> 8);
657 str[3] = (uint8_t)charcode;
658 return 4;
659 } 655 }
656 str[0] = (uint8_t)(charcode >> 24);
657 str[1] = (uint8_t)(charcode >> 16);
658 str[2] = (uint8_t)(charcode >> 8);
659 str[3] = (uint8_t)charcode;
660 return 4;
660 } 661 }
661 return 0; 662 return 0;
662 } 663 }
663 CPDF_CID2UnicodeMap::CPDF_CID2UnicodeMap() 664 CPDF_CID2UnicodeMap::CPDF_CID2UnicodeMap()
664 { 665 {
665 m_EmbeddedCount = 0; 666 m_EmbeddedCount = 0;
666 } 667 }
667 CPDF_CID2UnicodeMap::~CPDF_CID2UnicodeMap() 668 CPDF_CID2UnicodeMap::~CPDF_CID2UnicodeMap()
668 { 669 {
669 } 670 }
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
787 charsize = 2; 788 charsize = 2;
788 } 789 }
789 int ret = FXSYS_MultiByteToWideChar(g_CharsetCPs[m_pCMap->m_Coding], 0, (const FX_CHAR*)&charcode, charsize, &unicode, 1); 790 int ret = FXSYS_MultiByteToWideChar(g_CharsetCPs[m_pCMap->m_Coding], 0, (const FX_CHAR*)&charcode, charsize, &unicode, 1);
790 if (ret != 1) { 791 if (ret != 1) {
791 return 0; 792 return 0;
792 } 793 }
793 return unicode; 794 return unicode;
794 #endif 795 #endif
795 if (m_pCMap->m_pEmbedMap) { 796 if (m_pCMap->m_pEmbedMap) {
796 return _EmbeddedUnicodeFromCharcode(m_pCMap->m_pEmbedMap, m_pCMap->m _Charset, charcode); 797 return _EmbeddedUnicodeFromCharcode(m_pCMap->m_pEmbedMap, m_pCMap->m _Charset, charcode);
797 } else {
798 return 0;
799 } 798 }
799 return 0;
800 } 800 }
801 return m_pCID2UnicodeMap->UnicodeFromCID(CIDFromCharCode(charcode)); 801 return m_pCID2UnicodeMap->UnicodeFromCID(CIDFromCharCode(charcode));
802 } 802 }
803 FX_DWORD CPDF_CIDFont::_CharCodeFromUnicode(FX_WCHAR unicode) const 803 FX_DWORD CPDF_CIDFont::_CharCodeFromUnicode(FX_WCHAR unicode) const
804 { 804 {
805 switch (m_pCMap->m_Coding) { 805 switch (m_pCMap->m_Coding) {
806 case CIDCODING_UNKNOWN: 806 case CIDCODING_UNKNOWN:
807 return 0; 807 return 0;
808 case CIDCODING_UCS2: 808 case CIDCODING_UCS2:
809 case CIDCODING_UTF16: 809 case CIDCODING_UTF16:
810 return unicode; 810 return unicode;
811 case CIDCODING_CID: { 811 case CIDCODING_CID: {
812 if (m_pCID2UnicodeMap == NULL || !m_pCID2UnicodeMap->IsLoaded()) { 812 if (m_pCID2UnicodeMap == NULL || !m_pCID2UnicodeMap->IsLoaded()) {
813 return 0; 813 return 0;
814 } 814 }
815 FX_DWORD CID = 0; 815 FX_DWORD CID = 0;
816 while (CID < 65536) { 816 while (CID < 65536) {
817 FX_WCHAR this_unicode = m_pCID2UnicodeMap->UnicodeFromCID((F X_WORD)CID); 817 FX_WCHAR this_unicode = m_pCID2UnicodeMap->UnicodeFromCID((F X_WORD)CID);
818 if (this_unicode == unicode) { 818 if (this_unicode == unicode) {
819 return CID; 819 return CID;
820 } 820 }
821 CID ++; 821 CID ++;
822 } 822 }
823 break; 823 break;
824 } 824 }
825 } 825 }
826 826
827 if (unicode < 0x80) { 827 if (unicode < 0x80) {
828 return static_cast<FX_DWORD>(unicode); 828 return static_cast<FX_DWORD>(unicode);
829 } else if (m_pCMap->m_Coding == CIDCODING_CID) { 829 }
830 if (m_pCMap->m_Coding == CIDCODING_CID) {
830 return 0; 831 return 0;
831 } 832 }
832 #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ 833 #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_
833 uint8_t buffer[32]; 834 uint8_t buffer[32];
834 int ret = FXSYS_WideCharToMultiByte(g_CharsetCPs[m_pCMap->m_Coding], 0, &uni code, 1, (char*)buffer, 4, NULL, NULL); 835 int ret = FXSYS_WideCharToMultiByte(g_CharsetCPs[m_pCMap->m_Coding], 0, &uni code, 1, (char*)buffer, 4, NULL, NULL);
835 if (ret == 1) { 836 if (ret == 1) {
836 return buffer[0]; 837 return buffer[0];
837 } else if (ret == 2) { 838 }
839 if (ret == 2) {
838 return buffer[0] * 256 + buffer[1]; 840 return buffer[0] * 256 + buffer[1];
839 } 841 }
840 return 0; 842 #else
841 #endif
842 if (m_pCMap->m_pEmbedMap) { 843 if (m_pCMap->m_pEmbedMap) {
843 return _EmbeddedCharcodeFromUnicode(m_pCMap->m_pEmbedMap, m_pCMap->m_Cha rset, unicode); 844 return _EmbeddedCharcodeFromUnicode(m_pCMap->m_pEmbedMap, m_pCMap->m_Cha rset, unicode);
844 } 845 }
846 #endif
845 return 0; 847 return 0;
846 } 848 }
847 static void FT_UseCIDCharmap(FXFT_Face face, int coding) 849 static void FT_UseCIDCharmap(FXFT_Face face, int coding)
848 { 850 {
849 int encoding; 851 int encoding;
850 switch (coding) { 852 switch (coding) {
851 case CIDCODING_GB: 853 case CIDCODING_GB:
852 encoding = FXFT_ENCODING_GB2312; 854 encoding = FXFT_ENCODING_GB2312;
853 break; 855 break;
854 case CIDCODING_BIG5: 856 case CIDCODING_BIG5:
(...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after
1227 FX_DWORD maccode = FT_CharCodeFromUnicode(FXFT_ENCODING_APPL E_ROMAN, unicode); 1229 FX_DWORD maccode = FT_CharCodeFromUnicode(FXFT_ENCODING_APPL E_ROMAN, unicode);
1228 index = !maccode ? FXFT_Get_Name_Index(m_Font.m_Face, (char *)name) : FXFT_Get_Char_Index(m_Font.m_Face, maccode); 1230 index = !maccode ? FXFT_Get_Name_Index(m_Font.m_Face, (char *)name) : FXFT_Get_Char_Index(m_Font.m_Face, maccode);
1229 } else { 1231 } else {
1230 return FXFT_Get_Char_Index(m_Font.m_Face, unicode); 1232 return FXFT_Get_Char_Index(m_Font.m_Face, unicode);
1231 } 1233 }
1232 } else { 1234 } else {
1233 return charcode == 0 ? -1 : (int)charcode; 1235 return charcode == 0 ? -1 : (int)charcode;
1234 } 1236 }
1235 if (index == 0 || index == 0xffff) { 1237 if (index == 0 || index == 0xffff) {
1236 return charcode == 0 ? -1 : (int)charcode; 1238 return charcode == 0 ? -1 : (int)charcode;
1237 } else {
1238 return index;
1239 } 1239 }
1240 return index;
1240 } 1241 }
1241 if (m_Charset == CIDSET_JAPAN1) { 1242 if (m_Charset == CIDSET_JAPAN1) {
1242 if (unicode == '\\') { 1243 if (unicode == '\\') {
1243 unicode = '/'; 1244 unicode = '/';
1244 } 1245 }
1245 #if _FXM_PLATFORM_ != _FXM_PLATFORM_APPLE_ 1246 #if _FXM_PLATFORM_ != _FXM_PLATFORM_APPLE_
1246 else if (unicode == 0xa5) { 1247 else if (unicode == 0xa5) {
1247 unicode = 0x5c; 1248 unicode = 0x5c;
1248 } 1249 }
1249 #endif 1250 #endif
(...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after
1585 if (middlecode > CID) { 1586 if (middlecode > CID) {
1586 end = middle - 1; 1587 end = middle - 1;
1587 } else if (middlecode < CID) { 1588 } else if (middlecode < CID) {
1588 begin = middle + 1; 1589 begin = middle + 1;
1589 } else { 1590 } else {
1590 return &Japan1_VertCIDs[middle].a; 1591 return &Japan1_VertCIDs[middle].a;
1591 } 1592 }
1592 } 1593 }
1593 return NULL; 1594 return NULL;
1594 } 1595 }
OLDNEW
« no previous file with comments | « core/src/fpdfapi/fpdf_font/fpdf_font.cpp ('k') | core/src/fpdfapi/fpdf_page/fpdf_page.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698