Skip to content

Commit

Permalink
FFI: Add MuPDF fz_is_document_reflowable (#960)
Browse files Browse the repository at this point in the history
This will be queried in front to dynamically set font size.

Cf. <koreader/koreader#4368>.
  • Loading branch information
Frenzie committed Aug 29, 2019
1 parent 97afa1c commit 2685afc
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions ffi-cdecl/mupdf_decl.c
Expand Up @@ -88,6 +88,7 @@ cdecl_struct(fz_page_s)

cdecl_func(mupdf_open_document)
cdecl_func(mupdf_open_document_with_stream)
cdecl_func(fz_is_document_reflowable)
cdecl_func(fz_needs_password)
cdecl_func(fz_authenticate_password)
cdecl_func(fz_drop_document) // NOTE: libk2pdfopt uses old fz_free_document symbol
Expand Down
6 changes: 6 additions & 0 deletions ffi/mupdf.lua
Expand Up @@ -171,6 +171,12 @@ function document_mt.__index:getPages()
return pages
end
function document_mt.__index:isDocumentReflowable(width, height, em)
if self.is_reflowable then return self.is_reflowable end
self.is_reflowable = M.fz_is_document_reflowable(context(), self.doc) == 1
return self.is_reflowable
end
function document_mt.__index:layoutDocument(width, height, em)
-- Reset the cache.
self.number_of_pages = nil
Expand Down
1 change: 1 addition & 0 deletions ffi/mupdf_h.lua
Expand Up @@ -182,6 +182,7 @@ struct fz_page_s {
};
fz_document *mupdf_open_document(fz_context *, const char *);
fz_document *mupdf_open_document_with_stream(fz_context *, const char *, struct fz_stream_s *);
int fz_is_document_reflowable(fz_context *, fz_document *);
int fz_needs_password(fz_context *, fz_document *);
int fz_authenticate_password(fz_context *, fz_document *, const char *);
void fz_drop_document(fz_context *, fz_document *);
Expand Down

0 comments on commit 2685afc

Please sign in to comment.