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 "../../../include/fxge/fx_ge.h" | 7 #include "../../../include/fxge/fx_ge.h" |
8 #include "../../../include/fpdfapi/fpdf_render.h" | 8 #include "../../../include/fpdfapi/fpdf_render.h" |
9 #include "../../../include/fpdfapi/fpdf_pageobj.h" | 9 #include "../../../include/fpdfapi/fpdf_pageobj.h" |
10 #include "../fpdf_page/pageint.h" | 10 #include "../fpdf_page/pageint.h" |
(...skipping 15 matching lines...) Expand all Loading... |
26 _CPDF_UniqueKeyGen keygen; | 26 _CPDF_UniqueKeyGen keygen; |
27 keygen.Generate(4, FXSYS_round(pMatrix->a * 10000), FXSYS_round(pMatrix->b *
10000), | 27 keygen.Generate(4, FXSYS_round(pMatrix->a * 10000), FXSYS_round(pMatrix->b *
10000), |
28 FXSYS_round(pMatrix->c * 10000), FXSYS_round(pMatrix->d * 10
000)); | 28 FXSYS_round(pMatrix->c * 10000), FXSYS_round(pMatrix->d * 10
000)); |
29 CFX_ByteStringC FaceGlyphsKey(keygen.m_Key, keygen.m_KeyLen); | 29 CFX_ByteStringC FaceGlyphsKey(keygen.m_Key, keygen.m_KeyLen); |
30 CPDF_Type3Glyphs* pSizeCache = NULL; | 30 CPDF_Type3Glyphs* pSizeCache = NULL; |
31 if(!m_SizeMap.Lookup(FaceGlyphsKey, (void*&)pSizeCache)) { | 31 if(!m_SizeMap.Lookup(FaceGlyphsKey, (void*&)pSizeCache)) { |
32 pSizeCache = new CPDF_Type3Glyphs; | 32 pSizeCache = new CPDF_Type3Glyphs; |
33 m_SizeMap.SetAt(FaceGlyphsKey, pSizeCache); | 33 m_SizeMap.SetAt(FaceGlyphsKey, pSizeCache); |
34 } | 34 } |
35 CFX_GlyphBitmap* pGlyphBitmap; | 35 CFX_GlyphBitmap* pGlyphBitmap; |
36 if(pSizeCache->m_GlyphMap.Lookup((FX_LPVOID)(FX_UINTPTR)charcode, (void*&)pG
lyphBitmap)) { | 36 if(pSizeCache->m_GlyphMap.Lookup((FX_LPVOID)(uintptr_t)charcode, (void*&)pGl
yphBitmap)) { |
37 return pGlyphBitmap; | 37 return pGlyphBitmap; |
38 } | 38 } |
39 pGlyphBitmap = RenderGlyph(pSizeCache, charcode, pMatrix, retinaScaleX, reti
naScaleY); | 39 pGlyphBitmap = RenderGlyph(pSizeCache, charcode, pMatrix, retinaScaleX, reti
naScaleY); |
40 pSizeCache->m_GlyphMap.SetAt((FX_LPVOID)(FX_UINTPTR)charcode, pGlyphBitmap); | 40 pSizeCache->m_GlyphMap.SetAt((FX_LPVOID)(uintptr_t)charcode, pGlyphBitmap); |
41 return pGlyphBitmap; | 41 return pGlyphBitmap; |
42 } | 42 } |
43 CPDF_Type3Glyphs::~CPDF_Type3Glyphs() | 43 CPDF_Type3Glyphs::~CPDF_Type3Glyphs() |
44 { | 44 { |
45 FX_POSITION pos = m_GlyphMap.GetStartPosition(); | 45 FX_POSITION pos = m_GlyphMap.GetStartPosition(); |
46 FX_LPVOID Key; | 46 FX_LPVOID Key; |
47 CFX_GlyphBitmap* pGlyphBitmap; | 47 CFX_GlyphBitmap* pGlyphBitmap; |
48 while(pos) { | 48 while(pos) { |
49 m_GlyphMap.GetNextAssoc(pos, Key, (void*&)pGlyphBitmap); | 49 m_GlyphMap.GetNextAssoc(pos, Key, (void*&)pGlyphBitmap); |
50 delete pGlyphBitmap; | 50 delete pGlyphBitmap; |
(...skipping 454 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
505 } | 505 } |
506 class CPDF_CharPosList | 506 class CPDF_CharPosList |
507 { | 507 { |
508 public: | 508 public: |
509 CPDF_CharPosList(); | 509 CPDF_CharPosList(); |
510 ~CPDF_CharPosList(); | 510 ~CPDF_CharPosList(); |
511 void Load(int nChars, FX_DWORD* pCharCodes, F
X_FLOAT* pCharPos, CPDF_Font* pFont, FX_FLOAT font_size); | 511 void Load(int nChars, FX_DWORD* pCharCodes, F
X_FLOAT* pCharPos, CPDF_Font* pFont, FX_FLOAT font_size); |
512 FXTEXT_CHARPOS* m_pCharPos; | 512 FXTEXT_CHARPOS* m_pCharPos; |
513 FX_DWORD m_nChars; | 513 FX_DWORD m_nChars; |
514 }; | 514 }; |
515 FX_FLOAT _CIDTransformToFloat(FX_BYTE ch); | 515 FX_FLOAT _CIDTransformToFloat(uint8_t ch); |
516 CPDF_CharPosList::CPDF_CharPosList() | 516 CPDF_CharPosList::CPDF_CharPosList() |
517 { | 517 { |
518 m_pCharPos = NULL; | 518 m_pCharPos = NULL; |
519 } | 519 } |
520 CPDF_CharPosList::~CPDF_CharPosList() | 520 CPDF_CharPosList::~CPDF_CharPosList() |
521 { | 521 { |
522 if (m_pCharPos) { | 522 if (m_pCharPos) { |
523 FX_Free(m_pCharPos); | 523 FX_Free(m_pCharPos); |
524 } | 524 } |
525 } | 525 } |
526 void CPDF_CharPosList::Load(int nChars, FX_DWORD* pCharCodes, FX_FLOAT* pCharPos
, CPDF_Font* pFont, | 526 void CPDF_CharPosList::Load(int nChars, FX_DWORD* pCharCodes, FX_FLOAT* pCharPos
, CPDF_Font* pFont, |
527 FX_FLOAT FontSize) | 527 FX_FLOAT FontSize) |
528 { | 528 { |
529 m_pCharPos = FX_Alloc(FXTEXT_CHARPOS, nChars); | 529 m_pCharPos = FX_Alloc(FXTEXT_CHARPOS, nChars); |
530 m_nChars = 0; | 530 m_nChars = 0; |
531 CPDF_CIDFont* pCIDFont = pFont->GetCIDFont(); | 531 CPDF_CIDFont* pCIDFont = pFont->GetCIDFont(); |
532 FX_BOOL bVertWriting = pCIDFont && pCIDFont->IsVertWriting(); | 532 FX_BOOL bVertWriting = pCIDFont && pCIDFont->IsVertWriting(); |
533 for (int iChar = 0; iChar < nChars; iChar ++) { | 533 for (int iChar = 0; iChar < nChars; iChar ++) { |
534 FX_DWORD CharCode = nChars == 1 ? (FX_DWORD)(FX_UINTPTR)pCharCodes : pCh
arCodes[iChar]; | 534 FX_DWORD CharCode = nChars == 1 ? (FX_DWORD)(uintptr_t)pCharCodes : pCha
rCodes[iChar]; |
535 if (CharCode == (FX_DWORD) - 1) { | 535 if (CharCode == (FX_DWORD) - 1) { |
536 continue; | 536 continue; |
537 } | 537 } |
538 FX_BOOL bVert = FALSE; | 538 FX_BOOL bVert = FALSE; |
539 FXTEXT_CHARPOS& charpos = m_pCharPos[m_nChars++]; | 539 FXTEXT_CHARPOS& charpos = m_pCharPos[m_nChars++]; |
540 if (pCIDFont) { | 540 if (pCIDFont) { |
541 charpos.m_bFontStyle = pCIDFont->IsFontStyleFromCharCode(CharCode); | 541 charpos.m_bFontStyle = pCIDFont->IsFontStyleFromCharCode(CharCode); |
542 } | 542 } |
543 charpos.m_GlyphIndex = pFont->GlyphFromCharCode(CharCode, &bVert); | 543 charpos.m_GlyphIndex = pFont->GlyphFromCharCode(CharCode, &bVert); |
544 #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ | 544 #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
607 int nChars = pFont->CountChar(str, str.GetLength()); | 607 int nChars = pFont->CountChar(str, str.GetLength()); |
608 if (nChars == 0) { | 608 if (nChars == 0) { |
609 return; | 609 return; |
610 } | 610 } |
611 FX_DWORD charcode; | 611 FX_DWORD charcode; |
612 int offset = 0; | 612 int offset = 0; |
613 FX_DWORD* pCharCodes; | 613 FX_DWORD* pCharCodes; |
614 FX_FLOAT* pCharPos; | 614 FX_FLOAT* pCharPos; |
615 if (nChars == 1) { | 615 if (nChars == 1) { |
616 charcode = pFont->GetNextChar(str, str.GetLength(), offset); | 616 charcode = pFont->GetNextChar(str, str.GetLength(), offset); |
617 pCharCodes = (FX_DWORD*)(FX_UINTPTR)charcode; | 617 pCharCodes = (FX_DWORD*)(uintptr_t)charcode; |
618 pCharPos = NULL; | 618 pCharPos = NULL; |
619 } else { | 619 } else { |
620 pCharCodes = FX_Alloc(FX_DWORD, nChars); | 620 pCharCodes = FX_Alloc(FX_DWORD, nChars); |
621 pCharPos = FX_Alloc(FX_FLOAT, nChars - 1); | 621 pCharPos = FX_Alloc(FX_FLOAT, nChars - 1); |
622 FX_FLOAT cur_pos = 0; | 622 FX_FLOAT cur_pos = 0; |
623 for (int i = 0; i < nChars; i ++) { | 623 for (int i = 0; i < nChars; i ++) { |
624 pCharCodes[i] = pFont->GetNextChar(str, str.GetLength(), offset); | 624 pCharCodes[i] = pFont->GetNextChar(str, str.GetLength(), offset); |
625 if (i) { | 625 if (i) { |
626 pCharPos[i - 1] = cur_pos; | 626 pCharPos[i - 1] = cur_pos; |
627 } | 627 } |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
737 } | 737 } |
738 } | 738 } |
739 CFX_PathData* CPDF_Font::LoadGlyphPath(FX_DWORD charcode, int dest_width) | 739 CFX_PathData* CPDF_Font::LoadGlyphPath(FX_DWORD charcode, int dest_width) |
740 { | 740 { |
741 int glyph_index = GlyphFromCharCode(charcode); | 741 int glyph_index = GlyphFromCharCode(charcode); |
742 if (m_Font.m_Face == NULL) { | 742 if (m_Font.m_Face == NULL) { |
743 return NULL; | 743 return NULL; |
744 } | 744 } |
745 return m_Font.LoadGlyphPath(glyph_index, dest_width); | 745 return m_Font.LoadGlyphPath(glyph_index, dest_width); |
746 } | 746 } |
OLD | NEW |