Merge remote-tracking branch 'origin/main' into fix/psd-head-view

This commit is contained in:
Dylan M. Taylor committed 2026-11-13 06:06:44 +00:00
commit 79923702ff
15 files changed
+184 -116

No files matched your search

+8
View File
@@ -1,2 +1,10 @@
# Font-build test fixtures are compared byte for byte: a checkout must not convert them.
crates/fonts-build/tests/fixture/** -text
# The pinned font index is hashed and compiled in as committed: a checkout must not convert its
# line endings, or `Index::bundled` fails its checksum on Windows.
crates/font-store/index/sources.json -text
crates/font-store/index/indexes/*.gz binary
# Copies of the vendored krilla source diff, one per patch (see vendor/krilla/README.craft.md).
vendor/krilla/patches/*.patch linguist-generated=true
+60 -58
View File
@@ -12,64 +12,66 @@ permissions:
jobs:
native:
name: Workspace (${{ matrix.os }})
timeout-minutes: 30
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- name: Install software Vulkan renderer
if: runner.os == 'Linux'
run: |
sudo apt-get update
sudo apt-get install -y mesa-vulkan-drivers libvulkan1
echo 'WGPU_BACKEND=vulkan' >> "$GITHUB_ENV"
- uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt, clippy
- uses: Swatinem/rust-cache@v2
with:
key: workspace
- name: Prepare the Windows test driver
if: runner.os == 'Windows'
shell: powershell
run: |
$ErrorActionPreference = 'Stop'
Start-Service Spooler
Add-PrinterDriver -Name 'Generic / Text Only'
- run: cargo fmt --check
- run: cargo clippy --workspace --all-targets --locked -- -D warnings
- run: cargo clippy --workspace --all-targets --all-features --locked -- -D warnings
- run: cargo test --workspace --locked
env:
CRAFT_PRINT_REQUIRE_QUEUE: ${{ runner.os == 'Windows' && '1' || '0' }}
- run: cargo test --workspace --all-features --locked
env:
CRAFT_PRINT_REQUIRE_QUEUE: ${{ runner.os == 'Windows' && '1' || '0' }}
name: Workspace
uses: storytold/craft-common-actions/.github/workflows/gate.yml@main
with:
os: '["ubuntu-latest","windows-latest","macos-latest"]'
timeout-minutes: 120
tools: ""
packages: mesa-vulkan-drivers libvulkan1
craft-fonts-ref: b076417b5880bd4154bd22f00695b1d28c6bea83
linux-env: WGPU_BACKEND=vulkan
windows-env: CRAFT_PRINT_REQUIRE_QUEUE=1
env: CRAFT_PRINT_REQUIRE_QUEUE=0
setup-command: |
set -euo pipefail
corpus_fetcher=.test-inputs/photocraft
mkdir -p "$corpus_fetcher"
git -C "$corpus_fetcher" init
git -C "$corpus_fetcher" remote add origin https://github.com/storytold/PhotoCraft.git
git -C "$corpus_fetcher" fetch --quiet --depth=1 origin 74330157cb601573ae4523a95bb9132822fc3918
git -C "$corpus_fetcher" checkout --quiet --detach FETCH_HEAD
(cd "$corpus_fetcher" && cargo xtask corpus --psd --psd-tools --atn)
python scripts/test-fetch-pdf-test-fonts.py
python scripts/fetch-pdf-test-fonts.py "$RUNNER_TEMP/craft-pdf-test-fonts"
printf 'CRAFT_PSD_CORPUS=%s\n' "$GITHUB_WORKSPACE/$corpus_fetcher/corpus" >> "$GITHUB_ENV"
printf 'CRAFT_PDF_TEST_FONT_DIR=%s\n' "$RUNNER_TEMP/craft-pdf-test-fonts" >> "$GITHUB_ENV"
command: |
cargo fmt --check
cargo clippy --workspace --all-targets --locked -- -D warnings
cargo clippy --workspace --all-targets --all-features --locked -- -D warnings
cargo test --workspace --locked
cargo test --workspace --all-features --locked
windows-command: |
powershell.exe -NoProfile -Command '$ErrorActionPreference = "Stop"; Start-Service Spooler; Add-PrinterDriver -Name "Generic / Text Only"'
cargo fmt --check
cargo clippy --workspace --all-targets --locked -- -D warnings
cargo clippy --workspace --all-targets --all-features --locked -- -D warnings
cargo test --workspace --locked
cargo test --workspace --all-features --locked
msrv:
name: Rust 1.95 (Linux libraries)
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@1.95.0
- uses: Swatinem/rust-cache@v2
with:
key: workspace-msrv
- run: cargo check --workspace --lib --all-features --locked
name: Rust 1.95
uses: storytold/craft-common-actions/.github/workflows/gate.yml@main
with:
os: '["ubuntu-latest"]'
toolchain: 1.95.0
targets: ""
tools: ""
craft-fonts-ref: ""
require-craft-fonts: false
timeout-minutes: 15
dev-debug: ""
command: cargo check --workspace --lib --all-features --locked
wasm:
name: UI and settings WASM
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
targets: wasm32-unknown-unknown
- uses: Swatinem/rust-cache@v2
with:
key: workspace-wasm
- run: cargo check -p craft-ui -p craft-settings --all-features --locked --target wasm32-unknown-unknown
uses: storytold/craft-common-actions/.github/workflows/gate.yml@main
with:
os: '["ubuntu-latest"]'
targets: wasm32-unknown-unknown
tools: ""
craft-fonts-ref: ""
require-craft-fonts: false
timeout-minutes: 15
command: cargo check -p craft-ui -p craft-settings --all-features --locked --target wasm32-unknown-unknown
+4 -4
View File
@@ -111,9 +111,9 @@ impl CmykModel {
// Overprints with black: multiplicative in reflectance above a first-surface floor.
let floor = 0.006;
let mut prim = [[0.0; 3]; 16];
for m in 0..16 {
for (m, slot) in prim.iter_mut().enumerate() {
let p = base[m & 7];
prim[m] = if m & 8 == 0 {
*slot = if m & 8 == 0 {
p
} else {
std::array::from_fn(|i| {
@@ -133,7 +133,7 @@ impl CmykModel {
(v + 4.0 * self.tvi[i] * v * (1.0 - v)).clamp(0.0, 1.0)
});
let mut s = [0.0; 3];
for m in 0..16 {
for (m, prim) in self.prim_n.iter().enumerate() {
let mut w = 1.0;
for (i, ai) in a.iter().enumerate() {
w *= if m & (1 << i) != 0 { *ai } else { 1.0 - ai };
@@ -141,7 +141,7 @@ impl CmykModel {
if w == 0.0 {
continue;
}
for (acc, p) in s.iter_mut().zip(&self.prim_n[m]) {
for (acc, p) in s.iter_mut().zip(prim) {
*acc += w * p;
}
}
+3 -3
View File
@@ -768,7 +768,7 @@ fn ascii(tags: &[Tag], strings: Strings) -> Vec<u8> {
/// Write tags as binary DXF (DXF Reference, "Binary DXF Files", R13+ layout): the sentinel,
/// then per tag a 2-byte little-endian group code and the value in the binary form of the code's
/// [`Kind`]: a zero-terminated string, an 8-byte real, a 2-, 4- or 8-byte integer, a 1-byte
/// boolean, or a binary chunk (one length byte, then up to 255 bytes; longer data is split into
/// boolean, or a binary chunk (one length byte, then up to 127 bytes; longer data is split into
/// several groups of the same code). Strings are UTF-8 when `utf8` (R2007+), otherwise escaped as
/// in [`write_ascii`]. A tag's value is converted to its code's kind, so a number written as text
/// is stored as a number; a code outside the 16-bit range is skipped.
@@ -822,8 +822,8 @@ fn binary(tags: &[Tag], strings: Strings) -> Vec<u8> {
}
Kind::Hex => {
let bytes = hex_bytes(&t.value.as_str());
// An empty chunk is still one group, as in ASCII.
let mut chunks: Vec<&[u8]> = bytes.chunks(255).collect();
// At most 127 bytes per group, as in ASCII; an empty chunk is still one group.
let mut chunks: Vec<&[u8]> = bytes.chunks(127).collect();
if chunks.is_empty() {
chunks.push(&[]);
}
+2 -3
View File
@@ -44,9 +44,8 @@ fn binary_converts_values_to_their_codes_kind() {
let back = parse(&write_binary(&tags, true)).unwrap();
assert_eq!(back[0], Tag::i(70, 12));
assert_eq!(back[1], Tag::i(62, i64::from(i16::MAX)));
assert_eq!(back[2].code, 310);
assert_eq!(back[3].code, 310, "300 bytes are split into chunks of at most 255");
assert_eq!(back[2].str().len() + back[3].str().len(), 600);
let sizes: Vec<usize> = back.iter().filter(|t| t.code == 310).map(|t| t.str().len()).collect();
assert_eq!(sizes, vec![254, 254, 92], "300 bytes are split into chunks of at most 127 (254 hex digits)");
}
#[test]
-3
View File
@@ -2,7 +2,6 @@
//! 1004 specify at most 127 payload bytes per chunk, even though a length byte represents 255.
//! Inspect writer bytes without our parser; accept any compliant partition preserving payload,
//! code and following-record framing. Oversized binary read fixtures test tolerance only.
//! Pending writer regressions extend the chunk-size finding in issue #1025.
//! Public DXF Reference, Group Codes in Numerical Order and Binary DXF Files:
//! <https://help.autodesk.com/cloudhelp/2025/ENU/AutoCAD-DXF/files/GUID-3F0380A5-1C15-464D-BC66-2C5F094BCFB9.htm>
//! <https://help.autodesk.com/cloudhelp/2025/ENU/AutoCAD-DXF/files/GUID-FC1C3C69-DBC2-49E4-893A-000D6538C0FE.htm>
@@ -100,7 +99,6 @@ fn binary_reader_tolerates_the_full_length_byte_domain() {
}
#[test]
#[ignore = "Confirmed ASCII DXF writer nonconformance: hex payloads above 127 bytes are emitted as one oversized chunk"]
fn ascii_writer_splits_large_payloads_into_conforming_chunks() {
for code in (310..=319).chain([1004]) {
for length in [128, 254, 255, 256, 1024] {
@@ -112,7 +110,6 @@ fn ascii_writer_splits_large_payloads_into_conforming_chunks() {
}
#[test]
#[ignore = "Confirmed binary DXF writer nonconformance: 255-byte partitioning exceeds the documented 127-byte group limit"]
fn binary_writer_splits_large_payloads_into_conforming_chunks() {
for code in (310..=319).chain([1004]) {
for length in [128, 254, 255, 256, 1024] {
+1 -1
View File
@@ -120,7 +120,7 @@ fn hex_chunks_keep_bytes_and_order() {
// DXF groups 310–319 and 1004 permit 127 payload bytes per chunk. A binary length
// byte can represent more, but that is reader tolerance, not writer conformance.
// Larger payloads need chunk-size/reassembly checks rather than exact tag equality;
// see hex_chunks.rs for the independent wire checks and pending writer regressions.
// see hex_chunks.rs for the independent wire checks.
for length in [0, 1, 2, 126, 127] {
let hex: String = (0..length).fold(String::new(), |mut out, i| {
use std::fmt::Write as _;
+35 -8
View File
@@ -161,6 +161,16 @@ fn children<'a>(el: &'a El, container: &'static str, tag: &'static str) -> impl
}
fn node(el: &El, is_mask: bool, count: &mut usize) -> Result<Node> {
let mut out = node_fields(el, is_mask)?;
if !is_mask {
out.layers = layers(el, count)?;
out.masks = children(el, "masks", "mask").map(|m| node(m, true, count)).collect::<Result<_>>()?;
}
Ok(out)
}
/// A node's own attributes, without its children.
fn node_fields(el: &El, is_mask: bool) -> Result<Node> {
let owned = |name: &str| attr(el, name).map(str::to_string);
let node_type = attr(el, "nodetype").unwrap_or("").to_string();
// Only the kinds whose pixels are read need sound numbers; a node an application will leave
@@ -168,7 +178,7 @@ fn node(el: &El, is_mask: bool, count: &mut usize) -> Result<Node> {
let read = matches!(node_type.as_str(), "paintlayer" | "grouplayer" | "transparencymask");
let lenient = |v: Result<f64>, default: f64| if read { v } else { Ok(v.unwrap_or(default)) };
let (x, y) = if is_mask && !read { (offset(el, "x").unwrap_or(0), offset(el, "y").unwrap_or(0)) } else { (offset(el, "x")?, offset(el, "y")?) };
let mut out = Node {
let out = Node {
node_type,
name: owned("name"),
visible: attr(el, "visible") != Some("0"),
@@ -187,22 +197,39 @@ fn node(el: &El, is_mask: bool, count: &mut usize) -> Result<Node> {
layers: Vec::new(),
masks: Vec::new(),
};
if !is_mask {
out.layers = layers(el, count)?;
out.masks = children(el, "masks", "mask").map(|m| node(m, true, count)).collect::<Result<_>>()?;
}
Ok(out)
}
/// The `<layers>` of `el`. Recursion is bounded by [`MAX_XML_DEPTH`].
/// The `<layers>` of `el`, walked with an explicit stack: groups can nest up to [`MAX_XML_DEPTH`]
/// deep, more than a small thread stack can recurse.
fn layers(el: &El, count: &mut usize) -> Result<Vec<Node>> {
struct Frame<'a> {
node: Node,
rest: std::vec::IntoIter<&'a El>,
}
let mut root = children(el, "layers", "layer").collect::<Vec<_>>().into_iter();
let mut stack: Vec<Frame> = Vec::new();
let mut out = Vec::new();
for child in children(el, "layers", "layer") {
loop {
let next = match stack.last_mut() {
Some(frame) => frame.rest.next(),
None => root.next(),
};
let Some(child) = next else {
let Some(frame) = stack.pop() else { break };
match stack.last_mut() {
Some(parent) => parent.node.layers.push(frame.node),
None => out.push(frame.node),
}
continue;
};
*count += 1;
if *count > MAX_NODES {
return Err(invalid(format!("more than {MAX_NODES} layers")));
}
out.push(node(child, false, count)?);
let mut built = node_fields(child, false)?;
built.masks = children(child, "masks", "mask").map(|m| node(m, true, count)).collect::<Result<_>>()?;
stack.push(Frame { node: built, rest: children(child, "layers", "layer").collect::<Vec<_>>().into_iter() });
}
Ok(out)
}
+6 -6
View File
@@ -353,9 +353,9 @@ fn table_borders_and_borderless_round_trip() {
let mut doc = Document::new();
let mut t_borderless = Table::new(2, 2, 400.0);
t_borderless.props.style = None;
for r in 0..2 {
for c in 0..2 {
t_borderless.rows[r].cells[c].blocks = vec![para_block(Paragraph::with_text("cell", CharProps::default()))];
for row in &mut t_borderless.rows {
for cell in &mut row.cells {
cell.blocks = vec![para_block(Paragraph::with_text("cell", CharProps::default()))];
}
}
doc.body = vec![Arc::new(Block::Table(t_borderless))];
@@ -369,9 +369,9 @@ fn table_borders_and_borderless_round_trip() {
let mut doc_bordered = Document::new();
let mut t_bordered = Table::new(2, 2, 400.0);
t_bordered.props.style = Some("TableGrid".to_string());
for r in 0..2 {
for c in 0..2 {
t_bordered.rows[r].cells[c].blocks = vec![para_block(Paragraph::with_text("cell", CharProps::default()))];
for row in &mut t_bordered.rows {
for cell in &mut row.cells {
cell.blocks = vec![para_block(Paragraph::with_text("cell", CharProps::default()))];
}
}
doc_bordered.body = vec![Arc::new(Block::Table(t_bordered))];
+2 -1
View File
@@ -443,7 +443,8 @@ fn the_unhashed_area_never_decides_who_is_blamed() {
// An issuer only in the unhashed area finds a key, which counts because it fits.
let alice = secret(ALICE, Make::default());
let mut config = config(&alice.primary_key, pgp::packet::SignatureType::Binary, t, vec![]);
let alice_created = made(&alice);
let mut config = config(&alice.primary_key, pgp::packet::SignatureType::Binary, alice_created, vec![]);
config.hashed_subpackets.retain(|p| matches!(p.data, SubpacketData::SignatureCreationTime(_)));
config.unhashed_subpackets = vec![Subpacket::regular(SubpacketData::IssuerFingerprint(alice.primary_key.fingerprint())).unwrap()];
let sig = config.sign(&alice.primary_key, &Password::empty(), SIGNED_PART.as_bytes()).unwrap();
+48 -13
View File
@@ -189,28 +189,63 @@ fn props(el: &El) -> Result<Props> {
})
}
/// The elements of `stack`. Recursion is bounded by [`MAX_XML_DEPTH`].
/// The elements of `stack`, walked with an explicit stack: a stack can nest up to
/// [`MAX_XML_DEPTH`] deep, more than a small thread stack can recurse.
fn stack(el: &El, count: &mut usize) -> Result<Vec<Node>> {
struct Frame<'a> {
props: Props,
isolation: Option<String>,
children: Vec<Node>,
rest: std::vec::IntoIter<&'a El>,
}
let mut root = el.elements().collect::<Vec<_>>().into_iter();
let mut frames: Vec<Frame> = Vec::new();
let mut out = Vec::new();
for child in el.elements() {
loop {
let next = match frames.last_mut() {
Some(frame) => frame.rest.next(),
None => root.next(),
};
let Some(child) = next else {
let Some(frame) = frames.pop() else { break };
let node = Node::Stack(Stack { props: frame.props, isolation: frame.isolation, children: frame.children });
match frames.last_mut() {
Some(parent) => parent.children.push(node),
None => out.push(node),
}
continue;
};
*count += 1;
if *count > MAX_NODES {
return Err(invalid(format!("more than {MAX_NODES} layers")));
}
out.push(match child.name.as_str() {
"layer" => Node::Layer(Layer {
props: props(child)?,
x: int(child, "x")?,
y: int(child, "y")?,
src: child.attr("src").map(|s| s.trim().to_string()),
}),
"stack" => Node::Stack(Stack {
match child.name.as_str() {
"layer" => {
let node = Node::Layer(Layer {
props: props(child)?,
x: int(child, "x")?,
y: int(child, "y")?,
src: child.attr("src").map(|s| s.trim().to_string()),
});
match frames.last_mut() {
Some(parent) => parent.children.push(node),
None => out.push(node),
}
}
"stack" => frames.push(Frame {
props: props(child)?,
isolation: child.attr("isolation").map(|s| s.trim().to_string()),
children: stack(child, count)?,
children: Vec::new(),
rest: child.elements().collect::<Vec<_>>().into_iter(),
}),
other => Node::Other { tag: other.to_string(), name: child.attr("name").map(str::to_string) },
});
other => {
let node = Node::Other { tag: other.to_string(), name: child.attr("name").map(str::to_string) };
match frames.last_mut() {
Some(parent) => parent.children.push(node),
None => out.push(node),
}
}
}
}
Ok(out)
}
+2 -2
View File
@@ -135,7 +135,7 @@ fn silhouette_registration_marks() {
let p = silhouette::encode(&pro, &j).unwrap();
let (head, rest) = p.split_at_registration();
let text = |c: &[Command]| c.iter().map(Command::to_ascii).collect::<Vec<_>>().join(" ");
assert!(text(head).ends_with(" FC18,1,1 TB50,0 TB99 TB52,2 TB51,400 TB53,10 TB55,1 TB123,4600,3600,200,100"));
assert!(text(head).ends_with(" FC18,1,1 TB50,0 TB99 TB52,2 TB51,400 TB53,10 TB54,0,0 TB55,1 TB123,4600,3600,200,100"));
// The design is shifted so the first mark is the origin.
assert_eq!(text(rest), "M100,100 D100,300 M100,0 SO0");
assert_eq!(p.registration_wait, Some(head.len()));
@@ -148,7 +148,7 @@ fn silhouette_registration_marks() {
reg.origin_right_mm = 0.0;
assert!(ascii(&reg).ends_with(" TB124,4600,3600,0,0"));
reg.search = false;
assert_eq!(ascii(&reg), "TB50,0 TB99 TB52,2 TB51,400 TB53,10 TB55,1 TB23,4600,3600");
assert_eq!(ascii(&reg), "TB50,0 TB99 TB52,2 TB51,400 TB53,10 TB54,0,0 TB55,1 TB23,4600,3600");
}
#[test]
+11 -5
View File
@@ -754,11 +754,12 @@ mod tests {
/// spec's default `~/.local/share` applies, and with no home there is no folder.
#[test]
fn xdg_data_home_follows_the_spec() {
let home = Path::new("/home/a");
assert_eq!(xdg_data_home(Some("/data".into()), Some(home)), Some(PathBuf::from("/data")));
assert_eq!(xdg_data_home(Some("/data".into()), None), Some(PathBuf::from("/data")));
let home = std::env::temp_dir().join("xdg-home");
let data = std::env::temp_dir().join("xdg-data");
assert_eq!(xdg_data_home(Some(data.as_os_str().to_owned()), Some(&home)), Some(data.clone()));
assert_eq!(xdg_data_home(Some(data.as_os_str().to_owned()), None), Some(data));
for xdg in [None, Some(""), Some("relative/data")] {
assert_eq!(xdg_data_home(xdg.map(Into::into), Some(home)), Some(home.join(".local/share")), "{xdg:?}");
assert_eq!(xdg_data_home(xdg.map(Into::into), Some(&home)), Some(home.join(".local/share")), "{xdg:?}");
assert_eq!(xdg_data_home(xdg.map(Into::into), None), None, "{xdg:?}");
}
}
@@ -1010,7 +1011,12 @@ mod tests {
assert!(load(&aff, &big).unwrap_err().contains("too large"));
// A directory, and on Unix an endless device, are not dictionary files. (No clock: a
// reader that read `/dev/zero` would never return, so the error itself is the proof.)
assert!(load(&aff, &dir).unwrap_err().contains("not a regular file"));
let error = load(&aff, &dir).unwrap_err();
// Windows may reject opening a directory before the reader can inspect its type.
#[cfg(unix)]
assert!(error.contains("not a regular file"), "{error}");
#[cfg(not(unix))]
assert!(!error.is_empty());
#[cfg(unix)]
assert!(load(&aff, Path::new("/dev/zero")).unwrap_err().contains("not a regular file"));
// Turkish reads through the same reader.
+1 -5
View File
@@ -100,11 +100,7 @@ fn check(d: &TrDict, word: &str, opts: &crate::Options) -> bool {
}
// Compound words separated by hyphens (e.g., `afyon-karahisar`)
if w.contains('-') && w.split('-').all(|part| part.is_empty() || check(d, part, opts)) {
return true;
}
false
w.contains('-') && w.split('-').all(|part| part.is_empty() || check(d, part, opts))
}
#[cfg(test)]
+1 -4
View File
@@ -522,10 +522,7 @@ fn sao_edge_ctb<S: Sample>(
return false;
}
}
if !pic.pps.loop_filter_across_tiles && pic.layout.tile_id[pic.layout.rs_to_ts[nrs] as usize] != pic.layout.tile_id[cur_ts as usize] {
return false;
}
true
pic.pps.loop_filter_across_tiles || pic.layout.tile_id[pic.layout.rs_to_ts[nrs] as usize] == pic.layout.tile_id[cur_ts as usize]
};
// avail[dy][dx]: the CTB at (rx + dx - 1, ry + dy - 1) may be used.
let (rx, ry) = (rs % pic.wctb, rs / pic.wctb);