OLD | NEW |
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_page/include/cpdf_textstatedata.h" | 7 #include "core/fpdfapi/fpdf_page/include/cpdf_textstatedata.h" |
8 | 8 |
9 #include "core/fpdfapi/fpdf_font/include/cpdf_font.h" | 9 #include "core/fpdfapi/fpdf_font/include/cpdf_font.h" |
10 #include "core/fpdfapi/fpdf_page/pageint.h" | 10 #include "core/fpdfapi/fpdf_page/pageint.h" |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 } | 65 } |
66 } | 66 } |
67 | 67 |
68 CPDF_TextStateData::~CPDF_TextStateData() { | 68 CPDF_TextStateData::~CPDF_TextStateData() { |
69 if (m_pDocument && m_pFont) { | 69 if (m_pDocument && m_pFont) { |
70 CPDF_DocPageData* pPageData = m_pDocument->GetPageData(); | 70 CPDF_DocPageData* pPageData = m_pDocument->GetPageData(); |
71 if (pPageData && !pPageData->IsForceClear()) | 71 if (pPageData && !pPageData->IsForceClear()) |
72 pPageData->ReleaseFont(m_pFont->GetFontDict()); | 72 pPageData->ReleaseFont(m_pFont->GetFontDict()); |
73 } | 73 } |
74 } | 74 } |
| 75 |
| 76 void CPDF_TextStateData::SetFont(CPDF_Font* pFont) { |
| 77 CPDF_Document* pDoc = m_pDocument; |
| 78 CPDF_DocPageData* pPageData = pDoc ? pDoc->GetPageData() : nullptr; |
| 79 if (pPageData && m_pFont && !pPageData->IsForceClear()) |
| 80 pPageData->ReleaseFont(m_pFont->GetFontDict()); |
| 81 |
| 82 m_pDocument = pFont ? pFont->m_pDocument : nullptr; |
| 83 m_pFont = pFont; |
| 84 } |
| 85 |
| 86 FX_FLOAT CPDF_TextStateData::GetFontSizeV() const { |
| 87 return FXSYS_fabs(FXSYS_sqrt2(m_Matrix[1], m_Matrix[3]) * m_FontSize); |
| 88 } |
| 89 |
| 90 FX_FLOAT CPDF_TextStateData::GetFontSizeH() const { |
| 91 return FXSYS_fabs(FXSYS_sqrt2(m_Matrix[0], m_Matrix[2]) * m_FontSize); |
| 92 } |
| 93 |
| 94 FX_FLOAT CPDF_TextStateData::GetBaselineAngle() const { |
| 95 return FXSYS_atan2(m_Matrix[2], m_Matrix[0]); |
| 96 } |
| 97 |
| 98 FX_FLOAT CPDF_TextStateData::GetShearAngle() const { |
| 99 return GetBaselineAngle() + FXSYS_atan2(m_Matrix[1], m_Matrix[3]); |
| 100 } |
OLD | NEW |