summaryrefslogtreecommitdiff
path: root/core/fpdfapi/render/cpdf_type3glyphs.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'core/fpdfapi/render/cpdf_type3glyphs.cpp')
-rw-r--r--core/fpdfapi/render/cpdf_type3glyphs.cpp36
1 files changed, 19 insertions, 17 deletions
diff --git a/core/fpdfapi/render/cpdf_type3glyphs.cpp b/core/fpdfapi/render/cpdf_type3glyphs.cpp
index 01b689f80f..ef14d731c4 100644
--- a/core/fpdfapi/render/cpdf_type3glyphs.cpp
+++ b/core/fpdfapi/render/cpdf_type3glyphs.cpp
@@ -6,38 +6,40 @@
#include "core/fpdfapi/render/cpdf_type3glyphs.h"
+#include <algorithm>
#include <map>
#include "core/fxge/fx_font.h"
-CPDF_Type3Glyphs::CPDF_Type3Glyphs()
- : m_TopBlueCount(0), m_BottomBlueCount(0) {}
+namespace {
-CPDF_Type3Glyphs::~CPDF_Type3Glyphs() {}
+constexpr int kType3MaxBlues = 16;
-static int _AdjustBlue(float pos, int& count, int blues[]) {
+int AdjustBlueHelper(float pos, std::vector<int>* blues) {
float min_distance = 1000000.0f;
int closest_pos = -1;
- for (int i = 0; i < count; i++) {
- float distance = fabs(pos - static_cast<float>(blues[i]));
- if (distance < 1.0f * 80.0f / 100.0f && distance < min_distance) {
+ for (int i = 0; i < static_cast<int>(blues->size()); ++i) {
+ float distance = fabs(pos - static_cast<float>(blues->at(i)));
+ if (distance < std::min(0.8f, min_distance)) {
min_distance = distance;
closest_pos = i;
}
}
if (closest_pos >= 0)
- return blues[closest_pos];
+ return blues->at(closest_pos);
int new_pos = FXSYS_round(pos);
- if (count == TYPE3_MAX_BLUES)
- return new_pos;
- blues[count++] = new_pos;
+ if (blues->size() < kType3MaxBlues)
+ blues->push_back(new_pos);
return new_pos;
}
-void CPDF_Type3Glyphs::AdjustBlue(float top,
- float bottom,
- int& top_line,
- int& bottom_line) {
- top_line = _AdjustBlue(top, m_TopBlueCount, m_TopBlue);
- bottom_line = _AdjustBlue(bottom, m_BottomBlueCount, m_BottomBlue);
+} // namespace
+
+CPDF_Type3Glyphs::CPDF_Type3Glyphs() {}
+
+CPDF_Type3Glyphs::~CPDF_Type3Glyphs() {}
+
+std::pair<int, int> CPDF_Type3Glyphs::AdjustBlue(float top, float bottom) {
+ return std::make_pair(AdjustBlueHelper(top, &m_TopBlue),
+ AdjustBlueHelper(bottom, &m_BottomBlue));
}