Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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 Loading... | |
| 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 |
| OLD | NEW |