Skip to content

Commit

Permalink
update mupdf
Browse files Browse the repository at this point in the history
  • Loading branch information
kjk committed Dec 28, 2023
1 parent 9752c25 commit b9dc867
Show file tree
Hide file tree
Showing 35 changed files with 1,977 additions and 571 deletions.
8 changes: 7 additions & 1 deletion mupdf/docs/src/language-bindings.rst
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ Extensions beyond the basic C API
* There are various custom class methods and constructors.

* There are extra functions for generating a text representation of 'POD'
structs and their C++ wrapper classes.
(plain old data) structs and their C++ wrapper classes.

For example for `fz_rect` we provide these functions:

Expand Down Expand Up @@ -890,6 +890,12 @@ Building and installing the Python bindings using `pip`
available from pypi.org so pip will fail to install prerequisites from
`pypackage.toml`.

Instead one can run `setup.py` directly:

.. code-block:: shell
cd mupdf && setup.py install
Building the Python bindings
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Expand Down
30 changes: 30 additions & 0 deletions mupdf/include/mupdf/fitz/archive.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,9 @@ fz_archive *fz_open_directory(fz_context *ctx, const char *path);

/**
Determine if a given path is a directory.
In the case of the path not existing, or having no access
we will return 0.
*/
int fz_is_directory(fz_context *ctx, const char *path);

Expand Down Expand Up @@ -214,6 +217,13 @@ int fz_is_libarchive_archive(fz_context *ctx, fz_stream *file);
*/
int fz_is_chm_archive(fz_context *ctx, fz_stream *file);

/**
Detect if stream object is a cfb archive.
Assumes that the stream object is seekable.
*/
int fz_is_cfb_archive(fz_context *ctx, fz_stream *file);

/**
Open a tar archive file.
Expand Down Expand Up @@ -277,6 +287,26 @@ fz_archive *fz_open_chm_archive(fz_context *ctx, const char *filename);
*/
fz_archive *fz_open_chm_archive_with_stream(fz_context *ctx, fz_stream *file);

/**
Open a cfb file as an archive.
An exception is thrown if the file is not recognised as a cfb.
filename: a path to an archive file as it would be given to
open(2).
*/
fz_archive *fz_open_cfb_archive(fz_context *ctx, const char *filename);

/**
Open a cfb file as an archive.
Open an archive using a seekable stream object rather than
opening a file or directory on disk.
An exception is thrown if the file is not recognised as a chm.
*/
fz_archive *fz_open_cfb_archive_with_stream(fz_context *ctx, fz_stream *file);

/**
fz_archive: zip implementation
*/
Expand Down
59 changes: 59 additions & 0 deletions mupdf/include/mupdf/html.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
// Copyright (C) 2023 Artifex Software, Inc.
//
// This file is part of MuPDF.
//
// MuPDF is free software: you can redistribute it and/or modify it under the
// terms of the GNU Affero General Public License as published by the Free
// Software Foundation, either version 3 of the License, or (at your option)
// any later version.
//
// MuPDF is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
// FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
// details.
//
// You should have received a copy of the GNU Affero General Public License
// along with MuPDF. If not, see <https://www.gnu.org/licenses/agpl-3.0.en.html>
//
// Alternative licensing terms are available from the licensor.
// For commercial licensing, see <https://www.artifex.com/> or contact
// Artifex Software, Inc., 39 Mesa Street, Suite 108A, San Francisco,
// CA 94129, USA, for further information.

// This header allows people to easily build HTML-based document handlers.

#ifndef MUPDF_HTML_HTML_H
#define MUPDF_HTML_HTML_H

#include "mupdf/fitz/system.h"
#include "mupdf/fitz/context.h"
#include "mupdf/fitz/document.h"

/*
HTML types required
*/
typedef struct fz_html_s fz_html;
typedef struct fz_html_font_set_s fz_html_font_set;

typedef struct
{
const char *format_name;
fz_buffer *(*convert_to_html)(fz_context *ctx, fz_html_font_set *set, fz_buffer *buf, const char *user_css);
int try_xml;
int try_html5;
int patch_mobi;
} fz_htdoc_format_t;

fz_document *fz_htdoc_open_document_with_buffer(fz_context *ctx, fz_archive *zip, fz_buffer *buf, const fz_htdoc_format_t *format);

fz_document *fz_htdoc_open_document_with_file_and_dir(fz_context *ctx, const char *dirname, const char *filename, const fz_htdoc_format_t *format);

fz_document *fz_htdoc_open_document_with_file(fz_context *ctx, const char *filename, const fz_htdoc_format_t *format);

fz_document *fz_htdoc_open_document_with_stream_and_dir(fz_context *ctx, const char *dirname, fz_stream *stm, const fz_htdoc_format_t *format);

fz_document *fz_htdoc_open_document_with_stream(fz_context *ctx, fz_stream *file, const fz_htdoc_format_t *format);



