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

Unified Diff: pdf/pdfium/pdfium_engine.cc

Issue 1142313002: PDF: On Linux, convert font names to UTF-8 if needed. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 7 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 | « chrome/renderer/pepper/pepper_flash_font_file_host.cc ('k') | 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
diff --git a/pdf/pdfium/pdfium_engine.cc b/pdf/pdfium/pdfium_engine.cc
index f4df4a99529cad87648d71b267ed0c69a8046252..f9feec8e0a7ed290440a750d89b0a3f51179a107 100644
--- a/pdf/pdfium/pdfium_engine.cc
+++ b/pdf/pdfium/pdfium_engine.cc
@@ -6,6 +6,8 @@
#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/logging.h"
#include "base/memory/scoped_ptr.h"
@@ -223,10 +225,22 @@ void* MapFont(struct _FPDF_SYSFONTINFO*, int weight, int italic,
}
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 passing.
- description.set_face(face);
+ // Convert to UTF-8 before calling set_face().
+ std::string face_utf8;
+ 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_italic(italic > 0);
}
« no previous file with comments | « chrome/renderer/pepper/pepper_flash_font_file_host.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698