turbo-html2pdf 0.3.9 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -5
- package/THIRD_PARTY_NOTICES.md +18 -2
- package/package.json +1 -1
- package/src/convert.rs +5 -2
- package/src/lib.rs +3 -4
- package/turbo-pdf-napi.darwin-arm64.node +0 -0
- package/turbo-pdf-napi.linux-arm64-gnu.node +0 -0
- package/turbo-pdf-napi.linux-x64-gnu.node +0 -0
- package/turbo-pdf-napi.linux-x64-musl.node +0 -0
- package/turbo-pdf-napi.win32-x64-msvc.node +0 -0
package/README.md
CHANGED
|
@@ -119,9 +119,9 @@ template (HTML + Jinja + t: directives)
|
|
|
119
119
|
▼
|
|
120
120
|
render_pages(data, css, fonts):
|
|
121
121
|
│ 1. render markup ── Jinja → HTML string (data substituted)
|
|
122
|
-
│ 2. parse ──
|
|
123
|
-
│ 3. cascade + inherit ──
|
|
124
|
-
│ 4. layout ──
|
|
122
|
+
│ 2. parse ── turbo-dom document, t: directives as markers
|
|
123
|
+
│ 3. cascade + inherit ── turbo-dom-layout → ComputedStyle per node
|
|
124
|
+
│ 4. layout ── turbo-dom-layout: block / inline / flex (taffy) / table
|
|
125
125
|
│ → a "galley" of positioned, shaped fragments
|
|
126
126
|
│ 5. paginate ── break the galley into pages (orphans/widows,
|
|
127
127
|
│ break rules, repeated <thead>); resolve
|
|
@@ -131,7 +131,7 @@ render_pages(data, css, fonts):
|
|
|
131
131
|
PDF bytes borders, raster images, watermark
|
|
132
132
|
```
|
|
133
133
|
|
|
134
|
-
Layout, font shaping (`rustybuzz`), and PDF writing (`pdf-writer` + `subsetter`) are
|
|
134
|
+
Layout (the shared `turbo-dom-layout` crate), font shaping (`rustybuzz`), and PDF writing (`pdf-writer` + `subsetter`) are
|
|
135
135
|
all native; `taffy` powers flexbox. The engine embeds no fonts and does no network
|
|
136
136
|
or filesystem I/O — fonts and images are supplied by the caller.
|
|
137
137
|
|
|
@@ -201,7 +201,7 @@ fs.writeFileSync('out.pdf', pdf) // %PDF-1.7
|
|
|
201
201
|
|
|
202
202
|
## Status
|
|
203
203
|
|
|
204
|
-
`v0.
|
|
204
|
+
`v0.7.0` is the release version for npm, PyPI and crates.io; registry
|
|
205
205
|
verification follows the root `PUBLISHING.md`. The core engine is heavily tested (the `turbo-html2pdf-core`
|
|
206
206
|
crate holds 100% line coverage with a cyclomatic-complexity ≤ 5 gate). Bindings:
|
|
207
207
|
Node (napi) and WebAssembly. See [`docs/`](https://github.com/miaskiewicz/turbo-html2pdf/blob/main/docs/) for the full guide and
|
package/THIRD_PARTY_NOTICES.md
CHANGED
|
@@ -63,8 +63,9 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
63
63
|
|
|
64
64
|
# Bundled fonts — attribution & licenses
|
|
65
65
|
|
|
66
|
-
These fonts are embedded into `turbo-
|
|
67
|
-
|
|
66
|
+
These fonts are embedded into `turbo-dom-layout` (and so into turbo-html2pdf and
|
|
67
|
+
turbo-dom-raster) when the default `bundled-fonts` feature is enabled (see
|
|
68
|
+
turbo-dom-layout's `src/text/bundled.rs`). They back the CSS generic
|
|
68
69
|
families so a document renders with zero caller-supplied fonts. Every face below
|
|
69
70
|
is redistributed under a permissive open license; the full upstream license text
|
|
70
71
|
ships alongside each family.
|
|
@@ -89,6 +90,19 @@ Notes:
|
|
|
89
90
|
- Inter is the static OTF (CFF) build from the upstream `rsms/inter` v4.1
|
|
90
91
|
release; all other families are TrueType (`glyf`) outlines.
|
|
91
92
|
|
|
93
|
+
- `ic-fixture/IcFixture.ttf` is a test fixture only (never bundled): a box-glyph
|
|
94
|
+
face written by `scripts/make-ic-fixture-font.py` in this repository (no third-party
|
|
95
|
+
outlines; it is covered by the repository's MIT licence). It maps U+6C34 to a 0.9em
|
|
96
|
+
advance so the CSS `ic` unit has a glyph to measure (turbo-dom#237).
|
|
97
|
+
|
|
98
|
+
Test fixtures only (not bundled; `test_support::fixture_fonts()` and the Chrome
|
|
99
|
+
controls load them for the bidi comparisons, miaskiewicz/turbo-dom#238):
|
|
100
|
+
|
|
101
|
+
| Family | Faces | License | License file |
|
|
102
|
+
|------------------|---------|---------|-----------------------------|
|
|
103
|
+
| Noto Sans Hebrew | Regular | OFL 1.1 | `noto-sans-hebrew/OFL.txt` |
|
|
104
|
+
| Noto Sans Arabic | Regular | OFL 1.1 | `noto-sans-arabic/OFL.txt` |
|
|
105
|
+
|
|
92
106
|
## Sources
|
|
93
107
|
|
|
94
108
|
- Inter — https://github.com/rsms/inter (release v4.1, `extras/otf/`)
|
|
@@ -97,6 +111,8 @@ Notes:
|
|
|
97
111
|
- PT Serif — https://fonts.google.com/specimen/PT+Serif
|
|
98
112
|
- Fira Code — https://github.com/tonsky/FiraCode (release 6.2)
|
|
99
113
|
- IBM Plex Mono — https://fonts.google.com/specimen/IBM+Plex+Mono
|
|
114
|
+
- Noto Sans Hebrew — https://github.com/notofonts/hebrew (notofonts.github.io `hinted/ttf`)
|
|
115
|
+
- Noto Sans Arabic — https://github.com/notofonts/arabic (notofonts.github.io `hinted/ttf`)
|
|
100
116
|
|
|
101
117
|
The SIL Open Font License 1.1 permits embedding the font (including subsetted) in
|
|
102
118
|
documents and bundling with software, provided the copyright + license notices
|
package/package.json
CHANGED
package/src/convert.rs
CHANGED
|
@@ -104,7 +104,8 @@ impl ImageResolver for MapResolver {
|
|
|
104
104
|
}
|
|
105
105
|
|
|
106
106
|
/// Build a [`FontRegistry`] from caller-supplied faces. Each face is parsed via
|
|
107
|
-
/// [`FontFace::
|
|
107
|
+
/// [`FontFace::from_web_font_bytes`] (Chrome 156 web-font kerning, turbo-dom#240)
|
|
108
|
+
/// and tagged with its `family`/`weight`/`italic`, so
|
|
108
109
|
/// author CSS `font-family`/bold selects the right face via the cascade.
|
|
109
110
|
///
|
|
110
111
|
/// Unparseable blobs are skipped (the registry simply has fewer faces); the
|
|
@@ -114,7 +115,9 @@ pub fn build_registry(fonts: Vec<JsFont>) -> FontRegistry {
|
|
|
114
115
|
for font in fonts {
|
|
115
116
|
let weight = font.weight.unwrap_or(400);
|
|
116
117
|
let italic = font.italic.unwrap_or(false);
|
|
117
|
-
if let Some(face) =
|
|
118
|
+
if let Some(face) =
|
|
119
|
+
FontFace::from_web_font_bytes(font.data.to_vec(), font.family, weight, italic)
|
|
120
|
+
{
|
|
118
121
|
reg.add(face);
|
|
119
122
|
}
|
|
120
123
|
}
|
package/src/lib.rs
CHANGED
|
@@ -454,11 +454,10 @@ fn build_stamp_watermark(w: JsStampWatermark) -> napi::Result<StampWatermark> {
|
|
|
454
454
|
/// render-time mark (`FontRegistry::new().select(&[], 400, false)`).
|
|
455
455
|
fn resolve_stamp_face(font: Option<Buffer>) -> napi::Result<FontFace> {
|
|
456
456
|
match font {
|
|
457
|
-
Some(bytes) =>
|
|
458
|
-
|
|
457
|
+
Some(bytes) => FontFace::from_web_font_bytes(bytes.to_vec(), "watermark", 400, false)
|
|
458
|
+
.ok_or_else(|| {
|
|
459
459
|
errors::from_invalid_font("stamp watermark font: not a valid TrueType/OTF font")
|
|
460
|
-
})
|
|
461
|
-
}
|
|
460
|
+
}),
|
|
462
461
|
None => Ok(FontRegistry::new()
|
|
463
462
|
.select(&[], 400, false)
|
|
464
463
|
.expect("bundled sans face")
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|