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 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
117 case CIDSET_KOREA1: | 117 case CIDSET_KOREA1: |
118 return true; | 118 return true; |
119 | 119 |
120 default: | 120 default: |
121 return false; | 121 return false; |
122 } | 122 } |
123 } | 123 } |
124 | 124 |
125 FX_WCHAR EmbeddedUnicodeFromCharcode(const FXCMAP_CMap* pEmbedMap, | 125 FX_WCHAR EmbeddedUnicodeFromCharcode(const FXCMAP_CMap* pEmbedMap, |
126 CIDSet charset, | 126 CIDSet charset, |
127 FX_DWORD charcode) { | 127 uint32_t charcode) { |
128 if (!IsValidEmbeddedCharcodeFromUnicodeCharset(charset)) | 128 if (!IsValidEmbeddedCharcodeFromUnicodeCharset(charset)) |
129 return 0; | 129 return 0; |
130 | 130 |
131 uint16_t cid = FPDFAPI_CIDFromCharCode(pEmbedMap, charcode); | 131 uint16_t cid = FPDFAPI_CIDFromCharCode(pEmbedMap, charcode); |
132 if (cid == 0) | 132 if (cid == 0) |
133 return 0; | 133 return 0; |
134 | 134 |
135 CPDF_FontGlobals* pFontGlobals = | 135 CPDF_FontGlobals* pFontGlobals = |
136 CPDF_ModuleMgr::Get()->GetPageModule()->GetFontGlobals(); | 136 CPDF_ModuleMgr::Get()->GetPageModule()->GetFontGlobals(); |
137 const uint16_t* pCodes = pFontGlobals->m_EmbeddedToUnicodes[charset].m_pMap; | 137 const uint16_t* pCodes = pFontGlobals->m_EmbeddedToUnicodes[charset].m_pMap; |
138 if (!pCodes) | 138 if (!pCodes) |
139 return 0; | 139 return 0; |
140 | 140 |
141 if (cid < pFontGlobals->m_EmbeddedToUnicodes[charset].m_Count) | 141 if (cid < pFontGlobals->m_EmbeddedToUnicodes[charset].m_Count) |
142 return pCodes[cid]; | 142 return pCodes[cid]; |
143 return 0; | 143 return 0; |
144 } | 144 } |
145 | 145 |
146 FX_DWORD EmbeddedCharcodeFromUnicode(const FXCMAP_CMap* pEmbedMap, | 146 uint32_t EmbeddedCharcodeFromUnicode(const FXCMAP_CMap* pEmbedMap, |
147 CIDSet charset, | 147 CIDSet charset, |
148 FX_WCHAR unicode) { | 148 FX_WCHAR unicode) { |
149 if (!IsValidEmbeddedCharcodeFromUnicodeCharset(charset)) | 149 if (!IsValidEmbeddedCharcodeFromUnicodeCharset(charset)) |
150 return 0; | 150 return 0; |
151 | 151 |
152 CPDF_FontGlobals* pFontGlobals = | 152 CPDF_FontGlobals* pFontGlobals = |
153 CPDF_ModuleMgr::Get()->GetPageModule()->GetFontGlobals(); | 153 CPDF_ModuleMgr::Get()->GetPageModule()->GetFontGlobals(); |
154 const uint16_t* pCodes = pFontGlobals->m_EmbeddedToUnicodes[charset].m_pMap; | 154 const uint16_t* pCodes = pFontGlobals->m_EmbeddedToUnicodes[charset].m_pMap; |
155 if (!pCodes) | 155 if (!pCodes) |
156 return 0; | 156 return 0; |
157 | 157 |
158 int nCodes = pFontGlobals->m_EmbeddedToUnicodes[charset].m_Count; | 158 int nCodes = pFontGlobals->m_EmbeddedToUnicodes[charset].m_Count; |
159 for (int i = 0; i < nCodes; ++i) { | 159 for (int i = 0; i < nCodes; ++i) { |
160 if (pCodes[i] == unicode) { | 160 if (pCodes[i] == unicode) { |
161 FX_DWORD CharCode = FPDFAPI_CharCodeFromCID(pEmbedMap, i); | 161 uint32_t CharCode = FPDFAPI_CharCodeFromCID(pEmbedMap, i); |
162 if (CharCode != 0) { | 162 if (CharCode != 0) { |
163 return CharCode; | 163 return CharCode; |
164 } | 164 } |
165 } | 165 } |
166 } | 166 } |
167 return 0; | 167 return 0; |
168 } | 168 } |
169 | 169 |
170 #endif // _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_ | 170 #endif // _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_ |
171 | 171 |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
227 } | 227 } |
228 | 228 |
229 const CPDF_CIDFont* CPDF_CIDFont::AsCIDFont() const { | 229 const CPDF_CIDFont* CPDF_CIDFont::AsCIDFont() const { |
230 return this; | 230 return this; |
231 } | 231 } |
232 | 232 |
233 CPDF_CIDFont* CPDF_CIDFont::AsCIDFont() { | 233 CPDF_CIDFont* CPDF_CIDFont::AsCIDFont() { |
234 return this; | 234 return this; |
235 } | 235 } |
236 | 236 |
237 uint16_t CPDF_CIDFont::CIDFromCharCode(FX_DWORD charcode) const { | 237 uint16_t CPDF_CIDFont::CIDFromCharCode(uint32_t charcode) const { |
238 if (!m_pCMap) { | 238 if (!m_pCMap) { |
239 return (uint16_t)charcode; | 239 return (uint16_t)charcode; |
240 } | 240 } |
241 return m_pCMap->CIDFromCharCode(charcode); | 241 return m_pCMap->CIDFromCharCode(charcode); |
242 } | 242 } |
243 | 243 |
244 FX_BOOL CPDF_CIDFont::IsVertWriting() const { | 244 FX_BOOL CPDF_CIDFont::IsVertWriting() const { |
245 return m_pCMap ? m_pCMap->IsVertWriting() : FALSE; | 245 return m_pCMap ? m_pCMap->IsVertWriting() : FALSE; |
246 } | 246 } |
247 | 247 |
248 CFX_WideString CPDF_CIDFont::UnicodeFromCharCode(FX_DWORD charcode) const { | 248 CFX_WideString CPDF_CIDFont::UnicodeFromCharCode(uint32_t charcode) const { |
249 CFX_WideString str = CPDF_Font::UnicodeFromCharCode(charcode); | 249 CFX_WideString str = CPDF_Font::UnicodeFromCharCode(charcode); |
250 if (!str.IsEmpty()) | 250 if (!str.IsEmpty()) |
251 return str; | 251 return str; |
252 FX_WCHAR ret = GetUnicodeFromCharCode(charcode); | 252 FX_WCHAR ret = GetUnicodeFromCharCode(charcode); |
253 if (ret == 0) | 253 if (ret == 0) |
254 return CFX_WideString(); | 254 return CFX_WideString(); |
255 return ret; | 255 return ret; |
256 } | 256 } |
257 | 257 |
258 FX_WCHAR CPDF_CIDFont::GetUnicodeFromCharCode(FX_DWORD charcode) const { | 258 FX_WCHAR CPDF_CIDFont::GetUnicodeFromCharCode(uint32_t charcode) const { |
259 switch (m_pCMap->m_Coding) { | 259 switch (m_pCMap->m_Coding) { |
260 case CIDCODING_UCS2: | 260 case CIDCODING_UCS2: |
261 case CIDCODING_UTF16: | 261 case CIDCODING_UTF16: |
262 return (FX_WCHAR)charcode; | 262 return (FX_WCHAR)charcode; |
263 case CIDCODING_CID: | 263 case CIDCODING_CID: |
264 if (!m_pCID2UnicodeMap || !m_pCID2UnicodeMap->IsLoaded()) { | 264 if (!m_pCID2UnicodeMap || !m_pCID2UnicodeMap->IsLoaded()) { |
265 return 0; | 265 return 0; |
266 } | 266 } |
267 return m_pCID2UnicodeMap->UnicodeFromCID((uint16_t)charcode); | 267 return m_pCID2UnicodeMap->UnicodeFromCID((uint16_t)charcode); |
268 } | 268 } |
(...skipping 17 matching lines...) Expand all Loading... |
286 if (m_pCMap->m_pEmbedMap) { | 286 if (m_pCMap->m_pEmbedMap) { |
287 return EmbeddedUnicodeFromCharcode(m_pCMap->m_pEmbedMap, | 287 return EmbeddedUnicodeFromCharcode(m_pCMap->m_pEmbedMap, |
288 m_pCMap->m_Charset, charcode); | 288 m_pCMap->m_Charset, charcode); |
289 } | 289 } |
290 return 0; | 290 return 0; |
291 #endif | 291 #endif |
292 } | 292 } |
293 return m_pCID2UnicodeMap->UnicodeFromCID(CIDFromCharCode(charcode)); | 293 return m_pCID2UnicodeMap->UnicodeFromCID(CIDFromCharCode(charcode)); |
294 } | 294 } |
295 | 295 |
296 FX_DWORD CPDF_CIDFont::CharCodeFromUnicode(FX_WCHAR unicode) const { | 296 uint32_t CPDF_CIDFont::CharCodeFromUnicode(FX_WCHAR unicode) const { |
297 FX_DWORD charcode = CPDF_Font::CharCodeFromUnicode(unicode); | 297 uint32_t charcode = CPDF_Font::CharCodeFromUnicode(unicode); |
298 if (charcode) | 298 if (charcode) |
299 return charcode; | 299 return charcode; |
300 switch (m_pCMap->m_Coding) { | 300 switch (m_pCMap->m_Coding) { |
301 case CIDCODING_UNKNOWN: | 301 case CIDCODING_UNKNOWN: |
302 return 0; | 302 return 0; |
303 case CIDCODING_UCS2: | 303 case CIDCODING_UCS2: |
304 case CIDCODING_UTF16: | 304 case CIDCODING_UTF16: |
305 return unicode; | 305 return unicode; |
306 case CIDCODING_CID: { | 306 case CIDCODING_CID: { |
307 if (!m_pCID2UnicodeMap || !m_pCID2UnicodeMap->IsLoaded()) { | 307 if (!m_pCID2UnicodeMap || !m_pCID2UnicodeMap->IsLoaded()) { |
308 return 0; | 308 return 0; |
309 } | 309 } |
310 FX_DWORD CID = 0; | 310 uint32_t CID = 0; |
311 while (CID < 65536) { | 311 while (CID < 65536) { |
312 FX_WCHAR this_unicode = | 312 FX_WCHAR this_unicode = |
313 m_pCID2UnicodeMap->UnicodeFromCID((uint16_t)CID); | 313 m_pCID2UnicodeMap->UnicodeFromCID((uint16_t)CID); |
314 if (this_unicode == unicode) { | 314 if (this_unicode == unicode) { |
315 return CID; | 315 return CID; |
316 } | 316 } |
317 CID++; | 317 CID++; |
318 } | 318 } |
319 break; | 319 break; |
320 } | 320 } |
321 } | 321 } |
322 | 322 |
323 if (unicode < 0x80) { | 323 if (unicode < 0x80) { |
324 return static_cast<FX_DWORD>(unicode); | 324 return static_cast<uint32_t>(unicode); |
325 } | 325 } |
326 if (m_pCMap->m_Coding == CIDCODING_CID) { | 326 if (m_pCMap->m_Coding == CIDCODING_CID) { |
327 return 0; | 327 return 0; |
328 } | 328 } |
329 #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ | 329 #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ |
330 uint8_t buffer[32]; | 330 uint8_t buffer[32]; |
331 int ret = | 331 int ret = |
332 FXSYS_WideCharToMultiByte(g_CharsetCPs[m_pCMap->m_Coding], 0, &unicode, 1, | 332 FXSYS_WideCharToMultiByte(g_CharsetCPs[m_pCMap->m_Coding], 0, &unicode, 1, |
333 (char*)buffer, 4, NULL, NULL); | 333 (char*)buffer, 4, NULL, NULL); |
334 if (ret == 1) { | 334 if (ret == 1) { |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
459 m_DefaultVY = pDefaultArray->GetIntegerAt(0); | 459 m_DefaultVY = pDefaultArray->GetIntegerAt(0); |
460 m_DefaultW1 = pDefaultArray->GetIntegerAt(1); | 460 m_DefaultW1 = pDefaultArray->GetIntegerAt(1); |
461 } else { | 461 } else { |
462 m_DefaultVY = 880; | 462 m_DefaultVY = 880; |
463 m_DefaultW1 = -1000; | 463 m_DefaultW1 = -1000; |
464 } | 464 } |
465 } | 465 } |
466 return TRUE; | 466 return TRUE; |
467 } | 467 } |
468 | 468 |
469 FX_RECT CPDF_CIDFont::GetCharBBox(FX_DWORD charcode, int level) { | 469 FX_RECT CPDF_CIDFont::GetCharBBox(uint32_t charcode, int level) { |
470 if (charcode < 256 && m_CharBBox[charcode].right != FX_SMALL_RECT::kInvalid) | 470 if (charcode < 256 && m_CharBBox[charcode].right != FX_SMALL_RECT::kInvalid) |
471 return FX_RECT(m_CharBBox[charcode]); | 471 return FX_RECT(m_CharBBox[charcode]); |
472 | 472 |
473 FX_RECT rect; | 473 FX_RECT rect; |
474 FX_BOOL bVert = FALSE; | 474 FX_BOOL bVert = FALSE; |
475 int glyph_index = GlyphFromCharCode(charcode, &bVert); | 475 int glyph_index = GlyphFromCharCode(charcode, &bVert); |
476 FXFT_Face face = m_Font.GetFace(); | 476 FXFT_Face face = m_Font.GetFace(); |
477 if (face) { | 477 if (face) { |
478 if (FXFT_Is_Face_Tricky(face)) { | 478 if (FXFT_Is_Face_Tricky(face)) { |
479 int err = FXFT_Load_Glyph(face, glyph_index, | 479 int err = FXFT_Load_Glyph(face, glyph_index, |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
531 CFX_FloatRect rect_f(rect); | 531 CFX_FloatRect rect_f(rect); |
532 rect_f.Transform(&matrix); | 532 rect_f.Transform(&matrix); |
533 rect = rect_f.GetOutterRect(); | 533 rect = rect_f.GetOutterRect(); |
534 } | 534 } |
535 } | 535 } |
536 if (charcode < 256) | 536 if (charcode < 256) |
537 m_CharBBox[charcode] = rect.ToSmallRect(); | 537 m_CharBBox[charcode] = rect.ToSmallRect(); |
538 | 538 |
539 return rect; | 539 return rect; |
540 } | 540 } |
541 int CPDF_CIDFont::GetCharWidthF(FX_DWORD charcode, int level) { | 541 int CPDF_CIDFont::GetCharWidthF(uint32_t charcode, int level) { |
542 if (m_pAnsiWidths && charcode < 0x80) { | 542 if (m_pAnsiWidths && charcode < 0x80) { |
543 return m_pAnsiWidths[charcode]; | 543 return m_pAnsiWidths[charcode]; |
544 } | 544 } |
545 uint16_t cid = CIDFromCharCode(charcode); | 545 uint16_t cid = CIDFromCharCode(charcode); |
546 int size = m_WidthList.GetSize(); | 546 int size = m_WidthList.GetSize(); |
547 FX_DWORD* list = m_WidthList.GetData(); | 547 uint32_t* list = m_WidthList.GetData(); |
548 for (int i = 0; i < size; i += 3) { | 548 for (int i = 0; i < size; i += 3) { |
549 if (cid >= list[i] && cid <= list[i + 1]) { | 549 if (cid >= list[i] && cid <= list[i + 1]) { |
550 return (int)list[i + 2]; | 550 return (int)list[i + 2]; |
551 } | 551 } |
552 } | 552 } |
553 return m_DefaultWidth; | 553 return m_DefaultWidth; |
554 } | 554 } |
555 short CPDF_CIDFont::GetVertWidth(uint16_t CID) const { | 555 short CPDF_CIDFont::GetVertWidth(uint16_t CID) const { |
556 FX_DWORD vertsize = m_VertMetrics.GetSize() / 5; | 556 uint32_t vertsize = m_VertMetrics.GetSize() / 5; |
557 if (vertsize == 0) { | 557 if (vertsize == 0) { |
558 return m_DefaultW1; | 558 return m_DefaultW1; |
559 } | 559 } |
560 const FX_DWORD* pTable = m_VertMetrics.GetData(); | 560 const uint32_t* pTable = m_VertMetrics.GetData(); |
561 for (FX_DWORD i = 0; i < vertsize; i++) | 561 for (uint32_t i = 0; i < vertsize; i++) |
562 if (pTable[i * 5] <= CID && pTable[i * 5 + 1] >= CID) { | 562 if (pTable[i * 5] <= CID && pTable[i * 5 + 1] >= CID) { |
563 return (short)(int)pTable[i * 5 + 2]; | 563 return (short)(int)pTable[i * 5 + 2]; |
564 } | 564 } |
565 return m_DefaultW1; | 565 return m_DefaultW1; |
566 } | 566 } |
567 void CPDF_CIDFont::GetVertOrigin(uint16_t CID, short& vx, short& vy) const { | 567 void CPDF_CIDFont::GetVertOrigin(uint16_t CID, short& vx, short& vy) const { |
568 FX_DWORD vertsize = m_VertMetrics.GetSize() / 5; | 568 uint32_t vertsize = m_VertMetrics.GetSize() / 5; |
569 if (vertsize) { | 569 if (vertsize) { |
570 const FX_DWORD* pTable = m_VertMetrics.GetData(); | 570 const uint32_t* pTable = m_VertMetrics.GetData(); |
571 for (FX_DWORD i = 0; i < vertsize; i++) | 571 for (uint32_t i = 0; i < vertsize; i++) |
572 if (pTable[i * 5] <= CID && pTable[i * 5 + 1] >= CID) { | 572 if (pTable[i * 5] <= CID && pTable[i * 5 + 1] >= CID) { |
573 vx = (short)(int)pTable[i * 5 + 3]; | 573 vx = (short)(int)pTable[i * 5 + 3]; |
574 vy = (short)(int)pTable[i * 5 + 4]; | 574 vy = (short)(int)pTable[i * 5 + 4]; |
575 return; | 575 return; |
576 } | 576 } |
577 } | 577 } |
578 FX_DWORD dwWidth = m_DefaultWidth; | 578 uint32_t dwWidth = m_DefaultWidth; |
579 int size = m_WidthList.GetSize(); | 579 int size = m_WidthList.GetSize(); |
580 const FX_DWORD* list = m_WidthList.GetData(); | 580 const uint32_t* list = m_WidthList.GetData(); |
581 for (int i = 0; i < size; i += 3) { | 581 for (int i = 0; i < size; i += 3) { |
582 if (CID >= list[i] && CID <= list[i + 1]) { | 582 if (CID >= list[i] && CID <= list[i + 1]) { |
583 dwWidth = (uint16_t)list[i + 2]; | 583 dwWidth = (uint16_t)list[i + 2]; |
584 break; | 584 break; |
585 } | 585 } |
586 } | 586 } |
587 vx = (short)dwWidth / 2; | 587 vx = (short)dwWidth / 2; |
588 vy = (short)m_DefaultVY; | 588 vy = (short)m_DefaultVY; |
589 } | 589 } |
590 int CPDF_CIDFont::GetGlyphIndex(FX_DWORD unicode, FX_BOOL* pVertGlyph) { | 590 int CPDF_CIDFont::GetGlyphIndex(uint32_t unicode, FX_BOOL* pVertGlyph) { |
591 if (pVertGlyph) { | 591 if (pVertGlyph) { |
592 *pVertGlyph = FALSE; | 592 *pVertGlyph = FALSE; |
593 } | 593 } |
594 FXFT_Face face = m_Font.GetFace(); | 594 FXFT_Face face = m_Font.GetFace(); |
595 int index = FXFT_Get_Char_Index(face, unicode); | 595 int index = FXFT_Get_Char_Index(face, unicode); |
596 if (unicode == 0x2502) { | 596 if (unicode == 0x2502) { |
597 return index; | 597 return index; |
598 } | 598 } |
599 if (index && IsVertWriting()) { | 599 if (index && IsVertWriting()) { |
600 if (m_pTTGSUBTable) { | 600 if (m_pTTGSUBTable) { |
(...skipping 29 matching lines...) Expand all Loading... |
630 } | 630 } |
631 } | 631 } |
632 } | 632 } |
633 return index; | 633 return index; |
634 } | 634 } |
635 if (pVertGlyph) { | 635 if (pVertGlyph) { |
636 *pVertGlyph = FALSE; | 636 *pVertGlyph = FALSE; |
637 } | 637 } |
638 return index; | 638 return index; |
639 } | 639 } |
640 int CPDF_CIDFont::GlyphFromCharCode(FX_DWORD charcode, FX_BOOL* pVertGlyph) { | 640 int CPDF_CIDFont::GlyphFromCharCode(uint32_t charcode, FX_BOOL* pVertGlyph) { |
641 if (pVertGlyph) { | 641 if (pVertGlyph) { |
642 *pVertGlyph = FALSE; | 642 *pVertGlyph = FALSE; |
643 } | 643 } |
644 if (!m_pFontFile && !m_pCIDToGIDMap) { | 644 if (!m_pFontFile && !m_pCIDToGIDMap) { |
645 uint16_t cid = CIDFromCharCode(charcode); | 645 uint16_t cid = CIDFromCharCode(charcode); |
646 FX_WCHAR unicode = 0; | 646 FX_WCHAR unicode = 0; |
647 if (m_bCIDIsGID) { | 647 if (m_bCIDIsGID) { |
648 #if _FXM_PLATFORM_ != _FXM_PLATFORM_APPLE_ | 648 #if _FXM_PLATFORM_ != _FXM_PLATFORM_APPLE_ |
649 return cid; | 649 return cid; |
650 #else | 650 #else |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
688 } | 688 } |
689 const FX_CHAR* name = GetAdobeCharName(iBaseEncoding, NULL, charcode); | 689 const FX_CHAR* name = GetAdobeCharName(iBaseEncoding, NULL, charcode); |
690 if (!name) { | 690 if (!name) { |
691 return charcode == 0 ? -1 : (int)charcode; | 691 return charcode == 0 ? -1 : (int)charcode; |
692 } | 692 } |
693 uint16_t unicode = PDF_UnicodeFromAdobeName(name); | 693 uint16_t unicode = PDF_UnicodeFromAdobeName(name); |
694 if (unicode) { | 694 if (unicode) { |
695 if (bMSUnicode) { | 695 if (bMSUnicode) { |
696 index = FXFT_Get_Char_Index(face, unicode); | 696 index = FXFT_Get_Char_Index(face, unicode); |
697 } else if (bMacRoman) { | 697 } else if (bMacRoman) { |
698 FX_DWORD maccode = | 698 uint32_t maccode = |
699 FT_CharCodeFromUnicode(FXFT_ENCODING_APPLE_ROMAN, unicode); | 699 FT_CharCodeFromUnicode(FXFT_ENCODING_APPLE_ROMAN, unicode); |
700 index = !maccode ? FXFT_Get_Name_Index(face, (char*)name) | 700 index = !maccode ? FXFT_Get_Name_Index(face, (char*)name) |
701 : FXFT_Get_Char_Index(face, maccode); | 701 : FXFT_Get_Char_Index(face, maccode); |
702 } else { | 702 } else { |
703 return FXFT_Get_Char_Index(face, unicode); | 703 return FXFT_Get_Char_Index(face, unicode); |
704 } | 704 } |
705 } else { | 705 } else { |
706 return charcode == 0 ? -1 : (int)charcode; | 706 return charcode == 0 ? -1 : (int)charcode; |
707 } | 707 } |
708 if (index == 0 || index == 0xffff) { | 708 if (index == 0 || index == 0xffff) { |
(...skipping 10 matching lines...) Expand all Loading... |
719 #endif | 719 #endif |
720 } | 720 } |
721 } | 721 } |
722 if (!face) | 722 if (!face) |
723 return unicode; | 723 return unicode; |
724 | 724 |
725 int err = FXFT_Select_Charmap(face, FXFT_ENCODING_UNICODE); | 725 int err = FXFT_Select_Charmap(face, FXFT_ENCODING_UNICODE); |
726 if (err != 0) { | 726 if (err != 0) { |
727 int i; | 727 int i; |
728 for (i = 0; i < FXFT_Get_Face_CharmapCount(face); i++) { | 728 for (i = 0; i < FXFT_Get_Face_CharmapCount(face); i++) { |
729 FX_DWORD ret = FT_CharCodeFromUnicode( | 729 uint32_t ret = FT_CharCodeFromUnicode( |
730 FXFT_Get_Charmap_Encoding(FXFT_Get_Face_Charmaps(face)[i]), | 730 FXFT_Get_Charmap_Encoding(FXFT_Get_Face_Charmaps(face)[i]), |
731 (FX_WCHAR)charcode); | 731 (FX_WCHAR)charcode); |
732 if (ret == 0) { | 732 if (ret == 0) { |
733 continue; | 733 continue; |
734 } | 734 } |
735 FXFT_Set_Charmap(face, FXFT_Get_Face_Charmaps(face)[i]); | 735 FXFT_Set_Charmap(face, FXFT_Get_Face_Charmaps(face)[i]); |
736 unicode = (FX_WCHAR)ret; | 736 unicode = (FX_WCHAR)ret; |
737 break; | 737 break; |
738 } | 738 } |
739 if (i == FXFT_Get_Face_CharmapCount(face) && i) { | 739 if (i == FXFT_Get_Face_CharmapCount(face) && i) { |
(...skipping 29 matching lines...) Expand all Loading... |
769 FXFT_ENCODING_UNICODE) { | 769 FXFT_ENCODING_UNICODE) { |
770 CFX_WideString unicode_str = UnicodeFromCharCode(charcode); | 770 CFX_WideString unicode_str = UnicodeFromCharCode(charcode); |
771 if (unicode_str.IsEmpty()) { | 771 if (unicode_str.IsEmpty()) { |
772 return -1; | 772 return -1; |
773 } | 773 } |
774 charcode = unicode_str.GetAt(0); | 774 charcode = unicode_str.GetAt(0); |
775 } | 775 } |
776 return GetGlyphIndex(charcode, pVertGlyph); | 776 return GetGlyphIndex(charcode, pVertGlyph); |
777 } | 777 } |
778 } | 778 } |
779 FX_DWORD byte_pos = cid * 2; | 779 uint32_t byte_pos = cid * 2; |
780 if (byte_pos + 2 > m_pCIDToGIDMap->GetSize()) | 780 if (byte_pos + 2 > m_pCIDToGIDMap->GetSize()) |
781 return -1; | 781 return -1; |
782 | 782 |
783 const uint8_t* pdata = m_pCIDToGIDMap->GetData() + byte_pos; | 783 const uint8_t* pdata = m_pCIDToGIDMap->GetData() + byte_pos; |
784 return pdata[0] * 256 + pdata[1]; | 784 return pdata[0] * 256 + pdata[1]; |
785 } | 785 } |
786 FX_DWORD CPDF_CIDFont::GetNextChar(const FX_CHAR* pString, | 786 uint32_t CPDF_CIDFont::GetNextChar(const FX_CHAR* pString, |
787 int nStrLen, | 787 int nStrLen, |
788 int& offset) const { | 788 int& offset) const { |
789 return m_pCMap->GetNextChar(pString, nStrLen, offset); | 789 return m_pCMap->GetNextChar(pString, nStrLen, offset); |
790 } | 790 } |
791 int CPDF_CIDFont::GetCharSize(FX_DWORD charcode) const { | 791 int CPDF_CIDFont::GetCharSize(uint32_t charcode) const { |
792 return m_pCMap->GetCharSize(charcode); | 792 return m_pCMap->GetCharSize(charcode); |
793 } | 793 } |
794 int CPDF_CIDFont::CountChar(const FX_CHAR* pString, int size) const { | 794 int CPDF_CIDFont::CountChar(const FX_CHAR* pString, int size) const { |
795 return m_pCMap->CountChar(pString, size); | 795 return m_pCMap->CountChar(pString, size); |
796 } | 796 } |
797 int CPDF_CIDFont::AppendChar(FX_CHAR* str, FX_DWORD charcode) const { | 797 int CPDF_CIDFont::AppendChar(FX_CHAR* str, uint32_t charcode) const { |
798 return m_pCMap->AppendChar(str, charcode); | 798 return m_pCMap->AppendChar(str, charcode); |
799 } | 799 } |
800 FX_BOOL CPDF_CIDFont::IsUnicodeCompatible() const { | 800 FX_BOOL CPDF_CIDFont::IsUnicodeCompatible() const { |
801 if (!m_pCMap->IsLoaded() || !m_pCID2UnicodeMap || | 801 if (!m_pCMap->IsLoaded() || !m_pCID2UnicodeMap || |
802 !m_pCID2UnicodeMap->IsLoaded()) { | 802 !m_pCID2UnicodeMap->IsLoaded()) { |
803 return m_pCMap->m_Coding != CIDCODING_UNKNOWN; | 803 return m_pCMap->m_Coding != CIDCODING_UNKNOWN; |
804 } | 804 } |
805 return TRUE; | 805 return TRUE; |
806 } | 806 } |
807 FX_BOOL CPDF_CIDFont::IsFontStyleFromCharCode(FX_DWORD charcode) const { | 807 FX_BOOL CPDF_CIDFont::IsFontStyleFromCharCode(uint32_t charcode) const { |
808 return TRUE; | 808 return TRUE; |
809 } | 809 } |
810 void CPDF_CIDFont::LoadSubstFont() { | 810 void CPDF_CIDFont::LoadSubstFont() { |
811 m_Font.LoadSubst(m_BaseFont, !m_bType1, m_Flags, m_StemV * 5, m_ItalicAngle, | 811 m_Font.LoadSubst(m_BaseFont, !m_bType1, m_Flags, m_StemV * 5, m_ItalicAngle, |
812 g_CharsetCPs[m_Charset], IsVertWriting()); | 812 g_CharsetCPs[m_Charset], IsVertWriting()); |
813 } | 813 } |
814 void CPDF_CIDFont::LoadMetricsArray(CPDF_Array* pArray, | 814 void CPDF_CIDFont::LoadMetricsArray(CPDF_Array* pArray, |
815 CFX_ArrayTemplate<FX_DWORD>& result, | 815 CFX_ArrayTemplate<uint32_t>& result, |
816 int nElements) { | 816 int nElements) { |
817 int width_status = 0; | 817 int width_status = 0; |
818 int iCurElement = 0; | 818 int iCurElement = 0; |
819 int first_code = 0; | 819 int first_code = 0; |
820 int last_code = 0; | 820 int last_code = 0; |
821 FX_DWORD count = pArray->GetCount(); | 821 uint32_t count = pArray->GetCount(); |
822 for (FX_DWORD i = 0; i < count; i++) { | 822 for (uint32_t i = 0; i < count; i++) { |
823 CPDF_Object* pObj = pArray->GetElementValue(i); | 823 CPDF_Object* pObj = pArray->GetElementValue(i); |
824 if (!pObj) | 824 if (!pObj) |
825 continue; | 825 continue; |
826 | 826 |
827 if (CPDF_Array* pArray = pObj->AsArray()) { | 827 if (CPDF_Array* pArray = pObj->AsArray()) { |
828 if (width_status != 1) | 828 if (width_status != 1) |
829 return; | 829 return; |
830 | 830 |
831 FX_DWORD count = pArray->GetCount(); | 831 uint32_t count = pArray->GetCount(); |
832 for (FX_DWORD j = 0; j < count; j += nElements) { | 832 for (uint32_t j = 0; j < count; j += nElements) { |
833 result.Add(first_code); | 833 result.Add(first_code); |
834 result.Add(first_code); | 834 result.Add(first_code); |
835 for (int k = 0; k < nElements; k++) { | 835 for (int k = 0; k < nElements; k++) { |
836 result.Add(pArray->GetIntegerAt(j + k)); | 836 result.Add(pArray->GetIntegerAt(j + k)); |
837 } | 837 } |
838 first_code++; | 838 first_code++; |
839 } | 839 } |
840 width_status = 0; | 840 width_status = 0; |
841 } else { | 841 } else { |
842 if (width_status == 0) { | 842 if (width_status == 0) { |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
899 | 899 |
900 const uint8_t* CPDF_CIDFont::GetCIDTransform(uint16_t CID) const { | 900 const uint8_t* CPDF_CIDFont::GetCIDTransform(uint16_t CID) const { |
901 if (m_Charset != CIDSET_JAPAN1 || m_pFontFile) | 901 if (m_Charset != CIDSET_JAPAN1 || m_pFontFile) |
902 return nullptr; | 902 return nullptr; |
903 | 903 |
904 const struct CIDTransform* found = (const struct CIDTransform*)FXSYS_bsearch( | 904 const struct CIDTransform* found = (const struct CIDTransform*)FXSYS_bsearch( |
905 &CID, g_Japan1_VertCIDs, FX_ArraySize(g_Japan1_VertCIDs), | 905 &CID, g_Japan1_VertCIDs, FX_ArraySize(g_Japan1_VertCIDs), |
906 sizeof(g_Japan1_VertCIDs[0]), CompareCIDTransform); | 906 sizeof(g_Japan1_VertCIDs[0]), CompareCIDTransform); |
907 return found ? &found->a : nullptr; | 907 return found ? &found->a : nullptr; |
908 } | 908 } |
OLD | NEW |