From 89c74c7b2127a49ef27b041a72af4dc8f9cd9f54 Mon Sep 17 00:00:00 2001 From: Stephen Gaito Date: Mon, 29 Jun 2020 11:39:52 +0000 Subject: [PATCH 1/2] add fixes for issues 70, g9, 68, 66, and 65 --- buildScripts/buildPoppler | 2 +- buildScripts/createDockerAlpineImageFromTarFile | 5 +++++ buildScripts/createDockerUbuntuImageFromDeb | 7 ++++++- pdf2htmlEX/CMakeLists.txt | 6 +++++- pdf2htmlEX/CMakeLists.txt.patch | 12 ------------ pdf2htmlEX/pdf2htmlEX.1.in | 4 ++++ pdf2htmlEX/src/HTMLRenderer/font.cc | 5 +++++ pdf2htmlEX/src/Param.h | 1 + pdf2htmlEX/src/pdf2htmlEX.cc | 1 + 9 files changed, 28 insertions(+), 15 deletions(-) delete mode 100644 pdf2htmlEX/CMakeLists.txt.patch diff --git a/buildScripts/buildPoppler b/buildScripts/buildPoppler index 4583ccb..8c0df80 100755 --- a/buildScripts/buildPoppler +++ b/buildScripts/buildPoppler @@ -40,7 +40,7 @@ cmake \ -DWITH_JPEG=ON \ -DWITH_PNG=ON \ -DWITH_TIFF=OFF \ - -DWITH_NSS=OFF \ + -DWITH_NSS3=OFF \ -DWITH_Cairo=ON \ .. diff --git a/buildScripts/createDockerAlpineImageFromTarFile b/buildScripts/createDockerAlpineImageFromTarFile index a67d63f..5f4d5b4 100755 --- a/buildScripts/createDockerAlpineImageFromTarFile +++ b/buildScripts/createDockerAlpineImageFromTarFile @@ -59,6 +59,11 @@ WORKDIR /root RUN chmod a+x $ALPINE_NAME.install && \ ./$ALPINE_NAME.install + +# make the /pdf directory the default working directory for any run of +# pdf2htmlEX +# +WORKDIR /pdf ENTRYPOINT ["$PDF2HTMLEX_PREFIX/bin/pdf2htmlEX"] DOCKERFILE_HERE_DOC diff --git a/buildScripts/createDockerUbuntuImageFromDeb b/buildScripts/createDockerUbuntuImageFromDeb index b5db6af..f779290 100755 --- a/buildScripts/createDockerUbuntuImageFromDeb +++ b/buildScripts/createDockerUbuntuImageFromDeb @@ -59,7 +59,12 @@ COPY ./$DPKG_NAME /root RUN apt update && \ apt -y upgrade && \ apt -y --no-install-recommends install \ - /root/$DPKG_NAME + /root/$DPKG_NAME + +# make the /pdf directory the default working directory for any run of +# pdf2htmlEX +# +WORKDIR /pdf ENTRYPOINT ["$PDF2HTMLEX_PREFIX/bin/pdf2htmlEX"] DOCKERFILE_HERE_DOC diff --git a/pdf2htmlEX/CMakeLists.txt b/pdf2htmlEX/CMakeLists.txt index 218c54d..b5cb520 100644 --- a/pdf2htmlEX/CMakeLists.txt +++ b/pdf2htmlEX/CMakeLists.txt @@ -10,7 +10,11 @@ option(ENABLE_SVG "Enable SVG support, for generating SVG background images and include_directories(${CMAKE_SOURCE_DIR}/src) -set(PDF2HTMLEX_VERSION "0.18.7") +# Read/Set Cmake's PDF2HTMLEX_VERSION directly from the shell environment +# variable PDF2HTMLEX_VERSION +# +set(PDF2HTMLEX_VERSION $ENV{PDF2HTMLEX_VERSION}) +# set(ARCHIVE_NAME pdf2htmlex-${PDF2HTMLEX_VERSION}) add_custom_target(dist COMMAND git archive --prefix=${ARCHIVE_NAME}/ HEAD diff --git a/pdf2htmlEX/CMakeLists.txt.patch b/pdf2htmlEX/CMakeLists.txt.patch deleted file mode 100644 index 7d70e4a..0000000 --- a/pdf2htmlEX/CMakeLists.txt.patch +++ /dev/null @@ -1,12 +0,0 @@ -diff --git a/CMakeLists.txt b/CMakeLists.txt -index 135e02f..97c7035 100644 ---- a/CMakeLists.txt -+++ b/CMakeLists.txt -@@ -7,6 +7,7 @@ cmake_minimum_required(VERSION 2.6.0 FATAL_ERROR) - - option(ENABLE_SVG "Enable SVG support, for generating SVG background images and converting Type 3 fonts" ON) - -+include_directories(${CMAKE_INSTALL_PREFIX}/include) - include_directories(${CMAKE_SOURCE_DIR}/src) - - set(PDF2HTMLEX_VERSION "0.15.0") diff --git a/pdf2htmlEX/pdf2htmlEX.1.in b/pdf2htmlEX/pdf2htmlEX.1.in index 570997c..fe4f661 100644 --- a/pdf2htmlEX/pdf2htmlEX.1.in +++ b/pdf2htmlEX/pdf2htmlEX.1.in @@ -174,6 +174,10 @@ Specify the format of fonts extracted from the PDF file. .B \-\-decompose\-ligature <0|1> (Default: 0) Decompose ligatures. For example 'fi' \-> 'f''i'. +.TP +.B \-\-turn\-off\-ligatures <0|1> (Default: 0) +Explicitly tell browsers not to use ligatures. + .TP .B \-\-auto\-hint <0|1> (Default: 0) If set to 1, hints will be generated for the fonts using FontForge. diff --git a/pdf2htmlEX/src/HTMLRenderer/font.cc b/pdf2htmlEX/src/HTMLRenderer/font.cc index 466f691..6f240ba 100644 --- a/pdf2htmlEX/src/HTMLRenderer/font.cc +++ b/pdf2htmlEX/src/HTMLRenderer/font.cc @@ -1001,6 +1001,10 @@ void HTMLRenderer::install_external_font(GfxFont * font, FontInfo & info) void HTMLRenderer::export_remote_font(const FontInfo & info, const string & format, GfxFont * font) { + string css_turn_off_ligatures = ""; + if (param.turn_off_ligatures) { + css_turn_off_ligatures = "font-variant-ligatures:none;font-feature-settings: "liga" 0, "clig" 0, "dlig" 0, "hlig" 0, "calt" 0;"; + } string css_font_format; if(format == "ttf") { @@ -1055,6 +1059,7 @@ void HTMLRenderer::export_remote_font(const FontInfo & info, const string & form f_css.fs << ")" << "format(\"" << css_font_format << "\");" + << css_turn_off_ligatures << "}" // end of @font-face << "." << CSS::FONT_FAMILY_CN << info.id << "{" << "font-family:" << CSS::FONT_FAMILY_CN << info.id << ";" diff --git a/pdf2htmlEX/src/Param.h b/pdf2htmlEX/src/Param.h index 9189f49..859c78b 100644 --- a/pdf2htmlEX/src/Param.h +++ b/pdf2htmlEX/src/Param.h @@ -51,6 +51,7 @@ struct Param int embed_external_font; std::string font_format; int decompose_ligature; + int turn_off_ligatures; int auto_hint; std::string external_hint_tool; int stretch_narrow_glyph; diff --git a/pdf2htmlEX/src/pdf2htmlEX.cc b/pdf2htmlEX/src/pdf2htmlEX.cc index 7197e51..d77fb83 100644 --- a/pdf2htmlEX/src/pdf2htmlEX.cc +++ b/pdf2htmlEX/src/pdf2htmlEX.cc @@ -170,6 +170,7 @@ void parse_options (int argc, char **argv) .add("embed-external-font", ¶m.embed_external_font, 1, "embed local match for external fonts") .add("font-format", ¶m.font_format, "woff", "suffix for embedded font files (ttf,otf,woff,svg)") .add("decompose-ligature", ¶m.decompose_ligature, 0, "decompose ligatures, such as \uFB01 -> fi") + .add("turn-off-ligatures", ¶m.turn_off_ligatures, 0, "explicitly tell browsers not to use ligatures") .add("auto-hint", ¶m.auto_hint, 0, "use fontforge autohint on fonts without hints") .add("external-hint-tool", ¶m.external_hint_tool, "", "external tool for hinting fonts (overrides --auto-hint)") .add("stretch-narrow-glyph", ¶m.stretch_narrow_glyph, 0, "stretch narrow glyphs instead of padding them") From 33d2a5e1768f2a733c14dfbc3a2c4cc4c5c849c0 Mon Sep 17 00:00:00 2001 From: Stephen Gaito Date: Mon, 29 Jun 2020 12:23:01 +0000 Subject: [PATCH 2/2] tested and corrected issue 68 and 66 --- buildScripts/buildPdf2htmlEX | 4 ++++ buildScripts/versionEnvs | 2 +- pdf2htmlEX/src/HTMLRenderer/font.cc | 4 ++-- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/buildScripts/buildPdf2htmlEX b/buildScripts/buildPdf2htmlEX index daa62a3..e5452b6 100755 --- a/buildScripts/buildPdf2htmlEX +++ b/buildScripts/buildPdf2htmlEX @@ -2,9 +2,13 @@ # This shell script builds pdf2htmlEX +# source ./buildScripts/reSourceVersionEnvs +. ./buildScripts/reSourceVersionEnvs + echo "" echo "-------------------------------------------------------------------" echo "BUILDING pdf2htmlEX (using gcc)" +echo " PDF2HTMLEX_VERSION = [$PDF2HTMLEX_VERSION]" echo "-------------------------------------------------------------------" echo "" diff --git a/buildScripts/versionEnvs b/buildScripts/versionEnvs index 00ac4b6..53a58ac 100755 --- a/buildScripts/versionEnvs +++ b/buildScripts/versionEnvs @@ -6,7 +6,7 @@ # see: https://poppler.freedesktop.org/releases.html # current working: 0.83.0 -export PDF2HTMLEX_VERSION=0.18.8.alpha +export PDF2HTMLEX_VERSION=0.18.8.rc1 export POPPLER_VERSION=poppler-0.89.0 #export POPPLER_VERSION=poppler-0.88.0 diff --git a/pdf2htmlEX/src/HTMLRenderer/font.cc b/pdf2htmlEX/src/HTMLRenderer/font.cc index 6f240ba..b93e9be 100644 --- a/pdf2htmlEX/src/HTMLRenderer/font.cc +++ b/pdf2htmlEX/src/HTMLRenderer/font.cc @@ -1003,7 +1003,7 @@ void HTMLRenderer::export_remote_font(const FontInfo & info, const string & form { string css_turn_off_ligatures = ""; if (param.turn_off_ligatures) { - css_turn_off_ligatures = "font-variant-ligatures:none;font-feature-settings: "liga" 0, "clig" 0, "dlig" 0, "hlig" 0, "calt" 0;"; + css_turn_off_ligatures = "font-variant-ligatures:none;font-feature-settings: \"liga\" 0, \"clig\" 0, \"dlig\" 0, \"hlig\" 0, \"calt\" 0;"; } string css_font_format; if(format == "ttf") @@ -1059,7 +1059,6 @@ void HTMLRenderer::export_remote_font(const FontInfo & info, const string & form f_css.fs << ")" << "format(\"" << css_font_format << "\");" - << css_turn_off_ligatures << "}" // end of @font-face << "." << CSS::FONT_FAMILY_CN << info.id << "{" << "font-family:" << CSS::FONT_FAMILY_CN << info.id << ";" @@ -1067,6 +1066,7 @@ void HTMLRenderer::export_remote_font(const FontInfo & info, const string & form << "font-style:normal;" << "font-weight:normal;" << "visibility:visible;" + << css_turn_off_ligatures << "}" << endl; }