Repository navigation
Conversation
An e-book, a comic book archive, an OpenDocument or Office file, a 3MF or FreeCAD model and a Krita or OpenRaster drawing keep a cover or a preview picture in their zip. With no thumbnailer installed for the type, Folio now reads that picture itself, by offset and within named limits, on the road RAW photos already take.
[Medium impact] The PR appears safe to merge, with the earlier non-blocking font-scan concern still open. Findings
SummaryAdds thumbnails from pictures stored inside books, documents, parts, and drawings, plus font samples drawn from each font’s own bytes.
|
| for (char32_t c = kFirstCharacter; c <= kLastCharacter && letters.size() < 2; ++c) { | ||
| const bool letter = QChar::isLetter(c); | ||
| if ((!letter && drawable.size() == 2) || !QChar::isPrint(c) || QChar::isSpace(c)) | ||
| continue; | ||
| if (const std::optional<quint32> glyph = glyphFor(font, c)) { |
There was a problem hiding this comment.
Symbol fonts waste worker time
sample() scans through 0x10FFFF whenever a font has fewer than two drawable letters. Symbol-only fonts therefore walk the whole Unicode range even after finding both fallback characters, calling glyphFor() for every printable letter. This adds needless work to each uncached thumbnail and holds a thumbnail worker until the scan ends. Walk the font’s mapped characters instead, or bound the search.
A font file showed only its icon unless a font thumbnailer was installed. Folio now draws "Aa" in the font itself, read from the file's bytes and never added to the application's fonts, or the first letters the font has when it lacks those.
6779b78 to
d5d1ed7
Compare
Files that carry a picture of themselves now show it as their thumbnail, and a font is drawn in its own letters, one commit each with its own tests. This is stacked on #67, whose branch is its base, and adds two commits; the suite goes from 215 to 220 tests. No library or
dependsentry is added: the containers are zip files read with the zlib #67 already links, and a font is drawn by Qt from the file's bytes.What you'd notice
.otffile is drawn whichever type its extension gives it, since the MIME database shares that ending with an OpenDocument template. A Type 1 font, which is PostScript and so text to the MIME database, is no longer previewed as its source.Screenshots
A folder with two books, a 3MF part, a FreeCAD part, a Krita painting and four fonts, on a machine with no thumbnailer for any of these types. In the grid at its largest tiles: #67 above, this branch below. The symbol font shows what it draws for "A" and "a", an alpha in each case.
The details pane on a book, each part, the painting and a font: #67 above, this branch below.
The same folder as a list: #67 on the left, this branch on the right.
And in columns.
Tests
Five new cases, each failing without its commit: every type shows the member it keeps, picked out by its size, with both EPUB generations, both ways an Office or 3MF file names its thumbnail, and the fallback members; a container without its picture, or a broken one, is remembered as a miss and not read again; each limit above is shown at its edge (8192 entries drawn and 8193 not, 64 MiB drawn and one byte more not, a stream that inflates past its claim, zip64, encryption, a second disk, an absolute path inside, a picture claiming 20000 by 20000 pixels, a pipe named like a document); a container is read on a thumbnail worker and never once its request is cancelled; and a font is drawn in its own letters with each fallback, as a collection, as WOFF and as an
.otf, and never joins the application's fonts. The case that names the package for a type now checks that an OpenDocument file names none. Every commit builds and passes the suite on its own, also withTMPDIRset to a folder whose name has a space, where onlyextractRefusesWhatWouldLandOutsidefails, as it does on main.Limits
.otffile is still named an OpenDocument formula template in its type line. Naming it a font is part of Previews: archive names, font sheets, media length #63.