Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(68)

Unified Diff: core/fpdfapi/fpdf_page/cpdf_textstatedata.cpp

Issue 2287313004: Make CPDF_TextState have a CPDF_TextStateData rather than inheriting one. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@moar_better_constness
Patch Set: Move impl to .cpp file Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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;
+}

Powered by Google App Engine
This is Rietveld 408576698