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_DocPageData* pPageData = | |
78 m_pDocument ? m_pDocument->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 const FX_FLOAT* pMatrix = GetMatrix(); | |
88 FX_FLOAT unit = FXSYS_sqrt2(pMatrix[1], pMatrix[3]); | |
89 FX_FLOAT size = unit * GetFontSize(); | |
90 return (FX_FLOAT)FXSYS_fabs(size); | |
91 } | |
92 | |
93 FX_FLOAT CPDF_TextStateData::GetFontSizeH() const { | |
94 const FX_FLOAT* pMatrix = GetMatrix(); | |
95 FX_FLOAT unit = FXSYS_sqrt2(pMatrix[0], pMatrix[2]); | |
96 FX_FLOAT size = unit * GetFontSize(); | |
97 return (FX_FLOAT)FXSYS_fabs(size); | |
98 } | |
99 | |
100 FX_FLOAT CPDF_TextStateData::GetBaselineAngle() const { | |
101 const FX_FLOAT* pMatrix = GetMatrix(); | |
102 return FXSYS_atan2(pMatrix[2], pMatrix[0]); | |
103 } | |
104 | |
105 FX_FLOAT CPDF_TextStateData::GetShearAngle() const { | |
106 const FX_FLOAT* pMatrix = GetMatrix(); | |
107 FX_FLOAT shear_angle = FXSYS_atan2(pMatrix[1], pMatrix[3]); | |
108 return GetBaselineAngle() + shear_angle; | |
109 } | |
OLD | NEW |