summaryrefslogtreecommitdiff
path: root/samples/pdfium_test.cc
diff options
context:
space:
mode:
authorTom Sepez <tsepez@chromium.org>2015-08-13 11:52:45 -0700
committerTom Sepez <tsepez@chromium.org>2015-08-13 11:52:45 -0700
commit9311163b564785a3a3ccdcb09bd3b7d0b2976d1a (patch)
treea6bb01ee4e1f43ad6659baa1c24fac729bcd5033 /samples/pdfium_test.cc
parent98367f3ef7dc76c856db1c8a3721bef5f9b7adfc (diff)
downloadpdfium-9311163b564785a3a3ccdcb09bd3b7d0b2976d1a.tar.xz
Allow external font-path configuration from pdfium_test.
R=thestig@chromium.org Committed: https://pdfium.googlesource.com/pdfium/+/d8b5e73d8609b74e6a995ee1768d20d47bd4b089 Review URL: https://codereview.chromium.org/1268323004 .
Diffstat (limited to 'samples/pdfium_test.cc')
-rw-r--r--samples/pdfium_test.cc26
1 files changed, 23 insertions, 3 deletions
diff --git a/samples/pdfium_test.cc b/samples/pdfium_test.cc
index 0d76b63f26..5a171c3933 100644
--- a/samples/pdfium_test.cc
+++ b/samples/pdfium_test.cc
@@ -46,6 +46,7 @@ struct Options {
std::string scale_factor_as_string;
std::string exe_path;
std::string bin_directory;
+ std::string font_directory;
};
// Reads the entire contents of a file into a newly malloc'd buffer.
@@ -347,7 +348,15 @@ bool ParseCommandLine(const std::vector<std::string>& args,
return false;
}
options->output_format = OUTPUT_PNG;
+ } else if (cur_arg.size() > 11 &&
+ cur_arg.compare(0, 11, "--font-dir=") == 0) {
+ if (!options->font_directory.empty()) {
+ fprintf(stderr, "Duplicate --font-dir argument\n");
+ return false;
+ }
+ options->font_directory = cur_arg.substr(11);
}
+
#ifdef _WIN32
else if (cur_arg == "--emf") {
if (options->output_format != OUTPUT_NONE) {
@@ -560,8 +569,9 @@ void RenderPdf(const std::string& name, const char* pBuf, size_t len,
static const char usage_string[] =
"Usage: pdfium_test [OPTION] [FILE]...\n"
- " --bin-dir=<path> - override path to v8 external data\n"
- " --scale=<number> - scale output size by number (e.g. 0.5)\n"
+ " --bin-dir=<path> - override path to v8 external data\n"
+ " --font-dir=<path> - override path to external fonts\n"
+ " --scale=<number> - scale output size by number (e.g. 0.5)\n"
#ifdef _WIN32
" --bmp - write page images <pdf-name>.<page-number>.bmp\n"
" --emf - write page meta files <pdf-name>.<page-number>.emf\n"
@@ -599,7 +609,17 @@ int main(int argc, const char* argv[]) {
v8::V8::SetSnapshotDataBlob(&snapshot);
#endif // V8_USE_EXTERNAL_STARTUP_DATA
- FPDF_InitLibrary();
+ if (!options.font_directory.empty()) {
+ const char* path_array[2];
+ path_array[0] = options.font_directory.c_str();
+ path_array[1] = nullptr;
+ FPDF_LIBRARY_CONFIG config;
+ config.version = 1;
+ config.m_pUserFontPaths = path_array;
+ FPDF_InitLibraryWithConfig(&config);
+ } else {
+ FPDF_InitLibrary();
+ }
UNSUPPORT_INFO unsuppored_info;
memset(&unsuppored_info, '\0', sizeof(unsuppored_info));