mirror of
https://github.com/storytold/materialcraft.git
synced 2026-11-19 05:50:57 +01:00
Use shared Liberation fallback for clean-room SBS assets
Preserve available user fonts and use craft-fonts Liberation Mono only when font data is missing. Keep original identifiers and retain repairable references if the fallback is unavailable. Attribute the bundled clean-room SBS library, remove the bundled font binary, and share documentation and license staging across Windows MSI and portable packages.
This commit is contained in:
1 parent
43f665f988
commit
8737d45b64
22 files changed
+493
-93
No files matched your search
+7
-3
@@ -1,7 +1,9 @@
|
||||
# Attribution
|
||||
|
||||
Every bundled non-code asset in this repository, with its author, source and license. The rule:
|
||||
**each asset gets a row here in the same change that adds it.** MaterialCraft's own code and
|
||||
**each asset is covered by a row here in the same change that adds it.**
|
||||
The original SBS library shares one recursive entry below; its separately sourced resources keep
|
||||
their own entries and licenses. MaterialCraft's own code and
|
||||
original assets are MIT OR Apache-2.0 (see [`LICENSE-MIT`](LICENSE-MIT),
|
||||
[`LICENSE-APACHE`](LICENSE-APACHE) and [`NOTICE`](NOTICE)); third-party assets must be permissively
|
||||
licensed and keep their license file next to them. No asset from any commercial product (icons,
|
||||
@@ -32,11 +34,11 @@ images, materials, sample graphs, presets, environments) may ever be added.
|
||||
| `docs/images/materialcraft-levels-editor.png` | Docs screenshot: the Levels editor with the input histogram | MaterialCraft contributors | Offscreen render of MaterialCraft's UI (`crates/ui-egui/tests/snapshot.rs`) | MIT OR Apache-2.0 |
|
||||
| `docs/brand/artcraft-*.svg`, `docs/brand/artcraft-*.png` | ArtCraft logo and mark | ArtCraft Team | storytold/craftrules `assets/brand/` | ArtCraft brand terms, not open source ([`docs/brand/LICENSE-brand.txt`](docs/brand/LICENSE-brand.txt)) |
|
||||
| `crates/nodes/src/atomic/text.rs` (`GLYPHS`) | Single-stroke vector font of the Text node (A–Z, a–z, 0–9, punctuation) | MaterialCraft contributors | Original, designed as stroke data in code | MIT OR Apache-2.0 |
|
||||
| `assets/sbs/` (every `.sbs` package, recursively), `examples/atomic_sample.sbs` | Procedural node, function graph and material library; atomic sample | ArtCraft Team and the MaterialCraft contributors | Original clean-room recreations of the professional node-based material workflow, created for MaterialCraft; authorship confirmed by the project maintainer | MIT OR Apache-2.0 |
|
||||
| `assets/sbs/resources/bluenoise_256.png` | 256 × 256 grayscale blue noise, contributor-supplied PNG | Christoph Peters | [Moments in Graphics](https://momentsingraphics.de/BlueNoise.html); contributor-supplied provenance | CC0-1.0 ([license](assets/sbs/resources/LICENSE_BLUE_NOISE.txt)) |
|
||||
| `assets/sbs/resources/bluenoise_256_c.exr` | 256 × 256 color blue noise, contributor-supplied EXR conversion | Christoph Peters | [Moments in Graphics](https://momentsingraphics.de/BlueNoise.html); contributor-supplied provenance | CC0-1.0 ([license](assets/sbs/resources/LICENSE_BLUE_NOISE.txt)) |
|
||||
| `assets/sbs/resources/shuf4_64_32.exr` | 64 × 32 sampling lookup, contributor-supplied EXR | Lukas Hosek and Alexander Wilkie | [Skylight Modelling](https://cgg.mff.cuni.cz/projects/SkylightModelling/); contributor-supplied provenance | BSD-3-Clause ([license](assets/sbs/resources/LICENSE_HOSEK_WILKIE.txt)) |
|
||||
| `assets/sbs/resources/sun.exr` | 512 × 16 solar coefficient lookup, contributor-supplied RGBA32F EXR | Lukas Hosek and Alexander Wilkie | [Skylight Modelling](https://cgg.mff.cuni.cz/projects/SkylightModelling/), source archive 1.4a identified in EXR metadata | BSD-3-Clause ([license](assets/sbs/resources/LICENSE_HOSEK_WILKIE.txt)) |
|
||||
| `assets/sbs/resources/cursor.otf` | TeX Gyre Cursor Regular 2.004, unchanged font with renamed file | Bogusław Jackowski and Janusz M. Nowacki, on behalf of TeX users groups; see upstream README for earlier credits | [CTAN](https://ctan.org/pkg/tex-gyre-cursor) | [GUST Font License (GFL)](https://ctan.org/license/gfl) ([bundled notice](assets/sbs/resources/GUST-FONT-LICENSE.txt)); incorporates LPPL-1.3c+ conditions ([text](assets/sbs/resources/LPPL-1.3c.txt)) |
|
||||
| `assets/sbs/resources/scratch_damage.png` | Scratch damage texture | Nick Rose | Original artwork supplied by the contributor; [artist website](https://www.artstation.com/nrose3d) | CC0-1.0 ([license](assets/sbs/resources/LICENSE_NICK_ROSE.txt)) |
|
||||
| `assets/sbs/resources/leather.png` | Leather texture | Nick Rose | Original artwork supplied by the contributor; [artist website](https://www.artstation.com/nrose3d) | CC0-1.0 ([license](assets/sbs/resources/LICENSE_NICK_ROSE.txt)) |
|
||||
| `assets/sbs/resources/scratched_metal.png` | Scratched metal texture | Nick Rose | Original artwork supplied by the contributor; [artist website](https://www.artstation.com/nrose3d) | CC0-1.0 ([license](assets/sbs/resources/LICENSE_NICK_ROSE.txt)) |
|
||||
@@ -44,9 +46,11 @@ images, materials, sample graphs, presets, environments) may ever be added.
|
||||
|
||||
## Third-party assets compiled into the binary
|
||||
|
||||
These come from Rust crate dependencies (not files in this repository) and keep their licenses.
|
||||
These come from Rust crate dependencies or the optional craft-fonts build input (not font files
|
||||
in this repository) and keep their licenses.
|
||||
|
||||
| Asset | Used for | Author | Source | License |
|
||||
|---|---|---|---|---|
|
||||
| Phosphor Icons (regular), via the `egui-phosphor` crate (vendored in `vendor/egui-phosphor` for egui 0.37) | Every UI icon (toolbars, panels, node quick-insert buttons) | Phosphor Icons (Helena Zhang, Tobias Fried) | https://phosphoricons.com, https://github.com/amPerl/egui-phosphor | MIT (icons); crate MIT OR Apache-2.0 |
|
||||
| egui default fonts (Ubuntu-Light, Hack, Noto Emoji, emoji-icon-font), via `epaint_default_fonts` | UI text | Canonical / Source Foundry / Google / Jessie Jung | https://github.com/emilk/egui | Ubuntu Font Licence 1.0, MIT + Bitstream Vera License, OFL 1.1, MIT |
|
||||
| Liberation Mono Regular 2.1.5, from the optional `CRAFT_FONTS_DIR` Latin catalog; exposed as `sbs://resources/LiberationMono-Regular.ttf` | Fallback for missing SBS fonts on native and web builds | Red Hat, Inc.; digitized data Google Corporation (Cousine) | [craft-fonts](https://github.com/storytold/craft-fonts/blob/c1db6d1a8ed772191241c3d185e2104be84d8691/ATTRIBUTION.md), from the Liberation Fonts 2.1.5 release | OFL-1.1 ([license](https://github.com/storytold/craft-fonts/blob/c1db6d1a8ed772191241c3d185e2104be84d8691/fonts/liberation-mono/OFL.txt)); embedded as `sbs://resources/OFL-LiberationMono.txt` and included in [`NOTICE`](NOTICE) for all packages and installers |
|
||||
Generated
+2
@@ -2701,6 +2701,7 @@ version = "0.1.3"
|
||||
dependencies = [
|
||||
"base64 0.22.1",
|
||||
"bytemuck",
|
||||
"craft-fonts-build",
|
||||
"dds",
|
||||
"flate2",
|
||||
"gltf",
|
||||
@@ -2713,6 +2714,7 @@ dependencies = [
|
||||
"roxmltree 0.20.0",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"sha2",
|
||||
"thiserror 2.0.21",
|
||||
"tobj",
|
||||
"zip 2.6.1",
|
||||
|
||||
@@ -101,6 +101,8 @@ craft-window = { git = "https://github.com/storytold/craft-libs", rev = "1b34eba
|
||||
craft-update = { git = "https://github.com/storytold/craft-libs", rev = "1b34eba41e62138fc2438d2734523b302840b45d", features = ["egui"] }
|
||||
# Atomic persistence, at the suite's existing revision.
|
||||
craft-atomic = { git = "https://github.com/storytold/craft-libs", rev = "1b34eba41e62138fc2438d2734523b302840b45d" }
|
||||
# Parse the optional shared font catalog at build time; the font repository is not a dependency.
|
||||
craft-fonts-build = { git = "https://github.com/storytold/craft-libs", rev = "1b34eba41e62138fc2438d2734523b302840b45d" }
|
||||
|
||||
# egui 0.37 and winit: the suite's forks (storytold/egui, storytold/winit), as craft-libs pins them.
|
||||
[patch.crates-io]
|
||||
|
||||
@@ -17,10 +17,117 @@ egui default fonts (compiled in through the epaint_default_fonts crate): Ubuntu-
|
||||
Font Licence 1.0; Hack — MIT and Bitstream Vera License; Noto Emoji — SIL Open Font License 1.1;
|
||||
emoji-icon-font — MIT.
|
||||
|
||||
Every other bundled asset is original to MaterialCraft (generated in code or drawn for this
|
||||
project).
|
||||
All bundled SBS packages are original clean-room recreations by the ArtCraft Team and the
|
||||
MaterialCraft contributors, under MIT OR Apache-2.0. Separately sourced resource assets retain
|
||||
the authorship and licenses recorded in ATTRIBUTION.md.
|
||||
|
||||
Builds made with craft-fonts (CRAFT_FONTS_DIR; all official releases) also embed the fonts listed
|
||||
in https://github.com/storytold/craft-fonts/blob/main/ATTRIBUTION.md (BIZ UDPGothic on desktop and
|
||||
web, Noto Sans CJK SC on desktop), under the SIL Open Font License 1.1. Their licence texts ship
|
||||
with the package as OFL-<family>.txt.
|
||||
web, Noto Sans CJK SC on desktop, and Liberation Mono Regular for missing SBS fonts), under the
|
||||
SIL Open Font License 1.1. The UI font notices ship as OFL-<family>.txt. The Liberation Mono
|
||||
notice follows, so it accompanies packages and installers even when font build inputs are absent
|
||||
at packaging time.
|
||||
|
||||
Liberation Mono Regular 2.1.5
|
||||
|
||||
Digitized data copyright (c) 2010 Google Corporation
|
||||
with Reserved Font Arimo, Tinos and Cousine.
|
||||
Copyright (c) 2012 Red Hat, Inc.
|
||||
with Reserved Font Name Liberation.
|
||||
|
||||
This Font Software is licensed under the SIL Open Font License,
|
||||
Version 1.1.
|
||||
|
||||
This license is copied below, and is also available with a FAQ at:
|
||||
http://scripts.sil.org/OFL
|
||||
|
||||
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
|
||||
|
||||
PREAMBLE The goals of the Open Font License (OFL) are to stimulate
|
||||
worldwide development of collaborative font projects, to support the font
|
||||
creation efforts of academic and linguistic communities, and to provide
|
||||
a free and open framework in which fonts may be shared and improved in
|
||||
partnership with others.
|
||||
|
||||
The OFL allows the licensed fonts to be used, studied, modified and
|
||||
redistributed freely as long as they are not sold by themselves.
|
||||
The fonts, including any derivative works, can be bundled, embedded,
|
||||
redistributed and/or sold with any software provided that any reserved
|
||||
names are not used by derivative works. The fonts and derivatives,
|
||||
however, cannot be released under any other type of license. The
|
||||
requirement for fonts to remain under this license does not apply to
|
||||
any document created using the fonts or their derivatives.
|
||||
|
||||
|
||||
|
||||
DEFINITIONS
|
||||
"Font Software" refers to the set of files released by the Copyright
|
||||
Holder(s) under this license and clearly marked as such.
|
||||
This may include source files, build scripts and documentation.
|
||||
|
||||
"Reserved Font Name" refers to any names specified as such after the
|
||||
copyright statement(s).
|
||||
|
||||
"Original Version" refers to the collection of Font Software components
|
||||
as distributed by the Copyright Holder(s).
|
||||
|
||||
"Modified Version" refers to any derivative made by adding to, deleting,
|
||||
or substituting ? in part or in whole ?
|
||||
any of the components of the Original Version, by changing formats or
|
||||
by porting the Font Software to a new environment.
|
||||
|
||||
"Author" refers to any designer, engineer, programmer, technical writer
|
||||
or other person who contributed to the Font Software.
|
||||
|
||||
|
||||
PERMISSION & CONDITIONS
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a
|
||||
copy of the Font Software, to use, study, copy, merge, embed, modify,
|
||||
redistribute, and sell modified and unmodified copies of the Font
|
||||
Software, subject to the following conditions:
|
||||
|
||||
1) Neither the Font Software nor any of its individual components,in
|
||||
Original or Modified Versions, may be sold by itself.
|
||||
|
||||
2) Original or Modified Versions of the Font Software may be bundled,
|
||||
redistributed and/or sold with any software, provided that each copy
|
||||
contains the above copyright notice and this license. These can be
|
||||
included either as stand-alone text files, human-readable headers or
|
||||
in the appropriate machine-readable metadata fields within text or
|
||||
binary files as long as those fields can be easily viewed by the user.
|
||||
|
||||
3) No Modified Version of the Font Software may use the Reserved Font
|
||||
Name(s) unless explicit written permission is granted by the
|
||||
corresponding Copyright Holder. This restriction only applies to the
|
||||
primary font name as presented to the users.
|
||||
|
||||
4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
|
||||
Software shall not be used to promote, endorse or advertise any
|
||||
Modified Version, except to acknowledge the contribution(s) of the
|
||||
Copyright Holder(s) and the Author(s) or with their explicit written
|
||||
permission.
|
||||
|
||||
5) The Font Software, modified or unmodified, in part or in whole, must
|
||||
be distributed entirely under this license, and must not be distributed
|
||||
under any other license. The requirement for fonts to remain under
|
||||
this license does not apply to any document created using the Font
|
||||
Software.
|
||||
|
||||
|
||||
|
||||
TERMINATION
|
||||
This license becomes null and void if any of the above conditions are not met.
|
||||
|
||||
|
||||
|
||||
DISCLAIMER
|
||||
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
|
||||
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
|
||||
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
|
||||
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM OTHER
|
||||
DEALINGS IN THE FONT SOFTWARE.
|
||||
Binary file not shown.
@@ -1 +1 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?><package><identifier v="Unsaved Package"/><formatVersion v="0.1.3"/><updaterVersion v="0.1.3"/><fileUID v="{43c7ef21-a3a7-4650-ad85-3e767305ec20}"/><versionUID v="0"/><dependencies><dependency><filename v="functions.sbs"/><uid v="1290776887"/><type v="package"/><fileUID v="0"/><versionUID v="0"/></dependency><dependency><filename v="?himself"/><uid v="1545739604"/><type v="package"/><fileUID v="{43c7ef21-a3a7-4650-ad85-3e767305ec20}"/><versionUID v="0"/></dependency><dependency><filename v="blend_switch.sbs"/><uid v="1299239600"/><type v="package"/><fileUID v="{052d6b3d-8709-43a1-bd08-1b84104248d1}"/><versionUID v="0"/></dependency><dependency><filename v="value_get_size.sbs"/><uid v="1387509338"/><type v="package"/><fileUID v="{3608867f-e427-46d3-9c71-52389d0ccfa3}"/><versionUID v="0"/></dependency><dependency><filename v="quad_transform.sbs"/><uid v="1302869619"/><type v="package"/><fileUID v="{bcaf47af-02e3-4b7d-8313-8eccb950de0d}"/><versionUID v="0"/></dependency><dependency><filename v="uv_mapper.sbs"/><uid v="1477136496"/><type v="package"/><fileUID v="{a3c26e7a-e2c6-4a1e-9609-a0f2a224d0ae}"/><versionUID v="0"/></dependency></dependencies><content><graph><identifier v="spline_circle"/><uid v="1460658682"/><graphtype v="texture_generator"/><attributes><category v="Splines & Paths"/><label v="Spline circle"/><tags v="Splines"/><group v="Spline generators"/><description v="spline circle: processing graph. Inputs: circle_radius, circle_pre_rotation, circle_size, circle_post_rotation, circle_position, start_height, end_height, start_thickness, end_thickness, trim, spiral, spiral_turns, spiral_power, flip_direction, uniform_distribution, append_input_spline, non_square_correction, preview_show_direction_helper, show_thickness_envelope, preview_segment_amount, spline_coords, spline_data, spline_amount, preview, thickness_px. Outputs: spline_coords, spline_data, spline_amount, preview."/></attributes><paraminputs><paraminput><identifier v="circle_radius"/><uid v="1460684099"/><attributes><label v="Circle radius"/><description v="Controls the circle radius value in this graph."/></attributes><type v="256"/><defaultValue><constantValueFloat1 v="0.25"/></defaultValue><defaultWidget><name v="slider"/><options><option><name v="clamp"/><value v="0"/></option><option><name v="default"/><value v="0.25"/></option><option><name v="max"/><value v="0.5"/></option><option><name v="min"/><value v="0"/></option><option><name v="step"/><value v="0.01"/></option></options></defaultWidget></paraminput><paraminput><identifier v="circle_pre_rotation"/><uid v="1460685077"/><attributes><label v="Circle pre-rotation"/><description v="Controls the circle pre rotation value in this graph."/></attributes><type v="256"/><defaultValue><constantValueFloat1 v="0"/></defaultValue><defaultWidget><name v="angle"/><options><option><name v="clamp"/><value v="0"/></option><option><name v="default"/><value v="0"/></option><option><name v="max"/><value v="1"/></option><option><name v="min"/><value v="0"/></option><option><name v="valueInterpretation"/><value v="angle"/></option></options></defaultWidget></paraminput><paraminput><identifier v="circle_size"/><uid v="1460685032"/><attributes><label v="Circle size"/><description v="Controls the circle size value in this graph."/></attributes><type v="512"/><defaultValue><constantValueFloat2 v="1 1"/></defaultValue><defaultWidget><name v="slider"/><options><option><name v="clamp"/><value v="0"/></option><option><name v="default"/><value v="1;1"/></option><option><name v="label0"/><value v="X"/></option><option><name v="label1"/><value v="Y"/></option><option><name v="max"/><value v="1"/></option><option><name v="min"/><value v="0"/></option><option><name v="step"/><value v="0.01"/></option></options></defaultWidget></paraminput><paraminput><identifier v="circle_post_rotation"/><uid v="1474681566"/><attributes><label v="Circle post-rotation"/><description v="Controls the circle post rotation value in this graph."/></attributes><type v="256"/><defaultValue><constantValueFloat1 v="0"/></defaultValue><defaultWidget><name v="angle"/><options><option><name v="clamp"/><value v="0"/></option><option><name v="default"/><value v="0"/></option><option><name v="max"/><value v="1"/></option><option><name v="min"/><value v="0"/></option><option><name v="valueInterpretation"/><value v="angle"/></option></options></defaultWidget></paraminput><paraminput><identifier v="circle_position"/><uid v="1460684159"/><attributes><label v="Circle position"/><description v="Controls the circle position value in this graph."/></attributes><type v="512"/><defaultValue><constantValueFloat2 v="0.5 0.5"/></defaultValue><defaultWidget><name v="position"/><options><option><name v="clamp"/><value v="0"/></option><option><name v="default"/><value v="0.5;0.5"/></option><option><name v="max"/><value v="1"/></option><option><name v="min"/><value v="0"/></option></options></defaultWidget></paraminputLine truncated
|
||||
<?xml version="1.0" encoding="UTF-8"?><package><identifier v="Unsaved Package"/><formatVersion v="0.1.3"/><updaterVersion v="0.1.3"/><fileUID v="{43c7ef21-a3a7-4650-ad85-3e767305ec20}"/><versionUID v="0"/><dependencies><dependency><filename v="functions.sbs"/><uid v="1290776887"/><type v="package"/><fileUID v="0"/><versionUID v="0"/></dependency><dependency><filename v="?himself"/><uid v="1545739604"/><type v="package"/><fileUID v="{43c7ef21-a3a7-4650-ad85-3e767305ec20}"/><versionUID v="0"/></dependency><dependency><filename v="blend_switch.sbs"/><uid v="1299239600"/><type v="package"/><fileUID v="{052d6b3d-8709-43a1-bd08-1b84104248d1}"/><versionUID v="0"/></dependency><dependency><filename v="value_get_size.sbs"/><uid v="1387509338"/><type v="package"/><fileUID v="{3608867f-e427-46d3-9c71-52389d0ccfa3}"/><versionUID v="0"/></dependency><dependency><filename v="quad_transform.sbs"/><uid v="1302869619"/><type v="package"/><fileUID v="{bcaf47af-02e3-4b7d-8313-8eccb950de0d}"/><versionUID v="0"/></dependency><dependency><filename v="uv_mapper.sbs"/><uid v="1477136496"/><type v="package"/><fileUID v="{a3c26e7a-e2c6-4a1e-9609-a0f2a224d0ae}"/><versionUID v="0"/></dependency></dependencies><content><graph><identifier v="spline_circle"/><uid v="1460658682"/><graphtype v="texture_generator"/><attributes><category v="Splines & Paths"/><label v="Spline circle"/><tags v="Splines"/><group v="Spline generators"/><description v="spline circle: processing graph. Inputs: circle_radius, circle_pre_rotation, circle_size, circle_post_rotation, circle_position, start_height, end_height, start_thickness, end_thickness, trim, spiral, spiral_turns, spiral_power, flip_direction, uniform_distribution, append_input_spline, non_square_correction, preview_show_direction_helper, show_thickness_envelope, preview_segment_amount, spline_coords, spline_data, spline_amount, preview, thickness_px. Outputs: spline_coords, spline_data, spline_amount, preview."/></attributes><paraminputs><paraminput><identifier v="circle_radius"/><uid v="1460684099"/><attributes><label v="Circle radius"/><description v="Controls the circle radius value in this graph."/></attributes><type v="256"/><defaultValue><constantValueFloat1 v="0.25"/></defaultValue><defaultWidget><name v="slider"/><options><option><name v="clamp"/><value v="0"/></option><option><name v="default"/><value v="0.25"/></option><option><name v="max"/><value v="0.5"/></option><option><name v="min"/><value v="0"/></option><option><name v="step"/><value v="0.01"/></option></options></defaultWidget></paraminput><paraminput><identifier v="circle_pre_rotation"/><uid v="1460685077"/><attributes><label v="Circle pre-rotation"/><description v="Controls the circle pre rotation value in this graph."/></attributes><type v="256"/><defaultValue><constantValueFloat1 v="0"/></defaultValue><defaultWidget><name v="angle"/><options><option><name v="clamp"/><value v="0"/></option><option><name v="default"/><value v="0"/></option><option><name v="max"/><value v="1"/></option><option><name v="min"/><value v="0"/></option><option><name v="valueInterpretation"/><value v="angle"/></option></options></defaultWidget></paraminput><paraminput><identifier v="circle_size"/><uid v="1460685032"/><attributes><label v="Circle size"/><description v="Controls the circle size value in this graph."/></attributes><type v="512"/><defaultValue><constantValueFloat2 v="1 1"/></defaultValue><defaultWidget><name v="slider"/><options><option><name v="clamp"/><value v="0"/></option><option><name v="default"/><value v="1;1"/></option><option><name v="label0"/><value v="X"/></option><option><name v="label1"/><value v="Y"/></option><option><name v="max"/><value v="1"/></option><option><name v="min"/><value v="0"/></option><option><name v="step"/><value v="0.01"/></option></options></defaultWidget></paraminput><paraminput><identifier v="circle_post_rotation"/><uid v="1474681566"/><attributes><label v="Circle post-rotation"/><description v="Controls the circle post rotation value in this graph."/></attributes><type v="256"/><defaultValue><constantValueFloat1 v="0"/></defaultValue><defaultWidget><name v="angle"/><options><option><name v="clamp"/><value v="0"/></option><option><name v="default"/><value v="0"/></option><option><name v="max"/><value v="1"/></option><option><name v="min"/><value v="0"/></option><option><name v="valueInterpretation"/><value v="angle"/></option></options></defaultWidget></paraminput><paraminput><identifier v="circle_position"/><uid v="1460684159"/><attributes><label v="Circle position"/><description v="Controls the circle position value in this graph."/></attributes><type v="512"/><defaultValue><constantValueFloat2 v="0.5 0.5"/></defaultValue><defaultWidget><name v="position"/><options><option><name v="clamp"/><value v="0"/></option><option><name v="default"/><value v="0.5;0.5"/></option><option><name v="max"/><value v="1"/></option><option><name v="min"/><value v="0"/></option></options></defaultWidget></paraminputLine truncated
|
||||
@@ -11,15 +11,22 @@ fn byte_only_sbs_import_resolves_library_resource_substitutes() {
|
||||
</content></package>"#;
|
||||
let mut session = Session::new(Package::new("Empty"));
|
||||
file_cmds::open_bytes(&mut session, xml, Some("example.sbs".into())).unwrap();
|
||||
assert!(session.load_warnings.is_empty(), "{:?}", session.load_warnings);
|
||||
for (name, filename) in [("noise", "bluenoise_256_c.exr"), ("font", "cursor.otf")] {
|
||||
let fallback = materialcraft_engine::formats::sbs::library::read(materialcraft_engine::formats::sbs::library::FALLBACK_FONT);
|
||||
if fallback.is_ok() {
|
||||
assert!(session.load_warnings.is_empty(), "{:?}", session.load_warnings);
|
||||
} else {
|
||||
assert_eq!(session.load_warnings.len(), 1);
|
||||
assert!(session.load_warnings[0].contains("LiberationMono-Regular.ttf"));
|
||||
}
|
||||
let font_file = if fallback.is_ok() { "LiberationMono-Regular.ttf" } else { "cour.ttf" };
|
||||
for (name, filename) in [("noise", "bluenoise_256_c.exr"), ("font", font_file)] {
|
||||
let resource = session.pkg.resource(name).unwrap();
|
||||
assert_eq!(resource.file, filename);
|
||||
assert_eq!(resource.bytes.as_slice(), materialcraft_engine::formats::sbs::library::read(&format!("sbs://resources/{filename}")).unwrap());
|
||||
assert_eq!(resource.bytes.as_slice(), materialcraft_engine::formats::sbs::library::read(&format!("sbs://resources/{filename}")).unwrap_or_default());
|
||||
}
|
||||
let saved = String::from_utf8(file_cmds::save_bytes(&session).unwrap()).unwrap();
|
||||
assert!(!saved.contains(".surface"));
|
||||
assert!(!saved.contains("cour.ttf"));
|
||||
assert_eq!(saved.contains("old/cour.ttf"), fallback.is_err());
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
@@ -29,3 +29,5 @@ resvg = { workspace = true }
|
||||
|
||||
[build-dependencies]
|
||||
flate2 = { workspace = true }
|
||||
craft-fonts-build = { workspace = true }
|
||||
sha2 = { workspace = true }
|
||||
@@ -8,6 +8,9 @@ use std::{
|
||||
};
|
||||
type Result<T> = std::result::Result<T, Box<dyn std::error::Error>>;
|
||||
|
||||
#[path = "build/sbs_font.rs"]
|
||||
mod sbs_font;
|
||||
|
||||
fn scan(root: &Path, folder: &Path, files: &mut Vec<PathBuf>) -> Result<()> {
|
||||
if folder.components().count() > 6 || files.len() > 4096 {
|
||||
return Err("bundled library exceeds its scan limits".into());
|
||||
@@ -44,13 +47,14 @@ fn main() -> Result<()> {
|
||||
std::fs::create_dir_all(&compressed)?;
|
||||
let mut files = Vec::new();
|
||||
scan(&root, Path::new(""), &mut files)?;
|
||||
files.sort_by_key(|path| path.to_string_lossy().replace('\\', "/"));
|
||||
let mut files: Vec<_> = files.into_iter().map(|relative| (relative.clone(), root.join(relative))).collect();
|
||||
files.extend(sbs_font::assets()?);
|
||||
files.sort_by_key(|(relative, _)| relative.to_string_lossy().replace('\\', "/"));
|
||||
let mut assets = String::from("const EMBEDDED_ASSETS: &[(&str, &[u8], usize)] = &[\n");
|
||||
let mut packages = String::from("pub const BUNDLED: &[&str] = &[\n");
|
||||
for (index, relative) in files.iter().enumerate() {
|
||||
let file = root.join(relative);
|
||||
for (index, (relative, file)) in files.iter().enumerate() {
|
||||
let mut bytes = Vec::new();
|
||||
std::fs::File::open(&file)?.take((256 << 20) + 1).read_to_end(&mut bytes)?;
|
||||
std::fs::File::open(file)?.take((256 << 20) + 1).read_to_end(&mut bytes)?;
|
||||
if bytes.len() > 256 << 20 {
|
||||
return Err("bundled asset exceeds 256 MiB".into());
|
||||
}
|
||||
|
||||
@@ -0,0 +1,72 @@
|
||||
//! Select just the SBS fallback face from the optional craft-fonts Latin catalog.
|
||||
use sha2::{Digest, Sha256};
|
||||
use std::{
|
||||
io::Read,
|
||||
path::{Component, Path, PathBuf},
|
||||
};
|
||||
|
||||
type Result<T> = std::result::Result<T, Box<dyn std::error::Error>>;
|
||||
|
||||
fn read(path: &Path, limit: u64) -> Result<Vec<u8>> {
|
||||
let mut bytes = Vec::new();
|
||||
std::fs::File::open(path)?.take(limit + 1).read_to_end(&mut bytes)?;
|
||||
if bytes.is_empty() || bytes.len() as u64 > limit {
|
||||
return Err(format!("{} is empty or exceeds its size limit", path.display()).into());
|
||||
}
|
||||
Ok(bytes)
|
||||
}
|
||||
|
||||
fn checkout_file(root: &Path, relative: &str) -> Result<PathBuf> {
|
||||
// A manifest must not embed arbitrary files from the build host, including through symlinks.
|
||||
if relative.is_empty() || relative.contains(['\\', ':']) || !Path::new(relative).components().all(|part| matches!(part, Component::Normal(_))) {
|
||||
return Err("font manifest path is not checkout-relative".into());
|
||||
}
|
||||
let path = root.join(relative).canonicalize()?;
|
||||
if !path.starts_with(root) {
|
||||
return Err("font manifest path escapes the checkout".into());
|
||||
}
|
||||
println!("cargo:rerun-if-changed={}", path.display());
|
||||
Ok(path)
|
||||
}
|
||||
|
||||
fn select(directory: &Path) -> Result<Vec<(PathBuf, PathBuf)>> {
|
||||
let root = directory.canonicalize()?;
|
||||
let manifest = checkout_file(&root, "fonts/latin-manifest.txt")?;
|
||||
let bytes = read(&manifest, 1 << 20)?;
|
||||
let entries = craft_fonts_build::parse_manifest(std::str::from_utf8(&bytes)?)?;
|
||||
let face = entries
|
||||
.iter()
|
||||
.find(|face| face.family == "Liberation Mono" && face.style == "Regular")
|
||||
.ok_or("Liberation Mono Regular is missing from the Latin font catalog")?;
|
||||
if face.licence != "OFL-1.1" || face.index != 0 {
|
||||
return Err("the SBS fallback must be the OFL-1.1 Liberation Mono Regular single font".into());
|
||||
}
|
||||
let font = checkout_file(&root, &face.file)?;
|
||||
let bytes = read(&font, 16 << 20)?;
|
||||
if !bytes.starts_with(b"\0\x01\0\0") || format!("{:x}", Sha256::digest(&bytes)) != face.sha256 {
|
||||
return Err("Liberation Mono Regular does not match its catalog checksum or TrueType format".into());
|
||||
}
|
||||
let license = checkout_file(&root, &face.licence_file)?;
|
||||
read(&license, 64 << 10)?;
|
||||
Ok(vec![("resources/LiberationMono-Regular.ttf".into(), font), ("resources/OFL-LiberationMono.txt".into(), license)])
|
||||
}
|
||||
|
||||
pub fn assets() -> Result<Vec<(PathBuf, PathBuf)>> {
|
||||
println!("cargo:rerun-if-env-changed=CRAFT_FONTS_DIR");
|
||||
println!("cargo:rerun-if-env-changed=CRAFT_FONTS_REQUIRED");
|
||||
let required = std::env::var_os("CRAFT_FONTS_REQUIRED").is_some_and(|value| value == "1");
|
||||
let directory = std::env::var_os("CRAFT_FONTS_DIR").filter(|value| !value.is_empty());
|
||||
let selected = match directory {
|
||||
Some(directory) => select(Path::new(&directory)),
|
||||
None if required => Err("CRAFT_FONTS_REQUIRED=1 requires CRAFT_FONTS_DIR for the SBS fallback font".into()),
|
||||
None => return Ok(Vec::new()),
|
||||
};
|
||||
match selected {
|
||||
Ok(assets) => Ok(assets),
|
||||
Err(error) if required => Err(error),
|
||||
Err(error) => {
|
||||
println!("cargo:warning=building without the SBS fallback font from craft-fonts: {error}");
|
||||
Ok(Vec::new())
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -35,7 +35,12 @@ const RECIPES: &[Recipe] = &[
|
||||
Recipe { key: "shuf4_64_32", path: "resources/shuf4_64_32.exr", extension: "exr", description: "Four-channel 64 by 32 floating-point sampling lookup." },
|
||||
Recipe { key: "sun", path: "resources/sun.exr", extension: "exr", description: "512 by 16 solar coefficient lookup. All RGBA channels are numeric data." },
|
||||
Recipe { key: "moss01_bmp", path: "resources/moss01_bmp.bmp", extension: "bmp", description: "Moss texture for coverage and surface detail." },
|
||||
Recipe { key: "courier_new", path: "resources/cursor.otf", extension: "otf", description: "Monospaced OpenType font for point-preview labels." },
|
||||
Recipe {
|
||||
key: "courier_new",
|
||||
path: "resources/LiberationMono-Regular.ttf",
|
||||
extension: "ttf",
|
||||
description: "Liberation Mono Regular fallback from craft-fonts for missing point-preview fonts.",
|
||||
},
|
||||
Recipe {
|
||||
key: "DoorFrame",
|
||||
path: "resources/DoorFrame.svg",
|
||||
@@ -95,7 +100,7 @@ pub fn notices(key: &str) -> &'static [&'static str] {
|
||||
"scratch_damage" | "leather" | "scratched_metal" | "moss01_bmp" => &["LICENSE_NICK_ROSE.txt"],
|
||||
"bluenoise_256" | "bluenoise_256_c" => &["LICENSE_BLUE_NOISE.txt"],
|
||||
"shuf4_64_32" | "sun" => &["LICENSE_HOSEK_WILKIE.txt", "sun_lookup_readme.txt"],
|
||||
"courier_new" => &["GUST-FONT-LICENSE.txt", "LPPL-1.3c.txt", "README-TeX-Gyre-Cursor.txt", "MANIFEST-TeX-Gyre-Cursor.txt"],
|
||||
"courier_new" => &["OFL-LiberationMono.txt"],
|
||||
_ => &[],
|
||||
}
|
||||
}
|
||||
@@ -78,7 +78,7 @@ fn references_are_relative_portable_and_confined_to_the_library() {
|
||||
#[test]
|
||||
fn resource_names_survive_and_surface_replacements_declare_their_actual_formats() {
|
||||
for (key, original, expected, format) in [
|
||||
("courier_new", "cour.ttf", "cursor.otf", "otf"),
|
||||
("courier_new", "cour.ttf", "LiberationMono-Regular.ttf", "ttf"),
|
||||
("moss01_bmp", "moss01_bmp.bmp", "moss01_bmp.bmp", "bmp"),
|
||||
("bluenoise_256_c", "bluenoise_256_c.surface", "bluenoise_256_c.exr", "exr"),
|
||||
("shuf4_64_32", "shuf4_64_32.surface", "shuf4_64_32.exr", "exr"),
|
||||
@@ -124,6 +124,10 @@ fn library_art_is_decodable_without_reading_source_assets() {
|
||||
fn curated_resources_keep_the_supplied_bytes_and_required_notices() {
|
||||
for key in ["bluenoise_256", "bluenoise_256_c", "sun", "shuf4_64_32", "courier_new", "scratch_damage", "leather", "scratched_metal", "moss01_bmp"] {
|
||||
let recipe = resources::recipe(key).unwrap();
|
||||
if key == "courier_new" && materialcraft_formats::sbs::library::read(&format!("sbs://{}", recipe.path)).is_err() {
|
||||
assert!(resources::load(key).is_err(), "a build without craft-fonts cannot export its font");
|
||||
continue;
|
||||
}
|
||||
let bytes = resources::load(key).unwrap();
|
||||
let supplied = materialcraft_formats::sbs::library::read(&format!("sbs://{}", recipe.path)).unwrap();
|
||||
assert!(bytes == supplied, "converter replaced the supplied bytes for {key}");
|
||||
@@ -132,7 +136,9 @@ fn curated_resources_keep_the_supplied_bytes_and_required_notices() {
|
||||
assert!(!materialcraft_formats::sbs::library::read(&format!("sbs://resources/{notice}")).unwrap().is_empty());
|
||||
}
|
||||
}
|
||||
assert!(resources::load("courier_new").unwrap().starts_with(b"OTTO"));
|
||||
if let Ok(font) = resources::load("courier_new") {
|
||||
assert!(font.starts_with(b"\0\x01\0\0"));
|
||||
}
|
||||
let shuffled = image::load_from_memory(&resources::load("shuf4_64_32").unwrap()).unwrap().into_rgba32f();
|
||||
assert_eq!(shuffled.dimensions(), (64, 32));
|
||||
assert!(shuffled.as_raw().iter().all(|v| v.is_finite()));
|
||||
|
||||
@@ -2,6 +2,13 @@
|
||||
|
||||
include!(concat!(env!("OUT_DIR"), "/sbs_assets.rs"));
|
||||
|
||||
/// Shared fallback for missing SBS font resources; supplied by the optional craft-fonts build input.
|
||||
pub const FALLBACK_FONT: &str = "sbs://resources/LiberationMono-Regular.ttf";
|
||||
|
||||
fn is_shared_font_asset(relative: &str) -> bool {
|
||||
matches!(relative, "resources/LiberationMono-Regular.ttf" | "resources/OFL-LiberationMono.txt")
|
||||
}
|
||||
|
||||
/// Validate alias paths before joining a filesystem root. No package may escape the library.
|
||||
pub fn relative_path(uri: &str) -> Result<&str, String> {
|
||||
let path = uri.strip_prefix("sbs://").ok_or("not an SBS library alias")?;
|
||||
@@ -78,6 +85,10 @@ pub fn contains_file(path: &std::path::Path) -> bool {
|
||||
/// Read a validated library alias from the configured directory or the embedded fallback.
|
||||
pub fn read(uri: &str) -> Result<Vec<u8>, String> {
|
||||
let relative = relative_path(uri)?;
|
||||
// These assets live in craft-fonts, so a source checkout's SBS directory cannot supply them.
|
||||
if is_shared_font_asset(relative) {
|
||||
return read_embedded(relative).map_err(|error| format!("{error}; build with CRAFT_FONTS_DIR containing Liberation Mono Regular"));
|
||||
}
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
{
|
||||
let root = root();
|
||||
@@ -165,9 +176,12 @@ mod tests {
|
||||
fn embedded_library_contains_every_disk_asset() {
|
||||
let root = std::path::Path::new(env!("CARGO_MANIFEST_DIR")).join("../../assets/sbs");
|
||||
for (relative, _, _) in EMBEDDED_ASSETS {
|
||||
if is_shared_font_asset(relative) {
|
||||
assert_eq!(read(&format!("sbs://{relative}")).unwrap(), read_embedded(relative).unwrap());
|
||||
continue;
|
||||
}
|
||||
assert_eq!(read_embedded(relative).unwrap(), std::fs::read(root.join(relative)).unwrap(), "{relative}");
|
||||
}
|
||||
assert!(read_embedded("resources/cursor.otf").unwrap().starts_with(b"OTTO"));
|
||||
}
|
||||
|
||||
/// Discovered packages have unique valid aliases and the embedded fallback is present.
|
||||
|
||||
@@ -7,7 +7,7 @@ pub(super) fn write(content: &mut String, resource: &Resource, writer: &mut SbsW
|
||||
let file = resource.file.to_ascii_lowercase();
|
||||
let kind = if file.ends_with(".svg") {
|
||||
"svg"
|
||||
} else if file.ends_with(".ttf") || file.ends_with(".otf") {
|
||||
} else if super::resource_replacement::is_font(&file) {
|
||||
"font"
|
||||
} else {
|
||||
"bitmap"
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
//! Map unsupported resource containers and the legacy font to shared library assets.
|
||||
//! Map unsupported resource containers and missing fonts to shared library assets.
|
||||
use super::{
|
||||
library,
|
||||
sbs_reader::{SbsReader, unique_name},
|
||||
@@ -9,16 +9,22 @@ use roxmltree::Node;
|
||||
|
||||
pub(super) fn target(reference: &str) -> Option<String> {
|
||||
let filename = reference.trim().rsplit(['/', '\\']).next()?;
|
||||
let replacement = if filename.eq_ignore_ascii_case("cour.ttf") {
|
||||
"cursor.otf".to_string()
|
||||
} else {
|
||||
let (stem, extension) = filename.rsplit_once('.')?;
|
||||
if !extension.eq_ignore_ascii_case("surface") {
|
||||
return None;
|
||||
}
|
||||
format!("{stem}.exr")
|
||||
};
|
||||
Some(format!("sbs://resources/{replacement}"))
|
||||
let (stem, extension) = filename.rsplit_once('.')?;
|
||||
extension.eq_ignore_ascii_case("surface").then(|| format!("sbs://resources/{stem}.exr"))
|
||||
}
|
||||
|
||||
pub(super) fn is_font(reference: &str) -> bool {
|
||||
reference.rsplit_once('.').is_some_and(|(_, extension)| matches!(extension.to_ascii_lowercase().as_str(), "ttf" | "otf" | "ttc" | "otc" | "woff" | "woff2"))
|
||||
}
|
||||
|
||||
fn store(pkg: &mut Package, identifier: &str, path: &str, source: &str, bytes: Vec<u8>) -> String {
|
||||
let taken: Vec<_> = pkg.resources.iter().map(|resource| resource.name.clone()).collect();
|
||||
let name = unique_name(&taken, if identifier.is_empty() { "resource" } else { identifier });
|
||||
let mut resource = Resource::new(name.clone(), crate::safe_file_name(source.rsplit(['/', '\\']).next().unwrap_or("resource")), ResourceBytes::new(bytes));
|
||||
resource.source = source.into();
|
||||
resource.folder = path.rsplit_once('/').map_or("", |(folder, _)| folder).into();
|
||||
pkg.resources.push(resource);
|
||||
name
|
||||
}
|
||||
|
||||
pub(super) fn load(
|
||||
@@ -29,19 +35,18 @@ pub(super) fn load(
|
||||
target: &str,
|
||||
linked: &dyn Fn(&str) -> Option<Vec<u8>>,
|
||||
) -> String {
|
||||
let taken: Vec<_> = pkg.resources.iter().map(|resource| resource.name.clone()).collect();
|
||||
let name = unique_name(&taken, if identifier.is_empty() { "resource" } else { identifier });
|
||||
// A missing replacement must never fall back to the old container or embedded payload.
|
||||
let bytes =
|
||||
library::relative_path(target).ok().and_then(|_| linked(target)).filter(|bytes| bytes.len() as u64 <= crate::MAX_RESOURCE).unwrap_or_else(|| {
|
||||
reader.warnings.add(format!("resource `{path}` could not be loaded: replacement `{target}` is invalid, missing or exceeds 256 MiB"));
|
||||
Vec::new()
|
||||
});
|
||||
let mut resource = Resource::new(name.clone(), target.rsplit('/').next().unwrap_or("resource.exr"), ResourceBytes::new(bytes));
|
||||
resource.source = target.into();
|
||||
resource.folder = path.rsplit_once('/').map_or("", |(folder, _)| folder).into();
|
||||
pkg.resources.push(resource);
|
||||
name
|
||||
store(pkg, identifier, path, target, bytes)
|
||||
}
|
||||
|
||||
pub(super) fn load_font(pkg: &mut Package, identifier: &str, path: &str, linked: &dyn Fn(&str) -> Option<Vec<u8>>) -> Option<String> {
|
||||
let bytes = linked(library::FALLBACK_FONT).filter(|bytes| !bytes.is_empty() && bytes.len() as u64 <= crate::MAX_RESOURCE)?;
|
||||
Some(store(pkg, identifier, path, library::FALLBACK_FONT, bytes))
|
||||
}
|
||||
|
||||
pub(super) fn read_direct(reader: &mut SbsReader<'_, '_>, content: Node<'_, '_>, pkg: &mut Package, linked: &dyn Fn(&str) -> Option<Vec<u8>>) {
|
||||
@@ -52,21 +57,51 @@ pub(super) fn read_direct(reader: &mut SbsReader<'_, '_>, content: Node<'_, '_>,
|
||||
.filter(|node| node.has_tag_name("parameter") && matches!(child_value(*node, "name"), Some("fontdata" | "bitmapresourcepath" | "vectorresourcepath")))
|
||||
{
|
||||
let Some(reference) = child_element(parameter, "paramValue").and_then(|value| child_value(value, "constantValueString")) else { continue };
|
||||
if reference.starts_with("pkg://") || reader.direct_resource_names.contains_key(reference) {
|
||||
if reference.trim().is_empty() || reader.direct_resource_names.contains_key(reference) {
|
||||
continue;
|
||||
}
|
||||
let font = child_value(parameter, "name") == Some("fontdata");
|
||||
let package_reference = reference.starts_with("pkg://");
|
||||
if package_reference && (!font || reader.resource_name(reference).is_some()) {
|
||||
continue;
|
||||
}
|
||||
let Some(target) = target(reference) else { continue };
|
||||
if reader.direct_resource_names.len() >= 1024 {
|
||||
reader.warnings.add("Only the first 1024 direct resource references were read");
|
||||
break;
|
||||
}
|
||||
if font {
|
||||
let original = if package_reference { reader.resolve_reference(reference).0 } else { reference.to_string() };
|
||||
let filename = original.rsplit(['/', '\\']).next().unwrap_or("font");
|
||||
let identifier = if package_reference { filename } else { filename.rsplit_once('.').map_or(filename, |(stem, _)| stem) };
|
||||
let path = format!("Resources/{identifier}");
|
||||
let supplied = if package_reference { None } else { linked(reference).filter(|bytes| !bytes.is_empty() && bytes.len() <= remaining) };
|
||||
let name = if let Some(bytes) = supplied {
|
||||
store(pkg, identifier, &path, reference, bytes)
|
||||
} else if let Some(name) = load_font(pkg, identifier, &path, &|path| linked(path).filter(|bytes| bytes.len() <= remaining)) {
|
||||
name
|
||||
} else {
|
||||
reader.warnings.add(format!("font `{reference}` and fallback `{}` are unavailable", library::FALLBACK_FONT));
|
||||
// Without a declaration there is no filename to invent: keep the unresolved SBS reference.
|
||||
if package_reference {
|
||||
reader.direct_resource_names.insert(reference.into(), reference.into());
|
||||
continue;
|
||||
}
|
||||
store(pkg, identifier, &path, reference, Vec::new())
|
||||
};
|
||||
if let Some(resource) = pkg.resources.last() {
|
||||
remaining = remaining.saturating_sub(resource.bytes.len());
|
||||
}
|
||||
reader.direct_resource_names.insert(reference.into(), name);
|
||||
continue;
|
||||
}
|
||||
let Some(target) = target(reference) else { continue };
|
||||
let name = if let Some(name) = targets.get(&target) {
|
||||
name.clone()
|
||||
} else {
|
||||
let filename = target.rsplit('/').next().unwrap_or("resource");
|
||||
let filename = target.rsplit(['/', '\\']).next().unwrap_or("resource");
|
||||
let identifier = filename.rsplit_once('.').map_or(filename, |(stem, _)| stem);
|
||||
let name =
|
||||
load(reader, pkg, identifier, &format!("Resources/{identifier}"), &target, &|path| linked(path).filter(|bytes| bytes.len() <= remaining));
|
||||
let path = format!("Resources/{identifier}");
|
||||
let name = load(reader, pkg, identifier, &path, &target, &|path| linked(path).filter(|bytes| bytes.len() <= remaining));
|
||||
if let Some(resource) = pkg.resources.last() {
|
||||
remaining = remaining.saturating_sub(resource.bytes.len());
|
||||
}
|
||||
|
||||
@@ -98,13 +98,15 @@ impl<'text> SbsReader<'text, '_> {
|
||||
.and_then(|copy| child_value(copy, "filename"))
|
||||
.filter(|path| !path.is_empty())
|
||||
.or_else(|| child_value(item, "filepath"));
|
||||
let font = kind == "font" || super::resource_replacement::is_font(&fallback_filename) || external.is_some_and(super::resource_replacement::is_font);
|
||||
let mut bytes: Option<Vec<u8>> = None;
|
||||
let mut loaded_source = "";
|
||||
let mut why_missing = String::new();
|
||||
|
||||
if let Some(embedded) = source.and_then(|s| child_element(s, "binembedded")) {
|
||||
match decode_embedded(child_value(embedded, "strdata").unwrap_or("")) {
|
||||
Ok(data) => bytes = Some(data),
|
||||
Ok(data) if !font || !data.is_empty() => bytes = Some(data),
|
||||
Ok(_) => why_missing = "its embedded font data is empty".into(),
|
||||
Err(e) => why_missing = format!("its embedded data is damaged ({e})"),
|
||||
}
|
||||
}
|
||||
@@ -118,16 +120,26 @@ impl<'text> SbsReader<'text, '_> {
|
||||
}
|
||||
|
||||
match linked(file) {
|
||||
Some(data) => {
|
||||
Some(data) if !font || !data.is_empty() => {
|
||||
bytes = Some(data);
|
||||
loaded_source = file;
|
||||
break;
|
||||
}
|
||||
Some(_) => why_missing = format!("its font file `{file}` is empty"),
|
||||
None => why_missing = format!("its file `{file}` was not found next to the package"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// A supplied font, including cour.ttf or embedded data, always wins. Only absence uses the shared fallback.
|
||||
if font && bytes.is_none() {
|
||||
if let Some(name) = super::resource_replacement::load_font(pkg, identifier, path, linked) {
|
||||
return name;
|
||||
}
|
||||
let why = if why_missing.is_empty() { "it has no font data" } else { &why_missing };
|
||||
why_missing = format!("{why}; fallback `{}` is unavailable", super::library::FALLBACK_FONT);
|
||||
}
|
||||
|
||||
let taken: Vec<String> = pkg.resources.iter().map(|r| r.name.clone()).collect();
|
||||
let name = unique_name(&taken, if identifier.is_empty() { "resource" } else { identifier });
|
||||
match bytes {
|
||||
@@ -143,7 +155,13 @@ impl<'text> SbsReader<'text, '_> {
|
||||
None => {
|
||||
let why = if why_missing.is_empty() { "it has no data".to_string() } else { why_missing };
|
||||
let extension = if kind == "svg" { "svg" } else { &format };
|
||||
let mut resource = Resource::new(name.clone(), crate::safe_file_name(&format!("{name}.{extension}")), ResourceBytes::new(Vec::new()));
|
||||
let filename = format!("{name}.{extension}");
|
||||
let filename = if font {
|
||||
external.and_then(|path| path.rsplit(['/', '\\']).next()).filter(|file| !file.is_empty()).unwrap_or(&filename)
|
||||
} else {
|
||||
&filename
|
||||
};
|
||||
let mut resource = Resource::new(name.clone(), crate::safe_file_name(filename), ResourceBytes::new(Vec::new()));
|
||||
resource.source = external.unwrap_or("").into();
|
||||
resource.folder = path.rsplit_once('/').map_or("", |(folder, _)| folder).into();
|
||||
pkg.resources.push(resource);
|
||||
@@ -645,24 +663,33 @@ impl<'text> SbsReader<'text, '_> {
|
||||
}
|
||||
}
|
||||
|
||||
fn resource_binding(&mut self, url: &str, graph_name: &str) -> Option<String> {
|
||||
pub(super) fn resource_name(&self, url: &str) -> Option<&String> {
|
||||
if let Some(name) = self.direct_resource_names.get(url) {
|
||||
return Some(name);
|
||||
}
|
||||
let dependency_uid = url.split_once('?').and_then(|(_, query)| query.split('&').find_map(|part| part.strip_prefix("dependency=")));
|
||||
if dependency_uid.is_some_and(|uid| !self.dependencies.contains_key(uid)) {
|
||||
return None;
|
||||
}
|
||||
let (path, dependency) = self.resolve_reference(url);
|
||||
match dependency.filter(|file| file != SELF_DEPENDENCY) {
|
||||
Some(file) => self.external_resource_names.get(&(file, path)),
|
||||
None => self.resource_names.get(&path),
|
||||
}
|
||||
}
|
||||
|
||||
fn resource_binding(&mut self, url: &str, graph_name: &str) -> Option<String> {
|
||||
if let Some(name) = self.resource_name(url) {
|
||||
return Some(name.clone());
|
||||
}
|
||||
let dependency_uid = url.split_once('?').and_then(|(_, query)| query.split('&').find_map(|part| part.strip_prefix("dependency=")));
|
||||
if let Some(uid) = dependency_uid.filter(|uid| !self.dependencies.contains_key(*uid)) {
|
||||
self.warnings.add(format!("graph `{graph_name}`: resource reference has unknown dependency `{uid}`"));
|
||||
return None;
|
||||
}
|
||||
let (path, dependency) = self.resolve_reference(url);
|
||||
let name = match dependency.filter(|file| file != SELF_DEPENDENCY) {
|
||||
Some(file) => self.external_resource_names.get(&(file, path.clone())),
|
||||
None => self.resource_names.get(&path),
|
||||
};
|
||||
if name.is_none() {
|
||||
} else {
|
||||
let (path, _) = self.resolve_reference(url);
|
||||
self.warnings.add(format!("graph `{graph_name}`: Node uses resource `{path}`, which is not in the package"));
|
||||
}
|
||||
name.cloned()
|
||||
None
|
||||
}
|
||||
}
|
||||
pub(super) fn unique_name(taken: &[String], base: &str) -> String {
|
||||
|
||||
@@ -0,0 +1,108 @@
|
||||
use materialcraft_core::Value;
|
||||
use materialcraft_formats::sbs::{read_sbs, write_sbs};
|
||||
|
||||
const FALLBACK: &str = "sbs://resources/LiberationMono-Regular.ttf";
|
||||
|
||||
fn resource(file: &str) -> String {
|
||||
format!(r#"<package><content><resource><identifier v="font"/><type v="font"/><format v="ttf"/><filepath v="{file}"/></resource></content></package>"#)
|
||||
}
|
||||
|
||||
fn direct(file: &str) -> String {
|
||||
format!(
|
||||
r#"<package><content><graph><identifier v="Text"/><compNodes><compNode><uid v="1"/><compImplementation><compFilter><filter v="text"/><parameters><parameter><name v="fontdata"/><paramValue><constantValueString v="{file}"/></paramValue></parameter></parameters></compFilter></compImplementation></compNode></compNodes></graph></content></package>"#
|
||||
)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn existing_relative_fonts_including_cour_take_precedence_over_the_fallback() {
|
||||
let mut empty = materialcraft_core::Package::new("Empty");
|
||||
empty.resources.push(materialcraft_core::Resource::new("font", "empty.ttf", materialcraft_core::ResourceBytes::new(Vec::new())));
|
||||
let embedded = String::from_utf8(write_sbs(&empty).unwrap()).unwrap();
|
||||
let doc = roxmltree::Document::parse(&embedded).unwrap();
|
||||
let source = &embedded[doc.descendants().find(|node| node.has_tag_name("source")).unwrap().range()];
|
||||
for file in ["fonts/cour.ttf", "fonts/custom.otf", r"fonts\Custom.TTF"] {
|
||||
for xml in [
|
||||
resource(file),
|
||||
direct(file),
|
||||
resource(file).replace("</resource>", "<source><externalcopy><filename v=\"empty.ttf\"/></externalcopy></source></resource>"),
|
||||
resource(file).replace("</resource>", &format!("{source}</resource>")),
|
||||
] {
|
||||
let read = read_sbs(xml.as_bytes(), "example.sbs", &|path| {
|
||||
if path == "empty.ttf" {
|
||||
return Some(Vec::new());
|
||||
}
|
||||
assert_eq!(path, file, "an available font must not read the fallback");
|
||||
Some(vec![1, 2, 3])
|
||||
})
|
||||
.unwrap();
|
||||
assert!(read.warnings.is_empty(), "{:?}", read.warnings);
|
||||
assert_eq!(read.pkg.resources.len(), 1);
|
||||
assert_eq!(read.pkg.resources[0].source, file);
|
||||
assert_eq!(read.pkg.resources[0].bytes.as_slice(), &[1, 2, 3]);
|
||||
let reopened = read_sbs(&write_sbs(&read.pkg).unwrap(), "moved.sbs", &|_| None).unwrap();
|
||||
assert!(reopened.warnings.is_empty(), "{:?}", reopened.warnings);
|
||||
assert_eq!(reopened.pkg.resources[0].bytes.as_slice(), &[1, 2, 3]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn every_missing_font_uses_liberation_mono_and_survives_a_portable_save() {
|
||||
for file in ["cour.ttf", "fonts/Other.otf", "fonts/Collection.ttc", "sbs://resources/cursor.otf"] {
|
||||
for xml in [resource(file), direct(file)] {
|
||||
let read = read_sbs(xml.as_bytes(), "example.sbs", &|path| (path == FALLBACK).then(|| vec![4, 5, 6])).unwrap();
|
||||
assert!(read.warnings.is_empty(), "{:?}", read.warnings);
|
||||
assert_eq!(read.pkg.resources.len(), 1);
|
||||
let font = &read.pkg.resources[0];
|
||||
assert_eq!(font.source, FALLBACK);
|
||||
assert_eq!(font.file, "LiberationMono-Regular.ttf");
|
||||
assert_eq!(font.bytes.as_slice(), &[4, 5, 6]);
|
||||
if let Some(graph) = read.pkg.graphs.first() {
|
||||
assert_eq!(graph.nodes[0].params["fontdata"], Value::Text(font.name.clone()));
|
||||
}
|
||||
let reopened = read_sbs(&write_sbs(&read.pkg).unwrap(), "moved.sbs", &|_| None).unwrap();
|
||||
assert!(reopened.warnings.is_empty(), "{:?}", reopened.warnings);
|
||||
assert_eq!(reopened.pkg.resources[0].bytes.as_slice(), &[4, 5, 6]);
|
||||
|
||||
// An unavailable fallback must keep the SBS reference repairable after saving.
|
||||
for fallback in [None, Some(Vec::new())] {
|
||||
let missing = read_sbs(xml.as_bytes(), "example.sbs", &|path| if path == FALLBACK { fallback.clone() } else { None }).unwrap();
|
||||
let original = &missing.pkg.resources[0];
|
||||
assert_eq!(original.source, file);
|
||||
assert_eq!(original.file, file.rsplit(['/', '\\']).next().unwrap());
|
||||
assert!(original.bytes.is_empty());
|
||||
assert!(!missing.warnings.is_empty());
|
||||
let saved = write_sbs(&missing.pkg).unwrap();
|
||||
let repaired = read_sbs(&saved, "example.sbs", &|path| (path == file).then(|| vec![7, 8, 9])).unwrap();
|
||||
assert!(repaired.warnings.is_empty(), "{:?}", repaired.warnings);
|
||||
assert_eq!(repaired.pkg.resources[0].name, original.name);
|
||||
assert_eq!(repaired.pkg.resources[0].bytes.as_slice(), &[7, 8, 9]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for reference in ["pkg:///Resources/Original", "pkg:///Resources/Original?dependency=2", "pkg:///Resources/Original?dependency=999"] {
|
||||
let xml =
|
||||
direct(reference).replace("<package>", "<package><dependencies><dependency><filename v=\"fonts.sbs\"/><uid v=\"2\"/></dependency></dependencies>");
|
||||
for foreign in [None, Some(b"<package><content/></package>".to_vec())] {
|
||||
let read = read_sbs(xml.as_bytes(), "example.sbs", &|path| match path {
|
||||
FALLBACK => Some(vec![4, 5, 6]),
|
||||
"fonts.sbs" => foreign.clone(),
|
||||
_ => None,
|
||||
})
|
||||
.unwrap();
|
||||
assert_eq!(read.pkg.resources.len(), 1);
|
||||
let font = &read.pkg.resources[0];
|
||||
assert_eq!(font.name, "Original");
|
||||
assert_eq!(font.bytes.as_slice(), &[4, 5, 6]);
|
||||
assert_eq!(read.pkg.graphs[0].nodes[0].params["fontdata"], Value::Text(font.name.clone()));
|
||||
let reopened = read_sbs(&write_sbs(&read.pkg).unwrap(), "moved.sbs", &|_| None).unwrap();
|
||||
assert!(reopened.warnings.is_empty(), "{:?}", reopened.warnings);
|
||||
assert_eq!(reopened.pkg.resources[0].name, "Original");
|
||||
|
||||
let missing = read_sbs(xml.as_bytes(), "example.sbs", &|_| None).unwrap();
|
||||
assert!(missing.pkg.resources.is_empty());
|
||||
assert_eq!(missing.pkg.graphs[0].nodes[0].params["fontdata"], Value::Text(reference.into()));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -58,7 +58,7 @@ fn linked_resources_retain_the_successful_path_but_embedded_resources_do_not_lin
|
||||
let saved = write_sbs(&read.pkg).unwrap();
|
||||
let saved = String::from_utf8(saved).unwrap();
|
||||
assert!(saved.contains("<type v=\"font\"/>"));
|
||||
let saved = saved.replace("<filepath v=\"\"/>", "<filepath v=\"stale.ttf\"/>");
|
||||
let saved = saved.replace("<filepath v=\"\"/>", "<filepath v=\"fonts/cour.ttf\"/>");
|
||||
let embedded = read_sbs(saved.as_bytes(), "saved.sbs", &|_| None).unwrap();
|
||||
assert!(embedded.warnings.is_empty(), "{:?}", embedded.warnings);
|
||||
assert!(embedded.pkg.resources[0].source.is_empty());
|
||||
|
||||
@@ -20,11 +20,10 @@ fn package(content: &str, foreign: &str) -> String {
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn surface_and_font_resources_use_library_replacements_before_embedded_or_external_data() {
|
||||
fn surface_resources_use_library_replacements_before_embedded_or_external_data() {
|
||||
for (file, format, expected, filter, parameter, key) in [
|
||||
("sbs://resources/sun.surface", "surface", "sun.exr", "bitmap", "bitmapresourcepath", "resource"),
|
||||
("../textures/arbitrary.SURFACE", "surface", "arbitrary.exr", "bitmap", "bitmapresourcepath", "resource"),
|
||||
(r"C:\fonts\COUR.TTF", "ttf", "cursor.otf", "text", "fontdata", "fontdata"),
|
||||
] {
|
||||
// Valid old embedded data must not take precedence over the requested replacement.
|
||||
let mut original = materialcraft_core::Package::new("Old");
|
||||
@@ -98,32 +97,16 @@ fn foreign_font_binding_is_imported_once_and_round_trips() {
|
||||
let foreign = package(&resource("../fonts/cour.ttf", "ttf", ""), "");
|
||||
let read = read_sbs(xml.as_bytes(), "example.sbs", &|path| match path {
|
||||
"nested/fonts.sbs" => Some(foreign.as_bytes().to_vec()),
|
||||
"sbs://resources/cursor.otf" => Some(vec![4, 5, 6]),
|
||||
"sbs://resources/LiberationMono-Regular.ttf" => Some(vec![4, 5, 6]),
|
||||
_ => None,
|
||||
})
|
||||
.unwrap();
|
||||
assert!(read.warnings.is_empty(), "{:?}", read.warnings);
|
||||
assert_eq!(read.pkg.resources.len(), 1);
|
||||
assert_eq!(read.pkg.resources[0].file, "cursor.otf");
|
||||
assert_eq!(read.pkg.resources[0].file, "LiberationMono-Regular.ttf");
|
||||
assert_eq!(read.pkg.graphs[0].nodes[0].params["fontdata"], Value::Text("asset".into()));
|
||||
let reopened = read_sbs(&write_sbs(&read.pkg).unwrap(), "moved.sbs", &|_| None).unwrap();
|
||||
assert!(reopened.warnings.is_empty(), "{:?}", reopened.warnings);
|
||||
assert_eq!(reopened.pkg.graphs[0].nodes[0].params["fontdata"], Value::Text("asset".into()));
|
||||
assert_eq!(reopened.pkg.resources[0].bytes.as_slice(), &[4, 5, 6]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn direct_font_filename_is_replaced_but_unrelated_fonts_are_preserved() {
|
||||
for file in ["cour.ttf", "sbs://resources/cour.ttf", r"C:\Fonts\cour.ttf"] {
|
||||
let xml = package(&node("text", "fontdata", file), "");
|
||||
let read = read_sbs(xml.as_bytes(), "example.sbs", &|path| (path == "sbs://resources/cursor.otf").then(|| vec![7])).unwrap();
|
||||
assert!(read.warnings.is_empty(), "{:?}", read.warnings);
|
||||
assert_eq!(read.pkg.resources.len(), 1);
|
||||
assert_eq!(read.pkg.resources[0].file, "cursor.otf");
|
||||
assert_eq!(read.pkg.graphs[0].nodes[0].params["fontdata"], Value::Text(read.pkg.resources[0].name.clone()));
|
||||
}
|
||||
let xml = package(&node("text", "fontdata", "mycour.ttf"), "");
|
||||
let read = read_sbs(xml.as_bytes(), "example.sbs", &|_| panic!("unrelated font should not be read")).unwrap();
|
||||
assert!(read.pkg.resources.is_empty());
|
||||
assert_eq!(read.pkg.graphs[0].nodes[0].params["fontdata"], Value::Text("mycour.ttf".into()));
|
||||
}
|
||||
+16
-1
@@ -112,7 +112,22 @@ Resource paths resolve beside their owning package: `resources/tile.png` in
|
||||
the library root. Filesystem resolution checks the canonical target to prevent escaping that root.
|
||||
Native saves inside the library retain loaded resource links and write ordinary relative paths;
|
||||
ordinary project saves copy resource bytes alongside the package, and byte-only saves embed them.
|
||||
Unavailable resources retain their reference and missing state.
|
||||
Unavailable resources retain their reference and missing state. Font resources first load their
|
||||
embedded data or their file relative to the SBS package, including user-supplied `cour.ttf`.
|
||||
Only a missing font uses `sbs://resources/LiberationMono-Regular.ttf`. The same precedence applies
|
||||
to direct Text font references and unresolved package font references; a blank reference keeps the
|
||||
built-in stroke font. Empty embedded data and empty files do not hide later font sources. If the
|
||||
fallback is also unavailable, the original SBS font name and reference remain available for repair.
|
||||
Resource loading and round trips preserve these fonts; the Text cook does not yet rasterize external fonts.
|
||||
|
||||
The formats build reads Liberation Mono Regular and its OFL notice from the optional
|
||||
`CRAFT_FONTS_DIR/fonts/latin-manifest.txt` catalog, verifies its checksum, and embeds only that
|
||||
face for native and web builds. Font binaries stay in craft-fonts. Set `CRAFT_FONTS_REQUIRED=1`
|
||||
for releases to fail on an unavailable fallback. Without the optional input, builds still work;
|
||||
a missing font produces a repairable resource and a load warning. A checkout with the Latin
|
||||
catalog is required (for example craft-fonts revision `c1db6d1a8ed772191241c3d185e2104be84d8691`).
|
||||
All bundled `.sbs` packages, including nested materials, are original clean-room recreations
|
||||
covered together in [ATTRIBUTION.md](../ATTRIBUTION.md); their other resources retain separate credits.
|
||||
Bitmap/SVG references into another package import only the requested resource declarations,
|
||||
resolving asset paths beside that owner. These become local resource snapshots with distinct
|
||||
names on collisions; saving retains shared asset links inside the library or carries their bytes
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
<!--
|
||||
MaterialCraft MSI (WiX Toolset v5: `dotnet tool install -g wix`). Built by package.ps1:
|
||||
|
||||
wix build materialcraft.wxs -arch x64 -d Version=1.2.3 -d BinDir=... -d IconPath=... -o out.msi
|
||||
wix build materialcraft.wxs -arch x64 -d Version=1.2.3 -d BinDir=... -d DocsDir=... -d IconPath=... -o out.msi
|
||||
|
||||
Per-machine install into Program Files, a Start Menu shortcut, `.mcraft` owned by MaterialCraft,
|
||||
and MaterialCraft offered under "Open with" for the mesh formats it opens (without taking over
|
||||
@@ -42,10 +42,14 @@
|
||||
|
||||
<Feature Id="Main" Title="MaterialCraft" Level="1">
|
||||
<ComponentGroupRef Id="MaterialCraftFiles" />
|
||||
<ComponentGroupRef Id="MaterialCraftDocumentation" />
|
||||
</Feature>
|
||||
</Package>
|
||||
|
||||
<Fragment>
|
||||
<ComponentGroup Id="MaterialCraftDocumentation" Directory="INSTALLFOLDER">
|
||||
<Files Include="$(var.DocsDir)\**" />
|
||||
</ComponentGroup>
|
||||
<ComponentGroup Id="MaterialCraftFiles" Directory="INSTALLFOLDER">
|
||||
<Component Id="MaterialCraftApp">
|
||||
<File Id="MaterialCraftExe" Source="$(var.BinDir)\materialcraft.exe" KeyPath="yes">
|
||||
|
||||
@@ -90,12 +90,25 @@ Copy-Item (Join-Path $Bin 'materialcraft.exe'), (Join-Path $Bin 'materialcraft-c
|
||||
|
||||
& (Join-Path $PSScriptRoot 'sign.ps1') (Join-Path $Stage 'materialcraft.exe') (Join-Path $Stage 'materialcraft-cli.exe')
|
||||
|
||||
# Stage documentation once so the MSI and portable ZIP carry the same notices and licences.
|
||||
$Docs = Join-Path $Stage 'docs'
|
||||
New-Item -ItemType Directory -Force -Path $Docs | Out-Null
|
||||
foreach ($f in 'README.md', 'LICENSE-MIT', 'LICENSE-APACHE', 'NOTICE', 'ATTRIBUTION.md') {
|
||||
Copy-Item -LiteralPath (Join-Path $Root $f) -Destination $Docs
|
||||
}
|
||||
# Include craft-fonts notices for both the UI faces and the SBS fallback font.
|
||||
if ($env:CRAFT_FONTS_DIR) {
|
||||
foreach ($ofl in Get-ChildItem -Path (Join-Path $env:CRAFT_FONTS_DIR 'fonts\*\OFL.txt') -File -ErrorAction SilentlyContinue) {
|
||||
Copy-Item -LiteralPath $ofl.FullName -Destination (Join-Path $Docs "OFL-$($ofl.Directory.Name).txt")
|
||||
}
|
||||
}
|
||||
|
||||
# ---- MSI ---------------------------------------------------------------------------------------
|
||||
$Msi = Join-Path $Dist "materialcraft-$Version-windows-$Arch.msi"
|
||||
Invoke-Native 'wix build' {
|
||||
wix build (Join-Path $PSScriptRoot 'materialcraft.wxs') -arch $Arch `
|
||||
-d "Version=$MsiVersion" -d "BinDir=$Stage" -d "IconPath=$(Join-Path $Root 'assets\app-icon\materialcraft.ico')" `
|
||||
-o $Msi
|
||||
-d "DocsDir=$Docs" -o $Msi
|
||||
}
|
||||
Invoke-Native 'MSI shortcut icon validation (ICE50)' {
|
||||
wix msi validate $Msi -ice ICE50 -intermediateFolder (Join-Path $Stage 'msi-validation')
|
||||
@@ -109,17 +122,7 @@ $Portable = Join-Path $TargetDir "windows-package\materialcraft-$Version-windows
|
||||
Remove-Item -Recurse -Force $Portable -ErrorAction SilentlyContinue
|
||||
New-Item -ItemType Directory -Force -Path $Portable | Out-Null
|
||||
Copy-Item (Join-Path $Stage '*.exe') $Portable
|
||||
foreach ($f in 'README.md', 'LICENSE-MIT', 'LICENSE-APACHE', 'NOTICE', 'ATTRIBUTION.md') {
|
||||
$p = Join-Path $Root $f
|
||||
if (Test-Path $p) { Copy-Item $p $Portable }
|
||||
}
|
||||
# Licences of the craft-fonts faces crates/ui-egui/build.rs embeds (release builds set CRAFT_FONTS_DIR).
|
||||
if ($env:CRAFT_FONTS_DIR) {
|
||||
foreach ($f in 'biz-ud-pgothic', 'noto-sans-cjk-sc') {
|
||||
$p = Join-Path $env:CRAFT_FONTS_DIR "fonts\$f\OFL.txt"
|
||||
if (Test-Path $p) { Copy-Item $p (Join-Path $Portable "OFL-$f.txt") }
|
||||
}
|
||||
}
|
||||
Copy-Item -Recurse (Join-Path $Docs '*') $Portable
|
||||
$Zip = Join-Path $Dist "materialcraft-$Version-windows-$Arch-portable.zip"
|
||||
Remove-Item -Force $Zip -ErrorAction SilentlyContinue
|
||||
Compress-Archive -Path $Portable -DestinationPath $Zip
|
||||
|
||||
Reference in new issue
Block a user