| OLD | NEW |
| 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 "core/fpdfapi/fpdf_font/font_int.h" | 7 #include "core/fpdfapi/fpdf_font/font_int.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/ttgsubtable.h" | 10 #include "core/fpdfapi/fpdf_font/ttgsubtable.h" |
| (...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 188 return CIDSET_UNKNOWN; | 188 return CIDSET_UNKNOWN; |
| 189 } | 189 } |
| 190 return static_cast<CIDSet>(index); | 190 return static_cast<CIDSet>(index); |
| 191 } | 191 } |
| 192 | 192 |
| 193 CFX_ByteString CMap_GetString(const CFX_ByteStringC& word) { | 193 CFX_ByteString CMap_GetString(const CFX_ByteStringC& word) { |
| 194 return word.Mid(1, word.GetLength() - 2); | 194 return word.Mid(1, word.GetLength() - 2); |
| 195 } | 195 } |
| 196 | 196 |
| 197 int CompareDWORD(const void* data1, const void* data2) { | 197 int CompareDWORD(const void* data1, const void* data2) { |
| 198 return (*(FX_DWORD*)data1) - (*(FX_DWORD*)data2); | 198 return (*(uint32_t*)data1) - (*(uint32_t*)data2); |
| 199 } | 199 } |
| 200 | 200 |
| 201 int CompareCID(const void* key, const void* element) { | 201 int CompareCID(const void* key, const void* element) { |
| 202 if ((*(FX_DWORD*)key) < (*(FX_DWORD*)element)) { | 202 if ((*(uint32_t*)key) < (*(uint32_t*)element)) { |
| 203 return -1; | 203 return -1; |
| 204 } | 204 } |
| 205 if ((*(FX_DWORD*)key) > | 205 if ((*(uint32_t*)key) > |
| 206 (*(FX_DWORD*)element) + ((FX_DWORD*)element)[1] / 65536) { | 206 (*(uint32_t*)element) + ((uint32_t*)element)[1] / 65536) { |
| 207 return 1; | 207 return 1; |
| 208 } | 208 } |
| 209 return 0; | 209 return 0; |
| 210 } | 210 } |
| 211 | 211 |
| 212 int CheckCodeRange(uint8_t* codes, | 212 int CheckCodeRange(uint8_t* codes, |
| 213 int size, | 213 int size, |
| 214 CMap_CodeRange* pRanges, | 214 CMap_CodeRange* pRanges, |
| 215 int nRanges) { | 215 int nRanges) { |
| 216 int iSeg = nRanges - 1; | 216 int iSeg = nRanges - 1; |
| (...skipping 13 matching lines...) Expand all Loading... |
| 230 if (iChar == pRanges[iSeg].m_CharSize) | 230 if (iChar == pRanges[iSeg].m_CharSize) |
| 231 return 2; | 231 return 2; |
| 232 | 232 |
| 233 if (iChar) | 233 if (iChar) |
| 234 return (size == pRanges[iSeg].m_CharSize) ? 2 : 1; | 234 return (size == pRanges[iSeg].m_CharSize) ? 2 : 1; |
| 235 iSeg--; | 235 iSeg--; |
| 236 } | 236 } |
| 237 return 0; | 237 return 0; |
| 238 } | 238 } |
| 239 | 239 |
| 240 int GetCharSizeImpl(FX_DWORD charcode, | 240 int GetCharSizeImpl(uint32_t charcode, |
| 241 CMap_CodeRange* pRanges, | 241 CMap_CodeRange* pRanges, |
| 242 int iRangesSize) { | 242 int iRangesSize) { |
| 243 if (!iRangesSize) | 243 if (!iRangesSize) |
| 244 return 1; | 244 return 1; |
| 245 | 245 |
| 246 uint8_t codes[4]; | 246 uint8_t codes[4]; |
| 247 codes[0] = codes[1] = 0x00; | 247 codes[0] = codes[1] = 0x00; |
| 248 codes[2] = (uint8_t)(charcode >> 8 & 0xFF); | 248 codes[2] = (uint8_t)(charcode >> 8 & 0xFF); |
| 249 codes[3] = (uint8_t)charcode; | 249 codes[3] = (uint8_t)charcode; |
| 250 int offset = 0; | 250 int offset = 0; |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 372 m_Status = 4; | 372 m_Status = 4; |
| 373 } else if (word == "/Supplement") { | 373 } else if (word == "/Supplement") { |
| 374 m_Status = 5; | 374 m_Status = 5; |
| 375 } else if (word == "begincodespacerange") { | 375 } else if (word == "begincodespacerange") { |
| 376 m_Status = 7; | 376 m_Status = 7; |
| 377 m_CodeSeq = 0; | 377 m_CodeSeq = 0; |
| 378 } else if (word == "usecmap") { | 378 } else if (word == "usecmap") { |
| 379 } else if (m_Status == 1 || m_Status == 2) { | 379 } else if (m_Status == 1 || m_Status == 2) { |
| 380 m_CodePoints[m_CodeSeq] = CMap_GetCode(word); | 380 m_CodePoints[m_CodeSeq] = CMap_GetCode(word); |
| 381 m_CodeSeq++; | 381 m_CodeSeq++; |
| 382 FX_DWORD StartCode, EndCode; | 382 uint32_t StartCode, EndCode; |
| 383 uint16_t StartCID; | 383 uint16_t StartCID; |
| 384 if (m_Status == 1) { | 384 if (m_Status == 1) { |
| 385 if (m_CodeSeq < 2) { | 385 if (m_CodeSeq < 2) { |
| 386 return; | 386 return; |
| 387 } | 387 } |
| 388 EndCode = StartCode = m_CodePoints[0]; | 388 EndCode = StartCode = m_CodePoints[0]; |
| 389 StartCID = (uint16_t)m_CodePoints[1]; | 389 StartCID = (uint16_t)m_CodePoints[1]; |
| 390 } else { | 390 } else { |
| 391 if (m_CodeSeq < 3) { | 391 if (m_CodeSeq < 3) { |
| 392 return; | 392 return; |
| 393 } | 393 } |
| 394 StartCode = m_CodePoints[0]; | 394 StartCode = m_CodePoints[0]; |
| 395 EndCode = m_CodePoints[1]; | 395 EndCode = m_CodePoints[1]; |
| 396 StartCID = (uint16_t)m_CodePoints[2]; | 396 StartCID = (uint16_t)m_CodePoints[2]; |
| 397 } | 397 } |
| 398 if (EndCode < 0x10000) { | 398 if (EndCode < 0x10000) { |
| 399 for (FX_DWORD code = StartCode; code <= EndCode; code++) { | 399 for (uint32_t code = StartCode; code <= EndCode; code++) { |
| 400 m_pCMap->m_pMapping[code] = (uint16_t)(StartCID + code - StartCode); | 400 m_pCMap->m_pMapping[code] = (uint16_t)(StartCID + code - StartCode); |
| 401 } | 401 } |
| 402 } else { | 402 } else { |
| 403 FX_DWORD buf[2]; | 403 uint32_t buf[2]; |
| 404 buf[0] = StartCode; | 404 buf[0] = StartCode; |
| 405 buf[1] = ((EndCode - StartCode) << 16) + StartCID; | 405 buf[1] = ((EndCode - StartCode) << 16) + StartCID; |
| 406 m_AddMaps.AppendBlock(buf, sizeof buf); | 406 m_AddMaps.AppendBlock(buf, sizeof buf); |
| 407 } | 407 } |
| 408 m_CodeSeq = 0; | 408 m_CodeSeq = 0; |
| 409 } else if (m_Status == 3) { | 409 } else if (m_Status == 3) { |
| 410 CMap_GetString(word); | 410 CMap_GetString(word); |
| 411 m_Status = 0; | 411 m_Status = 0; |
| 412 } else if (m_Status == 4) { | 412 } else if (m_Status == 4) { |
| 413 m_pCMap->m_Charset = CharsetFromOrdering(CMap_GetString(word)); | 413 m_pCMap->m_Charset = CharsetFromOrdering(CMap_GetString(word)); |
| (...skipping 30 matching lines...) Expand all Loading... |
| 444 m_CodeRanges.Add(range); | 444 m_CodeRanges.Add(range); |
| 445 } | 445 } |
| 446 } | 446 } |
| 447 m_CodeSeq++; | 447 m_CodeSeq++; |
| 448 } | 448 } |
| 449 } | 449 } |
| 450 m_LastWord = word; | 450 m_LastWord = word; |
| 451 } | 451 } |
| 452 | 452 |
| 453 // Static. | 453 // Static. |
| 454 FX_DWORD CPDF_CMapParser::CMap_GetCode(const CFX_ByteStringC& word) { | 454 uint32_t CPDF_CMapParser::CMap_GetCode(const CFX_ByteStringC& word) { |
| 455 int num = 0; | 455 int num = 0; |
| 456 if (word.GetAt(0) == '<') { | 456 if (word.GetAt(0) == '<') { |
| 457 for (int i = 1; i < word.GetLength() && std::isxdigit(word.GetAt(i)); ++i) | 457 for (int i = 1; i < word.GetLength() && std::isxdigit(word.GetAt(i)); ++i) |
| 458 num = num * 16 + FXSYS_toHexDigit(word.GetAt(i)); | 458 num = num * 16 + FXSYS_toHexDigit(word.GetAt(i)); |
| 459 return num; | 459 return num; |
| 460 } | 460 } |
| 461 | 461 |
| 462 for (int i = 0; i < word.GetLength() && std::isdigit(word.GetAt(i)); ++i) | 462 for (int i = 0; i < word.GetLength() && std::isdigit(word.GetAt(i)); ++i) |
| 463 num = num * 10 + FXSYS_toDecimalDigit(static_cast<FX_WCHAR>(word.GetAt(i))); | 463 num = num * 10 + FXSYS_toDecimalDigit(static_cast<FX_WCHAR>(word.GetAt(i))); |
| 464 return num; | 464 return num; |
| (...skipping 15 matching lines...) Expand all Loading... |
| 480 range.m_CharSize = (i - 1) / 2; | 480 range.m_CharSize = (i - 1) / 2; |
| 481 if (range.m_CharSize > 4) | 481 if (range.m_CharSize > 4) |
| 482 return false; | 482 return false; |
| 483 | 483 |
| 484 for (i = 0; i < range.m_CharSize; ++i) { | 484 for (i = 0; i < range.m_CharSize; ++i) { |
| 485 uint8_t digit1 = first.GetAt(i * 2 + 1); | 485 uint8_t digit1 = first.GetAt(i * 2 + 1); |
| 486 uint8_t digit2 = first.GetAt(i * 2 + 2); | 486 uint8_t digit2 = first.GetAt(i * 2 + 2); |
| 487 range.m_Lower[i] = FXSYS_toHexDigit(digit1) * 16 + FXSYS_toHexDigit(digit2); | 487 range.m_Lower[i] = FXSYS_toHexDigit(digit1) * 16 + FXSYS_toHexDigit(digit2); |
| 488 } | 488 } |
| 489 | 489 |
| 490 FX_DWORD size = second.GetLength(); | 490 uint32_t size = second.GetLength(); |
| 491 for (i = 0; i < range.m_CharSize; ++i) { | 491 for (i = 0; i < range.m_CharSize; ++i) { |
| 492 uint8_t digit1 = ((FX_DWORD)i * 2 + 1 < size) | 492 uint8_t digit1 = ((uint32_t)i * 2 + 1 < size) |
| 493 ? second.GetAt((FX_STRSIZE)i * 2 + 1) | 493 ? second.GetAt((FX_STRSIZE)i * 2 + 1) |
| 494 : '0'; | 494 : '0'; |
| 495 uint8_t digit2 = ((FX_DWORD)i * 2 + 2 < size) | 495 uint8_t digit2 = ((uint32_t)i * 2 + 2 < size) |
| 496 ? second.GetAt((FX_STRSIZE)i * 2 + 2) | 496 ? second.GetAt((FX_STRSIZE)i * 2 + 2) |
| 497 : '0'; | 497 : '0'; |
| 498 range.m_Upper[i] = FXSYS_toHexDigit(digit1) * 16 + FXSYS_toHexDigit(digit2); | 498 range.m_Upper[i] = FXSYS_toHexDigit(digit1) * 16 + FXSYS_toHexDigit(digit2); |
| 499 } | 499 } |
| 500 return true; | 500 return true; |
| 501 } | 501 } |
| 502 | 502 |
| 503 CPDF_CMap::CPDF_CMap() { | 503 CPDF_CMap::CPDF_CMap() { |
| 504 m_Charset = CIDSET_UNKNOWN; | 504 m_Charset = CIDSET_UNKNOWN; |
| 505 m_Coding = CIDCODING_UNKNOWN; | 505 m_Coding = CIDCODING_UNKNOWN; |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 548 } | 548 } |
| 549 } | 549 } |
| 550 if (!map) | 550 if (!map) |
| 551 return FALSE; | 551 return FALSE; |
| 552 | 552 |
| 553 m_Charset = map->m_Charset; | 553 m_Charset = map->m_Charset; |
| 554 m_Coding = map->m_Coding; | 554 m_Coding = map->m_Coding; |
| 555 m_CodingScheme = map->m_CodingScheme; | 555 m_CodingScheme = map->m_CodingScheme; |
| 556 if (m_CodingScheme == MixedTwoBytes) { | 556 if (m_CodingScheme == MixedTwoBytes) { |
| 557 m_pLeadingBytes = FX_Alloc(uint8_t, 256); | 557 m_pLeadingBytes = FX_Alloc(uint8_t, 256); |
| 558 for (FX_DWORD i = 0; i < map->m_LeadingSegCount; ++i) { | 558 for (uint32_t i = 0; i < map->m_LeadingSegCount; ++i) { |
| 559 const uint8_t* segs = map->m_LeadingSegs; | 559 const uint8_t* segs = map->m_LeadingSegs; |
| 560 for (int b = segs[i * 2]; b <= segs[i * 2 + 1]; ++b) { | 560 for (int b = segs[i * 2]; b <= segs[i * 2 + 1]; ++b) { |
| 561 m_pLeadingBytes[b] = 1; | 561 m_pLeadingBytes[b] = 1; |
| 562 } | 562 } |
| 563 } | 563 } |
| 564 } | 564 } |
| 565 FPDFAPI_FindEmbeddedCMap(pName, m_Charset, m_Coding, m_pEmbedMap); | 565 FPDFAPI_FindEmbeddedCMap(pName, m_Charset, m_Coding, m_pEmbedMap); |
| 566 if (m_pEmbedMap) { | 566 if (m_pEmbedMap) { |
| 567 m_bLoaded = TRUE; | 567 m_bLoaded = TRUE; |
| 568 return TRUE; | 568 return TRUE; |
| 569 } | 569 } |
| 570 return FALSE; | 570 return FALSE; |
| 571 } | 571 } |
| 572 FX_BOOL CPDF_CMap::LoadEmbedded(const uint8_t* pData, FX_DWORD size) { | 572 FX_BOOL CPDF_CMap::LoadEmbedded(const uint8_t* pData, uint32_t size) { |
| 573 m_pMapping = FX_Alloc(uint16_t, 65536); | 573 m_pMapping = FX_Alloc(uint16_t, 65536); |
| 574 CPDF_CMapParser parser; | 574 CPDF_CMapParser parser; |
| 575 parser.Initialize(this); | 575 parser.Initialize(this); |
| 576 CPDF_SimpleParser syntax(pData, size); | 576 CPDF_SimpleParser syntax(pData, size); |
| 577 while (1) { | 577 while (1) { |
| 578 CFX_ByteStringC word = syntax.GetWord(); | 578 CFX_ByteStringC word = syntax.GetWord(); |
| 579 if (word.IsEmpty()) { | 579 if (word.IsEmpty()) { |
| 580 break; | 580 break; |
| 581 } | 581 } |
| 582 parser.ParseWord(word); | 582 parser.ParseWord(word); |
| 583 } | 583 } |
| 584 if (m_CodingScheme == MixedFourBytes && parser.m_AddMaps.GetSize()) { | 584 if (m_CodingScheme == MixedFourBytes && parser.m_AddMaps.GetSize()) { |
| 585 m_pAddMapping = FX_Alloc(uint8_t, parser.m_AddMaps.GetSize() + 4); | 585 m_pAddMapping = FX_Alloc(uint8_t, parser.m_AddMaps.GetSize() + 4); |
| 586 *(FX_DWORD*)m_pAddMapping = parser.m_AddMaps.GetSize() / 8; | 586 *(uint32_t*)m_pAddMapping = parser.m_AddMaps.GetSize() / 8; |
| 587 FXSYS_memcpy(m_pAddMapping + 4, parser.m_AddMaps.GetBuffer(), | 587 FXSYS_memcpy(m_pAddMapping + 4, parser.m_AddMaps.GetBuffer(), |
| 588 parser.m_AddMaps.GetSize()); | 588 parser.m_AddMaps.GetSize()); |
| 589 FXSYS_qsort(m_pAddMapping + 4, parser.m_AddMaps.GetSize() / 8, 8, | 589 FXSYS_qsort(m_pAddMapping + 4, parser.m_AddMaps.GetSize() / 8, 8, |
| 590 CompareDWORD); | 590 CompareDWORD); |
| 591 } | 591 } |
| 592 return TRUE; | 592 return TRUE; |
| 593 } | 593 } |
| 594 | 594 |
| 595 uint16_t CPDF_CMap::CIDFromCharCode(FX_DWORD charcode) const { | 595 uint16_t CPDF_CMap::CIDFromCharCode(uint32_t charcode) const { |
| 596 if (m_Coding == CIDCODING_CID) { | 596 if (m_Coding == CIDCODING_CID) { |
| 597 return (uint16_t)charcode; | 597 return (uint16_t)charcode; |
| 598 } | 598 } |
| 599 if (m_pEmbedMap) { | 599 if (m_pEmbedMap) { |
| 600 return FPDFAPI_CIDFromCharCode(m_pEmbedMap, charcode); | 600 return FPDFAPI_CIDFromCharCode(m_pEmbedMap, charcode); |
| 601 } | 601 } |
| 602 if (!m_pMapping) { | 602 if (!m_pMapping) { |
| 603 return (uint16_t)charcode; | 603 return (uint16_t)charcode; |
| 604 } | 604 } |
| 605 if (charcode >> 16) { | 605 if (charcode >> 16) { |
| 606 if (m_pAddMapping) { | 606 if (m_pAddMapping) { |
| 607 void* found = FXSYS_bsearch(&charcode, m_pAddMapping + 4, | 607 void* found = FXSYS_bsearch(&charcode, m_pAddMapping + 4, |
| 608 *(FX_DWORD*)m_pAddMapping, 8, CompareCID); | 608 *(uint32_t*)m_pAddMapping, 8, CompareCID); |
| 609 if (!found) { | 609 if (!found) { |
| 610 if (m_pUseMap) { | 610 if (m_pUseMap) { |
| 611 return m_pUseMap->CIDFromCharCode(charcode); | 611 return m_pUseMap->CIDFromCharCode(charcode); |
| 612 } | 612 } |
| 613 return 0; | 613 return 0; |
| 614 } | 614 } |
| 615 return (uint16_t)(((FX_DWORD*)found)[1] % 65536 + charcode - | 615 return (uint16_t)(((uint32_t*)found)[1] % 65536 + charcode - |
| 616 *(FX_DWORD*)found); | 616 *(uint32_t*)found); |
| 617 } | 617 } |
| 618 if (m_pUseMap) | 618 if (m_pUseMap) |
| 619 return m_pUseMap->CIDFromCharCode(charcode); | 619 return m_pUseMap->CIDFromCharCode(charcode); |
| 620 return 0; | 620 return 0; |
| 621 } | 621 } |
| 622 FX_DWORD CID = m_pMapping[charcode]; | 622 uint32_t CID = m_pMapping[charcode]; |
| 623 if (!CID && m_pUseMap) | 623 if (!CID && m_pUseMap) |
| 624 return m_pUseMap->CIDFromCharCode(charcode); | 624 return m_pUseMap->CIDFromCharCode(charcode); |
| 625 return (uint16_t)CID; | 625 return (uint16_t)CID; |
| 626 } | 626 } |
| 627 | 627 |
| 628 FX_DWORD CPDF_CMap::GetNextChar(const FX_CHAR* pString, | 628 uint32_t CPDF_CMap::GetNextChar(const FX_CHAR* pString, |
| 629 int nStrLen, | 629 int nStrLen, |
| 630 int& offset) const { | 630 int& offset) const { |
| 631 switch (m_CodingScheme) { | 631 switch (m_CodingScheme) { |
| 632 case OneByte: | 632 case OneByte: |
| 633 return ((uint8_t*)pString)[offset++]; | 633 return ((uint8_t*)pString)[offset++]; |
| 634 case TwoBytes: | 634 case TwoBytes: |
| 635 offset += 2; | 635 offset += 2; |
| 636 return ((uint8_t*)pString)[offset - 2] * 256 + | 636 return ((uint8_t*)pString)[offset - 2] * 256 + |
| 637 ((uint8_t*)pString)[offset - 1]; | 637 ((uint8_t*)pString)[offset - 1]; |
| 638 case MixedTwoBytes: { | 638 case MixedTwoBytes: { |
| 639 uint8_t byte1 = ((uint8_t*)pString)[offset++]; | 639 uint8_t byte1 = ((uint8_t*)pString)[offset++]; |
| 640 if (!m_pLeadingBytes[byte1]) { | 640 if (!m_pLeadingBytes[byte1]) { |
| 641 return byte1; | 641 return byte1; |
| 642 } | 642 } |
| 643 uint8_t byte2 = ((uint8_t*)pString)[offset++]; | 643 uint8_t byte2 = ((uint8_t*)pString)[offset++]; |
| 644 return byte1 * 256 + byte2; | 644 return byte1 * 256 + byte2; |
| 645 } | 645 } |
| 646 case MixedFourBytes: { | 646 case MixedFourBytes: { |
| 647 uint8_t codes[4]; | 647 uint8_t codes[4]; |
| 648 int char_size = 1; | 648 int char_size = 1; |
| 649 codes[0] = ((uint8_t*)pString)[offset++]; | 649 codes[0] = ((uint8_t*)pString)[offset++]; |
| 650 CMap_CodeRange* pRanges = (CMap_CodeRange*)m_pLeadingBytes; | 650 CMap_CodeRange* pRanges = (CMap_CodeRange*)m_pLeadingBytes; |
| 651 while (1) { | 651 while (1) { |
| 652 int ret = CheckCodeRange(codes, char_size, pRanges, m_nCodeRanges); | 652 int ret = CheckCodeRange(codes, char_size, pRanges, m_nCodeRanges); |
| 653 if (ret == 0) { | 653 if (ret == 0) { |
| 654 return 0; | 654 return 0; |
| 655 } | 655 } |
| 656 if (ret == 2) { | 656 if (ret == 2) { |
| 657 FX_DWORD charcode = 0; | 657 uint32_t charcode = 0; |
| 658 for (int i = 0; i < char_size; i++) { | 658 for (int i = 0; i < char_size; i++) { |
| 659 charcode = (charcode << 8) + codes[i]; | 659 charcode = (charcode << 8) + codes[i]; |
| 660 } | 660 } |
| 661 return charcode; | 661 return charcode; |
| 662 } | 662 } |
| 663 if (char_size == 4 || offset == nStrLen) { | 663 if (char_size == 4 || offset == nStrLen) { |
| 664 return 0; | 664 return 0; |
| 665 } | 665 } |
| 666 codes[char_size++] = ((uint8_t*)pString)[offset++]; | 666 codes[char_size++] = ((uint8_t*)pString)[offset++]; |
| 667 } | 667 } |
| 668 break; | 668 break; |
| 669 } | 669 } |
| 670 } | 670 } |
| 671 return 0; | 671 return 0; |
| 672 } | 672 } |
| 673 int CPDF_CMap::GetCharSize(FX_DWORD charcode) const { | 673 int CPDF_CMap::GetCharSize(uint32_t charcode) const { |
| 674 switch (m_CodingScheme) { | 674 switch (m_CodingScheme) { |
| 675 case OneByte: | 675 case OneByte: |
| 676 return 1; | 676 return 1; |
| 677 case TwoBytes: | 677 case TwoBytes: |
| 678 return 2; | 678 return 2; |
| 679 case MixedTwoBytes: | 679 case MixedTwoBytes: |
| 680 case MixedFourBytes: | 680 case MixedFourBytes: |
| 681 if (charcode < 0x100) { | 681 if (charcode < 0x100) { |
| 682 return 1; | 682 return 1; |
| 683 } | 683 } |
| (...skipping 28 matching lines...) Expand all Loading... |
| 712 while (offset < size) { | 712 while (offset < size) { |
| 713 GetNextChar(pString, size, offset); | 713 GetNextChar(pString, size, offset); |
| 714 count++; | 714 count++; |
| 715 } | 715 } |
| 716 return count; | 716 return count; |
| 717 } | 717 } |
| 718 } | 718 } |
| 719 return size; | 719 return size; |
| 720 } | 720 } |
| 721 | 721 |
| 722 int CPDF_CMap::AppendChar(FX_CHAR* str, FX_DWORD charcode) const { | 722 int CPDF_CMap::AppendChar(FX_CHAR* str, uint32_t charcode) const { |
| 723 switch (m_CodingScheme) { | 723 switch (m_CodingScheme) { |
| 724 case OneByte: | 724 case OneByte: |
| 725 str[0] = (uint8_t)charcode; | 725 str[0] = (uint8_t)charcode; |
| 726 return 1; | 726 return 1; |
| 727 case TwoBytes: | 727 case TwoBytes: |
| 728 str[0] = (uint8_t)(charcode / 256); | 728 str[0] = (uint8_t)(charcode / 256); |
| 729 str[1] = (uint8_t)(charcode % 256); | 729 str[1] = (uint8_t)(charcode % 256); |
| 730 return 2; | 730 return 2; |
| 731 case MixedTwoBytes: | 731 case MixedTwoBytes: |
| 732 case MixedFourBytes: | 732 case MixedFourBytes: |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 788 FPDFAPI_LoadCID2UnicodeMap(charset, m_pEmbeddedMap, m_EmbeddedCount); | 788 FPDFAPI_LoadCID2UnicodeMap(charset, m_pEmbeddedMap, m_EmbeddedCount); |
| 789 } | 789 } |
| 790 | 790 |
| 791 CIDSet CharsetFromOrdering(const CFX_ByteString& ordering) { | 791 CIDSet CharsetFromOrdering(const CFX_ByteString& ordering) { |
| 792 for (size_t charset = 1; charset < FX_ArraySize(g_CharsetNames); ++charset) { | 792 for (size_t charset = 1; charset < FX_ArraySize(g_CharsetNames); ++charset) { |
| 793 if (ordering == CFX_ByteStringC(g_CharsetNames[charset])) | 793 if (ordering == CFX_ByteStringC(g_CharsetNames[charset])) |
| 794 return CIDSetFromSizeT(charset); | 794 return CIDSetFromSizeT(charset); |
| 795 } | 795 } |
| 796 return CIDSET_UNKNOWN; | 796 return CIDSET_UNKNOWN; |
| 797 } | 797 } |
| OLD | NEW |