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

Unified Diff: xfa/fde/fde_gedevice.cpp

Issue 2169793002: Use smart pointers for CFX_Font and CFX_Type3Font classes (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: style fixes Created 4 years, 5 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: xfa/fde/fde_gedevice.cpp
diff --git a/xfa/fde/fde_gedevice.cpp b/xfa/fde/fde_gedevice.cpp
index e78ab8da4ca5a675468204cea96b35fd653bcce1..56f845c35bd23f0d0668bc7813dde0708e03b9a3 100644
--- a/xfa/fde/fde_gedevice.cpp
+++ b/xfa/fde/fde_gedevice.cpp
@@ -134,12 +134,12 @@ FX_BOOL CFDE_RenderDevice::DrawString(CFDE_Brush* pBrush,
#if _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_
uint32_t dwFontStyle = pFont->GetFontStyles();
CFX_Font FxFont;
- CFX_SubstFont SubstFxFont;
- FxFont.SetSubstFont(&SubstFxFont);
- SubstFxFont.m_Weight = dwFontStyle & FX_FONTSTYLE_Bold ? 700 : 400;
- SubstFxFont.m_ItalicAngle = dwFontStyle & FX_FONTSTYLE_Italic ? -12 : 0;
- SubstFxFont.m_WeightCJK = SubstFxFont.m_Weight;
- SubstFxFont.m_bItalicCJK = !!(dwFontStyle & FX_FONTSTYLE_Italic);
+ CFX_SubstFont* SubstFxFont = new CFX_SubstFont();
+ FxFont.SetSubstFont(std::unique_ptr<CFX_SubstFont>(SubstFxFont));
+ SubstFxFont->m_Weight = dwFontStyle & FX_FONTSTYLE_Bold ? 700 : 400;
+ SubstFxFont->m_ItalicAngle = dwFontStyle & FX_FONTSTYLE_Italic ? -12 : 0;
+ SubstFxFont->m_WeightCJK = SubstFxFont->m_Weight;
+ SubstFxFont->m_bItalicCJK = !!(dwFontStyle & FX_FONTSTYLE_Italic);
#endif // _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_
for (int32_t i = 0; i < iCount; ++i) {
@@ -175,7 +175,6 @@ FX_BOOL CFDE_RenderDevice::DrawString(CFDE_Brush* pBrush,
FX_BOOL bRet = m_pDevice->DrawNormalText(
iCurCount, pCurCP, &FxFont, pCache, -fFontSize,
(const CFX_Matrix*)pMatrix, argb, FXTEXT_CLEARTYPE);
- FxFont.SetSubstFont(nullptr);
dsinclair 2016/07/21 19:39:59 Isn't this still needed to clear the FxFont substi
Wei Li 2016/07/21 21:15:03 Substitution font in FxFont is stored as a unique_
FxFont.SetFace(nullptr);
return bRet;
#else
@@ -186,7 +185,6 @@ FX_BOOL CFDE_RenderDevice::DrawString(CFDE_Brush* pBrush,
}
#if _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_
- FxFont.SetSubstFont(nullptr);
dsinclair 2016/07/21 19:39:59 ditto
Wei Li 2016/07/21 21:15:03 same here.
FxFont.SetFace(nullptr);
#endif // _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_

Powered by Google App Engine
This is Rietveld 408576698