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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pdf/pdfium/pdfium_engine.cc
===================================================================
--- pdf/pdfium/pdfium_engine.cc (revision 275911)
+++ pdf/pdfium/pdfium_engine.cc (working copy)
@@ -136,6 +136,19 @@
bool italic;
};
+PP_BrowserFont_Trusted_Weight WeightToBrowserFontTrustedWeight(int weight) {
+ COMPILE_ASSERT(PP_BROWSERFONT_TRUSTED_WEIGHT_100 == 0,
+ PP_BrowserFont_Trusted_Weight_Min);
+ COMPILE_ASSERT(PP_BROWSERFONT_TRUSTED_WEIGHT_900 == 8,
+ PP_BrowserFont_Trusted_Weight_Max);
+ const int kMinimumWeight = 100;
+ const int kMaximumWeight = 900;
+ int normalized_weight =
+ std::min(std::max(weight, kMinimumWeight), kMaximumWeight);
+ normalized_weight = (normalized_weight / 100) - 1;
+ return static_cast<PP_BrowserFont_Trusted_Weight>(normalized_weight);
+}
+
// This list is for CPWL_FontMap::GetDefaultFontByCharset().
// We pretend to have these font natively and let the browser (or underlying
// fontconfig) to pick the proper font on the system.
@@ -221,6 +234,9 @@
// TODO(kochi): Pass the face in UTF-8. If face is not encoded in UTF-8,
// convert to UTF-8 before passing.
description.set_face(face);
+
+ description.set_weight(WeightToBrowserFontTrustedWeight(weight));
+ description.set_italic(italic > 0);
}
if (!pp::PDF::IsAvailable()) {
« 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