| 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_render/render_int.h" | 7 #include "core/fpdfapi/fpdf_render/render_int.h" |
| 8 | 8 |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 228 FX_BOOL CPDF_RenderStatus::ProcessText(const CPDF_TextObject* textobj, | 228 FX_BOOL CPDF_RenderStatus::ProcessText(const CPDF_TextObject* textobj, |
| 229 const CFX_Matrix* pObj2Device, | 229 const CFX_Matrix* pObj2Device, |
| 230 CFX_PathData* pClippingPath) { | 230 CFX_PathData* pClippingPath) { |
| 231 if (textobj->m_nChars == 0) | 231 if (textobj->m_nChars == 0) |
| 232 return TRUE; | 232 return TRUE; |
| 233 | 233 |
| 234 const TextRenderingMode& text_render_mode = textobj->m_TextState->m_TextMode; | 234 const TextRenderingMode& text_render_mode = textobj->m_TextState->m_TextMode; |
| 235 if (text_render_mode == TextRenderingMode::MODE_INVISIBLE) | 235 if (text_render_mode == TextRenderingMode::MODE_INVISIBLE) |
| 236 return TRUE; | 236 return TRUE; |
| 237 | 237 |
| 238 CPDF_Font* pFont = textobj->m_TextState->GetFont(); | 238 CPDF_Font* pFont = textobj->m_TextState.GetFont(); |
| 239 if (pFont->IsType3Font()) | 239 if (pFont->IsType3Font()) |
| 240 return ProcessType3Text(textobj, pObj2Device); | 240 return ProcessType3Text(textobj, pObj2Device); |
| 241 | 241 |
| 242 bool bFill = false; | 242 bool bFill = false; |
| 243 bool bStroke = false; | 243 bool bStroke = false; |
| 244 bool bClip = false; | 244 bool bClip = false; |
| 245 if (pClippingPath) { | 245 if (pClippingPath) { |
| 246 bClip = true; | 246 bClip = true; |
| 247 } else { | 247 } else { |
| 248 switch (text_render_mode) { | 248 switch (text_render_mode) { |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 290 bPattern = true; | 290 bPattern = true; |
| 291 } else { | 291 } else { |
| 292 fill_argb = GetFillArgb(textobj); | 292 fill_argb = GetFillArgb(textobj); |
| 293 } | 293 } |
| 294 } | 294 } |
| 295 CFX_Matrix text_matrix; | 295 CFX_Matrix text_matrix; |
| 296 textobj->GetTextMatrix(&text_matrix); | 296 textobj->GetTextMatrix(&text_matrix); |
| 297 if (!IsAvailableMatrix(text_matrix)) | 297 if (!IsAvailableMatrix(text_matrix)) |
| 298 return TRUE; | 298 return TRUE; |
| 299 | 299 |
| 300 FX_FLOAT font_size = textobj->m_TextState->GetFontSize(); | 300 FX_FLOAT font_size = textobj->m_TextState.GetFontSize(); |
| 301 if (bPattern) { | 301 if (bPattern) { |
| 302 DrawTextPathWithPattern(textobj, pObj2Device, pFont, font_size, | 302 DrawTextPathWithPattern(textobj, pObj2Device, pFont, font_size, |
| 303 &text_matrix, bFill, bStroke); | 303 &text_matrix, bFill, bStroke); |
| 304 return TRUE; | 304 return TRUE; |
| 305 } | 305 } |
| 306 if (bClip || bStroke) { | 306 if (bClip || bStroke) { |
| 307 const CFX_Matrix* pDeviceMatrix = pObj2Device; | 307 const CFX_Matrix* pDeviceMatrix = pObj2Device; |
| 308 CFX_Matrix device_matrix; | 308 CFX_Matrix device_matrix; |
| 309 if (bStroke) { | 309 if (bStroke) { |
| 310 const FX_FLOAT* pCTM = textobj->m_TextState->m_CTM; | 310 const FX_FLOAT* pCTM = textobj->m_TextState->m_CTM; |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 366 ReleaseCachedType3(m_pType3Font); | 366 ReleaseCachedType3(m_pType3Font); |
| 367 } | 367 } |
| 368 } | 368 } |
| 369 uint32_t m_dwCount; | 369 uint32_t m_dwCount; |
| 370 CPDF_Type3Font* const m_pType3Font; | 370 CPDF_Type3Font* const m_pType3Font; |
| 371 }; | 371 }; |
| 372 | 372 |
| 373 // TODO(npm): Font fallback for type 3 fonts? (Completely separate code!!) | 373 // TODO(npm): Font fallback for type 3 fonts? (Completely separate code!!) |
| 374 FX_BOOL CPDF_RenderStatus::ProcessType3Text(const CPDF_TextObject* textobj, | 374 FX_BOOL CPDF_RenderStatus::ProcessType3Text(const CPDF_TextObject* textobj, |
| 375 const CFX_Matrix* pObj2Device) { | 375 const CFX_Matrix* pObj2Device) { |
| 376 CPDF_Type3Font* pType3Font = textobj->m_TextState->GetFont()->AsType3Font(); | 376 CPDF_Type3Font* pType3Font = textobj->m_TextState.GetFont()->AsType3Font(); |
| 377 for (int i = 0; i < m_Type3FontCache.GetSize(); ++i) { | 377 for (int i = 0; i < m_Type3FontCache.GetSize(); ++i) { |
| 378 if (m_Type3FontCache.GetAt(i) == pType3Font) | 378 if (m_Type3FontCache.GetAt(i) == pType3Font) |
| 379 return TRUE; | 379 return TRUE; |
| 380 } | 380 } |
| 381 | 381 |
| 382 CFX_Matrix dCTM = m_pDevice->GetCTM(); | 382 CFX_Matrix dCTM = m_pDevice->GetCTM(); |
| 383 FX_FLOAT sa = FXSYS_fabs(dCTM.a); | 383 FX_FLOAT sa = FXSYS_fabs(dCTM.a); |
| 384 FX_FLOAT sd = FXSYS_fabs(dCTM.d); | 384 FX_FLOAT sd = FXSYS_fabs(dCTM.d); |
| 385 CFX_Matrix text_matrix; | 385 CFX_Matrix text_matrix; |
| 386 textobj->GetTextMatrix(&text_matrix); | 386 textobj->GetTextMatrix(&text_matrix); |
| 387 CFX_Matrix char_matrix = pType3Font->GetFontMatrix(); | 387 CFX_Matrix char_matrix = pType3Font->GetFontMatrix(); |
| 388 FX_FLOAT font_size = textobj->m_TextState->GetFontSize(); | 388 FX_FLOAT font_size = textobj->m_TextState.GetFontSize(); |
| 389 char_matrix.Scale(font_size, font_size); | 389 char_matrix.Scale(font_size, font_size); |
| 390 FX_ARGB fill_argb = GetFillArgb(textobj, TRUE); | 390 FX_ARGB fill_argb = GetFillArgb(textobj, TRUE); |
| 391 int fill_alpha = FXARGB_A(fill_argb); | 391 int fill_alpha = FXARGB_A(fill_argb); |
| 392 int device_class = m_pDevice->GetDeviceClass(); | 392 int device_class = m_pDevice->GetDeviceClass(); |
| 393 std::vector<FXTEXT_GLYPHPOS> glyphs; | 393 std::vector<FXTEXT_GLYPHPOS> glyphs; |
| 394 if (device_class == FXDC_DISPLAY) | 394 if (device_class == FXDC_DISPLAY) |
| 395 glyphs.resize(textobj->m_nChars); | 395 glyphs.resize(textobj->m_nChars); |
| 396 else if (fill_alpha < 255) | 396 else if (fill_alpha < 255) |
| 397 return FALSE; | 397 return FALSE; |
| 398 | 398 |
| (...skipping 465 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 864 matrix.Concat(font_size, 0, 0, font_size, charpos.m_OriginX, | 864 matrix.Concat(font_size, 0, 0, font_size, charpos.m_OriginX, |
| 865 charpos.m_OriginY); | 865 charpos.m_OriginY); |
| 866 path.m_Path.New()->Append(pPath, &matrix); | 866 path.m_Path.New()->Append(pPath, &matrix); |
| 867 path.m_Matrix = *pTextMatrix; | 867 path.m_Matrix = *pTextMatrix; |
| 868 path.m_bStroke = bStroke; | 868 path.m_bStroke = bStroke; |
| 869 path.m_FillType = bFill ? FXFILL_WINDING : 0; | 869 path.m_FillType = bFill ? FXFILL_WINDING : 0; |
| 870 path.CalcBoundingBox(); | 870 path.CalcBoundingBox(); |
| 871 ProcessPath(&path, pObj2Device); | 871 ProcessPath(&path, pObj2Device); |
| 872 } | 872 } |
| 873 } | 873 } |
| OLD | NEW |