diff options
author | dsinclair <dsinclair@chromium.org> | 2016-08-31 13:18:13 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-08-31 13:18:13 -0700 |
commit | 07146149674c61eaecf55cdfe6cdf7c31bbf0550 (patch) | |
tree | 5f6533f2171b57ff73efecb8047274894dea5478 | |
parent | fc9b11358a47e1dd9b257263c9457d7e53b9dd10 (diff) | |
download | pdfium-07146149674c61eaecf55cdfe6cdf7c31bbf0550.tar.xz |
Use CheckedNumeric for strength calculation.
Update the calculation of the outlines bold strength to use a CheckedNum instead of an int.
BUG=chromium:639506
Review-Url: https://codereview.chromium.org/2296193002
-rw-r--r-- | core/fxge/ge/cfx_facecache.cpp | 25 |
1 files changed, 12 insertions, 13 deletions
diff --git a/core/fxge/ge/cfx_facecache.cpp b/core/fxge/ge/cfx_facecache.cpp index c35830fbde..d59ae3269e 100644 --- a/core/fxge/ge/cfx_facecache.cpp +++ b/core/fxge/ge/cfx_facecache.cpp @@ -14,6 +14,7 @@ #include "core/fxge/include/cfx_pathdata.h" #include "core/fxge/include/cfx_substfont.h" #include "core/fxge/include/fx_freetype.h" +#include "third_party/base/numerics/safe_math.h" #ifdef _SKIA_SUPPORT_ #include "third_party/skia/include/core/SkStream.h" @@ -154,19 +155,17 @@ CFX_GlyphBitmap* CFX_FaceCache::RenderGlyph(CFX_Font* pFont, uint32_t index = (weight - 400) / 10; if (index >= CFX_Font::kWeightPowArraySize) return nullptr; - int level = 0; - if (pSubstFont->m_Charset == FXFONT_SHIFTJIS_CHARSET) { - level = - CFX_Font::s_WeightPow_SHIFTJIS[index] * 2 * - (FXSYS_abs((int)(ft_matrix.xx)) + FXSYS_abs((int)(ft_matrix.xy))) / - 36655; - } else { - level = - CFX_Font::s_WeightPow_11[index] * - (FXSYS_abs((int)(ft_matrix.xx)) + FXSYS_abs((int)(ft_matrix.xy))) / - 36655; - } - FXFT_Outline_Embolden(FXFT_Get_Glyph_Outline(m_Face), level); + pdfium::base::CheckedNumeric<signed long> level = 0; + if (pSubstFont->m_Charset == FXFONT_SHIFTJIS_CHARSET) + level = CFX_Font::s_WeightPow_SHIFTJIS[index] * 2; + else + level = CFX_Font::s_WeightPow_11[index]; + + level = level * (FXSYS_abs(static_cast<int>(ft_matrix.xx)) + + FXSYS_abs(static_cast<int>(ft_matrix.xy))) / + 36655; + FXFT_Outline_Embolden(FXFT_Get_Glyph_Outline(m_Face), + level.ValueOrDefault(0)); } FXFT_Library_SetLcdFilter(CFX_GEModule::Get()->GetFontMgr()->GetFTLibrary(), FT_LCD_FILTER_DEFAULT); |