Skip to content

Commit

Permalink
Clean pdf2htmlEX and wvWare packages (#18)
Browse files Browse the repository at this point in the history
  • Loading branch information
andiwand authored Sep 18, 2024
1 parent c5638b1 commit d5a8f98
Show file tree
Hide file tree
Showing 25 changed files with 517 additions and 585 deletions.
4 changes: 1 addition & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ name: build

on:
push:
paths:
- 'recipes/**'
schedule:
# Executed daily, 9:37 is randomly picked time, not 00:00,
# because 00:00 is used too frequently and GitHub asks to do cronjobs at less busy times
Expand Down Expand Up @@ -88,7 +86,7 @@ jobs:
if: ${{ github.event.inputs.build_dependents != 'false' }}
shell: bash # bash shell needed to pipefail on error
run: |
conan graph info recipes/odrcore/all/conanfile.py --version=4.1.0-pdf2htmlex-git --profile:host=android-21-armv8 --format=json | tee odrcore-dependency-tree.json
conan graph info recipes/odrcore/all/conanfile.py --version=4.1.0 --profile:host=android-21-armv8 --format=json | tee odrcore-dependency-tree.json
echo "graph_file=odrcore-dependency-tree.json" >> $GITHUB_OUTPUT
- name: Generate wvware dependency tree
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/build_inner.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ on:
secrets:
ARTIFACTORY:
required: true

jobs:
build:
runs-on: ${{ matrix.config.build_machine }}
Expand Down
6 changes: 4 additions & 2 deletions recipes/fontforge/all/conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def requirements(self):
self.requires("libxml2/2.12.7")
self.requires("giflib/5.2.2")
self.requires("libjpeg/9f")
self.requires("libpng/1.6.43")
self.requires("libpng/[>=1.6 <2]")

if self.options.with_tiff:
self.requires("libtiff/4.6.0")
Expand Down Expand Up @@ -80,7 +80,7 @@ def source(self):
apply_conandata_patches(self)

def layout(self):
cmake_layout(self)
cmake_layout(self, src_folder="src")

def generate(self):
deps = CMakeDeps(self)
Expand All @@ -94,6 +94,7 @@ def generate(self):
tc.variables["ENABLE_LIBTIFF"] = self.options.with_tiff
tc.variables["ENABLE_LIBREADLINE"] = "OFF"
tc.variables["INSTALL_PRIVATE_HEADERS"] = self.options.install_private_headers
tc.variables["CMAKE_INSTALL_INCLUDEDIR"] = "include/fontforge"
tc.generate()

def build(self):
Expand Down Expand Up @@ -149,3 +150,4 @@ def package(self):

def package_info(self):
self.cpp_info.libs = ["fontforge"]
self.cpp_info.includedirs = ["include", "include/fontforge"]
4 changes: 2 additions & 2 deletions recipes/fontforge/all/test_package/link_test.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include <fontforge.h>
#include "start.h"
#include <fontforge/fontforge.h>
#include "fontforge/start.h"

int main()
{
Expand Down
3 changes: 0 additions & 3 deletions recipes/odrcore/all/conandata.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,6 @@ sources:
source:
url: "https://github.com/opendocument-app/OpenDocument.core/archive/refs/tags/v4.1.0.tar.gz"
sha256: "3608b1ac4723881b88d6212420bc725a0d758360d97155c1a5919271ae8f3c79"
"4.1.0-pdf2htmlex-git":
source:
url: "https://github.com/opendocument-app/OpenDocument.core/archive/refs/heads/pdf2htmlex-conan.zip"
"4.1.1":
source:
url: "https://github.com/opendocument-app/OpenDocument.core/archive/refs/tags/v4.1.1.tar.gz"
Expand Down
15 changes: 1 addition & 14 deletions recipes/odrcore/all/conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,6 @@ def config_options(self):
# But by the time config_options() is executed, default_options is already done parsed.
del self.options.with_pdf2htmlEX
del self.options.with_wvWare
elif self.version != "4.1.0-pdf2htmlex-git":
del self.options.with_pdf2htmlEX
del self.options.with_wvWare

def configure(self):
if self.options.shared:
Expand All @@ -59,7 +56,7 @@ def requirements(self):
self.requires("uchardet/0.0.8")
self.requires("utfcpp/4.0.4")
if self.options.get_safe("with_pdf2htmlEX"):
self.requires("pdf2htmlex/0.18.8.rc1-20240905-git")
self.requires("pdf2htmlex/0.18.8.rc1-git-6f85c88")
if self.options.get_safe("with_wvWare"):
self.requires("wvware/1.2.9")

Expand Down Expand Up @@ -107,16 +104,6 @@ def build(self):
cmake.build()

def package(self):
# Not needed with CMake changes in 4.1.0-pdf2htmlex-git
# Other versions may not need it too
if self.version != "4.1.0-pdf2htmlex-git":
copy(
self,
"*.hpp",
src=os.path.join(self.recipe_folder, "src"),
dst=os.path.join(self.export_sources_folder, "include"),
)

cmake = CMake(self)
cmake.install()

Expand Down
2 changes: 0 additions & 2 deletions recipes/odrcore/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,5 @@ versions:
folder: "all"
"4.1.0":
folder: "all"
"4.1.0-pdf2htmlex-git":
folder: "all"
"4.1.1":
folder: "all"
12 changes: 9 additions & 3 deletions recipes/pdf2htmlex/all/conandata.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
sources:
"0.18.8.rc1-20240905-git":
url: "https://github.com/ViliusSutkus89/pdf2htmlEX/archive/0bbd6686f7214c5ddb230fa3323b75e954f39418.zip"
sha256: "394a5a5555005a18ada6f810ef7ab693f6d916cd9302d874483cbc4956caf557"
"0.18.8.rc1-git-6f85c88":
url: "https://github.com/opendocument-app/pdf2htmlEX/archive/refs/tags/v0.18.8.rc1-git-6f85c88.tar.gz"
sha256: "b88c0897c26caaba62c84069a22043be703a495852af3d9af9d63e18fde2296e"
patches:
"0.18.8.rc1-git-6f85c88":
- patch_file: "patches/0.18.8.rc1-git-6f85c88/0001-Upgrade-Poppler-to-24.06.1.patch"
- patch_file: "patches/0.18.8.rc1-git-6f85c88/0002-Update-missing-font-workaround.patch"
- patch_file: "patches/0.18.8.rc1-git-6f85c88/0003-use-find_package.patch"
- patch_file: "patches/0.18.8.rc1-git-6f85c88/0004-build-and-install-library.patch"
44 changes: 22 additions & 22 deletions recipes/pdf2htmlex/all/conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,25 @@ class pdf2htmlEXConan(ConanFile):
options = {"shared": [True, False], "fPIC": [True, False]}
default_options = {"shared": False, "fPIC": True}

def config_options(self):
if self.settings.os == "Windows":
self.options.rm_safe("fPIC")

def configure(self):
if self.options.shared:
self.options.rm_safe("fPIC")

def validate(self):
if not self.dependencies["poppler"].options.with_cairo:
raise ConanInvalidConfiguration('Dependency "poppler" needs to be built with "with_cairo" option')
if not self.dependencies["poppler"].options.with_glib:
raise ConanInvalidConfiguration('Dependency "poppler" needs to be built with "with_glib" option')
if self.dependencies["poppler"].options.shared:
raise ConanInvalidConfiguration('Dependency "poppler" needs to be built as a static library (shared=False)')
if not self.dependencies["fontforge"].options.install_private_headers:
raise ConanInvalidConfiguration(
'Dependency "fontforge" needs to be built with "install_private_headers" option')

def requirements(self):
self.requires("poppler/24.08.0-odr", options={
"with_cairo": True,
Expand Down Expand Up @@ -53,6 +72,9 @@ def requirements(self):
# self.requires("libiconv/1.17")
# self.requires("giflib/5.2.2")

def layout(self):
cmake_layout(self, src_folder="src")

def export_sources(self):
export_conandata_patches(self)

Expand All @@ -65,28 +87,6 @@ def source(self):
exe = os.path.join(self.source_folder, "pdf2htmlEX", "share", executable)
os.chmod(exe, os.stat(exe).st_mode | stat.S_IEXEC)

def config_options(self):
if self.settings.os == "Windows":
self.options.rm_safe("fPIC")

def configure(self):
if self.options.shared:
self.options.rm_safe("fPIC")

def validate(self):
if not self.dependencies["poppler"].options.with_cairo:
raise ConanInvalidConfiguration('Dependency "poppler" needs to be built with "with_cairo" option')
if not self.dependencies["poppler"].options.with_glib:
raise ConanInvalidConfiguration('Dependency "poppler" needs to be built with "with_glib" option')
if self.dependencies["poppler"].options.shared:
raise ConanInvalidConfiguration('Dependency "poppler" needs to be built as a static library (shared=False)')
if not self.dependencies["fontforge"].options.install_private_headers:
raise ConanInvalidConfiguration(
'Dependency "fontforge" needs to be built with "install_private_headers" option')

def layout(self):
cmake_layout(self, src_folder="src")

def generate(self):
deps = CMakeDeps(self)
deps.generate()
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,161 @@
From 5e5a947bd1320e19c1271f5dfaeef098baae4452 Mon Sep 17 00:00:00 2001
From: Vilius Sutkus '89 <[email protected]>
Date: Thu, 13 Jun 2024 14:18:06 +0300
Subject: [PATCH 1/4] Upgrade Poppler to 24.06.1

Poppler-24.02.0 OutlineItem changed Title from Unicode pointer and length counter into Unicode vector. ( https://gitlab.freedesktop.org/poppler/poppler/-/commit/fc1c711cb5f769546c6b31cc688bf0ee7f0c1dbc )

Poppler-24.03.0 GooString.h exposes std::string::starts_with and ::ends_with which are CXX20.
---
buildScripts/versionEnvs | 5 ++-
pdf2htmlEX/CMakeLists.txt | 4 +-
pdf2htmlEX/src/HTMLRenderer/outline.cc | 2 +-
pdf2htmlEX/src/util/encoding.cc | 60 +++++++++++++++-----------
pdf2htmlEX/src/util/encoding.h | 2 +
5 files changed, 44 insertions(+), 29 deletions(-)

diff --git a/buildScripts/versionEnvs b/buildScripts/versionEnvs
index 3ea6cba..9ef5f8b 100755
--- a/buildScripts/versionEnvs
+++ b/buildScripts/versionEnvs
@@ -4,11 +4,12 @@
# versions

# see: https://poppler.freedesktop.org/releases.html
-# current working: 24.01.0
+# current working: 24.06.1

export PDF2HTMLEX_VERSION=0.18.8.rc2

-export POPPLER_VERSION=poppler-24.01.0
+export POPPLER_VERSION=poppler-24.06.1
+#export POPPLER_VERSION=poppler-24.01.0
#export POPPLER_VERSION=poppler-23.12.0
#export POPPLER_VERSION=poppler-21.02.0
#export POPPLER_VERSION=poppler-0.89.0
diff --git a/pdf2htmlEX/CMakeLists.txt b/pdf2htmlEX/CMakeLists.txt
index 761bb21..84b4a98 100644
--- a/pdf2htmlEX/CMakeLists.txt
+++ b/pdf2htmlEX/CMakeLists.txt
@@ -125,8 +125,8 @@ set(CMAKE_THREAD_PREFER_PTHREAD ON)
set(THREADS_PREFER_PTHREAD_FLAG ON)
find_package(Threads REQUIRED)
set(PDF2HTMLEX_LIBS ${PDF2HTMLEX_LIBS} Threads::Threads)
-# Poppler-23.12.0 requires CXX17
-set(CMAKE_CXX_STANDARD 17)
+# Poppler-24.03.0 requires CXX20
+set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
if(NOT CYGWIN)
set(CMAKE_CXX_EXTENSIONS OFF)
diff --git a/pdf2htmlEX/src/HTMLRenderer/outline.cc b/pdf2htmlEX/src/HTMLRenderer/outline.cc
index 4fdc826..28415c8 100644
--- a/pdf2htmlEX/src/HTMLRenderer/outline.cc
+++ b/pdf2htmlEX/src/HTMLRenderer/outline.cc
@@ -42,7 +42,7 @@ void HTMLRenderer::process_outline_items(const std::vector<OutlineItem*> * items

f_outline.fs << ">";

- writeUnicodes(f_outline.fs, item->getTitle(), item->getTitleLength());
+ writeUnicodes(f_outline.fs, item->getTitle());

f_outline.fs << "</a>";

diff --git a/pdf2htmlEX/src/util/encoding.cc b/pdf2htmlEX/src/util/encoding.cc
index 6b600bc..1e3fc29 100644
--- a/pdf2htmlEX/src/util/encoding.cc
+++ b/pdf2htmlEX/src/util/encoding.cc
@@ -55,34 +55,46 @@ static int mapUTF8(Unicode u, char *buf, int bufSize)
}
}

+static void writeUnicode(ostream & out, const Unicode u) {
+ switch(u)
+ {
+ case '&':
+ out << "&amp;";
+ break;
+ case '\"':
+ out << "&quot;";
+ break;
+ case '\'':
+ out << "&apos;";
+ break;
+ case '<':
+ out << "&lt;";
+ break;
+ case '>':
+ out << "&gt;";
+ break;
+ default:
+ {
+ char buf[4];
+ auto n = mapUTF8(u, buf, 4);
+ out.write(buf, n);
+ }
+ }
+}
+
void writeUnicodes(ostream & out, const Unicode * u, int uLen)
{
for(int i = 0; i < uLen; ++i)
{
- switch(u[i])
- {
- case '&':
- out << "&amp;";
- break;
- case '\"':
- out << "&quot;";
- break;
- case '\'':
- out << "&apos;";
- break;
- case '<':
- out << "&lt;";
- break;
- case '>':
- out << "&gt;";
- break;
- default:
- {
- char buf[4];
- auto n = mapUTF8(u[i], buf, 4);
- out.write(buf, n);
- }
- }
+ writeUnicode(out, u[i]);
+ }
+}
+
+void writeUnicodes(ostream & out, const std::vector<Unicode> & u)
+{
+ for(const auto & i: u)
+ {
+ writeUnicode(out, i);
}
}

diff --git a/pdf2htmlEX/src/util/encoding.h b/pdf2htmlEX/src/util/encoding.h
index c4d7732..da3c00f 100644
--- a/pdf2htmlEX/src/util/encoding.h
+++ b/pdf2htmlEX/src/util/encoding.h
@@ -9,6 +9,7 @@
#define ENCODING_H__

#include <string>
+#include <vector>
#include <iostream>

#include <CharTypes.h>
@@ -19,6 +20,7 @@ namespace pdf2htmlEX {
* Escape necessary characters, and map Unicode to UTF-8
*/
void writeUnicodes(std::ostream & out, const Unicode * u, int uLen);
+void writeUnicodes(std::ostream & out, const std::vector<Unicode> & u);


/*
--
2.39.3 (Apple Git-146)

Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
From 2110b5eaa45decf7ee222953642af5c7967e0424 Mon Sep 17 00:00:00 2001
From: Vilius Sutkus '89 <[email protected]>
Date: Mon, 5 Aug 2024 21:35:29 +0300
Subject: [PATCH 2/4] Update missing font workaround

---
pdf2htmlEX/src/HTMLRenderer/font.cc | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/pdf2htmlEX/src/HTMLRenderer/font.cc b/pdf2htmlEX/src/HTMLRenderer/font.cc
index 9c3112b..ff27da2 100644
--- a/pdf2htmlEX/src/HTMLRenderer/font.cc
+++ b/pdf2htmlEX/src/HTMLRenderer/font.cc
@@ -1080,7 +1080,10 @@ static string general_font_family(GfxFont * font)
// TODO: this function is called when some font is unable to process, may use the name there as a hint
void HTMLRenderer::export_remote_default_font(long long fn_id)
{
- f_css.fs << "." << CSS::FONT_FAMILY_CN << fn_id << "{font-family:sans-serif;visibility:hidden;}" << endl;
+// Workaround for https://github.com/opendocument-app/pdf2htmlEX-Android/issues/94
+// Workaround for https://github.com/opendocument-app/OpenDocument.droid/issues/348
+// f_css.fs << "." << CSS::FONT_FAMILY_CN << fn_id << "{font-family:sans-serif;visibility:hidden;}" << endl;
+ f_css.fs << "." << CSS::FONT_FAMILY_CN << fn_id << "{font-family:sans-serif;visibility:visible;}" << endl;
}

void HTMLRenderer::export_local_font(const FontInfo & info, GfxFont * font, const string & original_font_name, const string & cssfont)
--
2.39.3 (Apple Git-146)

Loading

0 comments on commit d5a8f98

Please sign in to comment.