summaryrefslogtreecommitdiff
path: root/samples/pdfium_test.cc
diff options
context:
space:
mode:
authorLei Zhang <thestig@chromium.org>2015-09-23 15:31:44 -0700
committerLei Zhang <thestig@chromium.org>2015-09-23 15:31:44 -0700
commit6f62d53b7650311afc490bfdaa48f5e8536b8b4e (patch)
tree9b1e1cc17f3d75d6f9bd2413281d5b29450f1fcd /samples/pdfium_test.cc
parent5377ebf967ea860eec4b3cfa3877ed30b84509dc (diff)
downloadpdfium-6f62d53b7650311afc490bfdaa48f5e8536b8b4e.tar.xz
Merge to XFA: Allow external font-path configuration from pdfium_test.
TBR=tsepez@chromium.org Review URL: https://codereview.chromium.org/1268323004 . (cherry picked from commit 9311163b564785a3a3ccdcb09bd3b7d0b2976d1a) Review URL: https://codereview.chromium.org/1368513002 .
Diffstat (limited to 'samples/pdfium_test.cc')
-rw-r--r--samples/pdfium_test.cc25
1 files changed, 22 insertions, 3 deletions
diff --git a/samples/pdfium_test.cc b/samples/pdfium_test.cc
index f060eb018b..bf10675573 100644
--- a/samples/pdfium_test.cc
+++ b/samples/pdfium_test.cc
@@ -48,6 +48,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.
@@ -348,6 +349,13 @@ 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") {
@@ -578,8 +586,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"
@@ -612,7 +621,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));