| 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/src/fpdfapi/fpdf_render/render_int.h" | 7 #include "core/src/fpdfapi/fpdf_render/render_int.h" |
| 8 | 8 |
| 9 #include "core/include/fpdfapi/fpdf_pageobj.h" | 9 #include "core/include/fpdfapi/fpdf_pageobj.h" |
| 10 #include "core/include/fpdfapi/fpdf_render.h" | 10 #include "core/include/fpdfapi/fpdf_render.h" |
| (...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 191 const CFX_Matrix* pObj2Device, | 191 const CFX_Matrix* pObj2Device, |
| 192 CFX_PathData* pClippingPath) { | 192 CFX_PathData* pClippingPath) { |
| 193 if (textobj->m_nChars == 0) { | 193 if (textobj->m_nChars == 0) { |
| 194 return TRUE; | 194 return TRUE; |
| 195 } | 195 } |
| 196 int text_render_mode = textobj->m_TextState.GetObject()->m_TextMode; | 196 int text_render_mode = textobj->m_TextState.GetObject()->m_TextMode; |
| 197 if (text_render_mode == 3) { | 197 if (text_render_mode == 3) { |
| 198 return TRUE; | 198 return TRUE; |
| 199 } | 199 } |
| 200 CPDF_Font* pFont = textobj->m_TextState.GetFont(); | 200 CPDF_Font* pFont = textobj->m_TextState.GetFont(); |
| 201 if (pFont->GetFontType() == PDFFONT_TYPE3) { | 201 if (pFont->IsType3Font()) { |
| 202 return ProcessType3Text(textobj, pObj2Device); | 202 return ProcessType3Text(textobj, pObj2Device); |
| 203 } | 203 } |
| 204 FX_BOOL bFill = FALSE, bStroke = FALSE, bClip = FALSE; | 204 FX_BOOL bFill = FALSE, bStroke = FALSE, bClip = FALSE; |
| 205 if (pClippingPath) { | 205 if (pClippingPath) { |
| 206 bClip = TRUE; | 206 bClip = TRUE; |
| 207 } else { | 207 } else { |
| 208 switch (text_render_mode) { | 208 switch (text_render_mode) { |
| 209 case 0: | 209 case 0: |
| 210 case 4: | 210 case 4: |
| 211 bFill = TRUE; | 211 bFill = TRUE; |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 341 ~CPDF_RefType3Cache() { | 341 ~CPDF_RefType3Cache() { |
| 342 while (m_dwCount--) { | 342 while (m_dwCount--) { |
| 343 ReleaseCachedType3(m_pType3Font); | 343 ReleaseCachedType3(m_pType3Font); |
| 344 } | 344 } |
| 345 } | 345 } |
| 346 FX_DWORD m_dwCount; | 346 FX_DWORD m_dwCount; |
| 347 CPDF_Type3Font* m_pType3Font; | 347 CPDF_Type3Font* m_pType3Font; |
| 348 }; | 348 }; |
| 349 FX_BOOL CPDF_RenderStatus::ProcessType3Text(const CPDF_TextObject* textobj, | 349 FX_BOOL CPDF_RenderStatus::ProcessType3Text(const CPDF_TextObject* textobj, |
| 350 const CFX_Matrix* pObj2Device) { | 350 const CFX_Matrix* pObj2Device) { |
| 351 CPDF_Type3Font* pType3Font = textobj->m_TextState.GetFont()->GetType3Font(); | 351 CPDF_Type3Font* pType3Font = textobj->m_TextState.GetFont()->AsType3Font(); |
| 352 for (int j = 0; j < m_Type3FontCache.GetSize(); j++) { | 352 for (int j = 0; j < m_Type3FontCache.GetSize(); j++) { |
| 353 if (m_Type3FontCache.GetAt(j) == pType3Font) | 353 if (m_Type3FontCache.GetAt(j) == pType3Font) |
| 354 return TRUE; | 354 return TRUE; |
| 355 } | 355 } |
| 356 CFX_Matrix dCTM = m_pDevice->GetCTM(); | 356 CFX_Matrix dCTM = m_pDevice->GetCTM(); |
| 357 FX_FLOAT sa = FXSYS_fabs(dCTM.a); | 357 FX_FLOAT sa = FXSYS_fabs(dCTM.a); |
| 358 FX_FLOAT sd = FXSYS_fabs(dCTM.d); | 358 FX_FLOAT sd = FXSYS_fabs(dCTM.d); |
| 359 CFX_Matrix text_matrix; | 359 CFX_Matrix text_matrix; |
| 360 textobj->GetTextMatrix(&text_matrix); | 360 textobj->GetTextMatrix(&text_matrix); |
| 361 CFX_Matrix char_matrix = pType3Font->GetFontMatrix(); | 361 CFX_Matrix char_matrix = pType3Font->GetFontMatrix(); |
| (...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 524 CPDF_CharPosList::~CPDF_CharPosList() { | 524 CPDF_CharPosList::~CPDF_CharPosList() { |
| 525 FX_Free(m_pCharPos); | 525 FX_Free(m_pCharPos); |
| 526 } | 526 } |
| 527 void CPDF_CharPosList::Load(int nChars, | 527 void CPDF_CharPosList::Load(int nChars, |
| 528 FX_DWORD* pCharCodes, | 528 FX_DWORD* pCharCodes, |
| 529 FX_FLOAT* pCharPos, | 529 FX_FLOAT* pCharPos, |
| 530 CPDF_Font* pFont, | 530 CPDF_Font* pFont, |
| 531 FX_FLOAT FontSize) { | 531 FX_FLOAT FontSize) { |
| 532 m_pCharPos = FX_Alloc(FXTEXT_CHARPOS, nChars); | 532 m_pCharPos = FX_Alloc(FXTEXT_CHARPOS, nChars); |
| 533 m_nChars = 0; | 533 m_nChars = 0; |
| 534 CPDF_CIDFont* pCIDFont = pFont->GetCIDFont(); | 534 CPDF_CIDFont* pCIDFont = pFont->AsCIDFont(); |
| 535 FX_BOOL bVertWriting = pCIDFont && pCIDFont->IsVertWriting(); | 535 FX_BOOL bVertWriting = pCIDFont && pCIDFont->IsVertWriting(); |
| 536 for (int iChar = 0; iChar < nChars; iChar++) { | 536 for (int iChar = 0; iChar < nChars; iChar++) { |
| 537 FX_DWORD CharCode = | 537 FX_DWORD CharCode = |
| 538 nChars == 1 ? (FX_DWORD)(uintptr_t)pCharCodes : pCharCodes[iChar]; | 538 nChars == 1 ? (FX_DWORD)(uintptr_t)pCharCodes : pCharCodes[iChar]; |
| 539 if (CharCode == (FX_DWORD)-1) { | 539 if (CharCode == (FX_DWORD)-1) { |
| 540 continue; | 540 continue; |
| 541 } | 541 } |
| 542 FX_BOOL bVert = FALSE; | 542 FX_BOOL bVert = FALSE; |
| 543 FXTEXT_CHARPOS& charpos = m_pCharPos[m_nChars++]; | 543 FXTEXT_CHARPOS& charpos = m_pCharPos[m_nChars++]; |
| 544 if (pCIDFont) { | 544 if (pCIDFont) { |
| 545 charpos.m_bFontStyle = pCIDFont->IsFontStyleFromCharCode(CharCode); | 545 charpos.m_bFontStyle = pCIDFont->IsFontStyleFromCharCode(CharCode); |
| 546 } | 546 } |
| 547 charpos.m_GlyphIndex = pFont->GlyphFromCharCode(CharCode, &bVert); | 547 charpos.m_GlyphIndex = pFont->GlyphFromCharCode(CharCode, &bVert); |
| 548 #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ | 548 #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ |
| 549 charpos.m_ExtGID = pFont->GlyphFromCharCodeExt(CharCode); | 549 charpos.m_ExtGID = pFont->GlyphFromCharCodeExt(CharCode); |
| 550 #endif | 550 #endif |
| 551 if (!pFont->IsEmbedded() && pFont->GetFontType() != PDFFONT_CIDFONT) { | 551 if (!pFont->IsEmbedded() && !pFont->IsCIDFont()) { |
| 552 charpos.m_FontCharWidth = pFont->GetCharWidthF(CharCode); | 552 charpos.m_FontCharWidth = pFont->GetCharWidthF(CharCode); |
| 553 } else { | 553 } else { |
| 554 charpos.m_FontCharWidth = 0; | 554 charpos.m_FontCharWidth = 0; |
| 555 } | 555 } |
| 556 charpos.m_OriginX = iChar ? pCharPos[iChar - 1] : 0; | 556 charpos.m_OriginX = iChar ? pCharPos[iChar - 1] : 0; |
| 557 charpos.m_OriginY = 0; | 557 charpos.m_OriginY = 0; |
| 558 charpos.m_bGlyphAdjust = FALSE; | 558 charpos.m_bGlyphAdjust = FALSE; |
| 559 if (!pCIDFont) { | 559 if (!pCIDFont) { |
| 560 continue; | 560 continue; |
| 561 } | 561 } |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 658 cur_pos += pFont->GetCharWidthF(pCharCodes[i]) * font_size / 1000; | 658 cur_pos += pFont->GetCharWidthF(pCharCodes[i]) * font_size / 1000; |
| 659 } | 659 } |
| 660 } | 660 } |
| 661 CFX_Matrix matrix; | 661 CFX_Matrix matrix; |
| 662 if (pMatrix) | 662 if (pMatrix) |
| 663 matrix = *pMatrix; | 663 matrix = *pMatrix; |
| 664 | 664 |
| 665 matrix.e = origin_x; | 665 matrix.e = origin_x; |
| 666 matrix.f = origin_y; | 666 matrix.f = origin_y; |
| 667 | 667 |
| 668 if (pFont->GetFontType() != PDFFONT_TYPE3) { | 668 if (!pFont->IsType3Font()) { |
| 669 if (stroke_argb == 0) { | 669 if (stroke_argb == 0) { |
| 670 DrawNormalText(pDevice, nChars, pCharCodes, pCharPos, pFont, font_size, | 670 DrawNormalText(pDevice, nChars, pCharCodes, pCharPos, pFont, font_size, |
| 671 &matrix, fill_argb, pOptions); | 671 &matrix, fill_argb, pOptions); |
| 672 } else { | 672 } else { |
| 673 DrawTextPath(pDevice, nChars, pCharCodes, pCharPos, pFont, font_size, | 673 DrawTextPath(pDevice, nChars, pCharCodes, pCharPos, pFont, font_size, |
| 674 &matrix, NULL, pGraphState, fill_argb, stroke_argb, NULL); | 674 &matrix, NULL, pGraphState, fill_argb, stroke_argb, NULL); |
| 675 } | 675 } |
| 676 } | 676 } |
| 677 | 677 |
| 678 if (nChars > 1) { | 678 if (nChars > 1) { |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 711 } | 711 } |
| 712 if (dwFlags & RENDER_NO_NATIVETEXT) { | 712 if (dwFlags & RENDER_NO_NATIVETEXT) { |
| 713 FXGE_flags |= FXTEXT_NO_NATIVETEXT; | 713 FXGE_flags |= FXTEXT_NO_NATIVETEXT; |
| 714 } | 714 } |
| 715 if (dwFlags & RENDER_PRINTIMAGETEXT) { | 715 if (dwFlags & RENDER_PRINTIMAGETEXT) { |
| 716 FXGE_flags |= FXTEXT_PRINTIMAGETEXT; | 716 FXGE_flags |= FXTEXT_PRINTIMAGETEXT; |
| 717 } | 717 } |
| 718 } else { | 718 } else { |
| 719 FXGE_flags = FXTEXT_CLEARTYPE; | 719 FXGE_flags = FXTEXT_CLEARTYPE; |
| 720 } | 720 } |
| 721 if (pFont->GetFontType() & PDFFONT_CIDFONT) { | 721 if (pFont->IsCIDFont()) { |
| 722 FXGE_flags |= FXFONT_CIDFONT; | 722 FXGE_flags |= FXFONT_CIDFONT; |
| 723 } | 723 } |
| 724 return pDevice->DrawNormalText(CharPosList.m_nChars, CharPosList.m_pCharPos, | 724 return pDevice->DrawNormalText(CharPosList.m_nChars, CharPosList.m_pCharPos, |
| 725 &pFont->m_Font, pCache, font_size, | 725 &pFont->m_Font, pCache, font_size, |
| 726 pText2Device, fill_argb, FXGE_flags); | 726 pText2Device, fill_argb, FXGE_flags); |
| 727 } | 727 } |
| 728 void CPDF_RenderStatus::DrawTextPathWithPattern(const CPDF_TextObject* textobj, | 728 void CPDF_RenderStatus::DrawTextPathWithPattern(const CPDF_TextObject* textobj, |
| 729 const CFX_Matrix* pObj2Device, | 729 const CFX_Matrix* pObj2Device, |
| 730 CPDF_Font* pFont, | 730 CPDF_Font* pFont, |
| 731 FX_FLOAT font_size, | 731 FX_FLOAT font_size, |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 777 charpos.m_OriginY); | 777 charpos.m_OriginY); |
| 778 path.m_Path.New()->Append(pPath, &matrix); | 778 path.m_Path.New()->Append(pPath, &matrix); |
| 779 path.m_Matrix = *pTextMatrix; | 779 path.m_Matrix = *pTextMatrix; |
| 780 path.m_bStroke = bStroke; | 780 path.m_bStroke = bStroke; |
| 781 path.m_FillType = bFill ? FXFILL_WINDING : 0; | 781 path.m_FillType = bFill ? FXFILL_WINDING : 0; |
| 782 path.CalcBoundingBox(); | 782 path.CalcBoundingBox(); |
| 783 ProcessPath(&path, pObj2Device); | 783 ProcessPath(&path, pObj2Device); |
| 784 } | 784 } |
| 785 } | 785 } |
| 786 | 786 |
| 787 CFX_PathData* CPDF_Font::LoadGlyphPath(FX_DWORD charcode, int dest_width) { | |
| 788 int glyph_index = GlyphFromCharCode(charcode); | |
| 789 if (!m_Font.GetFace()) | |
| 790 return nullptr; | |
| 791 return m_Font.LoadGlyphPath(glyph_index, dest_width); | |
| 792 } | |
| OLD | NEW |