Commit Graph

524 Commits (master)

Author SHA1 Message Date
NiLuJe bf6c0cdd6c
LuaSettings: Add a method to initialize a setting properly (#7371)
* LuaSettings/DocSettings: Updated readSetting API to allow proper initialization to default.
Use it to initialize tables, e.g., fixing corner-cases in readerFooter that could prevent settings from being saved.
(Fixes an issue reported on Gitter).
* LuaSettings/DocSettings: Add simpler API than the the flip* ones to toggle boolean settings.
* Update LuaSettings/DocSettigns usage throughout the codebase to use the dedicated boolean methods wher appropriate, and clean up some of the more mind-bending uses.
* FileChooser: Implement an extended default exclusion list (fix #2360)
* ScreenSaver: Refactor to avoid the pile of kludges this was threatening to become. Code should be easier to follow and use, and fallbacks now behave as expected (fix #4418).
3 years ago
Frans de Jonge ac668ecb64
Add a few more mimetypes for OPDS (#7258)
Doesn't include application/zip as CBZ, but it will be downloaded (as ZIP).

Doesn't include CBR since that's not supported.

Closes #7218, closes #5997.
3 years ago
zwim 3118d0dba0 Refresh AltStatusBar once a minute, if there are changes 3 years ago
poire-z 05126b94b6 Dual pages: shown as 2 columns on a single page
Rework Dual pages code so that the view is considered
a single page number, so it looks more like 2-columns
on a single page.
This solves a few issues like:
- Page number and count are consistent between top
  and bottom status bars
- SkimTo -1/+1 doing nothing every other tap
- Statistics being wrong (like "Pages read" never
  going over half of the book page count)
3 years ago
poire-z 7779e2d8e7 CRe: use getDocumentRenderingHash() to detect rendering changes
Instead of just relying on document full height
and number of pages.
3 years ago
poire-z 8ff50a9e24 CreDocument: disable crengine image scaling options
Since their handling in crengine has been re-enabled.
3 years ago
Frans de Jonge 1ef6d0b257
[feat] Support mimetypes in DocumentRegistry:hasProvider() (#7155)
And make .djvu the canonical extension for DjVu.

Fixes #5478.
3 years ago
poire-z 396d1fbf46
bump crengine: parsing, lists, 2-pages mode fixes & tweaks (#7138)
Includes:
- EPUB: fix truncated HEAD>STYLE stylesheet
- XML parsing: slightly better parsing of <script>
- Update German hyphenation patterns
- (chore) Silence some clang warnings
- (Upstream) CSS content: fix regression with open-quote/close-quote
- (Upstream) HTML lists: support the 'reversed' attribute
- (Upstream) Tweak list items disc/circle/square symbols
- 2-pages mode: option to skip geometry checks

CRE bottom menu: allow toggling Dual Pages in portrait mode.
3 years ago
poire-z dd74194e0a cre.getWordFromPosition(): fix a few issues
Drop the use of crengine's getWordFromPosition() which
is a bit unreliable: it may returns wrong coordinates,
or words from far away in the book (ie. when holding
in the margins).
Rely only on the robust getTextFromPositions() that
we already use for multi words selection.
Having good coordinates allows refreshing a smaller region
(the higlighted word, or the 2 lines if hyphenated).
3 years ago
NiLuJe d80d6dc562 Handle the BlitBuffer struct changes
* stride is now a size_t
  On some platforms, that's 64 bits, which means it's no longer
  automatically converted to a Lua number to avoid precision loss.
  Do that ourselves, because lua-serialize doesn't know how to handle an
  uint64_t cdata ;).
3 years ago
jperon 8b7d60299f
JPG/PNG: MuPDF as default provider (#6931)
As said in #6929
3 years ago
jperon 8eeb010dc9
Paged documents: rework zoom options (#6885)
- Move zoom options from top menu to bottom config
- Add option to manually define zoom (relative to
  page width) and overlap (in percent)
- Add options to zoom to columns or rows, possibly
  with overlap. Add panning direction options when
  page forward in these modes
3 years ago
Jellby 5e3c554dd7 Hide non-linear fragments
Add option to hide (skip) non-linear fragments, only working
in 1-page mode. Tweaks mostly to footer, toc and skim code
to make it clear(er) which pages belong to linear or non-linear
fragments.
4 years ago
Jellby f892d4559f Fix typos 4 years ago
yparitcher edec69ac8b
[CRe] Tweak nightmode and CRe call cache interaction (#6859)
Simplify 4caf8f28 (#6854), allowing us not to track
nightmode in two places.
4 years ago
NiLuJe 4caf8f281d
[CRe] Ensure toggling nightmode invalidates the drawCurrentView cache (#6854)
* Use a CRe set* method when toggling nightmode

This ensures it gets flagged as add_reset by the call cache, and that
CRe will actually re-render, as it's necessary if nightmode_images is
enabled (the default).

Fix #6845

* Prevent ReaderHighlight:onTap from running ReaderHighlight:clear when
it's unnecessary.

Avoiding a clearSelection call in CRe that could invalidate the cache
and cause unnecessary redraws.

* Don't store empty highlight arrays when all HLs on a page have
been deleted
4 years ago
Martín Fernández 40b4ccffa8
KoptInterface:getWordFromBoxes: guard against nil boxes (#6827)
Fixes #6825
4 years ago
poire-z 8b886e5922
bump crengine: sync with upstream, new hyphenation languages (#6746)
Includes:
- (Upstream) various unimpacting changes to keep in sync
- (Upstream) Fix issues with legacy text rendering
- (Upstream) FB3/DocX/ODT: get lang and description metadata
- (Upstream) remove some global settings, make them per-doc
- TextLang, hyphenation: add Armenian, Friulian, Piedmontese,
  Romansh, Zulu and Brazilian Portuguese.

Also make cre the prefered engine for .xhtml (over MuPDF)
and for .xml (which might be HTML).
4 years ago
ezdiy 7a40b496fb
blitbuffer: fixups for base (#6714)
fixups for base bumped to https://github.com/koreader/koreader-base/pull/1201
otherwise tilecache breaks
4 years ago
Galunid b297fb7cf6
Panel zoom - improve output image resolution (#6709) 4 years ago
Galunid 15455b594d
[feat] Comics: zoom to panel (#6511)
This pull requests aims to provide convenient way to zoom in comics. The idea is when user holds/double taps (not decided yet) on a manga/comic panel, it gets cut out from the rest of the image and zoomed. More details in koreader/koreader-base#1148. Depends on koreader/koreader-base#1159
4 years ago
poire-z 4d53ec76fe
bump crengine: ODT support, more typography languages (#6675)
Includes:
- Update German hyphenation patterns
- (Upstream) Adds ODT (ODF) format support
- TextLang, hyphenation: add Basque, Croatian, Esperanto,
  Estonian, Georgian, Latvian, Lithuanian, Macedonian,
  Occitan, Welsh; update Bulgarian, Irish, Portuguese,
  Slovak, Dutch, Norwegian, Spanish; update hyphen min
  for Czech, English, Greek; fix Romanian and Ukrainian
  pattern file names
- HyphMan: adds HyphMethod::getLeft/RightHyphenMin()
- epub.css: update HR default style
- fb2.css: keep <date> in main text left-aligned
- getRenderedWidths(): inline-block and table fixes
- CSS: avoid style hash mismatch when serializing content:''
- Tables: re-order row groups when necessary
- XML parsing: don't drop trailing text
- HTML parser: tweak implicit head/body insertion code
- Fix text search failure when blank at start or end

readertypography.lua: some cleanup by removing the first
table listing hyph dicts, and including their filenames
in the second table so we can build the first table
dynamically. Also fetch hyph left/right min limits from
crengine to not have to duplicate them here and keep them
in sync.
css_tweaks.lua: for in-page footnotes, switched from
"-cr-only-if: epub-document" to ": -fb2-document"
("not" FB2 documents), so these tweaks also work with
DocX and ODT footnotes.

Also included in base bump:
- KOPTContext: add comic panel detection function/additional
  leptonica declarations
- Forcibly disable docs when building giflib
4 years ago
NiLuJe 99045b4311
Minor util & ffi/util cleanups (#6657) 4 years ago
ezdiy 426f7b5ddc
Add API to set OS level file associations (#6615) 4 years ago
Martín Fdez 454ed0ebeb enable usage of system fonts 4 years ago
poire-z 8d99523388
bump crengine: new HTML parser, libRu and FB2 tweaks (#6560)
Includes:
- Revert "FB2: don't draw cover in scroll mode"
- (Upstream) FB2: fix coverpage drawing in scroll mode
- FB2 footnotes: only merge run-in when next is erm_final
- fb2.css: use OTF tabular-nums for footnote numbers
- Text: ignore ascii and unicode control chars
- Fix HR positionning when floats involved
- writeNodeEx(): minor tweaks
- OnTagClose(): add self_closing_tag parameter
- HTML format detection: accept HTML5 doctype
- HTML parser: rework Lib.ru specific handling
- HTML parser: new more conforming implementation
- HTML parser: ensure foster parenting inside tables

Also includes:
- SDL: don't bypass X11 WM compositor
4 years ago
Frans de Jonge da507f8607
[chore] Update MD5 calls with new sha2 library (#6411)
Depends on <https://github.com/koreader/koreader-base/pull/1149>.
4 years ago
Martín Fernández f9293a67b0
[fix] Remove isAllowedScript leftovers (#6366)
Fixes #6365
4 years ago
Martín Fernández d87b09d11c
handle newlines in exported pdf highlights (#6247) 4 years ago
NiLuJe 64825eccd2
Update bundled fonts (#6242)
* Update bundled fonts

* Minor FreeFont update
* Noto Sans CJK downgrade to fix a number of issues w/ the git version
* Initial import of Noto Naskh Arabic

* Replace Noto Sans Arabic UI by Noto Naskh Arabic in the CRe fallback
list
4 years ago
poire-z 5536ce996a CRE: use same marks in top and bottom progress bars
Feed to crengine the same ticks (build from the TOC
entries) that we use in the bottom status bar.
(crengine otherwise builds a tick for each DocFragment,
which most often is really different than what's seen
in the bottom bar.)
4 years ago
poire-z 177551918f
bump_crengine: various fixes, tweaks and cleanups (#6188)
Includes:
- Don't reset invisible BR to display: inline
- ldomTextCollector: handle inline-block/table as inline
- Avoid re-rendering on font hinting mode change
- List markers: fix positionning when floats involved
- GIF decoding: avoid uneeded abort on LZW table overflow
- Adds getUnknownEntities(), can help with debugging
- Don't check stylesheet hashes when loading from cache
- Hardcoded elements and attributes list: cleanup
- Full rendering: 2 small optimisations
- Strut confinning: deal with images earlier
- lvtextfm: some cleanup and reordering
cre.cpp:
- fix getPageFromXPointer() and getPosFromXPointer()
  to not fail on invisible nodes and work on the next
  visible node (so links whose target is display:none
  can work).

Add support for 2 settings one can set manually
in reader.settings.reader.lua:
["cre_background_color"] = "0xccffcc",
["cre_background_image"] = "/path/to/bg_paper.jpg",
4 years ago
poire-z e074b603e0 Adds Word Expansion: use of letter spacing for justification
Bump crengine:
- Text: fix occasional BiDi bad word splitting
- Font: fix HB fallback measurement/drawing mismatches
- Font: do not add letter spacing on diacritics
- Text: tunable use of letter spacing for justification
- Text: dont adjust space after initial quotation mark/dash (rework)
- Text: fix possible bad widths after collapsed spaces

xtext.cpp: pick crengine fix with HB fallback
measurement/drawing mismatches

Adds "Word Expansion" to bottom Font size menu, and moved
"Word Spacing" there too, to balance the panels' heights
to 4 items.
4 years ago
poire-z 1a91893576
Allow toggling use of additional fallback fonts (#6095) 4 years ago
poire-z 7d83a0c967
bump crengine: multiple fallback fonts (#6090)
Includes:
- Simplify libunibreak includes
- Text: fix read/write outside array bounds
- lvtextfm: dont adjust space after initial quotation mark/dash (rework)
- Fonts: allow providing and using multiple fallback fonts

Users can set their prefered fallback font, which will be completed
with a few of our shipped fonts for maximum coverage.
4 years ago
poire-z 6dc8bbcc49
Adds ReaderTypography (replaces ReaderHyphenation) (#6072)
Replace Hyphenation menu with Typography menu.
This works mostly like before:
- typography/hyphenation is chosen according to the book
  metadata language,
- one can set a default or a fallback language,
- hyphenation is now just a subset of typography, and
  can be disabled while still setting a language and
  enabling the other features,
- the typography language enables newly added features
  to crengine: per-language line breaking rules and
  per-language Harfbuzz glyph selection.
4 years ago
Martín Fdez 8e831eb756 desktop: disable battery on touch menu and reader footer
isDesktop and isEmulator are now different entities
4 years ago
Frans de Jonge 2945a2fb79
Add EPUB3 extension to MuPDF document (#6013)
Loads fine, see 026140f809 (commitcomment-38122799)
4 years ago
poire-z 026140f809 Adds ReaderPageMap, to optionally show source pages numbers
bump crengine: support for EPUB3 nav toc and page maps
Includes:
- Fix lvRect:isRectInside(rc) with 0-width or 0-height rect
- TOC: parse EPUB3 nav toc, fallback to spine when no toc
- Parse and cache various hardcopy page list maps
- epub.css: hide EPUB3 <span epub:type="pagebreak"> content
cre.cpp: add a few PageMap helper functions.

Adds ReaderPageMap which will add a new menu (under TOC and
Bookmarks) that will allow:
- to list source page numbers (like a TOC)
- to show visible page labels in the right margin
- to use these source page numbers in the footer, the TOC,
  the GoTo and SkimTo widgets, and to use the source page
  number in the standard bookmark and highlight initial text.
4 years ago
Frans de Jonge c2aac0f71e
[fix] DocumentRegistry: only add provider once (#5947)
Fixes <https://github.com/koreader/koreader/issues/5946>.
4 years ago
poire-z fa6fed8569 cre: setFontFace(): increase bias given to the main font
Solve the issue when a font without bold and italic variants
is used as the default font (e.g. FreeSerif), and the style
tweak "Ignore publisher font-family" is used (which uses
a trick to cancel any font-family by requesting a font
named "NoSuchFont"):
When text is italic or bold, any of the registered fonts
which have a real italic or bold variant would win over our
default font, as the best substitute to NoSuchFont-Italic.
This gives our default font a bit more bias so it can
win in its scoring against the other fonts, and be rendered
as fake italic or fake bold - which will ensure consistent
font and line height.
(A bit hacky, but no alternative solution found.)
4 years ago
Martín Fernández 5d103a41f8
Avoid writting highlights into read-only PDFs (#5889) 4 years ago
poire-z 5a4f5b4d59 bump crengine, migrate books to normalized xpointers
Enable new rendering feature COMPLETE_INCOMPLETE_TABLES
on all enhanced rendering mode, but have it disabled for
earlier cre_dom_version.
Also increase default_cre_storage_size_factor from 20 to 40.
4 years ago
NiLuJe 5499d85cbc
Allow running shell scripts from the FileManager/Favorites (#5804)
* Allow running Shell/Python scripts from the FM

* Show an InfoMessage before/after running the script

Since we're blocking the UI ;).

* Allow running scripts from the favorites menu, too.
4 years ago
poire-z 1b55baf437 cre: default to enable crengine call cache
Also reset cache when calling :enableInternalHistory(), as it solves
screen orientation change unit tests failures (although there is no
issue in regular use of the app).
4 years ago
poire-z 6f04ff546c cre: add toggable crengine call cache
Optimise usage of some of CreDocument methods by caching
their results, either globally, or per page/pos for those
whose result may depend on current page number or y-pos.
This helps a lot on cre books with a lot of highlights.
4 years ago
poire-z 2e947e6ffe PicDocuments: fix crash on hold + pan (#5742) 4 years ago
poire-z 5541d5f5d3 bump crengine: word spacing and hyphenation tweaks
Includes:
- New option to tune word spacing: space width scale percent
- Text: look for hyphenation in more words if needed
- CSS: fix "hyphens:none" should override inherited "hyphens:auto"
- getHtml(): grab dir= and lang= attributes from upper nodes

Replace our Word Gap/Space condensing toggle/setting with
a new Word Spacing toggle/setting, made of 2 values:
- 1st number scales the normal width of spaces in all font
  (100% uses the font space width untouched)
- 2nd number applies after the 1st has been applied, and
  tells how much these spaces can additionally be condensed
  to make more text fit on a line.
5 years ago
poire-z 558bd1ebeb cre fonts list: ignore nerdfonts/symbol.ttf
It's rejected anyway by crengine, this just avoids
an error from being logged.
5 years ago
poire-z 0fb780ea21 PicDocument: log reason of opening failure 5 years ago
yparitcher 6c68df42ec [feat] Open unsupported documents as text (#5497) 5 years ago
poire-z 7caa21a3fb [chore] Remove uneeded doc_settings:close() (#5504)
When just reading settings, no need to close and
write the file to disk.
5 years ago
poire-z 7de022a617
bump crengine: adds DOCX and FB3 support (#5498)
Includes:
- (Upstream) Unified cache for chars and glyph's indexes
- (Upstream) Glyph caching: optional use of hash table instead of a linked list
- (Upstream) Adds docx and fb3 support
- Update hardcoded elements list and stylesheets
- DocX: build a HTML DOM instead of a FB2 DOM
- Text: allow wrap after '/' and '-'
- Text: with Harfbuzz, split measurement on text node change
- Clear fonts on load and re-rendering
5 years ago
poire-z 5bc6bf046c
bump crengine, show progress meter on load/re-rendering (#5406)
Includes:
- Adds tinyNodeCollection::getStatistics()
- epubfmt.cpp: cleanup indentation and small optimisation
- Add more progress callback events
- Optimisation: avoid re-init for EPUBs with embedded fonts
- Fix: don't draw border when border-color: transparent
- CSS: ignore 'inherit' inside font-family

Show a small progress meter at top left of screen when
crengine is loading, re-rendering, and saving cache file
(after a 2 second delay to not be bothered on small books).

Also add a wrapper for the last remaining bit of code that
was accessing _document directly (:getPageOffsetX()).
5 years ago
poire-z 788e6d90df
Fix: don't create sidecar file when indexing pdf documents (#5384) 5 years ago
Frans de Jonge 59355200dc
[fix] PdfDocument: Hash collision (#5337)
A typo introduced in <https://github.com/koreader/koreader/pull/5282>.

This might resolve <https://github.com/koreader/koreader/issues/5323>, <https://github.com/koreader/koreader/issues/5327>.
5 years ago
Frans de Jonge b2554ba5da
[fix] Prevent crash when no page boxes (#5289)
Can occur with invalid page numbers, for example by changing the font size in a reflowable MuPDF document.

Discussion in <https://github.com/koreader/koreader/pull/5282#issuecomment-526842921>.
5 years ago
Frans de Jonge bc2412a67a
[doc] Convert koptinterface comments to LDoc format (#5290) 5 years ago
Frans de Jonge f1f6eebce0
[feat] Add MuPDF EPUB/FB2 dynamic font size (#5282)
Closes #4368.
5 years ago
Frans de Jonge be87fb27a0
[chore] Convert a couple more todos (#5267)
Cf. <https://github.com/koreader/koreader/pull/5244>.

Also update check.
5 years ago
Frans de Jonge a2dcfe9aec
[doc] Tag @todo, @fixme and @warning (#5244)
This commit standardizes the various todos around the code a bit in a manner recognized by LDoc.

Besides drawing more attention by being displayed in the developer docs, they're also extractable with LDoc on the command line:

```sh
ldoc --tags todo,fixme *.lua
```

However, whether that particular usage offers any advantage over other search tools is questionable at best.

* and some random beautification
5 years ago
Martín Fernández 3a957d71e3 [Desktop] Open writable font dir, toggle system+user/user fonts, fix openLink on mac (#5220)
Fixes #5093
5 years ago
poire-z d25d449a26
bump crengine and others, adds HTML extended debug view (#5219)
Bump crengine: background image and other fixes:
- View HTML: option to show text unicode codepoints
- Fix attribute parsing: decode &-encoded chars
- Text: allow wrap after more unicode spaces and hyphen
- Fix: no left hanging when hanging punctuation disabled
- lvtextfm.cpp: more comments, some formatting cleanup
- Optimize background image drawing
- CSS: fix background-image file path resolution

Bump luasec to 0.8.1
Bump harfbuzz to 2.6.0

cre.cpp:
Adds setBackgroundImage() proxy function to crengine
facility to set background textures (this is unrelated
to the background-image CSS fixes).
No frontend code (yet) to select such an image.

View HTML: adds a 3rd view (extended debug view), showing the
unicode codepoint of each char and crengine rendereing methods.
5 years ago
poire-z 9f3c85ed83 cre: toggable enhanced rendering (floats, collapsed margins...)
Adds "Render mode" toggle with 4 modes, to enable some or all
of crengine's new enhanced block rendering features.
Use "legacy" rendering for previously opened books to not mess
with bookmarks, and "web" (all of the new features) for new books.

Also make available the added "HTML5" stylesheet to the Style menu.
5 years ago
NiLuJe 4ccb1f3dd5
Allow disabling automagic image inversion in Nightmode in CRe (#5095)
* Allow disabling automagic image inversion in NightMode

Fix #4986
5 years ago
Frans de Jonge de75f6bfa3
[fix] Don't try to save highlight into non-PDF document (#5027)
* [fix] Don't try to save highlight into non-PDF document

Fixes <https://github.com/koreader/koreader/issues/5024>.

Highlighting will still work with the .sdr metadata.

* temp fix
5 years ago
Qingping Hou 080c079d01 chore: add test for screen color toggle 5 years ago
NiLuJe 9134594119
Allow toggling CRe's new dithering & scaling (#4922)
Smooth scaling toggle is per document, in the gear tab.
Dithering is in the Dev top menu ;).
5 years ago
poire-z 5c38bcb8b7 [UX] Links menu and handling tweaks (#4867)
- Removed "Swipe to follow first link on page" menu item and
  handling code, as it feels not really as practical as
  "Swipe to follow nearest link".
- Removed recently added "External link action", as we can
  just always present a popup with the url and the available
  actions.
- Generic handling of these actions in onGoToExternalLink(),
  so they are proposed on the Wikipedia lookup popup too.
- Allow external link on PDF documents (previously, only
  internal links were handled).
- Have "Ignore external links on tap" available on all
  document types.
- Added "Ignore external links on swipe" (default to true,
  the current behaviour).
- Added multiswipe gesture "Follow nearest internal link"
  (the existing "Follow nearest link" now follows the
  nearest external or internal link)
- ButtonDialogTitle: added an option to look a bit more
  alike ConfirmBoxes.
- Footnote popups: fix link unhighlight when tap on external link.
5 years ago
poire-z 8f019b8183 Night mode: keep some images non-inverted
Have the code pre-invert some images when in night mode,
so they get inverted back to normal by night mode.
This will allow images to be displayed normally in
the following contexts:
- images in credocument pages
- long-press on images in credocument viewed in ImageViewer
- cover thumbnails in File browser and History
- full size covers when viewed in ImageViewer
- images in Wikipedia lookup results
5 years ago
NiLuJe 7210fb478d
Faster blitting @ BB8/BBRGB32 when no processing is needed (#4847)
* Pickup the eponymous blitting performance tweaks from koreader/koreader-base#878
* Cleanup BitOpts usage (require & cache)
* Unify oddness checks (MOD -> AND)
* Enforce the native Portrait orientation on Kobo (except @ 16bpp, i.e., KSM w/ 8bpp swap disabled), to allow for faster blitting when unrotted.
* Switch CRe BB to 32BPP on color screens
* Minor cleanups
5 years ago
poire-z 17f07e755f CoverBrowser: speedup "View full size cover"
It was doing a full document load to get the cover. It now does
the faster "only metadata" load.
Also move the trick of setting a default font in CreDocument, so
that all callers of document:loadDocument(false) benefit from it.
Prevent crash when no cover image is available (even if the cache
says it has one, the file may have been updated and doesn't have
it anymore).
5 years ago
poire-z 766b199880 cre 2-pages view: allow extending selection across pages
Similar to what's been added for 1 page view, but just turn
one page instead of switching to scroll mode when reaching
top left or bottom right corners.
Also make the selection start xpointer more accurate by
getting them in onHold(), instead of possibly too late in
onHoldPan() where we have already moved.
5 years ago
poire-z 220b2dcfc2 cre 2-pages view: fix markers when following links and back
Show markers in the middle margin when target is in the right page.
5 years ago
poire-z 22bc9dacb5 cre landscape view: adds 1 page / 2 pages toggable
Adds a toggle switch in the Orientation bottom config menu to
allow showing 1 page or 2 pages when in landscape mode.
Previously, this was hardcoded to be in 2-pages modes only
in some circumstances (device resolution + user dpi).
5 years ago
Qingping Hou 587758939e split UI agnostic code from font.lua into fontlist.lua 5 years ago
Qingping Hou 05f62cc4ba add more comment 5 years ago
Qingping Hou 1605409c60 rename runtimectl to document/canvascontext 5 years ago
Qingping Hou 8513778990 decouple device from koptinterface 5 years ago
Qingping Hou b1f94f9afa decouple device from credocument 5 years ago
Qingping Hou d749591984 decouple device from pdfdocument, font & bgr checking 5 years ago
Qingping Hou 9e57e56f95 decouple UI definitions from document modules 5 years ago
Qingping Hou 02eca23649 decouple device from document modules 5 years ago
poire-z 1c0a8c1ef9 cre scroll mode: fix last line of book hidden by footer
By scrolling last page a little bit further.

Also fix a few other scroll mode issues, all related
to doc_height not being updated (eg, in the middle of
a book, and doubling the font size, one would not
be able to turn pages and read the 2nd half of the
book...)
5 years ago
NiLuJe 6c29b7da65 [fix] PicDocument: Pass a copy of image_bb in getCoverPageImage() (#4628)
Avoids a use-after-free in mupdf.scaleBlitBuffer

Fix koreader/koreader-base#821

Thanks for the hint, @poire-z ;).

* As @poire-z suggested, the original unscaled bb should probably be free'd.
5 years ago
NiLuJe e3bcd6c2a9
Really disable HW dithering on Kindle ;) (#4617)
* Cosmestic tweak to an error message.
PicDocument handles more than just JPEGs ;)
* Bump base
To really disable HW dithering on Kindle ;).
5 years ago
poire-z 62d548fc61 Highlight adjusting: avoid start and end crossing each other 5 years ago
Galunid 015fb4d34e Allows adjusting highlight start and end (#4582)
Adds arrow buttons under Delete|Edit.
Tap to move by word, hold to move by char.
5 years ago
poire-z 6e3b40e2bf Adds CreDocument:getScreenPositionFromXPointer()
Factorize same code used by ReaderLink and ReaderRolling into
CreDocument:getScreenPositionFromXPointer().
5 years ago
poire-z f2a9ed0b79
bump crengine: count nb of images drawn & others (#4542)
Includes:
- Update french hyphenation pattern
- epub.css: update style for 'blockquote'
- DrawBuf: count nb of images and surface drawn

Adds Document:getDrawnImagesStatistics() to help deciding
if refresh with (possibly costly) dithering should be used
(on devices with HW dithering capabilities) with CreDocument:
when a page contains enough images to benefit from it.
5 years ago
Frans de Jonge 062d9a44d1
[fix] MuPDF: set default DPI-based EPUB fontsize (#4372)
Makes an attempt at a reasonable default. References #4368.
6 years ago
Hzj_jie 9be82da449 Lower file suffix (#4369) 6 years ago
poire-z 85ac59ae00 CreDocument: fix document loading interferences (#4349)
When a main document is opened for displaying, some other
document openings (for getting metadata or cover image)
could affect the main document.
Split some code from CreDocument:init() into another new
method CreDocument:setupDefaultView(), that will only be
called by ReaderUI when opening the main document (and not
by these other openings like Book inforation, View cover...)

Also speed up some of these other openings (Search, Screensaver)
by using doc:loadDocument(false) to load only metadata and
avoid parsing the HTML.

Details in https://github.com/koreader/koreader/issues/4346#issuecomment-440036496
6 years ago
xelxebar 05e687f570 [Feature] Support DjVu metadata (#4314) 6 years ago
poire-z 9d8531a4b5 Fix footnotes and markers with full status bar
Take full/top status bar's height into account when
computing coordinates.
Also wrap getPageMargins() in CreDocument, so we
don't use cre.cpp _document directly anywhere else.
6 years ago
Qingping Hou a72f8b6338 decouple UI from core document code 6 years ago
poire-z f9086a2ba9
EPUB links: show footnotes in popup, larger tap area (#4261)
Adds new options to the Links> submenu, for now only
available and used with CRE documents.
- Allow larger tap area around links
- Ignore external links
- Show footnotes in popup
- Show more links as footnotes

(This last item is mostly for testing and loosening the
footnote detection algorithm, and see how it would behave
with glossary-like links and inter glossary terms links.)

Fix distance computation from gesture position to link by
using segments.
Code for detecting if a link is a footnote is in cre.cpp, and
tweakable a bit with flags in ReaderLink:showAsFoonotePopup().

Footnotes HTML content is displayed by a new FootnoteWidget,
which uses MuPDF for its rendering.
From it, swipe south or tap outside to close, swipe to the left
to follow the original link and jump to the footnote location
in the book.

Also fix tap on highlights after the recent change to use segments
for displaying: use segments also when checking taps.
6 years ago
poire-z 0e2a3b6263 Selection menu: allow viewing HTML 6 years ago
poire-z 6ab34c6d1d cre highlights: draw segments instead of word boxes
It gives a cleaner drawing of multi-lines selected text.
Bump base and crengine.
6 years ago
poire-z 6f2368e3bc
cre: configurable kerning method (off/freetype/harfbuzz) (#4167)
Bump base & crengine for HarfBuzz support.
6 years ago
Robert cd37535056 Replace remaining 'local gettext' with '_' (#4160) 6 years ago
poire-z c1206888ab Hyphenation: speed up book loading by setting hyph algo earlier (#4142)
Setting the hyph algo before loading the document may save crengine
from re-doing some expensive work at render time (the hyph algo
is accounted in the nodeStyleHash, and would cause a mismatch if it is
different at render time from how it was at load time - "English US" by
default - causing a full re-init of the nodes styles.)
We will only re-set it on pre-render (only then, after loading, we
know the document language) if it's really needed: when no algo saved
in book settings, no default algo, and book has some language defined.
6 years ago
Robert e5a33ac6d9 Add "Open random document" to Plus menu (#4103) 6 years ago
poire-z d8e58a08fd
bump crengine: adds support for dpi-based css units (#4040)
Adds a new toggle to the bottom menu: Zoom (dpi), which
allows for scaling CSS absolute units and image sizes.
6 years ago
NiLuJe e2a0929c51
Better KOA2 support (#4037)
* Better KOA2 support
    * Fix FL
    * Add physical pageturn keys
    * Add accelerometer support
* Possibly better NaturalLight handling on the Clara
* Fix WiFi module name used in some(?) Mk7 Kobos
* A bunch of kodev fixes
6 years ago
Robert d29a65b96e cre: add Word Gap setting to bottom config panel (#4026)
Maps to crengine's Space Condensing feature (named Word Gap
as a similar feature is named for PDF)
6 years ago
poire-z d3d30c405a
bump crengine: fix handling of soft-hyphens (#4025)
Adds a new Hyphenation method: Soft-hyphens only.
Adds a new toggable option, usable with Algorithm and language
based methods: Trust soft hyphens (if enabled, if soft hyphens
found in word: use them and skip regular method).
6 years ago
poire-z dd9cd0e87e
Add 'cre_min_space_condensing_percent' setting (#4023)
Default in crengine is 50%, and this may be too much for some
people (words can look too much stuck to each other on some lines).
This manual setting may help testing if 70% or 80% is better, with:
"cre_min_space_condensing_percent" = 80
6 years ago
poire-z c3a938aad6
bump crengine: alternative TOC, no page break on borders (#4011)
Includes:
- Avoid page break between a node and its borders
- Allow building an alternative TOC from document headings

On CRE documents, allows toggling between original TOC and an
alternative TOC with long-press on the "Table of content" menu
item.

Also update the Wikipedia stylesheet to further avoid
page-breaks between images and their caption, so a full
bordered wikipedia thumbnail is always full on a single page.
6 years ago
poire-z 9a0728e421
Style menu cleanup (#3996)
Use epub.css as the main default style, with all file formats
except FB2 (which needs fb2.css).
(epub.css has been cleaned recently to be more conforming to HTML
specs and to not include class name based styles - with conditional
compatiblity styles for previously opened documents. It should be
usable on all HTML based documents, except FB2 which has some
incompatible specs.)

Consider all shipped css files other than "epub.css" and "fb2.css"
obsolete, and put them in a sub-menu (these other css files have
not been updated in the same way, and are kept as-is for when a
previously opened document requests one of them).

Add an icon indicating which style is set as default (like it's
been done for the Font and Style tweaks menus).

Also set the font size of the full status bar (available with
cre documents) when the setting "cre_header_status_font_size"
is present in settings.reader.lua (to add manually).
6 years ago
NiLuJe 5871132c25
UI Behavior tweaks (#3983)
* Switch all initial highlights to "fast" update

i.e., everything that does an invert
Plus a few other things that refresh small UI elements onTap
Re #3130

* Tweak refreshtype for a number of widgets:
  * Fix iconbutton dimen
  * Make touchmenu flash on close & initial menu popup. Full-screen on close.
  * Use flashing updates when opening/closing dictionary popup. Full-screen on close.
  * Switch FileManager to partial.
    It's mostly text, and we want flash promotion there.
  * Make configdialog & menu flash on exit
  * Make FLWidget flash on close
  * virtualkeyboard: flash on layout change & popup.
  * Potentially not that great workaround to ensure we actually see the
highlights in the FM's chevrons
  * Flash when closing BookStatus Widget
  * Optimize away a quirk of the dual "fast" update in touchmenu

* Promote updates to flashing slightly more agressively.

* Document what each refreshtype actually does.

With a few guidelines on their optimal usecases.

* Switch remaining scheduleIn(0.0) to nextTick()

* Tighter scheduling timers

Shaving a hundred ms off UI callbacks...

* Cache FFI C Library namespace

* Ask MuPDF to convert pixmaps to BGR on Kobo

Fix #3949

* Mention koxtoolchain in the README

re #3972

* Kindle: Handle *all* fonts via EXT_FONT_DIR instead of bind mounts insanity

* Make black flashes in UI elements user-configurable

(All or nothing).

* Jot down some random KOA2 sysfs path
6 years ago
poire-z b498d872be
bump crengine: LI and CITE fixes are now the defaults (#3976)
Books previously opened (that have a metadata.lua, whether with
highlights or not, but because they all have a last_xpointer that
points to the current page, that can be broken too by the changes)
will continue to have the old wrong behaviour, so they won't be
impacted by the breaking changes.
Update cre_dom_version code to use the new functions from cre.cpp.
Remove these Workarounds from Style tweaks.
6 years ago
poire-z 07713be429
Adds "Better rendering of list items" to Style tweaks (#3968)
Alternate rendering of list items as block elements (instead of
inline/final).
Check the built DOM is still coherent with styles on stylesheet
change, and propose to reload the document if not. Also
invalidate cache on close in that case so a new DOM is built
at next opening.
ReaderStyleTweak: fix tweak css duplication; when globally
enabled, when disabling and re-enabling locally, the css would
be added twice to the final CSS.
Also adds !important to "sub_sup_smaller" tweak, and increase
its priority so it can override "font_size_all_inherit".
Adds CreDocument:getCacheFilePath() for futur features.
6 years ago
poire-z 5b7664b064
Style tweaks: use css snippets to tweak book styles (#3944)
Adds a new menu "Style tweaks", with a few CSS snippets
that can make some things better with some books.
6 years ago
poire-z a9905c5129
Font menu: add symbols for default and fallback fonts (#3941)
Also allows for updating the fallback font and see results
in real-time on the underlying document.
Bump crengine for: fix updating fallback font

Also adds a menu item to generate a html document showing some
sample text rendered with each available font (only if the user has
a file koreader/settings/fonts-test-sample.html with some HTML
snippet of his choice).
6 years ago
poire-z 8b2253b3e9
bump base: crengine, freetype, libjpeg-turbo (#3928)
Includes:
- [build] FreeType: bump to 2.9.1
- [build] bump libjpeg-turbo to 1.5.3
- bump crengine:
 - Fix CSS selector specificity computation
 - [fix] crengine/src/lvfntman.cpp: improve letter_spacing limit
 - [fix] crengine/src/lvxml.cpp: add all empty HTML elements
 - html head styles: fix styles not being applied
 - Hyphenation: increase MAX_PATTERN_SIZE from 16 to 35
 - html documents: proper handling of <BR> tags
 - Allows requesting old (broken) XML/DOM building code
- cre.cpp: setStyleSheet(): accept filepath and/or css text,
  and added getIntProperty() and getStringProperty()

credocument/readerrolling: request older XML/DOM building code
for books previously opened, to not lose bookmarks and highlights

(unit tests update because of new handling of consecutive BR via css
pushed links down in the book)
6 years ago
poire-z 4bb3999cbc RenderImage: factorize all image rendering and scaling code
New module RenderImage (alongside existing RenderText) to provides
image rendering and scaling facilities.
Uses MuPDF, but tries first giflib on GIF.
Allows for getting all the frames from an animated GIF.
6 years ago
poire-z 7a2bf21434 PicDocument:getCoverPageImage(): use first page instead of MuPDF
The dedicated image format library may often give better results
than MuPDF (eg: for animated GIFs).
6 years ago
poire-z 7f6aebe399
cre hyphenation: allow for setting min left/right fragment length (#3890)
When hyphenating a word, the existing algorithms enforced a minimal
length of 2 for each word fragments on left or right side.
This adds a widget to allow changing these minimal sizes (from 1 to 10).
6 years ago
poire-z 152e17fbe3
Adds 'cre_disk_cache_max_size' setting (#3760)
For max disk space usable by crengine for storing book caches.
Increased default from 32 MB to 64 MB.
6 years ago
poire-z 7d71d73cc4
Speed up page turning on big cre documents (#3740)
Page turning, menu opening, ... everything actually
6 years ago
poire-z c93bbec40d
cre: more constrast settings (#3737)
Use ButtonProgress like it was done for kopt.
6 years ago
poire-z db31bd4b96
coverbrowser: quicker extraction of EPUB metadata (#3736)
bump crengine:
Allow for quicker loading when interested in metadata only.
Allow for more than 65535 different attribute values.
Increase gamma values range.
6 years ago
poire-z 5cd51ea0fe
Set default 'cre_storage_size_factor' to 20 (#3732)
Increase default crengine in-memory cache sizes to avoid pack/unpack
of chunks that is known to be the cause of bugs (rendering, cache
re-use...).
6 years ago
Frans de Jonge 076bf406fd
[UX] Add InfoMessage about OCR (#3718) 6 years ago
Frans de Jonge 8b3b2b0eb1
[fix] Better error handling when MuPDF document has no pages (#3710)
It happens in base so we don't have to worry about it in front.

References https://github.com/koreader/koreader/issues/3705
6 years ago
poire-z ea284bbc3b
cre: cache re-use fix, warnings and allow cache sizes increase (#3700)
Bump crengine for cache re-use fix and warnings when
cache sizes reached.
Allow for increasing some crengine cache sizes with a new
setting: "cre_storage_size_factor" = 1.5 (or 2, or 4...)
6 years ago
Frans de Jonge dc0dc7e962
[feat, UX] Add new OpenWithDialog based on RadioButton and RadioButtonTable (#3678)
Fixes #3659
6 years ago
Frans de Jonge ced9e45d92
[fix] DocumentRegistry: don't create empty sdr and add hasProvider() (#3675)
As suggested by @poire-z https://github.com/koreader/koreader/pull/3653#issuecomment-364663156
6 years ago
poire-z 501df2ebc2
cre cache: allow for disabling compression (#3670)
With ["cre_compress_cached_data"] = false in settings.reader.lua.
Not using compression for cache files does indeed take more space,
but it does speed up opening, rendering, page turns, and closing,
with big documents.
Bump base and crengine.
6 years ago
Frans de Jonge f6ca1c7c0a
[feat] Open with: choose which engine to use for file (#3653)
Fixes #3345

* Add SVG to MuPDF filetypes
6 years ago
Frans de Jonge d714bd3aea
[feat] DocumentRegistry: add getProviders() and preferred by weight (#3651)
This is step one toward "open with".

References https://github.com/koreader/koreader/issues/3345

* Fix up some mimetypes
* Add XHTML to supported filetypes
* Add a few image files to MuPDF
	* ".bmp",
	* ".gif",
	* ".hdp",
	* ".j2k",
	* ".jp2",
	* ".jpeg",
	* ".jpg",
	* ".jpx",
	* ".jxr",
	* ".pam",
	* ".pbm",
	* ".pgm",
	* ".png",
	* ".pnm",
	* ".ppm",
	* ".tif",
	* ".tiff",
        * ".wdp",
6 years ago
poire-z 7797c2369e
credocument: deal with loadDocument() failures (#3570)
cre:loadDocument() may fail in recognizing the document format, and
koreader would previously keep calling other methods on it, which would
make crengine segfaults. We now check loadDocument success at the
various places it is called, and try to deal the best way we can when it fails.
6 years ago
TnS-hun 15ec47d7e0 cbt support (#3533) (#3554) 6 years ago
TnS-hun 89164dcbd7 MuPDF 1.12 (#3547)
* addMarkupAnnotation expects a float array

* Use the latest from koreader-base with koreader/koreader-base#577

Closes #3519.
6 years ago
poire-z cfa5c8a941 djvu: enable color rendering (#3361)
* djvu: enable color rendering

* Bump base
7 years ago
poire-z 561caadc5c Avoid recalculation of partial_md5_checksum at each opening (#3352)
This is done by/for kosync plugin at each opening, because
the docsettings was re-opened and saved for this, but later
overwritten by the current koreader docsettings - so it was
redone each time. This correctly adds this partial_md5_checksum
to the current koreader docsettings, which will be saved on
document closing - so it will not be redone next time.
Note: this partial_md5_checksum is not (yet) used by anything.
7 years ago
poire-z 26def92983 credocument reader optimisation (avoid multiple TOC builds) (#3292)
Avoid unnecessary work in ReaderView:onSetViewMode() and
ReaderRolling:updatePos() that would result in TOC being reset
and rebuilt (which can take time on books with huge TOC) during
reader setup.
7 years ago
poire-z 53f083f516 Allow for toggling color rendering
New menu item in Screen submenu.
hasColorScreen enabled for SDL device.
7 years ago
poire-z 180f5755f4 Allow for colored rendering (#3276)
* Allow for colored rendering

Available with all engines (CRE, PDF, Images).
Needs to manually add setting: "color_rendering" = true

* Disable color for djvudocument

* Use Screen:isColorEnabled()

* Bump base
7 years ago
poire-z 75b7c4b524 Added Font Hinting toggle (#3182) 7 years ago
poire-z c24d75f18c Fix use of default font with font-family: styles
Base bumped.
Previsouly, parts of document in <p style="font-family: serif">
would be rendered with the first font set, and would not
follow change of font (unline other texts without styles).
That was observable with Embedded Styles set to On, but is even
more noticiable with the new Embedded Fonts setting set to off.
7 years ago
poire-z 774d2345e0 Added Embedded Fonts config toggle
Just under the existing "Embedded Styles". Support for this
was already there in crengine, and interfacing is similar to
what is done with Embedded Styles.
7 years ago
poire-z 031df2ffee Added PicDocument:getCoverPageImage() and :getProps()
So an image file can have a cover in coverbrowser's display.
It also allows for an alternative viewer (ImageViewer widget)
when holding on file / View full size cover.
7 years ago
poire-z 64f699ba36 Store book metadata and nb of pages in new settings
They may already be available (with other statistics stuff) under
the 'stats' key, but not if Statistics plugin is disabled. As this
plugin may be migrated to SQLite, readerui and readerfooter will now
set two new properties: doc_props (containing all and only the metadata
returned by document:getDocumentProps()) and doc_pages (updated
by readerfooter on any display or font change).

PDF document: returns additional PDF properties: Keywords
and Subject (as Description).
7 years ago
Frans de Jonge fa12f488e8 Fix garbled ImageWidget cache issues
Fixes #2805. Thanks to @poire-z, see https://github.com/koreader/koreader/issues/2805#issuecomment-296686695
7 years ago
poire-z 495accfec9 Reduce memory leaks when switching credocuments
CRE cache, hyphdict and fonts can be initialized only once
when first credocument is opened. Previously, they were
recreated for each document, and as previous instances were probably
not free'd, this caused memory leaks.
7 years ago
poire-z 76f6b49731 Fix crash with kopt semi-auto crop on blank page
When such blank page has only a few black pixels (dust), it would result in
a really small cropped area, than when scaled to fit screen, would cause a
crash with :
    ./ffi/mupdf.lua:63: could not allocate pixmap:
         malloc of array (451342 x 612558 bytes) failed (integer overflow) (1)
Fix similar to what is done in KoptInterface:getAutoBBox(): when cropped area too small,
fall back to whole page (or here: to user's manually set area).
7 years ago
Frans de Jonge c847d628e1 Docs: cosmetic updates and additions
* Content from wiki had some cosmetic leftover glitches
* Added/adapted some docs for other modules
7 years ago
Frans de Jonge a6ca0f9b55 CreDocument: add "md" (Markdown) to supported filetypes
Fixes #2632.
7 years ago