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

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

Issue 1252613002: FX_BOOL considered harmful. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Manual edits. 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_font/ttgsubtable.h » ('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"
11 #include "../../../include/fxge/fx_ge.h" 11 #include "../../../include/fxge/fx_ge.h"
12 #include "../fpdf_cmaps/cmap_int.h" 12 #include "../fpdf_cmaps/cmap_int.h"
13 #include "font_int.h" 13 #include "font_int.h"
14 14
15 extern short TT2PDF(int m, FXFT_Face face); 15 extern short TT2PDF(int m, FXFT_Face face);
16 extern FX_BOOL FT_UseTTCharmap(FXFT_Face face, int platform_id, int encoding_id) ; 16 extern bool FT_UseTTCharmap(FXFT_Face face, int platform_id, int encoding_id);
17 17
18 CPDF_CMapManager::CPDF_CMapManager() 18 CPDF_CMapManager::CPDF_CMapManager()
19 { 19 {
20 m_bPrompted = FALSE; 20 m_bPrompted = false;
21 FXSYS_memset(m_CID2UnicodeMaps, 0, sizeof m_CID2UnicodeMaps); 21 FXSYS_memset(m_CID2UnicodeMaps, 0, sizeof m_CID2UnicodeMaps);
22 } 22 }
23 CPDF_CMapManager::~CPDF_CMapManager() 23 CPDF_CMapManager::~CPDF_CMapManager()
24 { 24 {
25 DropAll(FALSE); 25 DropAll(false);
26 } 26 }
27 CPDF_CMap* CPDF_CMapManager::GetPredefinedCMap(const CFX_ByteString& name, FX_BO OL bPromptCJK) 27 CPDF_CMap* CPDF_CMapManager::GetPredefinedCMap(const CFX_ByteString& name, bool bPromptCJK)
28 { 28 {
29 CPDF_CMap* pCMap; 29 CPDF_CMap* pCMap;
30 if (m_CMaps.Lookup(name, (void*&)pCMap)) { 30 if (m_CMaps.Lookup(name, (void*&)pCMap)) {
31 return pCMap; 31 return pCMap;
32 } 32 }
33 pCMap = LoadPredefinedCMap(name, bPromptCJK); 33 pCMap = LoadPredefinedCMap(name, bPromptCJK);
34 if (name.IsEmpty()) { 34 if (name.IsEmpty()) {
35 return pCMap; 35 return pCMap;
36 } 36 }
37 m_CMaps.SetAt(name, pCMap); 37 m_CMaps.SetAt(name, pCMap);
38 return pCMap; 38 return pCMap;
39 } 39 }
40 CPDF_CMap* CPDF_CMapManager::LoadPredefinedCMap(const CFX_ByteString& name, FX_B OOL bPromptCJK) 40 CPDF_CMap* CPDF_CMapManager::LoadPredefinedCMap(const CFX_ByteString& name, bool bPromptCJK)
41 { 41 {
42 CPDF_CMap* pCMap = new CPDF_CMap; 42 CPDF_CMap* pCMap = new CPDF_CMap;
43 const FX_CHAR* pname = name; 43 const FX_CHAR* pname = name;
44 if (*pname == '/') { 44 if (*pname == '/') {
45 pname ++; 45 pname ++;
46 } 46 }
47 pCMap->LoadPredefined(this, pname, bPromptCJK); 47 pCMap->LoadPredefined(this, pname, bPromptCJK);
48 return pCMap; 48 return pCMap;
49 } 49 }
50 static const FX_CHAR* const g_CharsetNames[NUMBER_OF_CIDSETS] = {NULL, "GB1", "C NS1", "Japan1", "Korea1", "UCS" }; 50 static const FX_CHAR* const g_CharsetNames[NUMBER_OF_CIDSETS] = {NULL, "GB1", "C NS1", "Japan1", "Korea1", "UCS" };
51 static const int g_CharsetCPs[NUMBER_OF_CIDSETS] = {0, 936, 950, 932, 949, 1200 }; 51 static const int g_CharsetCPs[NUMBER_OF_CIDSETS] = {0, 936, 950, 932, 949, 1200 };
52 int _CharsetFromOrdering(const CFX_ByteString& Ordering) 52 int _CharsetFromOrdering(const CFX_ByteString& Ordering)
53 { 53 {
54 for (int charset = 1; charset < NUMBER_OF_CIDSETS; charset++) { 54 for (int charset = 1; charset < NUMBER_OF_CIDSETS; charset++) {
55 if (Ordering == CFX_ByteStringC(g_CharsetNames[charset])) 55 if (Ordering == CFX_ByteStringC(g_CharsetNames[charset]))
56 return charset; 56 return charset;
57 } 57 }
58 return CIDSET_UNKNOWN; 58 return CIDSET_UNKNOWN;
59 } 59 }
60 void CPDF_CMapManager::ReloadAll() 60 void CPDF_CMapManager::ReloadAll()
61 { 61 {
62 DropAll(TRUE); 62 DropAll(true);
63 } 63 }
64 void CPDF_CMapManager::DropAll(FX_BOOL bReload) 64 void CPDF_CMapManager::DropAll(bool bReload)
65 { 65 {
66 FX_POSITION pos = m_CMaps.GetStartPosition(); 66 FX_POSITION pos = m_CMaps.GetStartPosition();
67 while (pos) { 67 while (pos) {
68 CFX_ByteString name; 68 CFX_ByteString name;
69 CPDF_CMap* pCMap; 69 CPDF_CMap* pCMap;
70 m_CMaps.GetNextAssoc(pos, name, (void*&)pCMap); 70 m_CMaps.GetNextAssoc(pos, name, (void*&)pCMap);
71 if (pCMap == NULL) { 71 if (pCMap == NULL) {
72 continue; 72 continue;
73 } 73 }
74 if (bReload) { 74 if (bReload) {
75 pCMap->LoadPredefined(this, name, FALSE); 75 pCMap->LoadPredefined(this, name, false);
76 } else { 76 } else {
77 delete pCMap; 77 delete pCMap;
78 } 78 }
79 } 79 }
80 for (int i = 0; i < sizeof m_CID2UnicodeMaps / sizeof(CPDF_CID2UnicodeMap*); i ++) { 80 for (int i = 0; i < sizeof m_CID2UnicodeMaps / sizeof(CPDF_CID2UnicodeMap*); i ++) {
81 CPDF_CID2UnicodeMap* pMap = m_CID2UnicodeMaps[i]; 81 CPDF_CID2UnicodeMap* pMap = m_CID2UnicodeMaps[i];
82 if (pMap == NULL) { 82 if (pMap == NULL) {
83 continue; 83 continue;
84 } 84 }
85 if (bReload) { 85 if (bReload) {
86 pMap->Load(this, i, FALSE); 86 pMap->Load(this, i, false);
87 } else { 87 } else {
88 delete pMap; 88 delete pMap;
89 } 89 }
90 } 90 }
91 } 91 }
92 CPDF_CID2UnicodeMap* CPDF_CMapManager::GetCID2UnicodeMap(int charset, FX_BOOL bP romptCJK) 92 CPDF_CID2UnicodeMap* CPDF_CMapManager::GetCID2UnicodeMap(int charset, bool bProm ptCJK)
93 { 93 {
94 if (m_CID2UnicodeMaps[charset] == NULL) { 94 if (m_CID2UnicodeMaps[charset] == NULL) {
95 m_CID2UnicodeMaps[charset] = LoadCID2UnicodeMap(charset, bPromptCJK); 95 m_CID2UnicodeMaps[charset] = LoadCID2UnicodeMap(charset, bPromptCJK);
96 } 96 }
97 return m_CID2UnicodeMaps[charset]; 97 return m_CID2UnicodeMaps[charset];
98 } 98 }
99 CPDF_CID2UnicodeMap* CPDF_CMapManager::LoadCID2UnicodeMap(int charset, FX_BOOL b PromptCJK) 99 CPDF_CID2UnicodeMap* CPDF_CMapManager::LoadCID2UnicodeMap(int charset, bool bPro mptCJK)
100 { 100 {
101 CPDF_CID2UnicodeMap* pMap = new CPDF_CID2UnicodeMap(); 101 CPDF_CID2UnicodeMap* pMap = new CPDF_CID2UnicodeMap();
102 if (!pMap->Initialize()) { 102 if (!pMap->Initialize()) {
103 delete pMap; 103 delete pMap;
104 return NULL; 104 return NULL;
105 } 105 }
106 pMap->Load(this, charset, bPromptCJK); 106 pMap->Load(this, charset, bPromptCJK);
107 return pMap; 107 return pMap;
108 } 108 }
109 CPDF_CMapParser::CPDF_CMapParser() 109 CPDF_CMapParser::CPDF_CMapParser()
110 { 110 {
111 m_pCMap = NULL; 111 m_pCMap = NULL;
112 m_Status = 0; 112 m_Status = 0;
113 m_CodeSeq = 0; 113 m_CodeSeq = 0;
114 } 114 }
115 FX_BOOL»CPDF_CMapParser::Initialize(CPDF_CMap* pCMap) 115 bool» CPDF_CMapParser::Initialize(CPDF_CMap* pCMap)
116 { 116 {
117 m_pCMap = pCMap; 117 m_pCMap = pCMap;
118 m_Status = 0; 118 m_Status = 0;
119 m_CodeSeq = 0; 119 m_CodeSeq = 0;
120 m_AddMaps.EstimateSize(0, 10240); 120 m_AddMaps.EstimateSize(0, 10240);
121 return TRUE; 121 return true;
122 } 122 }
123 static FX_DWORD CMap_GetCode(const CFX_ByteStringC& word) 123 static FX_DWORD CMap_GetCode(const CFX_ByteStringC& word)
124 { 124 {
125 int num = 0; 125 int num = 0;
126 if (word.GetAt(0) == '<') { 126 if (word.GetAt(0) == '<') {
127 for (int i = 1; i < word.GetLength(); i ++) { 127 for (int i = 1; i < word.GetLength(); i ++) {
128 uint8_t digit = word.GetAt(i); 128 uint8_t digit = word.GetAt(i);
129 if (digit >= '0' && digit <= '9') { 129 if (digit >= '0' && digit <= '9') {
130 digit = digit - '0'; 130 digit = digit - '0';
131 } else if (digit >= 'a' && digit <= 'f') { 131 } else if (digit >= 'a' && digit <= 'f') {
132 digit = digit - 'a' + 10; 132 digit = digit - 'a' + 10;
133 } else if (digit >= 'A' && digit <= 'F') { 133 } else if (digit >= 'A' && digit <= 'F') {
134 digit = digit - 'A' + 10; 134 digit = digit - 'A' + 10;
135 } else { 135 } else {
136 return num; 136 return num;
137 } 137 }
138 num = num * 16 + digit; 138 num = num * 16 + digit;
139 } 139 }
140 } else { 140 } else {
141 for (int i = 0; i < word.GetLength(); i ++) { 141 for (int i = 0; i < word.GetLength(); i ++) {
142 if (word.GetAt(i) < '0' || word.GetAt(i) > '9') { 142 if (word.GetAt(i) < '0' || word.GetAt(i) > '9') {
143 return num; 143 return num;
144 } 144 }
145 num = num * 10 + word.GetAt(i) - '0'; 145 num = num * 10 + word.GetAt(i) - '0';
146 } 146 }
147 } 147 }
148 return num; 148 return num;
149 } 149 }
150 static FX_BOOL _CMap_GetCodeRange(_CMap_CodeRange& range, const CFX_ByteStringC& first, const CFX_ByteStringC& second) 150 static bool _CMap_GetCodeRange(_CMap_CodeRange& range, const CFX_ByteStringC& fi rst, const CFX_ByteStringC& second)
151 { 151 {
152 if (first.GetLength() == 0 || first.GetAt(0) != '<') { 152 if (first.GetLength() == 0 || first.GetAt(0) != '<') {
153 return FALSE; 153 return false;
154 } 154 }
155 int i; 155 int i;
156 for (i = 1; i < first.GetLength(); i ++) 156 for (i = 1; i < first.GetLength(); i ++)
157 if (first.GetAt(i) == '>') { 157 if (first.GetAt(i) == '>') {
158 break; 158 break;
159 } 159 }
160 range.m_CharSize = (i - 1) / 2; 160 range.m_CharSize = (i - 1) / 2;
161 if (range.m_CharSize > 4) { 161 if (range.m_CharSize > 4) {
162 return FALSE; 162 return false;
163 } 163 }
164 for (i = 0; i < range.m_CharSize; i ++) { 164 for (i = 0; i < range.m_CharSize; i ++) {
165 uint8_t digit1 = first.GetAt(i * 2 + 1); 165 uint8_t digit1 = first.GetAt(i * 2 + 1);
166 uint8_t digit2 = first.GetAt(i * 2 + 2); 166 uint8_t digit2 = first.GetAt(i * 2 + 2);
167 uint8_t byte = (digit1 >= '0' && digit1 <= '9') ? (digit1 - '0') : ((dig it1 & 0xdf) - 'A' + 10); 167 uint8_t byte = (digit1 >= '0' && digit1 <= '9') ? (digit1 - '0') : ((dig it1 & 0xdf) - 'A' + 10);
168 byte = byte * 16 + ((digit2 >= '0' && digit2 <= '9') ? (digit2 - '0') : ((digit2 & 0xdf) - 'A' + 10)); 168 byte = byte * 16 + ((digit2 >= '0' && digit2 <= '9') ? (digit2 - '0') : ((digit2 & 0xdf) - 'A' + 10));
169 range.m_Lower[i] = byte; 169 range.m_Lower[i] = byte;
170 } 170 }
171 FX_DWORD size = second.GetLength(); 171 FX_DWORD size = second.GetLength();
172 for (i = 0; i < range.m_CharSize; i ++) { 172 for (i = 0; i < range.m_CharSize; i ++) {
173 uint8_t digit1 = ((FX_DWORD)i * 2 + 1 < size) ? second.GetAt((FX_STRSIZE )i * 2 + 1) : 0; 173 uint8_t digit1 = ((FX_DWORD)i * 2 + 1 < size) ? second.GetAt((FX_STRSIZE )i * 2 + 1) : 0;
174 uint8_t digit2 = ((FX_DWORD)i * 2 + 2 < size) ? second.GetAt((FX_STRSIZE )i * 2 + 2) : 0; 174 uint8_t digit2 = ((FX_DWORD)i * 2 + 2 < size) ? second.GetAt((FX_STRSIZE )i * 2 + 2) : 0;
175 uint8_t byte = (digit1 >= '0' && digit1 <= '9') ? (digit1 - '0') : ((dig it1 & 0xdf) - 'A' + 10); 175 uint8_t byte = (digit1 >= '0' && digit1 <= '9') ? (digit1 - '0') : ((dig it1 & 0xdf) - 'A' + 10);
176 byte = byte * 16 + ((digit2 >= '0' && digit2 <= '9') ? (digit2 - '0') : ((digit2 & 0xdf) - 'A' + 10)); 176 byte = byte * 16 + ((digit2 >= '0' && digit2 <= '9') ? (digit2 - '0') : ((digit2 & 0xdf) - 'A' + 10));
177 range.m_Upper[i] = byte; 177 range.m_Upper[i] = byte;
178 } 178 }
179 return TRUE; 179 return true;
180 } 180 }
181 static CFX_ByteString CMap_GetString(const CFX_ByteStringC& word) 181 static CFX_ByteString CMap_GetString(const CFX_ByteStringC& word)
182 { 182 {
183 return word.Mid(1, word.GetLength() - 2); 183 return word.Mid(1, word.GetLength() - 2);
184 } 184 }
185 void CPDF_CMapParser::ParseWord(const CFX_ByteStringC& word) 185 void CPDF_CMapParser::ParseWord(const CFX_ByteStringC& word)
186 { 186 {
187 if (word.IsEmpty()) { 187 if (word.IsEmpty()) {
188 return; 188 return;
189 } 189 }
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
275 } 275 }
276 } 276 }
277 m_LastWord = word; 277 m_LastWord = word;
278 } 278 }
279 CPDF_CMap::CPDF_CMap() 279 CPDF_CMap::CPDF_CMap()
280 { 280 {
281 m_Charset = CIDSET_UNKNOWN; 281 m_Charset = CIDSET_UNKNOWN;
282 m_Coding = CIDCODING_UNKNOWN; 282 m_Coding = CIDCODING_UNKNOWN;
283 m_CodingScheme = TwoBytes; 283 m_CodingScheme = TwoBytes;
284 m_bVertical = 0; 284 m_bVertical = 0;
285 m_bLoaded = FALSE; 285 m_bLoaded = false;
286 m_pMapping = NULL; 286 m_pMapping = NULL;
287 m_pLeadingBytes = NULL; 287 m_pLeadingBytes = NULL;
288 m_pAddMapping = NULL; 288 m_pAddMapping = NULL;
289 m_pEmbedMap = NULL; 289 m_pEmbedMap = NULL;
290 m_pUseMap = NULL; 290 m_pUseMap = NULL;
291 m_nCodeRanges = 0; 291 m_nCodeRanges = 0;
292 } 292 }
293 CPDF_CMap::~CPDF_CMap() 293 CPDF_CMap::~CPDF_CMap()
294 { 294 {
295 if (m_pMapping) { 295 if (m_pMapping) {
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
339 { "KSC-EUC", CIDSET_KOREA1, CIDCODING_KOREA, CPDF_CMap::MixedTwoBytes, 1, {0 xa1, 0xfe} }, 339 { "KSC-EUC", CIDSET_KOREA1, CIDCODING_KOREA, CPDF_CMap::MixedTwoBytes, 1, {0 xa1, 0xfe} },
340 { "KSCms-UHC", CIDSET_KOREA1, CIDCODING_KOREA, CPDF_CMap::MixedTwoBytes, 1, {0x81, 0xfe} }, 340 { "KSCms-UHC", CIDSET_KOREA1, CIDCODING_KOREA, CPDF_CMap::MixedTwoBytes, 1, {0x81, 0xfe} },
341 { "KSCms-UHC-HW", CIDSET_KOREA1, CIDCODING_KOREA, CPDF_CMap::MixedTwoBytes, 1, {0x81, 0xfe} }, 341 { "KSCms-UHC-HW", CIDSET_KOREA1, CIDCODING_KOREA, CPDF_CMap::MixedTwoBytes, 1, {0x81, 0xfe} },
342 { "KSCpc-EUC", CIDSET_KOREA1, CIDCODING_KOREA, CPDF_CMap::MixedTwoBytes, 1, {0xa1, 0xfd} }, 342 { "KSCpc-EUC", CIDSET_KOREA1, CIDCODING_KOREA, CPDF_CMap::MixedTwoBytes, 1, {0xa1, 0xfd} },
343 { "UniKS-UCS2", CIDSET_KOREA1, CIDCODING_UCS2, CPDF_CMap::TwoBytes }, 343 { "UniKS-UCS2", CIDSET_KOREA1, CIDCODING_UCS2, CPDF_CMap::TwoBytes },
344 { "UniKS-UTF16", CIDSET_KOREA1, CIDCODING_UTF16, CPDF_CMap::TwoBytes }, 344 { "UniKS-UTF16", CIDSET_KOREA1, CIDCODING_UTF16, CPDF_CMap::TwoBytes },
345 { NULL, 0, 0 } 345 { NULL, 0, 0 }
346 }; 346 };
347 extern void FPDFAPI_FindEmbeddedCMap(const char* name, int charset, int coding, const FXCMAP_CMap*& pMap); 347 extern void FPDFAPI_FindEmbeddedCMap(const char* name, int charset, int coding, const FXCMAP_CMap*& pMap);
348 extern FX_WORD FPDFAPI_CIDFromCharCode(const FXCMAP_CMap* pMap, FX_DWORD charcod e); 348 extern FX_WORD FPDFAPI_CIDFromCharCode(const FXCMAP_CMap* pMap, FX_DWORD charcod e);
349 FX_BOOL CPDF_CMap::LoadPredefined(CPDF_CMapManager* pMgr, const FX_CHAR* pName, FX_BOOL bPromptCJK) 349 bool CPDF_CMap::LoadPredefined(CPDF_CMapManager* pMgr, const FX_CHAR* pName, boo l bPromptCJK)
350 { 350 {
351 m_PredefinedCMap = pName; 351 m_PredefinedCMap = pName;
352 if (m_PredefinedCMap == FX_BSTRC("Identity-H") || m_PredefinedCMap == FX_BST RC("Identity-V")) { 352 if (m_PredefinedCMap == FX_BSTRC("Identity-H") || m_PredefinedCMap == FX_BST RC("Identity-V")) {
353 m_Coding = CIDCODING_CID; 353 m_Coding = CIDCODING_CID;
354 m_bVertical = pName[9] == 'V'; 354 m_bVertical = pName[9] == 'V';
355 m_bLoaded = TRUE; 355 m_bLoaded = true;
356 return TRUE; 356 return true;
357 } 357 }
358 CFX_ByteString cmapid = m_PredefinedCMap; 358 CFX_ByteString cmapid = m_PredefinedCMap;
359 m_bVertical = cmapid.Right(1) == FX_BSTRC("V"); 359 m_bVertical = cmapid.Right(1) == FX_BSTRC("V");
360 if (cmapid.GetLength() > 2) { 360 if (cmapid.GetLength() > 2) {
361 cmapid = cmapid.Left(cmapid.GetLength() - 2); 361 cmapid = cmapid.Left(cmapid.GetLength() - 2);
362 } 362 }
363 int index = 0; 363 int index = 0;
364 while (1) { 364 while (1) {
365 if (g_PredefinedCMaps[index].m_pName == NULL) { 365 if (g_PredefinedCMaps[index].m_pName == NULL) {
366 return FALSE; 366 return false;
367 } 367 }
368 if (cmapid == CFX_ByteStringC(g_PredefinedCMaps[index].m_pName)) { 368 if (cmapid == CFX_ByteStringC(g_PredefinedCMaps[index].m_pName)) {
369 break; 369 break;
370 } 370 }
371 index ++; 371 index ++;
372 } 372 }
373 const CPDF_PredefinedCMap& map = g_PredefinedCMaps[index]; 373 const CPDF_PredefinedCMap& map = g_PredefinedCMaps[index];
374 m_Charset = map.m_Charset; 374 m_Charset = map.m_Charset;
375 m_Coding = map.m_Coding; 375 m_Coding = map.m_Coding;
376 m_CodingScheme = map.m_CodingScheme; 376 m_CodingScheme = map.m_CodingScheme;
377 if (m_CodingScheme == MixedTwoBytes) { 377 if (m_CodingScheme == MixedTwoBytes) {
378 m_pLeadingBytes = FX_Alloc(uint8_t, 256); 378 m_pLeadingBytes = FX_Alloc(uint8_t, 256);
379 for (FX_DWORD i = 0; i < map.m_LeadingSegCount; i ++) { 379 for (FX_DWORD i = 0; i < map.m_LeadingSegCount; i ++) {
380 for (int b = map.m_LeadingSegs[i * 2]; b <= map.m_LeadingSegs[i * 2 + 1]; b ++) { 380 for (int b = map.m_LeadingSegs[i * 2]; b <= map.m_LeadingSegs[i * 2 + 1]; b ++) {
381 m_pLeadingBytes[b] = 1; 381 m_pLeadingBytes[b] = 1;
382 } 382 }
383 } 383 }
384 } 384 }
385 FPDFAPI_FindEmbeddedCMap(pName, m_Charset, m_Coding, m_pEmbedMap); 385 FPDFAPI_FindEmbeddedCMap(pName, m_Charset, m_Coding, m_pEmbedMap);
386 if (m_pEmbedMap) { 386 if (m_pEmbedMap) {
387 m_bLoaded = TRUE; 387 m_bLoaded = true;
388 return TRUE; 388 return true;
389 } 389 }
390 return FALSE; 390 return false;
391 } 391 }
392 extern "C" { 392 extern "C" {
393 static int compare_dword(const void* data1, const void* data2) 393 static int compare_dword(const void* data1, const void* data2)
394 { 394 {
395 return (*(FX_DWORD*)data1) - (*(FX_DWORD*)data2); 395 return (*(FX_DWORD*)data1) - (*(FX_DWORD*)data2);
396 } 396 }
397 }; 397 };
398 FX_BOOL CPDF_CMap::LoadEmbedded(const uint8_t* pData, FX_DWORD size) 398 bool CPDF_CMap::LoadEmbedded(const uint8_t* pData, FX_DWORD size)
399 { 399 {
400 m_pMapping = FX_Alloc(FX_WORD, 65536); 400 m_pMapping = FX_Alloc(FX_WORD, 65536);
401 CPDF_CMapParser parser; 401 CPDF_CMapParser parser;
402 parser.Initialize(this); 402 parser.Initialize(this);
403 CPDF_SimpleParser syntax(pData, size); 403 CPDF_SimpleParser syntax(pData, size);
404 while (1) { 404 while (1) {
405 CFX_ByteStringC word = syntax.GetWord(); 405 CFX_ByteStringC word = syntax.GetWord();
406 if (word.IsEmpty()) { 406 if (word.IsEmpty()) {
407 break; 407 break;
408 } 408 }
409 parser.ParseWord(word); 409 parser.ParseWord(word);
410 } 410 }
411 if (m_CodingScheme == MixedFourBytes && parser.m_AddMaps.GetSize()) { 411 if (m_CodingScheme == MixedFourBytes && parser.m_AddMaps.GetSize()) {
412 m_pAddMapping = FX_Alloc(uint8_t, parser.m_AddMaps.GetSize() + 4); 412 m_pAddMapping = FX_Alloc(uint8_t, parser.m_AddMaps.GetSize() + 4);
413 *(FX_DWORD*)m_pAddMapping = parser.m_AddMaps.GetSize() / 8; 413 *(FX_DWORD*)m_pAddMapping = parser.m_AddMaps.GetSize() / 8;
414 FXSYS_memcpy(m_pAddMapping + 4, parser.m_AddMaps.GetBuffer(), parser.m_A ddMaps.GetSize()); 414 FXSYS_memcpy(m_pAddMapping + 4, parser.m_AddMaps.GetBuffer(), parser.m_A ddMaps.GetSize());
415 FXSYS_qsort(m_pAddMapping + 4, parser.m_AddMaps.GetSize() / 8, 8, compar e_dword); 415 FXSYS_qsort(m_pAddMapping + 4, parser.m_AddMaps.GetSize() / 8, 8, compar e_dword);
416 } 416 }
417 return TRUE; 417 return true;
418 } 418 }
419 extern "C" { 419 extern "C" {
420 static int compareCID(const void* key, const void* element) 420 static int compareCID(const void* key, const void* element)
421 { 421 {
422 if ((*(FX_DWORD*)key) < (*(FX_DWORD*)element)) { 422 if ((*(FX_DWORD*)key) < (*(FX_DWORD*)element)) {
423 return -1; 423 return -1;
424 } 424 }
425 if ((*(FX_DWORD*)key) > (*(FX_DWORD*)element) + ((FX_DWORD*)element)[1] / 65536) { 425 if ((*(FX_DWORD*)key) > (*(FX_DWORD*)element) + ((FX_DWORD*)element)[1] / 65536) {
426 return 1; 426 return 1;
427 } 427 }
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after
660 } 660 }
661 return 0; 661 return 0;
662 } 662 }
663 CPDF_CID2UnicodeMap::CPDF_CID2UnicodeMap() 663 CPDF_CID2UnicodeMap::CPDF_CID2UnicodeMap()
664 { 664 {
665 m_EmbeddedCount = 0; 665 m_EmbeddedCount = 0;
666 } 666 }
667 CPDF_CID2UnicodeMap::~CPDF_CID2UnicodeMap() 667 CPDF_CID2UnicodeMap::~CPDF_CID2UnicodeMap()
668 { 668 {
669 } 669 }
670 FX_BOOL CPDF_CID2UnicodeMap::Initialize() 670 bool CPDF_CID2UnicodeMap::Initialize()
671 { 671 {
672 return TRUE; 672 return true;
673 } 673 }
674 FX_BOOL CPDF_CID2UnicodeMap::IsLoaded() 674 bool CPDF_CID2UnicodeMap::IsLoaded()
675 { 675 {
676 return m_EmbeddedCount != 0; 676 return m_EmbeddedCount != 0;
677 } 677 }
678 FX_WCHAR CPDF_CID2UnicodeMap::UnicodeFromCID(FX_WORD CID) 678 FX_WCHAR CPDF_CID2UnicodeMap::UnicodeFromCID(FX_WORD CID)
679 { 679 {
680 if (m_Charset == CIDSET_UNICODE) { 680 if (m_Charset == CIDSET_UNICODE) {
681 return CID; 681 return CID;
682 } 682 }
683 if (CID < m_EmbeddedCount) { 683 if (CID < m_EmbeddedCount) {
684 return m_pEmbeddedMap[CID]; 684 return m_pEmbeddedMap[CID];
685 } 685 }
686 return 0; 686 return 0;
687 } 687 }
688 void FPDFAPI_LoadCID2UnicodeMap(int charset, const FX_WORD*& pMap, FX_DWORD& cou nt); 688 void FPDFAPI_LoadCID2UnicodeMap(int charset, const FX_WORD*& pMap, FX_DWORD& cou nt);
689 void CPDF_CID2UnicodeMap::Load(CPDF_CMapManager* pMgr, int charset, FX_BOOL bPro mptCJK) 689 void CPDF_CID2UnicodeMap::Load(CPDF_CMapManager* pMgr, int charset, bool bPrompt CJK)
690 { 690 {
691 m_Charset = charset; 691 m_Charset = charset;
692 FPDFAPI_LoadCID2UnicodeMap(charset, m_pEmbeddedMap, m_EmbeddedCount); 692 FPDFAPI_LoadCID2UnicodeMap(charset, m_pEmbeddedMap, m_EmbeddedCount);
693 } 693 }
694 #include "ttgsubtable.h" 694 #include "ttgsubtable.h"
695 CPDF_CIDFont::CPDF_CIDFont() : CPDF_Font(PDFFONT_CIDFONT) 695 CPDF_CIDFont::CPDF_CIDFont() : CPDF_Font(PDFFONT_CIDFONT)
696 { 696 {
697 m_pCMap = NULL; 697 m_pCMap = NULL;
698 m_pAllocatedCMap = NULL; 698 m_pAllocatedCMap = NULL;
699 m_pCID2UnicodeMap = NULL; 699 m_pCID2UnicodeMap = NULL;
700 m_pAnsiWidths = NULL; 700 m_pAnsiWidths = NULL;
701 m_pCIDToGIDMap = NULL; 701 m_pCIDToGIDMap = NULL;
702 m_bCIDIsGID = FALSE; 702 m_bCIDIsGID = false;
703 m_bAdobeCourierStd = FALSE; 703 m_bAdobeCourierStd = false;
704 m_pTTGSUBTable = NULL; 704 m_pTTGSUBTable = NULL;
705 FXSYS_memset(m_CharBBox, 0xff, 256 * sizeof(FX_SMALL_RECT)); 705 FXSYS_memset(m_CharBBox, 0xff, 256 * sizeof(FX_SMALL_RECT));
706 } 706 }
707 CPDF_CIDFont::~CPDF_CIDFont() 707 CPDF_CIDFont::~CPDF_CIDFont()
708 { 708 {
709 if (m_pAnsiWidths) { 709 if (m_pAnsiWidths) {
710 FX_Free(m_pAnsiWidths); 710 FX_Free(m_pAnsiWidths);
711 } 711 }
712 delete m_pAllocatedCMap; 712 delete m_pAllocatedCMap;
713 delete m_pCIDToGIDMap; 713 delete m_pCIDToGIDMap;
714 delete m_pTTGSUBTable; 714 delete m_pTTGSUBTable;
715 } 715 }
716 FX_WORD CPDF_CIDFont::CIDFromCharCode(FX_DWORD charcode) const 716 FX_WORD CPDF_CIDFont::CIDFromCharCode(FX_DWORD charcode) const
717 { 717 {
718 if (m_pCMap == NULL) { 718 if (m_pCMap == NULL) {
719 return (FX_WORD)charcode; 719 return (FX_WORD)charcode;
720 } 720 }
721 return m_pCMap->CIDFromCharCode(charcode); 721 return m_pCMap->CIDFromCharCode(charcode);
722 } 722 }
723 FX_BOOL CPDF_CIDFont::IsVertWriting() const 723 bool CPDF_CIDFont::IsVertWriting() const
724 { 724 {
725 return m_pCMap ? m_pCMap->IsVertWriting() : FALSE; 725 return m_pCMap ? m_pCMap->IsVertWriting() : false;
726 } 726 }
727 extern FX_DWORD FPDFAPI_CharCodeFromCID(const FXCMAP_CMap* pMap, FX_WORD cid); 727 extern FX_DWORD FPDFAPI_CharCodeFromCID(const FXCMAP_CMap* pMap, FX_WORD cid);
728 static FX_DWORD _EmbeddedCharcodeFromUnicode(const FXCMAP_CMap* pEmbedMap, int c harset, FX_WCHAR unicode) 728 static FX_DWORD _EmbeddedCharcodeFromUnicode(const FXCMAP_CMap* pEmbedMap, int c harset, FX_WCHAR unicode)
729 { 729 {
730 if (charset <= 0 || charset > 4) { 730 if (charset <= 0 || charset > 4) {
731 return 0; 731 return 0;
732 } 732 }
733 CPDF_FontGlobals* pFontGlobals = CPDF_ModuleMgr::Get()->GetPageModule()->Get FontGlobals(); 733 CPDF_FontGlobals* pFontGlobals = CPDF_ModuleMgr::Get()->GetPageModule()->Get FontGlobals();
734 const FX_WORD* pCodes = pFontGlobals->m_EmbeddedToUnicodes[charset].m_pMap; 734 const FX_WORD* pCodes = pFontGlobals->m_EmbeddedToUnicodes[charset].m_pMap;
735 if (pCodes == NULL) { 735 if (pCodes == NULL) {
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
864 encoding = FXFT_ENCODING_UNICODE; 864 encoding = FXFT_ENCODING_UNICODE;
865 } 865 }
866 int err = FXFT_Select_Charmap(face, encoding); 866 int err = FXFT_Select_Charmap(face, encoding);
867 if (err) { 867 if (err) {
868 err = FXFT_Select_Charmap(face, FXFT_ENCODING_UNICODE); 868 err = FXFT_Select_Charmap(face, FXFT_ENCODING_UNICODE);
869 } 869 }
870 if (err && FXFT_Get_Face_Charmaps(face)) { 870 if (err && FXFT_Get_Face_Charmaps(face)) {
871 FXFT_Set_Charmap(face, *FXFT_Get_Face_Charmaps(face)); 871 FXFT_Set_Charmap(face, *FXFT_Get_Face_Charmaps(face));
872 } 872 }
873 } 873 }
874 FX_BOOL CPDF_CIDFont::_Load() 874 bool CPDF_CIDFont::_Load()
875 { 875 {
876 if (m_pFontDict->GetString(FX_BSTRC("Subtype")) == FX_BSTRC("TrueType")) { 876 if (m_pFontDict->GetString(FX_BSTRC("Subtype")) == FX_BSTRC("TrueType")) {
877 return LoadGB2312(); 877 return LoadGB2312();
878 } 878 }
879 CPDF_Array* pFonts = m_pFontDict->GetArray(FX_BSTRC("DescendantFonts")); 879 CPDF_Array* pFonts = m_pFontDict->GetArray(FX_BSTRC("DescendantFonts"));
880 if (pFonts == NULL) { 880 if (pFonts == NULL) {
881 return FALSE; 881 return false;
882 } 882 }
883 if (pFonts->GetCount() != 1) { 883 if (pFonts->GetCount() != 1) {
884 return FALSE; 884 return false;
885 } 885 }
886 CPDF_Dictionary* pCIDFontDict = pFonts->GetDict(0); 886 CPDF_Dictionary* pCIDFontDict = pFonts->GetDict(0);
887 if (pCIDFontDict == NULL) { 887 if (pCIDFontDict == NULL) {
888 return FALSE; 888 return false;
889 } 889 }
890 m_BaseFont = pCIDFontDict->GetString(FX_BSTRC("BaseFont")); 890 m_BaseFont = pCIDFontDict->GetString(FX_BSTRC("BaseFont"));
891 if ((m_BaseFont.Compare("CourierStd") == 0 || m_BaseFont.Compare("CourierStd -Bold") == 0 891 if ((m_BaseFont.Compare("CourierStd") == 0 || m_BaseFont.Compare("CourierStd -Bold") == 0
892 || m_BaseFont.Compare("CourierStd-BoldOblique") == 0 || m_BaseFont.C ompare("CourierStd-Oblique") == 0) 892 || m_BaseFont.Compare("CourierStd-BoldOblique") == 0 || m_BaseFont.C ompare("CourierStd-Oblique") == 0)
893 && !IsEmbedded()) { 893 && !IsEmbedded()) {
894 m_bAdobeCourierStd = TRUE; 894 m_bAdobeCourierStd = true;
895 } 895 }
896 CPDF_Dictionary* pFontDesc = pCIDFontDict->GetDict(FX_BSTRC("FontDescriptor" )); 896 CPDF_Dictionary* pFontDesc = pCIDFontDict->GetDict(FX_BSTRC("FontDescriptor" ));
897 if (pFontDesc) { 897 if (pFontDesc) {
898 LoadFontDescriptor(pFontDesc); 898 LoadFontDescriptor(pFontDesc);
899 } 899 }
900 CPDF_Object* pEncoding = m_pFontDict->GetElementValue(FX_BSTRC("Encoding")); 900 CPDF_Object* pEncoding = m_pFontDict->GetElementValue(FX_BSTRC("Encoding"));
901 if (pEncoding == NULL) { 901 if (pEncoding == NULL) {
902 return FALSE; 902 return false;
903 } 903 }
904 CFX_ByteString subtype = pCIDFontDict->GetString(FX_BSTRC("Subtype")); 904 CFX_ByteString subtype = pCIDFontDict->GetString(FX_BSTRC("Subtype"));
905 m_bType1 = FALSE; 905 m_bType1 = false;
906 if (subtype == FX_BSTRC("CIDFontType0")) { 906 if (subtype == FX_BSTRC("CIDFontType0")) {
907 m_bType1 = TRUE; 907 m_bType1 = true;
908 } 908 }
909 if (pEncoding->GetType() == PDFOBJ_NAME) { 909 if (pEncoding->GetType() == PDFOBJ_NAME) {
910 CFX_ByteString cmap = pEncoding->GetString(); 910 CFX_ByteString cmap = pEncoding->GetString();
911 m_pCMap = CPDF_ModuleMgr::Get()->GetPageModule()->GetFontGlobals()->m_CM apManager.GetPredefinedCMap(cmap, 911 m_pCMap = CPDF_ModuleMgr::Get()->GetPageModule()->GetFontGlobals()->m_CM apManager.GetPredefinedCMap(cmap,
912 m_pFontFile && m_bType1); 912 m_pFontFile && m_bType1);
913 } else if (pEncoding->GetType() == PDFOBJ_STREAM) { 913 } else if (pEncoding->GetType() == PDFOBJ_STREAM) {
914 m_pAllocatedCMap = m_pCMap = new CPDF_CMap; 914 m_pAllocatedCMap = m_pCMap = new CPDF_CMap;
915 CPDF_Stream* pStream = (CPDF_Stream*)pEncoding; 915 CPDF_Stream* pStream = (CPDF_Stream*)pEncoding;
916 CPDF_StreamAcc acc; 916 CPDF_StreamAcc acc;
917 acc.LoadAllData(pStream, FALSE); 917 acc.LoadAllData(pStream, false);
918 m_pCMap->LoadEmbedded(acc.GetData(), acc.GetSize()); 918 m_pCMap->LoadEmbedded(acc.GetData(), acc.GetSize());
919 } else { 919 } else {
920 return FALSE; 920 return false;
921 } 921 }
922 if (m_pCMap == NULL) { 922 if (m_pCMap == NULL) {
923 return FALSE; 923 return false;
924 } 924 }
925 m_Charset = m_pCMap->m_Charset; 925 m_Charset = m_pCMap->m_Charset;
926 if (m_Charset == CIDSET_UNKNOWN) { 926 if (m_Charset == CIDSET_UNKNOWN) {
927 CPDF_Dictionary* pCIDInfo = pCIDFontDict->GetDict(FX_BSTRC("CIDSystemInf o")); 927 CPDF_Dictionary* pCIDInfo = pCIDFontDict->GetDict(FX_BSTRC("CIDSystemInf o"));
928 if (pCIDInfo) { 928 if (pCIDInfo) {
929 m_Charset = _CharsetFromOrdering(pCIDInfo->GetString(FX_BSTRC("Order ing"))); 929 m_Charset = _CharsetFromOrdering(pCIDInfo->GetString(FX_BSTRC("Order ing")));
930 } 930 }
931 } 931 }
932 if (m_Charset != CIDSET_UNKNOWN) 932 if (m_Charset != CIDSET_UNKNOWN)
933 m_pCID2UnicodeMap = CPDF_ModuleMgr::Get()->GetPageModule()->GetFontGloba ls()->m_CMapManager.GetCID2UnicodeMap(m_Charset, 933 m_pCID2UnicodeMap = CPDF_ModuleMgr::Get()->GetPageModule()->GetFontGloba ls()->m_CMapManager.GetCID2UnicodeMap(m_Charset,
(...skipping 12 matching lines...) Expand all
946 } 946 }
947 if (!IsEmbedded()) { 947 if (!IsEmbedded()) {
948 LoadSubstFont(); 948 LoadSubstFont();
949 } 949 }
950 if (1) { 950 if (1) {
951 if (m_pFontFile || (GetSubstFont()->m_SubstFlags & FXFONT_SUBST_EXACT)) { 951 if (m_pFontFile || (GetSubstFont()->m_SubstFlags & FXFONT_SUBST_EXACT)) {
952 CPDF_Object* pmap = pCIDFontDict->GetElementValue(FX_BSTRC("CIDToGID Map")); 952 CPDF_Object* pmap = pCIDFontDict->GetElementValue(FX_BSTRC("CIDToGID Map"));
953 if (pmap) { 953 if (pmap) {
954 if (pmap->GetType() == PDFOBJ_STREAM) { 954 if (pmap->GetType() == PDFOBJ_STREAM) {
955 m_pCIDToGIDMap = new CPDF_StreamAcc; 955 m_pCIDToGIDMap = new CPDF_StreamAcc;
956 m_pCIDToGIDMap->LoadAllData((CPDF_Stream*)pmap, FALSE); 956 m_pCIDToGIDMap->LoadAllData((CPDF_Stream*)pmap, false);
957 } else if (pmap->GetString() == FX_BSTRC("Identity")) { 957 } else if (pmap->GetString() == FX_BSTRC("Identity")) {
958 #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ 958 #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_
959 if (m_pFontFile) { 959 if (m_pFontFile) {
960 m_bCIDIsGID = TRUE; 960 m_bCIDIsGID = true;
961 } 961 }
962 #else 962 #else
963 m_bCIDIsGID = TRUE; 963 m_bCIDIsGID = true;
964 #endif 964 #endif
965 } 965 }
966 } 966 }
967 } 967 }
968 } 968 }
969 CheckFontMetrics(); 969 CheckFontMetrics();
970 if (IsVertWriting()) { 970 if (IsVertWriting()) {
971 pWidthArray = pCIDFontDict->GetArray(FX_BSTRC("W2")); 971 pWidthArray = pCIDFontDict->GetArray(FX_BSTRC("W2"));
972 if (pWidthArray) { 972 if (pWidthArray) {
973 LoadMetricsArray(pWidthArray, m_VertMetrics, 3); 973 LoadMetricsArray(pWidthArray, m_VertMetrics, 3);
974 } 974 }
975 CPDF_Array* pDefaultArray = pCIDFontDict->GetArray(FX_BSTRC("DW2")); 975 CPDF_Array* pDefaultArray = pCIDFontDict->GetArray(FX_BSTRC("DW2"));
976 if (pDefaultArray) { 976 if (pDefaultArray) {
977 m_DefaultVY = pDefaultArray->GetInteger(0); 977 m_DefaultVY = pDefaultArray->GetInteger(0);
978 m_DefaultW1 = pDefaultArray->GetInteger(1); 978 m_DefaultW1 = pDefaultArray->GetInteger(1);
979 } else { 979 } else {
980 m_DefaultVY = 880; 980 m_DefaultVY = 880;
981 m_DefaultW1 = -1000; 981 m_DefaultW1 = -1000;
982 } 982 }
983 } 983 }
984 return TRUE; 984 return true;
985 } 985 }
986 FX_FLOAT _CIDTransformToFloat(uint8_t ch) 986 FX_FLOAT _CIDTransformToFloat(uint8_t ch)
987 { 987 {
988 if (ch < 128) { 988 if (ch < 128) {
989 return ch * 1.0f / 127; 989 return ch * 1.0f / 127;
990 } 990 }
991 return (-255 + ch) * 1.0f / 127; 991 return (-255 + ch) * 1.0f / 127;
992 } 992 }
993 void CPDF_CIDFont::GetCharBBox(FX_DWORD charcode, FX_RECT& rect, int level) 993 void CPDF_CIDFont::GetCharBBox(FX_DWORD charcode, FX_RECT& rect, int level)
994 { 994 {
995 if (charcode < 256 && m_CharBBox[charcode].Right != -1) { 995 if (charcode < 256 && m_CharBBox[charcode].Right != -1) {
996 rect.bottom = m_CharBBox[charcode].Bottom; 996 rect.bottom = m_CharBBox[charcode].Bottom;
997 rect.left = m_CharBBox[charcode].Left; 997 rect.left = m_CharBBox[charcode].Left;
998 rect.right = m_CharBBox[charcode].Right; 998 rect.right = m_CharBBox[charcode].Right;
999 rect.top = m_CharBBox[charcode].Top; 999 rect.top = m_CharBBox[charcode].Top;
1000 return; 1000 return;
1001 } 1001 }
1002 FX_BOOL bVert = FALSE; 1002 bool bVert = false;
1003 int glyph_index = GlyphFromCharCode(charcode, &bVert); 1003 int glyph_index = GlyphFromCharCode(charcode, &bVert);
1004 if (m_Font.m_Face == NULL) { 1004 if (m_Font.m_Face == NULL) {
1005 rect = FX_RECT(0, 0, 0, 0); 1005 rect = FX_RECT(0, 0, 0, 0);
1006 } else { 1006 } else {
1007 rect.left = rect.bottom = rect.right = rect.top = 0; 1007 rect.left = rect.bottom = rect.right = rect.top = 0;
1008 FXFT_Face face = m_Font.m_Face; 1008 FXFT_Face face = m_Font.m_Face;
1009 if (FXFT_Is_Face_Tricky(face)) { 1009 if (FXFT_Is_Face_Tricky(face)) {
1010 int err = FXFT_Load_Glyph(face, glyph_index, FXFT_LOAD_IGNORE_GLOBAL _ADVANCE_WIDTH); 1010 int err = FXFT_Load_Glyph(face, glyph_index, FXFT_LOAD_IGNORE_GLOBAL _ADVANCE_WIDTH);
1011 if (!err) { 1011 if (!err) {
1012 FXFT_BBox cbox; 1012 FXFT_BBox cbox;
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
1111 const FX_DWORD* list = m_WidthList.GetData(); 1111 const FX_DWORD* list = m_WidthList.GetData();
1112 for (int i = 0; i < size; i += 3) { 1112 for (int i = 0; i < size; i += 3) {
1113 if (CID >= list[i] && CID <= list[i + 1]) { 1113 if (CID >= list[i] && CID <= list[i + 1]) {
1114 dwWidth = (FX_WORD)list[i + 2]; 1114 dwWidth = (FX_WORD)list[i + 2];
1115 break; 1115 break;
1116 } 1116 }
1117 } 1117 }
1118 vx = (short)dwWidth / 2; 1118 vx = (short)dwWidth / 2;
1119 vy = (short)m_DefaultVY; 1119 vy = (short)m_DefaultVY;
1120 } 1120 }
1121 int» CPDF_CIDFont::GetGlyphIndex(FX_DWORD unicode, FX_BOOL *pVertGlyph) 1121 int» CPDF_CIDFont::GetGlyphIndex(FX_DWORD unicode, bool *pVertGlyph)
1122 { 1122 {
1123 if (pVertGlyph) { 1123 if (pVertGlyph) {
1124 *pVertGlyph = FALSE; 1124 *pVertGlyph = false;
1125 } 1125 }
1126 int index = FXFT_Get_Char_Index(m_Font.m_Face, unicode ); 1126 int index = FXFT_Get_Char_Index(m_Font.m_Face, unicode );
1127 if (unicode == 0x2502) { 1127 if (unicode == 0x2502) {
1128 return index; 1128 return index;
1129 } 1129 }
1130 if (index && IsVertWriting()) { 1130 if (index && IsVertWriting()) {
1131 if (m_pTTGSUBTable) { 1131 if (m_pTTGSUBTable) {
1132 TT_uint32_t vindex = 0; 1132 TT_uint32_t vindex = 0;
1133 m_pTTGSUBTable->GetVerticalGlyph(index, &vindex); 1133 m_pTTGSUBTable->GetVerticalGlyph(index, &vindex);
1134 if (vindex) { 1134 if (vindex) {
1135 index = vindex; 1135 index = vindex;
1136 if (pVertGlyph) { 1136 if (pVertGlyph) {
1137 *pVertGlyph = TRUE; 1137 *pVertGlyph = true;
1138 } 1138 }
1139 } 1139 }
1140 return index; 1140 return index;
1141 } 1141 }
1142 if (NULL == m_Font.m_pGsubData) { 1142 if (NULL == m_Font.m_pGsubData) {
1143 unsigned long length = 0; 1143 unsigned long length = 0;
1144 int error = FXFT_Load_Sfnt_Table( m_Font.m_Face, FT_MAKE_TAG('G', 'S ', 'U', 'B'), 0, NULL, &length); 1144 int error = FXFT_Load_Sfnt_Table( m_Font.m_Face, FT_MAKE_TAG('G', 'S ', 'U', 'B'), 0, NULL, &length);
1145 if (!error) { 1145 if (!error) {
1146 m_Font.m_pGsubData = (unsigned char*)FX_Alloc(uint8_t, length); 1146 m_Font.m_pGsubData = (unsigned char*)FX_Alloc(uint8_t, length);
1147 } 1147 }
1148 } 1148 }
1149 int error = FXFT_Load_Sfnt_Table( m_Font.m_Face, FT_MAKE_TAG('G', 'S', ' U', 'B'), 0, m_Font.m_pGsubData, NULL); 1149 int error = FXFT_Load_Sfnt_Table( m_Font.m_Face, FT_MAKE_TAG('G', 'S', ' U', 'B'), 0, m_Font.m_pGsubData, NULL);
1150 if (!error && m_Font.m_pGsubData) { 1150 if (!error && m_Font.m_pGsubData) {
1151 m_pTTGSUBTable = new CFX_CTTGSUBTable; 1151 m_pTTGSUBTable = new CFX_CTTGSUBTable;
1152 m_pTTGSUBTable->LoadGSUBTable((FT_Bytes)m_Font.m_pGsubData); 1152 m_pTTGSUBTable->LoadGSUBTable((FT_Bytes)m_Font.m_pGsubData);
1153 TT_uint32_t vindex = 0; 1153 TT_uint32_t vindex = 0;
1154 m_pTTGSUBTable->GetVerticalGlyph(index, &vindex); 1154 m_pTTGSUBTable->GetVerticalGlyph(index, &vindex);
1155 if (vindex) { 1155 if (vindex) {
1156 index = vindex; 1156 index = vindex;
1157 if (pVertGlyph) { 1157 if (pVertGlyph) {
1158 *pVertGlyph = TRUE; 1158 *pVertGlyph = true;
1159 } 1159 }
1160 } 1160 }
1161 } 1161 }
1162 return index; 1162 return index;
1163 } 1163 }
1164 if (pVertGlyph) { 1164 if (pVertGlyph) {
1165 *pVertGlyph = FALSE; 1165 *pVertGlyph = false;
1166 } 1166 }
1167 return index; 1167 return index;
1168 } 1168 }
1169 int CPDF_CIDFont::GlyphFromCharCode(FX_DWORD charcode, FX_BOOL *pVertGlyph) 1169 int CPDF_CIDFont::GlyphFromCharCode(FX_DWORD charcode, bool *pVertGlyph)
1170 { 1170 {
1171 if (pVertGlyph) { 1171 if (pVertGlyph) {
1172 *pVertGlyph = FALSE; 1172 *pVertGlyph = false;
1173 } 1173 }
1174 if (m_pFontFile == NULL && m_pCIDToGIDMap == NULL) { 1174 if (m_pFontFile == NULL && m_pCIDToGIDMap == NULL) {
1175 FX_WORD cid = CIDFromCharCode(charcode); 1175 FX_WORD cid = CIDFromCharCode(charcode);
1176 FX_WCHAR unicode = 0; 1176 FX_WCHAR unicode = 0;
1177 if (m_bCIDIsGID) { 1177 if (m_bCIDIsGID) {
1178 #if _FXM_PLATFORM_ != _FXM_PLATFORM_APPLE_ 1178 #if _FXM_PLATFORM_ != _FXM_PLATFORM_APPLE_
1179 return cid; 1179 return cid;
1180 #else 1180 #else
1181 if (m_Flags & PDFFONT_SYMBOLIC) { 1181 if (m_Flags & PDFFONT_SYMBOLIC) {
1182 return cid; 1182 return cid;
(...skipping 14 matching lines...) Expand all
1197 if (unicode == 0 && !(m_Flags & PDFFONT_SYMBOLIC)) { 1197 if (unicode == 0 && !(m_Flags & PDFFONT_SYMBOLIC)) {
1198 unicode = UnicodeFromCharCode(charcode).GetAt(0); 1198 unicode = UnicodeFromCharCode(charcode).GetAt(0);
1199 } 1199 }
1200 } 1200 }
1201 if (unicode == 0) { 1201 if (unicode == 0) {
1202 if (!m_bAdobeCourierStd) { 1202 if (!m_bAdobeCourierStd) {
1203 return charcode == 0 ? -1 : (int)charcode; 1203 return charcode == 0 ? -1 : (int)charcode;
1204 } 1204 }
1205 charcode += 31; 1205 charcode += 31;
1206 int index = 0, iBaseEncoding; 1206 int index = 0, iBaseEncoding;
1207 FX_BOOL bMSUnicode = FT_UseTTCharmap(m_Font.m_Face, 3, 1); 1207 bool bMSUnicode = FT_UseTTCharmap(m_Font.m_Face, 3, 1);
1208 FX_BOOL bMacRoman = FALSE; 1208 bool bMacRoman = false;
1209 if (!bMSUnicode) { 1209 if (!bMSUnicode) {
1210 bMacRoman = FT_UseTTCharmap(m_Font.m_Face, 1, 0); 1210 bMacRoman = FT_UseTTCharmap(m_Font.m_Face, 1, 0);
1211 } 1211 }
1212 iBaseEncoding = PDFFONT_ENCODING_STANDARD; 1212 iBaseEncoding = PDFFONT_ENCODING_STANDARD;
1213 if (bMSUnicode) { 1213 if (bMSUnicode) {
1214 iBaseEncoding = PDFFONT_ENCODING_WINANSI; 1214 iBaseEncoding = PDFFONT_ENCODING_WINANSI;
1215 } else if (bMacRoman) { 1215 } else if (bMacRoman) {
1216 iBaseEncoding = PDFFONT_ENCODING_MACROMAN; 1216 iBaseEncoding = PDFFONT_ENCODING_MACROMAN;
1217 } 1217 }
1218 const FX_CHAR* name = GetAdobeCharName(iBaseEncoding, NULL, charcode ); 1218 const FX_CHAR* name = GetAdobeCharName(iBaseEncoding, NULL, charcode );
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
1319 return m_pCMap->GetCharSize(charcode); 1319 return m_pCMap->GetCharSize(charcode);
1320 } 1320 }
1321 int CPDF_CIDFont::CountChar(const FX_CHAR* pString, int size) const 1321 int CPDF_CIDFont::CountChar(const FX_CHAR* pString, int size) const
1322 { 1322 {
1323 return m_pCMap->CountChar(pString, size); 1323 return m_pCMap->CountChar(pString, size);
1324 } 1324 }
1325 int CPDF_CIDFont::AppendChar(FX_CHAR* str, FX_DWORD charcode) const 1325 int CPDF_CIDFont::AppendChar(FX_CHAR* str, FX_DWORD charcode) const
1326 { 1326 {
1327 return m_pCMap->AppendChar(str, charcode); 1327 return m_pCMap->AppendChar(str, charcode);
1328 } 1328 }
1329 FX_BOOL CPDF_CIDFont::IsUnicodeCompatible() const 1329 bool CPDF_CIDFont::IsUnicodeCompatible() const
1330 { 1330 {
1331 if (!m_pCMap->IsLoaded() || m_pCID2UnicodeMap == NULL || !m_pCID2UnicodeMap- >IsLoaded()) { 1331 if (!m_pCMap->IsLoaded() || m_pCID2UnicodeMap == NULL || !m_pCID2UnicodeMap- >IsLoaded()) {
1332 return m_pCMap->m_Coding != CIDCODING_UNKNOWN; 1332 return m_pCMap->m_Coding != CIDCODING_UNKNOWN;
1333 } 1333 }
1334 return TRUE; 1334 return true;
1335 } 1335 }
1336 FX_BOOL CPDF_CIDFont::IsFontStyleFromCharCode(FX_DWORD charcode) const 1336 bool CPDF_CIDFont::IsFontStyleFromCharCode(FX_DWORD charcode) const
1337 { 1337 {
1338 return TRUE; 1338 return true;
1339 } 1339 }
1340 void CPDF_CIDFont::LoadSubstFont() 1340 void CPDF_CIDFont::LoadSubstFont()
1341 { 1341 {
1342 m_Font.LoadSubst(m_BaseFont, !m_bType1, m_Flags, m_StemV * 5, m_ItalicAngle, g_CharsetCPs[m_Charset], IsVertWriting()); 1342 m_Font.LoadSubst(m_BaseFont, !m_bType1, m_Flags, m_StemV * 5, m_ItalicAngle, g_CharsetCPs[m_Charset], IsVertWriting());
1343 } 1343 }
1344 void CPDF_CIDFont::LoadMetricsArray(CPDF_Array* pArray, CFX_DWordArray& result, int nElements) 1344 void CPDF_CIDFont::LoadMetricsArray(CPDF_Array* pArray, CFX_DWordArray& result, int nElements)
1345 { 1345 {
1346 int width_status = 0; 1346 int width_status = 0;
1347 int iCurElement = 0; 1347 int iCurElement = 0;
1348 int first_code = 0, last_code; 1348 int first_code = 0, last_code;
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
1382 } 1382 }
1383 result.Add(pObj->GetInteger()); 1383 result.Add(pObj->GetInteger());
1384 iCurElement ++; 1384 iCurElement ++;
1385 if (iCurElement == nElements) { 1385 if (iCurElement == nElements) {
1386 width_status = 0; 1386 width_status = 0;
1387 } 1387 }
1388 } 1388 }
1389 } 1389 }
1390 } 1390 }
1391 } 1391 }
1392 FX_BOOL CPDF_CIDFont::LoadGB2312() 1392 bool CPDF_CIDFont::LoadGB2312()
1393 { 1393 {
1394 m_BaseFont = m_pFontDict->GetString(FX_BSTRC("BaseFont")); 1394 m_BaseFont = m_pFontDict->GetString(FX_BSTRC("BaseFont"));
1395 CPDF_Dictionary* pFontDesc = m_pFontDict->GetDict(FX_BSTRC("FontDescriptor") ); 1395 CPDF_Dictionary* pFontDesc = m_pFontDict->GetDict(FX_BSTRC("FontDescriptor") );
1396 if (pFontDesc) { 1396 if (pFontDesc) {
1397 LoadFontDescriptor(pFontDesc); 1397 LoadFontDescriptor(pFontDesc);
1398 } 1398 }
1399 m_Charset = CIDSET_GB1; 1399 m_Charset = CIDSET_GB1;
1400 m_bType1 = FALSE; 1400 m_bType1 = false;
1401 m_pCMap = CPDF_ModuleMgr::Get()->GetPageModule()->GetFontGlobals()->m_CMapMa nager.GetPredefinedCMap( 1401 m_pCMap = CPDF_ModuleMgr::Get()->GetPageModule()->GetFontGlobals()->m_CMapMa nager.GetPredefinedCMap(
1402 FX_BSTRC("GBK-EUC-H"), FALSE); 1402 FX_BSTRC("GBK-EUC-H"), false);
1403 m_pCID2UnicodeMap = CPDF_ModuleMgr::Get()->GetPageModule()->GetFontGlobals() ->m_CMapManager.GetCID2UnicodeMap(m_Charset, FALSE); 1403 m_pCID2UnicodeMap = CPDF_ModuleMgr::Get()->GetPageModule()->GetFontGlobals() ->m_CMapManager.GetCID2UnicodeMap(m_Charset, false);
1404 if (!IsEmbedded()) { 1404 if (!IsEmbedded()) {
1405 LoadSubstFont(); 1405 LoadSubstFont();
1406 } 1406 }
1407 CheckFontMetrics(); 1407 CheckFontMetrics();
1408 m_DefaultWidth = 1000; 1408 m_DefaultWidth = 1000;
1409 m_pAnsiWidths = FX_Alloc(FX_WORD, 128); 1409 m_pAnsiWidths = FX_Alloc(FX_WORD, 128);
1410 for (int i = 32; i < 127; i ++) { 1410 for (int i = 32; i < 127; i ++) {
1411 m_pAnsiWidths[i] = 500; 1411 m_pAnsiWidths[i] = 500;
1412 } 1412 }
1413 return TRUE; 1413 return true;
1414 } 1414 }
1415 const struct _CIDTransform { 1415 const struct _CIDTransform {
1416 FX_WORD CID; 1416 FX_WORD CID;
1417 uint8_t a, b, c, d, e, f; 1417 uint8_t a, b, c, d, e, f;
1418 } 1418 }
1419 Japan1_VertCIDs[] = { 1419 Japan1_VertCIDs[] = {
1420 {97, 129, 0, 0, 127, 55, 0}, 1420 {97, 129, 0, 0, 127, 55, 0},
1421 {7887, 127, 0, 0, 127, 76, 89}, 1421 {7887, 127, 0, 0, 127, 76, 89},
1422 {7888, 127, 0, 0, 127, 79, 94}, 1422 {7888, 127, 0, 0, 127, 79, 94},
1423 {7889, 0, 129, 127, 0, 17, 127}, 1423 {7889, 0, 129, 127, 0, 17, 127},
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
1585 if (middlecode > CID) { 1585 if (middlecode > CID) {
1586 end = middle - 1; 1586 end = middle - 1;
1587 } else if (middlecode < CID) { 1587 } else if (middlecode < CID) {
1588 begin = middle + 1; 1588 begin = middle + 1;
1589 } else { 1589 } else {
1590 return &Japan1_VertCIDs[middle].a; 1590 return &Japan1_VertCIDs[middle].a;
1591 } 1591 }
1592 } 1592 }
1593 return NULL; 1593 return NULL;
1594 } 1594 }
OLDNEW
« no previous file with comments | « core/src/fpdfapi/fpdf_font/fpdf_font.cpp ('k') | core/src/fpdfapi/fpdf_font/ttgsubtable.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698