blitz-pdf 0.1.5 → 0.1.7
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 +61 -9
- package/THIRD_PARTY_NOTICES.md +20 -0
- package/dist/types.d.ts +2 -1
- package/dist/types.d.ts.map +1 -1
- package/licenses/Noto-OFL.txt +94 -0
- package/licenses/NotoCJK-OFL.txt +92 -0
- package/licenses/NotoEmoji-OFL.txt +93 -0
- package/licenses/Unifont-OFL.txt +90 -0
- package/licenses/font-sources.json +106 -0
- package/package.json +1 -1
- package/src/types.ts +2 -1
- package/vendor/README.md +43 -0
- package/vendor/blitz-paint/Cargo.toml +50 -0
- package/vendor/blitz-paint/LICENSE-APACHE +176 -0
- package/vendor/blitz-paint/LICENSE-MIT +23 -0
- package/vendor/blitz-paint/src/color.rs +66 -0
- package/vendor/blitz-paint/src/debug_overlay.rs +168 -0
- package/vendor/blitz-paint/src/filters.rs +40 -0
- package/vendor/blitz-paint/src/gradient.rs +536 -0
- package/vendor/blitz-paint/src/kurbo_css/css_box.rs +847 -0
- package/vendor/blitz-paint/src/kurbo_css/mod.rs +77 -0
- package/vendor/blitz-paint/src/kurbo_css/non_uniform_radii.rs +60 -0
- package/vendor/blitz-paint/src/layers.rs +95 -0
- package/vendor/blitz-paint/src/lib.rs +190 -0
- package/vendor/blitz-paint/src/render/background.rs +968 -0
- package/vendor/blitz-paint/src/render/border.rs +631 -0
- package/vendor/blitz-paint/src/render/box_shadow.rs +157 -0
- package/vendor/blitz-paint/src/render/clip_path.rs +492 -0
- package/vendor/blitz-paint/src/render/form_controls.rs +103 -0
- package/vendor/blitz-paint/src/render/mask.rs +144 -0
- package/vendor/blitz-paint/src/render.rs +1351 -0
- package/vendor/blitz-paint/src/sizing.rs +63 -0
- package/vendor/blitz-paint/src/text.rs +747 -0
- package/vendor/fontique/Cargo.toml +194 -0
- package/vendor/fontique/LICENSE-APACHE +201 -0
- package/vendor/fontique/LICENSE-MIT +25 -0
- package/vendor/fontique/README.md +54 -0
- package/vendor/fontique/examples/generic_families.rs +37 -0
- package/vendor/fontique/src/attributes.rs +42 -0
- package/vendor/fontique/src/backend/android.rs +218 -0
- package/vendor/fontique/src/backend/coretext.rs +206 -0
- package/vendor/fontique/src/backend/dwrite.rs +395 -0
- package/vendor/fontique/src/backend/fontconfig.rs +844 -0
- package/vendor/fontique/src/backend/mod.rs +75 -0
- package/vendor/fontique/src/charmap.rs +127 -0
- package/vendor/fontique/src/collection/mod.rs +1016 -0
- package/vendor/fontique/src/collection/query.rs +392 -0
- package/vendor/fontique/src/fallback.rs +293 -0
- package/vendor/fontique/src/family.rs +111 -0
- package/vendor/fontique/src/family_name.rs +153 -0
- package/vendor/fontique/src/font.rs +562 -0
- package/vendor/fontique/src/generic.rs +36 -0
- package/vendor/fontique/src/impl_fontconfig.rs +159 -0
- package/vendor/fontique/src/lib.rs +87 -0
- package/vendor/fontique/src/matching.rs +483 -0
- package/vendor/fontique/src/scan.rs +312 -0
- package/vendor/fontique/src/script.rs +271 -0
- package/vendor/fontique/src/source.rs +108 -0
- package/vendor/fontique/src/source_cache.rs +254 -0
- package/wasm/blitz_pdf_bg.wasm +0 -0
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
use style::properties::generated::longhands::object_fit::computed_value::T as ObjectFit;
|
|
2
|
+
|
|
3
|
+
pub(crate) fn compute_object_fit(
|
|
4
|
+
container_size: taffy::Size<f32>,
|
|
5
|
+
object_size: Option<taffy::Size<f32>>,
|
|
6
|
+
object_fit: ObjectFit,
|
|
7
|
+
) -> taffy::Size<f32> {
|
|
8
|
+
match object_fit {
|
|
9
|
+
ObjectFit::None => object_size.unwrap_or(container_size),
|
|
10
|
+
ObjectFit::Fill => container_size,
|
|
11
|
+
ObjectFit::Cover => compute_object_fit_cover(container_size, object_size),
|
|
12
|
+
ObjectFit::Contain => compute_object_fit_contain(container_size, object_size),
|
|
13
|
+
ObjectFit::ScaleDown => {
|
|
14
|
+
let contain_size = compute_object_fit_contain(container_size, object_size);
|
|
15
|
+
match object_size {
|
|
16
|
+
Some(object_size) if object_size.width < contain_size.width => object_size,
|
|
17
|
+
_ => contain_size,
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
fn compute_object_fit_contain(
|
|
24
|
+
container_size: taffy::Size<f32>,
|
|
25
|
+
object_size: Option<taffy::Size<f32>>,
|
|
26
|
+
) -> taffy::Size<f32> {
|
|
27
|
+
let Some(object_size) = object_size else {
|
|
28
|
+
return container_size;
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
let x_ratio = container_size.width / object_size.width;
|
|
32
|
+
let y_ratio = container_size.height / object_size.height;
|
|
33
|
+
|
|
34
|
+
let ratio = match (x_ratio < 1.0, y_ratio < 1.0) {
|
|
35
|
+
(true, true) => x_ratio.min(y_ratio),
|
|
36
|
+
(true, false) => x_ratio,
|
|
37
|
+
(false, true) => y_ratio,
|
|
38
|
+
(false, false) => x_ratio.min(y_ratio),
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
object_size.map(|dim| dim * ratio)
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
fn compute_object_fit_cover(
|
|
45
|
+
container_size: taffy::Size<f32>,
|
|
46
|
+
object_size: Option<taffy::Size<f32>>,
|
|
47
|
+
) -> taffy::Size<f32> {
|
|
48
|
+
let Some(object_size) = object_size else {
|
|
49
|
+
return container_size;
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
let x_ratio = container_size.width / object_size.width;
|
|
53
|
+
let y_ratio = container_size.height / object_size.height;
|
|
54
|
+
|
|
55
|
+
let ratio = match (x_ratio < 1.0, y_ratio < 1.0) {
|
|
56
|
+
(true, true) => x_ratio.max(y_ratio),
|
|
57
|
+
(true, false) => y_ratio,
|
|
58
|
+
(false, true) => x_ratio,
|
|
59
|
+
(false, false) => x_ratio.max(y_ratio),
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
object_size.map(|dim| dim * ratio)
|
|
63
|
+
}
|