#endif /* MUPDF_HTML_HTML_H */
5 changes: 3 additions & 2 deletions mupdf/platform/wasm/examples/mutool.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@
//
// Alternative licensing terms are available from the licensor.
// For commercial licensing, see <https://www.artifex.com/> or contact
// Artifex Software, Inc., 1305 Grant Avenue - Suite 200, Novato,
// CA 94945, U.S.A., +1(415)492-9861, for further information.
// Artifex Software, Inc., 39 Mesa Street, Suite 108A, San Francisco,
// CA 94129, USA, for further information.


"use strict"

Expand Down
4 changes: 2 additions & 2 deletions mupdf/platform/wasm/lib/mupdf.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
//
// Alternative licensing terms are available from the licensor.
// For commercial licensing, see <https://www.artifex.com/> or contact
// Artifex Software, Inc., 1305 Grant Avenue - Suite 200, Novato,
// CA 94945, U.S.A., +1(415)492-9861, for further information.
// Artifex Software, Inc., 39 Mesa Street, Suite 108A, San Francisco,
// CA 94129, USA, for further information.

// TODO: Story
// TODO: DOM
Expand Down
4 changes: 2 additions & 2 deletions mupdf/platform/wasm/lib/mupdf.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
//
// Alternative licensing terms are available from the licensor.
// For commercial licensing, see <https://www.artifex.com/> or contact
// Artifex Software, Inc., 1305 Grant Avenue - Suite 200, Novato,
// CA 94945, U.S.A., +1(415)492-9861, for further information.
// Artifex Software, Inc., 39 Mesa Street, Suite 108A, San Francisco,
// CA 94129, USA, for further information.

"use strict"

Expand Down
4 changes: 2 additions & 2 deletions mupdf/platform/wasm/viewer/mupdf-view-page.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
//
// Alternative licensing terms are available from the licensor.
// For commercial licensing, see <https://www.artifex.com/> or contact
// Artifex Software, Inc., 1305 Grant Avenue - Suite 200, Novato,
// CA 94945, U.S.A., +1(415)492-9861, for further information.
// Artifex Software, Inc., 39 Mesa Street, Suite 108A, San Francisco,
// CA 94129, USA, for further information.

/* eslint-disable no-unused-vars */

Expand Down
4 changes: 2 additions & 2 deletions mupdf/platform/wasm/viewer/mupdf-view-worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
//
// Alternative licensing terms are available from the licensor.
// For commercial licensing, see <https://www.artifex.com/> or contact
// Artifex Software, Inc., 1305 Grant Avenue - Suite 200, Novato,
// CA 94945, U.S.A., +1(415)492-9861, for further information.
// Artifex Software, Inc., 39 Mesa Street, Suite 108A, San Francisco,
// CA 94129, USA, for further information.

/* global mupdf */

Expand Down
4 changes: 2 additions & 2 deletions mupdf/platform/wasm/viewer/mupdf-view.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
//
// Alternative licensing terms are available from the licensor.
// For commercial licensing, see <https://www.artifex.com/> or contact
// Artifex Software, Inc., 1305 Grant Avenue - Suite 200, Novato,
// CA 94945, U.S.A., +1(415)492-9861, for further information.
// Artifex Software, Inc., 39 Mesa Street, Suite 108A, San Francisco,
// CA 94129, USA, for further information.

"use strict"

Expand Down
5 changes: 4 additions & 1 deletion mupdf/platform/win32/libmupdf.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -580,6 +580,7 @@
<ClCompile Include="..\..\source\fitz\pool.c" />
<ClCompile Include="..\..\source\fitz\printf.c" />
<ClCompile Include="..\..\source\fitz\random.c" />
<ClCompile Include="..\..\source\fitz\uncfb.c" />
<ClCompile Include="..\..\source\fitz\unchm.c" />
<ClCompile Include="..\..\source\fitz\unlibarchive.c" />
<ClCompile Include="..\..\source\fitz\warp.c" />
Expand Down Expand Up @@ -620,6 +621,7 @@
<ClCompile Include="..\..\source\html\mobi.c" />
<ClCompile Include="..\..\source\html\office.c" />
<ClCompile Include="..\..\source\html\story-writer.c" />
<ClCompile Include="..\..\source\html\txt.c" />
<ClCompile Include="..\..\source\html\xml-dom.c" />
<ClCompile Include="..\..\source\pdf\pdf-annot.c" />
<ClCompile Include="..\..\source\pdf\pdf-appearance.c" />
Expand Down Expand Up @@ -740,6 +742,7 @@
<ClInclude Include="..\..\include\mupdf\fitz\write-pixmap.h" />
<ClInclude Include="..\..\include\mupdf\fitz\writer.h" />
<ClInclude Include="..\..\include\mupdf\fitz\xml.h" />
<ClInclude Include="..\..\include\mupdf\html.h" />
<ClInclude Include="..\..\include\mupdf\memento.h" />
<ClInclude Include="..\..\include\mupdf\pdf.h" />
<ClInclude Include="..\..\include\mupdf\pdf\annot.h" />
Expand Down Expand Up @@ -809,4 +812,4 @@
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>
</Project>
9 changes: 9 additions & 0 deletions mupdf/platform/win32/libmupdf.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -657,6 +657,12 @@
<ClCompile Include="..\..\source\fitz\heap.c">
<Filter>fitz</Filter>
</ClCompile>
<ClCompile Include="..\..\source\html\txt.c">
<Filter>html</Filter>
</ClCompile>
<ClCompile Include="..\..\source\fitz\uncfb.c">
<Filter>fitz</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\..\source\fitz\draw-imp.h">
Expand Down Expand Up @@ -929,5 +935,8 @@
<ClInclude Include="..\..\include\mupdf\fitz\heap-imp.h">
<Filter>!include\fitz</Filter>
</ClInclude>
<ClInclude Include="..\..\include\mupdf\html.h">
<Filter>!include</Filter>
</ClInclude>
</ItemGroup>
</Project>
4 changes: 2 additions & 2 deletions mupdf/scripts/wdev.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@


