Chromium Code Reviews| Index: core/fpdfapi/fpdf_page/cpdf_textstatedata.cpp |
| diff --git a/core/fpdfapi/fpdf_page/cpdf_textstatedata.cpp b/core/fpdfapi/fpdf_page/cpdf_textstatedata.cpp |
| index e60af0076efb414dcedfec66a8a4ab42b021abba..f04de7a18e7819898065c2b53a03e6181c71e1be 100644 |
| --- a/core/fpdfapi/fpdf_page/cpdf_textstatedata.cpp |
| +++ b/core/fpdfapi/fpdf_page/cpdf_textstatedata.cpp |
| @@ -72,3 +72,34 @@ CPDF_TextStateData::~CPDF_TextStateData() { |
| pPageData->ReleaseFont(m_pFont->GetFontDict()); |
| } |
| } |
| + |
| +void CPDF_TextStateData::SetFont(CPDF_Font* pFont) { |
| + CPDF_Document* pDoc = m_pDocument; |
| + CPDF_DocPageData* pPageData = pDoc ? pDoc->GetPageData() : nullptr; |
| + if (pPageData && m_pFont && !pPageData->IsForceClear()) |
| + pPageData->ReleaseFont(m_pFont->GetFontDict()); |
| + |
| + m_pDocument = pFont ? pFont->m_pDocument : nullptr; |
| + m_pFont = pFont; |
| +} |
| + |
| +FX_FLOAT CPDF_TextStateData::GetFontSizeV() const { |
| + FX_FLOAT unit = FXSYS_sqrt2(m_Matrix[1], m_Matrix[3]); |
| + FX_FLOAT size = unit * m_FontSize; |
|
dsinclair
2016/08/30 13:36:10
No need to store size. (and below)
Tom Sepez
2016/08/30 16:59:48
Done.
|
| + return (FX_FLOAT)FXSYS_fabs(size); |
|
dsinclair
2016/08/30 13:36:10
static_cast? (and below)
Tom Sepez
2016/08/30 16:59:48
FXSYS_fabs already includes this cast. Removed.
|
| +} |
| + |
| +FX_FLOAT CPDF_TextStateData::GetFontSizeH() const { |
| + FX_FLOAT unit = FXSYS_sqrt2(m_Matrix[0], m_Matrix[2]); |
| + FX_FLOAT size = unit * m_FontSize; |
| + return (FX_FLOAT)FXSYS_fabs(size); |
| +} |
| + |
| +FX_FLOAT CPDF_TextStateData::GetBaselineAngle() const { |
| + return FXSYS_atan2(m_Matrix[2], m_Matrix[0]); |
| +} |
| + |
| +FX_FLOAT CPDF_TextStateData::GetShearAngle() const { |
| + FX_FLOAT shear_angle = FXSYS_atan2(m_Matrix[1], m_Matrix[3]); |
| + return GetBaselineAngle() + shear_angle; |
| +} |