Commit d295587a authored by thestig's avatar thestig Committed by Commit bot

PDF: On Linux, convert font names to UTF-8 if needed.

BUG=419410

Review URL: https://codereview.chromium.org/1142313002

Cr-Commit-Position: refs/heads/master@{#330801}
parent 4717933a
...@@ -26,7 +26,7 @@ PepperFlashFontFileHost::PepperFlashFontFileHost( ...@@ -26,7 +26,7 @@ PepperFlashFontFileHost::PepperFlashFontFileHost(
: ResourceHost(host->GetPpapiHost(), instance, resource) { : ResourceHost(host->GetPpapiHost(), instance, resource) {
#if defined(OS_LINUX) || defined(OS_OPENBSD) #if defined(OS_LINUX) || defined(OS_OPENBSD)
fd_.reset(content::MatchFontWithFallback( fd_.reset(content::MatchFontWithFallback(
description.face.c_str(), description.face,
description.weight >= PP_BROWSERFONT_TRUSTED_WEIGHT_BOLD, description.weight >= PP_BROWSERFONT_TRUSTED_WEIGHT_BOLD,
description.italic, description.italic,
charset, charset,
......
...@@ -6,6 +6,8 @@ ...@@ -6,6 +6,8 @@
#include <math.h> #include <math.h>
#include "base/i18n/icu_encoding_detection.h"
#include "base/i18n/icu_string_conversions.h"
#include "base/json/json_writer.h" #include "base/json/json_writer.h"
#include "base/logging.h" #include "base/logging.h"
#include "base/memory/scoped_ptr.h" #include "base/memory/scoped_ptr.h"
...@@ -223,10 +225,22 @@ void* MapFont(struct _FPDF_SYSFONTINFO*, int weight, int italic, ...@@ -223,10 +225,22 @@ void* MapFont(struct _FPDF_SYSFONTINFO*, int weight, int italic,
} }
if (i == arraysize(PDFFontSubstitutions)) { if (i == arraysize(PDFFontSubstitutions)) {
// TODO(kochi): Pass the face in UTF-8. If face is not encoded in UTF-8, // Convert to UTF-8 before calling set_face().
// convert to UTF-8 before passing. std::string face_utf8;
description.set_face(face); if (base::IsStringUTF8(face)) {
face_utf8 = face;
} else {
std::string encoding;
if (base::DetectEncoding(face, &encoding)) {
// ConvertToUtf8AndNormalize() clears |face_utf8| on failure.
base::ConvertToUtf8AndNormalize(face, encoding, &face_utf8);
}
}
if (face_utf8.empty())
return nullptr;
description.set_face(face_utf8);
description.set_weight(WeightToBrowserFontTrustedWeight(weight)); description.set_weight(WeightToBrowserFontTrustedWeight(weight));
description.set_italic(italic > 0); description.set_italic(italic > 0);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment