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

Side by Side Diff: core/fpdfapi/fpdf_render/cpdf_type3glyphs.cpp

Issue 2393593002: Move core/fpdfapi/fpdf_render to core/fpdfapi/render (Closed)
Patch Set: Rebase to master Created 4 years, 2 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 unified diff | Download patch
« no previous file with comments | « core/fpdfapi/fpdf_render/cpdf_type3glyphs.h ('k') | core/fpdfapi/fpdf_render/fpdf_render.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2016 PDFium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6
7 #include "core/fpdfapi/fpdf_render/cpdf_type3glyphs.h"
8
9 #include <map>
10
11 #include "core/fxge/fx_font.h"
12
13 CPDF_Type3Glyphs::CPDF_Type3Glyphs()
14 : m_TopBlueCount(0), m_BottomBlueCount(0) {}
15
16 CPDF_Type3Glyphs::~CPDF_Type3Glyphs() {
17 for (const auto& pair : m_GlyphMap)
18 delete pair.second;
19 }
20
21 static int _AdjustBlue(FX_FLOAT pos, int& count, int blues[]) {
22 FX_FLOAT min_distance = 1000000.0f;
23 int closest_pos = -1;
24 for (int i = 0; i < count; i++) {
25 FX_FLOAT distance = FXSYS_fabs(pos - static_cast<FX_FLOAT>(blues[i]));
26 if (distance < 1.0f * 80.0f / 100.0f && distance < min_distance) {
27 min_distance = distance;
28 closest_pos = i;
29 }
30 }
31 if (closest_pos >= 0)
32 return blues[closest_pos];
33 int new_pos = FXSYS_round(pos);
34 if (count == TYPE3_MAX_BLUES)
35 return new_pos;
36 blues[count++] = new_pos;
37 return new_pos;
38 }
39
40 void CPDF_Type3Glyphs::AdjustBlue(FX_FLOAT top,
41 FX_FLOAT bottom,
42 int& top_line,
43 int& bottom_line) {
44 top_line = _AdjustBlue(top, m_TopBlueCount, m_TopBlue);
45 bottom_line = _AdjustBlue(bottom, m_BottomBlueCount, m_BottomBlue);
46 }
OLDNEW
« no previous file with comments | « core/fpdfapi/fpdf_render/cpdf_type3glyphs.h ('k') | core/fpdfapi/fpdf_render/fpdf_render.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698