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

Side by Side Diff: core/fpdfapi/fpdf_font/cpdf_cidfont.cpp

Issue 2367743003: Clean CPDF_CIDFont a little (Closed)
Patch Set: Evil winbots Created 4 years, 2 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 | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 <algorithm> 9 #include <algorithm>
10 #include <vector> 10 #include <vector>
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 } 132 }
133 133
134 FX_WCHAR EmbeddedUnicodeFromCharcode(const FXCMAP_CMap* pEmbedMap, 134 FX_WCHAR EmbeddedUnicodeFromCharcode(const FXCMAP_CMap* pEmbedMap,
135 CIDSet charset, 135 CIDSet charset,
136 uint32_t charcode) { 136 uint32_t charcode) {
137 if (!IsValidEmbeddedCharcodeFromUnicodeCharset(charset)) 137 if (!IsValidEmbeddedCharcodeFromUnicodeCharset(charset))
138 return 0; 138 return 0;
139 139
140 uint16_t cid = FPDFAPI_CIDFromCharCode(pEmbedMap, charcode); 140 uint16_t cid = FPDFAPI_CIDFromCharCode(pEmbedMap, charcode);
141 const auto& codes = GetFontGlobals()->m_EmbeddedToUnicodes[charset]; 141 const auto& codes = GetFontGlobals()->m_EmbeddedToUnicodes[charset];
142 return codes.m_pMap && cid && cid < codes.m_Count ? codes.m_pMap[cid] : 0; 142 if (codes.m_pMap && cid && cid < codes.m_Count)
143 return codes.m_pMap[cid];
144 return 0;
143 } 145 }
144 146
145 uint32_t EmbeddedCharcodeFromUnicode(const FXCMAP_CMap* pEmbedMap, 147 uint32_t EmbeddedCharcodeFromUnicode(const FXCMAP_CMap* pEmbedMap,
146 CIDSet charset, 148 CIDSet charset,
147 FX_WCHAR unicode) { 149 FX_WCHAR unicode) {
148 if (!IsValidEmbeddedCharcodeFromUnicodeCharset(charset)) 150 if (!IsValidEmbeddedCharcodeFromUnicodeCharset(charset))
149 return 0; 151 return 0;
150 152
151 const auto& codes = GetFontGlobals()->m_EmbeddedToUnicodes[charset]; 153 const auto& codes = GetFontGlobals()->m_EmbeddedToUnicodes[charset];
152 const uint16_t* pCodes = codes.m_pMap; 154 const uint16_t* pCodes = codes.m_pMap;
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
234 if (!str.IsEmpty()) 236 if (!str.IsEmpty())
235 return str; 237 return str;
236 FX_WCHAR ret = GetUnicodeFromCharCode(charcode); 238 FX_WCHAR ret = GetUnicodeFromCharCode(charcode);
237 return ret ? ret : CFX_WideString(); 239 return ret ? ret : CFX_WideString();
238 } 240 }
239 241
240 FX_WCHAR CPDF_CIDFont::GetUnicodeFromCharCode(uint32_t charcode) const { 242 FX_WCHAR CPDF_CIDFont::GetUnicodeFromCharCode(uint32_t charcode) const {
241 switch (m_pCMap->m_Coding) { 243 switch (m_pCMap->m_Coding) {
242 case CIDCODING_UCS2: 244 case CIDCODING_UCS2:
243 case CIDCODING_UTF16: 245 case CIDCODING_UTF16:
244 return (FX_WCHAR)charcode; 246 return static_cast<FX_WCHAR>(charcode);
245 case CIDCODING_CID: 247 case CIDCODING_CID:
246 if (!m_pCID2UnicodeMap || !m_pCID2UnicodeMap->IsLoaded()) 248 if (!m_pCID2UnicodeMap || !m_pCID2UnicodeMap->IsLoaded())
247 return 0; 249 return 0;
248 return m_pCID2UnicodeMap->UnicodeFromCID((uint16_t)charcode); 250 return m_pCID2UnicodeMap->UnicodeFromCID(static_cast<uint16_t>(charcode));
249 } 251 }
250 if (m_pCID2UnicodeMap && m_pCID2UnicodeMap->IsLoaded() && m_pCMap->IsLoaded()) 252 if (m_pCID2UnicodeMap && m_pCID2UnicodeMap->IsLoaded() && m_pCMap->IsLoaded())
251 return m_pCID2UnicodeMap->UnicodeFromCID(CIDFromCharCode(charcode)); 253 return m_pCID2UnicodeMap->UnicodeFromCID(CIDFromCharCode(charcode));
252 254
253 #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ 255 #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_
254 FX_WCHAR unicode; 256 FX_WCHAR unicode;
255 int charsize = 1; 257 int charsize = 1;
256 if (charcode > 255) { 258 if (charcode > 255) {
257 charcode = (charcode % 256) * 256 + (charcode / 256); 259 charcode = (charcode % 256) * 256 + (charcode / 256);
258 charsize = 2; 260 charsize = 2;
259 } 261 }
260 int ret = FXSYS_MultiByteToWideChar(g_CharsetCPs[m_pCMap->m_Coding], 0, 262 int ret = FXSYS_MultiByteToWideChar(
261 (const FX_CHAR*)&charcode, charsize, 263 g_CharsetCPs[m_pCMap->m_Coding], 0,
262 &unicode, 1); 264 reinterpret_cast<const FX_CHAR*>(&charcode), charsize, &unicode, 1);
263 return ret == 1 ? unicode : 0; 265 return ret == 1 ? unicode : 0;
264 #else 266 #else
265 if (!m_pCMap->m_pEmbedMap) 267 if (!m_pCMap->m_pEmbedMap)
266 return 0; 268 return 0;
267 return EmbeddedUnicodeFromCharcode(m_pCMap->m_pEmbedMap, m_pCMap->m_Charset, 269 return EmbeddedUnicodeFromCharcode(m_pCMap->m_pEmbedMap, m_pCMap->m_Charset,
268 charcode); 270 charcode);
269 #endif 271 #endif
270 } 272 }
271 273
272 uint32_t CPDF_CIDFont::CharCodeFromUnicode(FX_WCHAR unicode) const { 274 uint32_t CPDF_CIDFont::CharCodeFromUnicode(FX_WCHAR unicode) const {
273 uint32_t charcode = CPDF_Font::CharCodeFromUnicode(unicode); 275 uint32_t charcode = CPDF_Font::CharCodeFromUnicode(unicode);
274 if (charcode) 276 if (charcode)
275 return charcode; 277 return charcode;
276 switch (m_pCMap->m_Coding) { 278 switch (m_pCMap->m_Coding) {
277 case CIDCODING_UNKNOWN: 279 case CIDCODING_UNKNOWN:
278 return 0; 280 return 0;
279 case CIDCODING_UCS2: 281 case CIDCODING_UCS2:
280 case CIDCODING_UTF16: 282 case CIDCODING_UTF16:
281 return unicode; 283 return unicode;
282 case CIDCODING_CID: { 284 case CIDCODING_CID: {
283 if (!m_pCID2UnicodeMap || !m_pCID2UnicodeMap->IsLoaded()) { 285 if (!m_pCID2UnicodeMap || !m_pCID2UnicodeMap->IsLoaded())
284 return 0; 286 return 0;
285 }
286 uint32_t CID = 0; 287 uint32_t CID = 0;
287 while (CID < 65536) { 288 while (CID < 65536) {
288 FX_WCHAR this_unicode = 289 FX_WCHAR this_unicode =
289 m_pCID2UnicodeMap->UnicodeFromCID((uint16_t)CID); 290 m_pCID2UnicodeMap->UnicodeFromCID(static_cast<uint16_t>(CID));
290 if (this_unicode == unicode) { 291 if (this_unicode == unicode)
291 return CID; 292 return CID;
292 }
293 CID++; 293 CID++;
294 } 294 }
295 break; 295 break;
296 } 296 }
297 } 297 }
298 298
299 if (unicode < 0x80) { 299 if (unicode < 0x80)
300 return static_cast<uint32_t>(unicode); 300 return static_cast<uint32_t>(unicode);
301 } 301 if (m_pCMap->m_Coding == CIDCODING_CID)
302 if (m_pCMap->m_Coding == CIDCODING_CID) {
303 return 0; 302 return 0;
304 }
305 #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ 303 #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_
306 uint8_t buffer[32]; 304 uint8_t buffer[32];
307 int ret = 305 int ret = FXSYS_WideCharToMultiByte(
308 FXSYS_WideCharToMultiByte(g_CharsetCPs[m_pCMap->m_Coding], 0, &unicode, 1, 306 g_CharsetCPs[m_pCMap->m_Coding], 0, &unicode, 1,
309 (char*)buffer, 4, nullptr, nullptr); 307 reinterpret_cast<char*>(buffer), 4, nullptr, nullptr);
310 if (ret == 1) { 308 if (ret == 1)
311 return buffer[0]; 309 return buffer[0];
312 } 310 if (ret == 2)
313 if (ret == 2) {
314 return buffer[0] * 256 + buffer[1]; 311 return buffer[0] * 256 + buffer[1];
315 }
316 #else 312 #else
317 if (m_pCMap->m_pEmbedMap) { 313 if (m_pCMap->m_pEmbedMap) {
318 return EmbeddedCharcodeFromUnicode(m_pCMap->m_pEmbedMap, m_pCMap->m_Charset, 314 return EmbeddedCharcodeFromUnicode(m_pCMap->m_pEmbedMap, m_pCMap->m_Charset,
319 unicode); 315 unicode);
320 } 316 }
321 #endif 317 #endif
322 return 0; 318 return 0;
323 } 319 }
324 320
325 FX_BOOL CPDF_CIDFont::Load() { 321 FX_BOOL CPDF_CIDFont::Load() {
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
399 LoadSubstFont(); 395 LoadSubstFont();
400 396
401 if (m_pFontFile || (GetSubstFont()->m_SubstFlags & FXFONT_SUBST_EXACT)) { 397 if (m_pFontFile || (GetSubstFont()->m_SubstFlags & FXFONT_SUBST_EXACT)) {
402 CPDF_Object* pmap = pCIDFontDict->GetDirectObjectFor("CIDToGIDMap"); 398 CPDF_Object* pmap = pCIDFontDict->GetDirectObjectFor("CIDToGIDMap");
403 if (pmap) { 399 if (pmap) {
404 if (CPDF_Stream* pStream = pmap->AsStream()) { 400 if (CPDF_Stream* pStream = pmap->AsStream()) {
405 m_pStreamAcc.reset(new CPDF_StreamAcc); 401 m_pStreamAcc.reset(new CPDF_StreamAcc);
406 m_pStreamAcc->LoadAllData(pStream, FALSE); 402 m_pStreamAcc->LoadAllData(pStream, FALSE);
407 } else if (pmap->GetString() == "Identity") { 403 } else if (pmap->GetString() == "Identity") {
408 #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ 404 #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_
409 if (m_pFontFile) { 405 if (m_pFontFile)
410 m_bCIDIsGID = true; 406 m_bCIDIsGID = true;
411 }
412 #else 407 #else
413 m_bCIDIsGID = true; 408 m_bCIDIsGID = true;
414 #endif 409 #endif
415 } 410 }
416 } 411 }
417 } 412 }
418 413
419 CheckFontMetrics(); 414 CheckFontMetrics();
420 if (IsVertWriting()) { 415 if (IsVertWriting()) {
421 pWidthArray = pCIDFontDict->GetArrayFor("W2"); 416 pWidthArray = pCIDFontDict->GetArrayFor("W2");
422 if (pWidthArray) { 417 if (pWidthArray)
423 LoadMetricsArray(pWidthArray, m_VertMetrics, 3); 418 LoadMetricsArray(pWidthArray, m_VertMetrics, 3);
424 }
425 CPDF_Array* pDefaultArray = pCIDFontDict->GetArrayFor("DW2"); 419 CPDF_Array* pDefaultArray = pCIDFontDict->GetArrayFor("DW2");
426 if (pDefaultArray) { 420 if (pDefaultArray) {
427 m_DefaultVY = pDefaultArray->GetIntegerAt(0); 421 m_DefaultVY = pDefaultArray->GetIntegerAt(0);
428 m_DefaultW1 = pDefaultArray->GetIntegerAt(1); 422 m_DefaultW1 = pDefaultArray->GetIntegerAt(1);
429 } else { 423 } else {
430 m_DefaultVY = 880; 424 m_DefaultVY = 880;
431 m_DefaultW1 = -1000; 425 m_DefaultW1 = -1000;
432 } 426 }
433 } 427 }
434 return TRUE; 428 return TRUE;
(...skipping 20 matching lines...) Expand all
455 int pixel_size_x = ((FXFT_Face)face)->size->metrics.x_ppem; 449 int pixel_size_x = ((FXFT_Face)face)->size->metrics.x_ppem;
456 int pixel_size_y = ((FXFT_Face)face)->size->metrics.y_ppem; 450 int pixel_size_y = ((FXFT_Face)face)->size->metrics.y_ppem;
457 if (pixel_size_x == 0 || pixel_size_y == 0) { 451 if (pixel_size_x == 0 || pixel_size_y == 0) {
458 rect = FX_RECT(cbox.xMin, cbox.yMax, cbox.xMax, cbox.yMin); 452 rect = FX_RECT(cbox.xMin, cbox.yMax, cbox.xMax, cbox.yMin);
459 } else { 453 } else {
460 rect = FX_RECT(cbox.xMin * 1000 / pixel_size_x, 454 rect = FX_RECT(cbox.xMin * 1000 / pixel_size_x,
461 cbox.yMax * 1000 / pixel_size_y, 455 cbox.yMax * 1000 / pixel_size_y,
462 cbox.xMax * 1000 / pixel_size_x, 456 cbox.xMax * 1000 / pixel_size_x,
463 cbox.yMin * 1000 / pixel_size_y); 457 cbox.yMin * 1000 / pixel_size_y);
464 } 458 }
465 if (rect.top > FXFT_Get_Face_Ascender(face)) { 459 rect.top = std::min(rect.top,
466 rect.top = FXFT_Get_Face_Ascender(face); 460 static_cast<int>(FXFT_Get_Face_Ascender(face)));
467 } 461 rect.bottom = std::max(
468 if (rect.bottom < FXFT_Get_Face_Descender(face)) { 462 rect.bottom, static_cast<int>(FXFT_Get_Face_Descender(face)));
469 rect.bottom = FXFT_Get_Face_Descender(face);
470 }
471 FXFT_Done_Glyph(glyph); 463 FXFT_Done_Glyph(glyph);
472 } 464 }
473 } 465 }
474 } else { 466 } else {
475 int err = FXFT_Load_Glyph(face, glyph_index, FXFT_LOAD_NO_SCALE); 467 int err = FXFT_Load_Glyph(face, glyph_index, FXFT_LOAD_NO_SCALE);
476 if (err == 0) { 468 if (err == 0) {
477 rect = FX_RECT(TT2PDF(FXFT_Get_Glyph_HoriBearingX(face), face), 469 rect = FX_RECT(TT2PDF(FXFT_Get_Glyph_HoriBearingX(face), face),
478 TT2PDF(FXFT_Get_Glyph_HoriBearingY(face), face), 470 TT2PDF(FXFT_Get_Glyph_HoriBearingY(face), face),
479 TT2PDF(FXFT_Get_Glyph_HoriBearingX(face) + 471 TT2PDF(FXFT_Get_Glyph_HoriBearingX(face) +
480 FXFT_Get_Glyph_Width(face), 472 FXFT_Get_Glyph_Width(face),
(...skipping 21 matching lines...) Expand all
502 } 494 }
503 } 495 }
504 if (charcode < 256) 496 if (charcode < 256)
505 m_CharBBox[charcode] = rect; 497 m_CharBBox[charcode] = rect;
506 498
507 return rect; 499 return rect;
508 } 500 }
509 501
510 int CPDF_CIDFont::GetCharWidthF(uint32_t charcode, int level) { 502 int CPDF_CIDFont::GetCharWidthF(uint32_t charcode, int level) {
511 if (charcode < 0x80 && m_bAnsiWidthsFixed) 503 if (charcode < 0x80 && m_bAnsiWidthsFixed)
512 return charcode >= 32 && charcode < 127 ? 500 : 0; 504 return (charcode >= 32 && charcode < 127) ? 500 : 0;
513 505
514 uint16_t cid = CIDFromCharCode(charcode); 506 uint16_t cid = CIDFromCharCode(charcode);
515 int size = m_WidthList.GetSize(); 507 int size = m_WidthList.GetSize();
516 const uint32_t* pList = m_WidthList.GetData(); 508 const uint32_t* pList = m_WidthList.GetData();
517 for (int i = 0; i < size; i += 3) { 509 for (int i = 0; i < size; i += 3) {
518 const uint32_t* pEntry = pList + i; 510 const uint32_t* pEntry = pList + i;
519 if (IsMetricForCID(pEntry, cid)) 511 if (IsMetricForCID(pEntry, cid))
520 return static_cast<int>(pEntry[2]); 512 return static_cast<int>(pEntry[2]);
521 } 513 }
522 return m_DefaultWidth; 514 return m_DefaultWidth;
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
639 } 631 }
640 FXFT_Face face = m_Font.GetFace(); 632 FXFT_Face face = m_Font.GetFace();
641 if (unicode == 0) { 633 if (unicode == 0) {
642 if (!m_bAdobeCourierStd) 634 if (!m_bAdobeCourierStd)
643 return charcode ? static_cast<int>(charcode) : -1; 635 return charcode ? static_cast<int>(charcode) : -1;
644 636
645 charcode += 31; 637 charcode += 31;
646 bool bMSUnicode = FT_UseTTCharmap(face, 3, 1); 638 bool bMSUnicode = FT_UseTTCharmap(face, 3, 1);
647 bool bMacRoman = !bMSUnicode && FT_UseTTCharmap(face, 1, 0); 639 bool bMacRoman = !bMSUnicode && FT_UseTTCharmap(face, 1, 0);
648 int iBaseEncoding = PDFFONT_ENCODING_STANDARD; 640 int iBaseEncoding = PDFFONT_ENCODING_STANDARD;
649 if (bMSUnicode) { 641 if (bMSUnicode)
650 iBaseEncoding = PDFFONT_ENCODING_WINANSI; 642 iBaseEncoding = PDFFONT_ENCODING_WINANSI;
651 } else if (bMacRoman) { 643 else if (bMacRoman)
652 iBaseEncoding = PDFFONT_ENCODING_MACROMAN; 644 iBaseEncoding = PDFFONT_ENCODING_MACROMAN;
653 }
654 const FX_CHAR* name = GetAdobeCharName( 645 const FX_CHAR* name = GetAdobeCharName(
655 iBaseEncoding, std::vector<CFX_ByteString>(), charcode); 646 iBaseEncoding, std::vector<CFX_ByteString>(), charcode);
656 if (!name) 647 if (!name)
657 return charcode ? static_cast<int>(charcode) : -1; 648 return charcode ? static_cast<int>(charcode) : -1;
658 649
659 int index = 0; 650 int index = 0;
660 uint16_t name_unicode = PDF_UnicodeFromAdobeName(name); 651 uint16_t name_unicode = PDF_UnicodeFromAdobeName(name);
661 if (!name_unicode) 652 if (!name_unicode)
662 return charcode ? static_cast<int>(charcode) : -1; 653 return charcode ? static_cast<int>(charcode) : -1;
663 654
(...skipping 24 matching lines...) Expand all
688 } 679 }
689 if (!face) 680 if (!face)
690 return unicode; 681 return unicode;
691 682
692 int err = FXFT_Select_Charmap(face, FXFT_ENCODING_UNICODE); 683 int err = FXFT_Select_Charmap(face, FXFT_ENCODING_UNICODE);
693 if (err) { 684 if (err) {
694 int i; 685 int i;
695 for (i = 0; i < FXFT_Get_Face_CharmapCount(face); i++) { 686 for (i = 0; i < FXFT_Get_Face_CharmapCount(face); i++) {
696 uint32_t ret = FT_CharCodeFromUnicode( 687 uint32_t ret = FT_CharCodeFromUnicode(
697 FXFT_Get_Charmap_Encoding(FXFT_Get_Face_Charmaps(face)[i]), 688 FXFT_Get_Charmap_Encoding(FXFT_Get_Face_Charmaps(face)[i]),
698 (FX_WCHAR)charcode); 689 static_cast<FX_WCHAR>(charcode));
699 if (ret == 0) { 690 if (ret == 0)
700 continue; 691 continue;
701 }
702 FXFT_Set_Charmap(face, FXFT_Get_Face_Charmaps(face)[i]); 692 FXFT_Set_Charmap(face, FXFT_Get_Face_Charmaps(face)[i]);
703 unicode = (FX_WCHAR)ret; 693 unicode = static_cast<FX_WCHAR>(ret);
704 break; 694 break;
705 } 695 }
706 if (i == FXFT_Get_Face_CharmapCount(face) && i) { 696 if (i == FXFT_Get_Face_CharmapCount(face) && i) {
707 FXFT_Set_Charmap(face, FXFT_Get_Face_Charmaps(face)[0]); 697 FXFT_Set_Charmap(face, FXFT_Get_Face_Charmaps(face)[0]);
708 unicode = (FX_WCHAR)charcode; 698 unicode = static_cast<FX_WCHAR>(charcode);
709 } 699 }
710 } 700 }
711 if (FXFT_Get_Face_Charmap(face)) { 701 if (FXFT_Get_Face_Charmap(face)) {
712 int index = GetGlyphIndex(unicode, pVertGlyph); 702 int index = GetGlyphIndex(unicode, pVertGlyph);
713 return index != 0 ? index : -1; 703 return index != 0 ? index : -1;
714 } 704 }
715 return unicode; 705 return unicode;
716 } 706 }
717 707
718 if (!m_Font.GetFace()) 708 if (!m_Font.GetFace())
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
811 last_code = pObj->GetInteger(); 801 last_code = pObj->GetInteger();
812 width_status = 2; 802 width_status = 2;
813 iCurElement = 0; 803 iCurElement = 0;
814 } else { 804 } else {
815 if (!iCurElement) { 805 if (!iCurElement) {
816 result.Add(first_code); 806 result.Add(first_code);
817 result.Add(last_code); 807 result.Add(last_code);
818 } 808 }
819 result.Add(pObj->GetInteger()); 809 result.Add(pObj->GetInteger());
820 iCurElement++; 810 iCurElement++;
821 if (iCurElement == nElements) { 811 if (iCurElement == nElements)
822 width_status = 0; 812 width_status = 0;
823 }
824 } 813 }
825 } 814 }
826 } 815 }
827 } 816 }
828 817
829 // static 818 // static
830 FX_FLOAT CPDF_CIDFont::CIDTransformToFloat(uint8_t ch) { 819 FX_FLOAT CPDF_CIDFont::CIDTransformToFloat(uint8_t ch) {
831 return (ch < 128 ? ch : ch - 255) * (1.0f / 127); 820 return (ch < 128 ? ch : ch - 255) * (1.0f / 127);
832 } 821 }
833 822
(...skipping 17 matching lines...) Expand all
851 } 840 }
852 841
853 const uint8_t* CPDF_CIDFont::GetCIDTransform(uint16_t CID) const { 842 const uint8_t* CPDF_CIDFont::GetCIDTransform(uint16_t CID) const {
854 if (m_Charset != CIDSET_JAPAN1 || m_pFontFile) 843 if (m_Charset != CIDSET_JAPAN1 || m_pFontFile)
855 return nullptr; 844 return nullptr;
856 845
857 const auto* pEnd = g_Japan1_VertCIDs + FX_ArraySize(g_Japan1_VertCIDs); 846 const auto* pEnd = g_Japan1_VertCIDs + FX_ArraySize(g_Japan1_VertCIDs);
858 const auto* pTransform = std::lower_bound( 847 const auto* pTransform = std::lower_bound(
859 g_Japan1_VertCIDs, pEnd, CID, 848 g_Japan1_VertCIDs, pEnd, CID,
860 [](const CIDTransform& entry, uint16_t cid) { return entry.cid < cid; }); 849 [](const CIDTransform& entry, uint16_t cid) { return entry.cid < cid; });
861 return pTransform < pEnd && CID == pTransform->cid ? &pTransform->a : nullptr; 850 return (pTransform < pEnd && CID == pTransform->cid) ? &pTransform->a
851 : nullptr;
862 } 852 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698