class WindowsVS:
'''
r'''
Windows only. Finds locations of Visual Studio command-line tools. Assumes
VS2019-style paths.
Expand Down Expand Up @@ -101,7 +101,7 @@ def default(value, name):

# Find vcvars.bat.
#
vcvars = f'{directory}\\VC\Auxiliary\\Build\\vcvars{cpu.bits}.bat'
vcvars = f'{directory}\\VC\\Auxiliary\\Build\\vcvars{cpu.bits}.bat'
assert os.path.isfile( vcvars), f'No match for: {vcvars}'

# Find cl.exe.
Expand Down
28 changes: 16 additions & 12 deletions mupdf/scripts/wrap/__main__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env python3

'''
r'''
Support for generating C++ and python wrappers for the mupdf API.
Overview:
Expand Down Expand Up @@ -428,7 +428,7 @@ class instance and return them as a tuple in both Python and
Windows:
> py -m venv pylocal
> pylocal\\Scripts\\activate
> pylocal\Scripts\activate
(pylocal) > pip install libclang pyqt5
(pylocal) > cd ...\mupdf
(pylocal) > python setup.py install
Expand Down Expand Up @@ -898,10 +898,10 @@ class instance and return them as a tuple in both Python and
Compare generated class methods with functions called by platform/gl
code.
python3 -m cProfile -s cumulative ./scripts/mupdfwrap.py -b 0
python3 -m cProfile -s cumulative ./scripts/mupdfwrap.py --venv -b 0
Profile generation of C++ source code.
./scripts/mupdfwrap.py --venv --swig-windows-auto -b all -t
./scripts/mupdfwrap.py --venv -b all -t
Build and test on Windows.
Expand Down Expand Up @@ -1137,7 +1137,7 @@ def test( dir_so, expected_command):
assert command == expected_command, f'\nExpected: {expected_command}\nBut: {command}'

mupdf_root = os.path.abspath( f'{__file__}/../../../')
infix = 'CXX=clang++ ' if state.state_.openbsd else ''
infix = 'CXX=c++ ' if state.state_.openbsd else ''

test(
'shared-release',
Expand Down Expand Up @@ -1192,9 +1192,9 @@ def _get_m_command( build_dirs, j=None, make=None, m_target=None, m_vars=None):
if state.state_.openbsd:
# Need to run gmake, not make. Also for some
# reason gmake on OpenBSD sets CC to clang, but
# CXX to g++, so need to force CXX=clang++ too.
# CXX to g++, so need to force CXX=c++ too.
#
make = 'CXX=clang++ gmake'
make = 'CXX=c++ gmake'
if not make:
make = 'make'

Expand Down Expand Up @@ -1999,7 +1999,7 @@ def fn(name):
elif build_csharp:
cpp_path = f'{build_dirs.dir_mupdf}/platform/csharp/mupdfcpp_swig.cpp'
out_so = f'{build_dirs.dir_so}/mupdfcsharp.so' # todo: append {so_version} ?

cpp_path = os.path.relpath(cpp_path) # So we don't expose build machine details in __FILE__.
if state.state_.openbsd:
# clang needs around 2G on OpenBSD.
#
Expand Down Expand Up @@ -2972,17 +2972,21 @@ def system(command):
jlib.system(f'"{sys.executable}" -m venv --system-site-packages {venv}', out='log', verbose=1)
else:
jlib.system(f'"{sys.executable}" -m venv {venv}', out='log', verbose=1)

if state.state_.windows:
command = f'{venv}\\Scripts\\activate.bat'
command_venv_enter = f'{venv}\\Scripts\\activate.bat'
else:
command = f'. {venv}/bin/activate'
command += f' && python -m pip install --upgrade pip'
command_venv_enter = f'. {venv}/bin/activate'

command = f'{command_venv_enter} && python -m pip install --upgrade pip'
if state.state_.openbsd:
jlib.log( 'Not installing libclang on openbsd; we assume py3-llvm is installed.')
command += f' && python -m pip install --upgrade swig setuptools'
else:
command += f' && python -m pip install{force_reinstall} --upgrade libclang swig setuptools'
command += f' && python {shlex.quote(sys.argv[0])}'
jlib.system(command, out='log', verbose=1)

command = f'{command_venv_enter} && python {shlex.quote(sys.argv[0])}'
while 1:
try:
command += f' {shlex.quote(args.next())}'
Expand Down
Loading

0 comments on commit b9dc867

Please sign in to comment.