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

Side by Side Diff: pdf/pdfium/pdfium_engine.cc

Issue 326823002: Linux: Take into account the weight/italic parameters when mapping fonts on Linux. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 6 years, 6 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "pdf/pdfium/pdfium_engine.h" 5 #include "pdf/pdfium/pdfium_engine.h"
6 6
7 #include <math.h> 7 #include <math.h>
8 8
9 #include "base/json/json_writer.h" 9 #include "base/json/json_writer.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
214 if (PDFFontSubstitutions[i].italic) 214 if (PDFFontSubstitutions[i].italic)
215 description.set_italic(true); 215 description.set_italic(true);
216 break; 216 break;
217 } 217 }
218 } 218 }
219 219
220 if (i == arraysize(PDFFontSubstitutions)) { 220 if (i == arraysize(PDFFontSubstitutions)) {
221 // TODO(kochi): Pass the face in UTF-8. If face is not encoded in UTF-8, 221 // TODO(kochi): Pass the face in UTF-8. If face is not encoded in UTF-8,
222 // convert to UTF-8 before passing. 222 // convert to UTF-8 before passing.
223 description.set_face(face); 223 description.set_face(face);
224 int normalized_weight = std::min(std::max(weight, 100), 900);
225 normalized_weight = (normalized_weight / 100) - 1;
jam 2014/06/10 05:47:07 nit: put the 100 and 900 into constants
Lei Zhang 2014/06/10 07:10:27 Done.
226 description.set_weight(
227 static_cast<PP_BrowserFont_Trusted_Weight>(normalized_weight));
228 description.set_italic(italic > 0);
224 } 229 }
225 230
226 if (!pp::PDF::IsAvailable()) { 231 if (!pp::PDF::IsAvailable()) {
227 NOTREACHED(); 232 NOTREACHED();
228 return NULL; 233 return NULL;
229 } 234 }
230 235
231 PP_Resource font_resource = pp::PDF::GetFontFileWithFallback( 236 PP_Resource font_resource = pp::PDF::GetFontFileWithFallback(
232 pp::InstanceHandle(g_last_instance_id), 237 pp::InstanceHandle(g_last_instance_id),
233 &description.pp_font_description(), 238 &description.pp_font_description(),
(...skipping 3144 matching lines...) Expand 10 before | Expand all | Expand 10 after
3378 if (page_width > *max_page_width) { 3383 if (page_width > *max_page_width) {
3379 *max_page_width = page_width; 3384 *max_page_width = page_width;
3380 } 3385 }
3381 } 3386 }
3382 } 3387 }
3383 FPDF_CloseDocument(doc); 3388 FPDF_CloseDocument(doc);
3384 return true; 3389 return true;
3385 } 3390 }
3386 3391
3387 } // namespace chrome_pdf 3392 } // namespace chrome_pdf
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698