txt support
This commit is contained in:
11 files changed
+781
-14
No files matched your search
@@ -23,8 +23,8 @@ Asteria Qt is a cross-platform desktop book/document reader built with Qt6/C++.
|
||||
|
||||
## Format Support
|
||||
|
||||
Active implementation: **EPUB, FB2 (.fb2, .fbz, .fb2.zip), CBZ, CBR, Folder of images**
|
||||
Queued for reimplementation on new render pipeline: **TXT**
|
||||
Active implementation: **EPUB, FB2 (.fb2, .fbz, .fb2.zip), TXT, CBZ, CBR, Folder of images**
|
||||
Queued for reimplementation on new render pipeline: None
|
||||
|
||||
Full target format list:
|
||||
|
||||
@@ -32,7 +32,7 @@ Full target format list:
|
||||
|----------|---------|-----------------------------------------------------------------------------------------------------------------------------------------|
|
||||
| EPUB | Yes | Unzip (`ZipByteSource`) + parse OPF spine + CSS parser + `HtmlBlockParser` to `DocumentChunkBuilder` + Knuth-Plass |
|
||||
| FB2 | Yes | `Fb2ByteSource` (plain XML / ZIP) + `TextEncoding` + direct `DocumentChunkBuilder` streaming + Knuth-Plass |
|
||||
| TXT | Queued | `TextEncoding` + direct streaming into `DocumentChunkBuilder` + Knuth-Plass |
|
||||
| TXT | Yes | `TextEncoding` + direct streaming into `DocumentChunkBuilder` + Knuth-Plass |
|
||||
| PDF | Planned | `QtPdf` module (`QPdfDocument`, Qt 6.4+) |
|
||||
| DOC | Planned | `libwpd` or antiword subprocess |
|
||||
| RTF | Planned | `QTextDocumentReader` or RTF→HTML |
|
||||
@@ -52,7 +52,7 @@ Full target format list:
|
||||
|
||||
### Dependencies
|
||||
- Qt 6.10+ components: `Core`, `Gui`, `Qml`, `Quick`, `Widgets`, `Concurrent`, `Svg`, `QuickControls2`, `Test`, `Xml`, `Network`, optional `DBus`.
|
||||
- Third-party packages: `minizip`, `libarchive`, `iconv`.
|
||||
- Third-party packages: `minizip`, `libarchive`, `iconv`, optional `uchardet`.
|
||||
|
||||
### Windows Build Environment
|
||||
Qt 6.10.3 at `C:\msys64\opt\qt\6.10.3\mingw_64`. MinGW toolchain at `C:\msys64\mingw64\bin\`:
|
||||
@@ -168,7 +168,8 @@ public:
|
||||
- `HtmlBlockParser` serves as the unified XML/HTML-to-IR converter streaming directly into `DocumentChunkBuilder`. It handles both XHTML (EPUB) and FictionBook (FB2) elements with native semantic tag defaults, CSS cascade, container nesting, and inline styling.
|
||||
- `Fb2Reader` streams XML sections directly into `HtmlBlockParser::parseChunks()` without synthetic HTML DOM allocations.
|
||||
- `EpubReader` resolves spine XHTML DOM nodes against in-memory CSS stylesheets (`Css::StyleSheet`) via `HtmlBlockParser::parseChunks()`, streaming directly into `DocumentChunkBuilder` with on-the-fly image URL resolution and zero DOM string mutations.
|
||||
- `TextEncoding` provides unified BOM/XML/HTML/iconv encoding detection across `FB2` and queued formats (`TXT`, `MOBI`, `PDB`).
|
||||
- `TxtReader` streams plain text files (`.txt`) directly into `DocumentChunkBuilder`, identifying Gutenberg metadata headers (`Title`, `Author`), unwrapping paragraph lines, detecting scene transitions, and validating content against binary, encrypted, or corrupted payloads (null bytes, control characters >2%, and excessive unmappable replacement characters >20%).
|
||||
- `TextEncoding` provides unified BOM/XML/HTML/uchardet/heuristic/iconv encoding detection across `FB2`, `TXT`, and queued formats (`MOBI`, `PDB`).
|
||||
- `HtmlBlockParser` and `Fb2Reader` normalize paragraph typography across EPUB (`<div class="paragraph">` and `<p>`) and FB2 (`<p>`): unstyled paragraphs default to zero vertical margins (`marginTop = 0`, `marginBottom = 0`) and `2.0em` first-line indent (`textIndent = 2.0 * baseFontSize`), eliminating `ContainerStart`/`ContainerEnd` box allocation overhead and preventing blank vertical gaps between prose/dialogue lines. Explicit CSS margins in publisher stylesheets override this default. Shorthand `margin` and `padding` (1 to 4 token syntax) are fully parsed.
|
||||
- Headings (`h1`..`h6`) default to left-aligned (`TextAlign::Left`) without first-line indentation (`textIndent = 0`). In `Fb2Reader`, `<title>` flattens child `<p>` lines separated by `<br/>` with `text-align: left; text-indent: 0;`, preventing nested paragraph indent on titles. Scene transitions via FB2 `<empty-line>` use explicit margins to provide intended section gaps.
|
||||
- When viewport geometry or font preferences change, `ReadingModel::updateLayoutMetrics()` runs `ChunkLayoutEngine` off-thread:
|
||||
@@ -211,6 +212,7 @@ Driven by `FormatSpec` table built in `main.cpp`:
|
||||
- `FormatSpec::comic(ext, matchesDirectory, scheme, makeSource)`
|
||||
- `FormatSpec::epub(makeSource)`
|
||||
- `FormatSpec::fb2(ext, makeSource)`
|
||||
- `FormatSpec::txt(ext)`
|
||||
Each format registers its file extension / directory matcher, reader factory, `IByteSource` factory, and image URL scheme in a single table entry.
|
||||
|
||||
---
|
||||
@@ -256,6 +258,7 @@ src/
|
||||
ImageScaling.h
|
||||
ImageUrl.h/cpp
|
||||
TextEncoding.h/cpp
|
||||
TxtReader.h/cpp
|
||||
WebImageProvider.h/cpp
|
||||
comic/
|
||||
ComicReader.h/cpp
|
||||
@@ -320,6 +323,7 @@ tests/
|
||||
FolderReaderTest.cpp
|
||||
ImageUrlTest.cpp
|
||||
TextEncodingTest.cpp
|
||||
TxtReaderTest.cpp
|
||||
WebImageProviderTest.cpp
|
||||
reading/
|
||||
KnuthPlassRenderingSpecTest.cpp
|
||||
|
||||
Reference in new issue
Block a user