Chromium Code Reviews| Index: core/fpdfapi/fpdf_render/cpdf_type3glyphs.cpp |
| diff --git a/core/fpdfapi/fpdf_render/cpdf_type3glyphs.cpp b/core/fpdfapi/fpdf_render/cpdf_type3glyphs.cpp |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..32d518919ac8d10f4e31b6597b262e468e82fb2b |
| --- /dev/null |
| +++ b/core/fpdfapi/fpdf_render/cpdf_type3glyphs.cpp |
| @@ -0,0 +1,47 @@ |
| +// Copyright 2016 PDFium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
| + |
| +#include "core/fpdfapi/fpdf_render/cpdf_type3glyphs.h" |
| + |
| +#include <map> |
| + |
| +#include "core/fxge/include/fx_font.h" |
| + |
| +CPDF_Type3Glyphs::CPDF_Type3Glyphs() |
| + : m_TopBlueCount(0), m_BottomBlueCount(0) {} |
| + |
| +CPDF_Type3Glyphs::~CPDF_Type3Glyphs() { |
| + for (const auto& pair : m_GlyphMap) |
| + delete pair.second; |
| +} |
| + |
| +static int _AdjustBlue(FX_FLOAT pos, int& count, int blues[]) { |
| + FX_FLOAT min_distance = 1000000.0f * 1.0f; |
|
dsinclair
2016/09/01 19:28:35
.... Can we just remove the * 1.0f?
npm
2016/09/01 19:37:50
Done.
|
| + int closest_pos = -1; |
| + for (int i = 0; i < count; i++) { |
| + FX_FLOAT distance = (FX_FLOAT)FXSYS_fabs(pos - (FX_FLOAT)blues[i]); |
|
dsinclair
2016/09/01 19:28:35
FXSYS_fabs returns FX_FLOAT so the outer cast isn'
npm
2016/09/01 19:37:50
Done.
|
| + if (distance < 1.0f * 80.0f / 100.0f && distance < min_distance) { |
| + min_distance = distance; |
| + closest_pos = i; |
| + } |
| + } |
| + if (closest_pos >= 0) { |
| + return blues[closest_pos]; |
| + } |
|
dsinclair
2016/09/01 19:28:35
nit {}'s
npm
2016/09/01 19:37:50
Done.
|
| + int new_pos = FXSYS_round(pos); |
| + if (count == TYPE3_MAX_BLUES) { |
| + return new_pos; |
| + } |
| + blues[count++] = new_pos; |
| + return new_pos; |
| +} |
| +void CPDF_Type3Glyphs::AdjustBlue(FX_FLOAT top, |
|
dsinclair
2016/09/01 19:28:35
nit: blank line before
npm
2016/09/01 19:37:50
I think I completely forgot to nit-check this one,
|
| + FX_FLOAT bottom, |
| + int& top_line, |
| + int& bottom_line) { |
| + top_line = _AdjustBlue(top, m_TopBlueCount, m_TopBlue); |
| + bottom_line = _AdjustBlue(bottom, m_BottomBlueCount, m_BottomBlue); |
| +} |