diff options
author | thestig@chromium.org <thestig@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-06-10 21:29:57 +0000 |
---|---|---|
committer | thestig@chromium.org <thestig@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-06-10 21:29:57 +0000 |
commit | 580c990d8405b441dc9f821afe79a0f3f72d623f (patch) | |
tree | 735501506448cab14016d3f96aa0d8e6b66bfe4d /pdf | |
parent | ce28b04af130a7bce2168c525bcbb1857685e996 (diff) | |
download | chromium_src-580c990d8405b441dc9f821afe79a0f3f72d623f.zip chromium_src-580c990d8405b441dc9f821afe79a0f3f72d623f.tar.gz chromium_src-580c990d8405b441dc9f821afe79a0f3f72d623f.tar.bz2 |
Linux: Take into account the weight/italic parameters when mapping fonts on Linux.
BUG=pdfium:7
Review URL: https://codereview.chromium.org/326823002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@276161 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'pdf')
-rw-r--r-- | pdf/pdfium/pdfium_engine.cc | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/pdf/pdfium/pdfium_engine.cc b/pdf/pdfium/pdfium_engine.cc index 4565131..c012dec 100644 --- a/pdf/pdfium/pdfium_engine.cc +++ b/pdf/pdfium/pdfium_engine.cc @@ -136,6 +136,19 @@ struct PDFFontSubstitution { 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 @@ void* MapFont(struct _FPDF_SYSFONTINFO*, int weight, int italic, // 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()) { |