| 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 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 128 PP_Instance g_last_instance_id; | 128 PP_Instance g_last_instance_id; |
| 129 | 129 |
| 130 struct PDFFontSubstitution { | 130 struct PDFFontSubstitution { |
| 131 const char* pdf_name; | 131 const char* pdf_name; |
| 132 const char* face; | 132 const char* face; |
| 133 bool bold; | 133 bool bold; |
| 134 bool italic; | 134 bool italic; |
| 135 }; | 135 }; |
| 136 | 136 |
| 137 PP_BrowserFont_Trusted_Weight WeightToBrowserFontTrustedWeight(int weight) { | 137 PP_BrowserFont_Trusted_Weight WeightToBrowserFontTrustedWeight(int weight) { |
| 138 COMPILE_ASSERT(PP_BROWSERFONT_TRUSTED_WEIGHT_100 == 0, | 138 static_assert(PP_BROWSERFONT_TRUSTED_WEIGHT_100 == 0, |
| 139 PP_BrowserFont_Trusted_Weight_Min); | 139 "PP_BrowserFont_Trusted_Weight min"); |
| 140 COMPILE_ASSERT(PP_BROWSERFONT_TRUSTED_WEIGHT_900 == 8, | 140 static_assert(PP_BROWSERFONT_TRUSTED_WEIGHT_900 == 8, |
| 141 PP_BrowserFont_Trusted_Weight_Max); | 141 "PP_BrowserFont_Trusted_Weight max"); |
| 142 const int kMinimumWeight = 100; | 142 const int kMinimumWeight = 100; |
| 143 const int kMaximumWeight = 900; | 143 const int kMaximumWeight = 900; |
| 144 int normalized_weight = | 144 int normalized_weight = |
| 145 std::min(std::max(weight, kMinimumWeight), kMaximumWeight); | 145 std::min(std::max(weight, kMinimumWeight), kMaximumWeight); |
| 146 normalized_weight = (normalized_weight / 100) - 1; | 146 normalized_weight = (normalized_weight / 100) - 1; |
| 147 return static_cast<PP_BrowserFont_Trusted_Weight>(normalized_weight); | 147 return static_cast<PP_BrowserFont_Trusted_Weight>(normalized_weight); |
| 148 } | 148 } |
| 149 | 149 |
| 150 // This list is for CPWL_FontMap::GetDefaultFontByCharset(). | 150 // This list is for CPWL_FontMap::GetDefaultFontByCharset(). |
| 151 // We pretend to have these font natively and let the browser (or underlying | 151 // We pretend to have these font natively and let the browser (or underlying |
| (...skipping 3729 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3881 double* height) { | 3881 double* height) { |
| 3882 FPDF_DOCUMENT doc = FPDF_LoadMemDocument(pdf_buffer, pdf_buffer_size, NULL); | 3882 FPDF_DOCUMENT doc = FPDF_LoadMemDocument(pdf_buffer, pdf_buffer_size, NULL); |
| 3883 if (!doc) | 3883 if (!doc) |
| 3884 return false; | 3884 return false; |
| 3885 bool success = FPDF_GetPageSizeByIndex(doc, page_number, width, height) != 0; | 3885 bool success = FPDF_GetPageSizeByIndex(doc, page_number, width, height) != 0; |
| 3886 FPDF_CloseDocument(doc); | 3886 FPDF_CloseDocument(doc); |
| 3887 return success; | 3887 return success; |
| 3888 } | 3888 } |
| 3889 | 3889 |
| 3890 } // namespace chrome_pdf | 3890 } // namespace chrome_pdf |
| OLD | NEW |