From 76c64a3c2a739692528360ccb6326c5b9b15121e Mon Sep 17 00:00:00 2001 From: Stephen Gaito Date: Wed, 11 Dec 2019 10:06:31 +0000 Subject: [PATCH] now use argv0 to initialize ffw --- pdf2htmlEX/src/HTMLRenderer/HTMLRenderer.h | 2 +- pdf2htmlEX/src/HTMLRenderer/general.cc | 4 ++-- pdf2htmlEX/src/pdf2htmlEX.cc | 2 +- pdf2htmlEX/src/util/ffw.c | 6 ++++-- pdf2htmlEX/src/util/ffw.h | 2 +- 5 files changed, 9 insertions(+), 7 deletions(-) diff --git a/pdf2htmlEX/src/HTMLRenderer/HTMLRenderer.h b/pdf2htmlEX/src/HTMLRenderer/HTMLRenderer.h index a1195e8..c71d282 100644 --- a/pdf2htmlEX/src/HTMLRenderer/HTMLRenderer.h +++ b/pdf2htmlEX/src/HTMLRenderer/HTMLRenderer.h @@ -75,7 +75,7 @@ namespace pdf2htmlEX { struct HTMLRenderer : OutputDev { - HTMLRenderer(Param & param); + HTMLRenderer(const char* progPath, Param & param); virtual ~HTMLRenderer(); void process(PDFDoc * doc); diff --git a/pdf2htmlEX/src/HTMLRenderer/general.cc b/pdf2htmlEX/src/HTMLRenderer/general.cc index 459e091..7d43d13 100644 --- a/pdf2htmlEX/src/HTMLRenderer/general.cc +++ b/pdf2htmlEX/src/HTMLRenderer/general.cc @@ -41,7 +41,7 @@ using std::abs; using std::cerr; using std::endl; -HTMLRenderer::HTMLRenderer(Param & param) +HTMLRenderer::HTMLRenderer(const char* progPath, Param & param) :OutputDev() ,param(param) ,html_text_page(param, all_manager) @@ -56,7 +56,7 @@ HTMLRenderer::HTMLRenderer(Param & param) globalParams->setErrQuiet(true); } - ffw_init(param.debug); + ffw_init(progPath, param.debug); cur_mapping.resize(0x10000); cur_mapping2.resize(0x100); diff --git a/pdf2htmlEX/src/pdf2htmlEX.cc b/pdf2htmlEX/src/pdf2htmlEX.cc index 9191489..7f3b7e6 100644 --- a/pdf2htmlEX/src/pdf2htmlEX.cc +++ b/pdf2htmlEX/src/pdf2htmlEX.cc @@ -439,7 +439,7 @@ int main(int argc, char **argv) param.last_page = min(max(param.last_page, param.first_page), doc->getNumPages()); - unique_ptr(new HTMLRenderer(param))->process(doc); + unique_ptr(argv[0], new HTMLRenderer(param))->process(doc); finished = true; } diff --git a/pdf2htmlEX/src/util/ffw.c b/pdf2htmlEX/src/util/ffw.c index 901b508..fabfab9 100644 --- a/pdf2htmlEX/src/util/ffw.c +++ b/pdf2htmlEX/src/util/ffw.c @@ -19,6 +19,7 @@ #include "SignalHandler.h" #include "ffw.h" +#include "gfile.h" #include "fontforge-version-extras.h" // needed for FONTFORGE_GIT_VERSION #include "fontforge-20190801/autowidth.h" #include "fontforge-20190801/bitmapchar.h" @@ -67,10 +68,11 @@ static void dumb_logwarning(const char * format, ...) { } static void dumb_post_error(const char * title, const char * error, ...) { } -void ffw_init(int debug) +void ffw_init(const char* progPath, int debug) { ffwSetAction("initialize"); - FindProgDir(NULL); + char *localProgPath = strdup(progPath); + FindProgDir(localProgPath); InitSimpleStuff(); if ( default_encoding==NULL ) default_encoding=FindOrMakeEncoding("ISO8859-1"); diff --git a/pdf2htmlEX/src/util/ffw.h b/pdf2htmlEX/src/util/ffw.h index 5ce70e9..1e5e35f 100644 --- a/pdf2htmlEX/src/util/ffw.h +++ b/pdf2htmlEX/src/util/ffw.h @@ -21,7 +21,7 @@ extern "C" { //////////////////////// // global -void ffw_init(int debug); +void ffw_init(const char* progPath, int debug); void ffw_finalize(void); typedef struct ffw_version_info {