Merge main into fix/retype-drawn-shape-font-state

This commit is contained in:
dotCooCoo
2026-11-20 05:51:10 -08:00
14 changed files with 633 additions and 416 deletions
+3
View File
@@ -21,3 +21,6 @@ proptest = { workspace = true }
# The tests build containers and decode previews.
crc32fast = { workspace = true }
craft-image-codecs = { workspace = true }
# tests/it's `import_limits`, `outline_limits` and `text` modules need `synth`, also when this crate
# is tested without vectorcraft-engine (`cargo xtask ci shard`).
vectorcraft-affinity = { path = ".", features = ["synth"] }
+1 -1
View File
@@ -531,7 +531,7 @@ impl Line {
continue;
}
if t < 0.0 && !paints_as_one(&self) {
return self;
continue;
}
let mut tracked = self.clone();
tracked.tracking = t;
+25
View File
@@ -1244,6 +1244,31 @@ fn tracking_near_a_whole_number_is_kept_as_measured_when_rounding_moves_glyphs()
assert_same_places(&before, &text_of(&s, r["ids"][0].as_u64().unwrap()));
}
#[test]
fn a_tracking_translucent_glyphs_cannot_take_keeps_the_tracking_that_fits() {
// The first three glyphs are tracked 50 and the last 150 further on. A tracking tighter than
// zero is not tried for glyphs that cannot be one object, and the tracked prefix is kept.
let mut s = session();
let id = s.execute("text.create", &json!({"x": 40, "y": 100, "text": "MMMM", "size": 30})).unwrap()["id"].as_u64().unwrap();
s.execute("text.setRangeStyle", &json!({"id": id, "start": 0, "end": 2, "tracking": 50})).unwrap();
s.execute("text.setRangeStyle", &json!({"id": id, "start": 2, "end": 3, "tracking": 150})).unwrap();
s.execute("select.set", &json!({"ids": [id]})).unwrap();
let g = s.execute("type.createOutlines", &json!({})).unwrap()["ids"][0].as_u64().unwrap();
let kids = children_of(&s, g);
s.edit("test", |d, _| {
for k in &kids {
d.node_mut(NodeId(*k)).unwrap().opacity = 0.5;
}
Ok(())
})
.unwrap();
s.execute("select.set", &json!({"ids": [g]})).unwrap();
let r = s.execute("type.retype", &json!({})).unwrap();
let texts: Vec<&str> = r["texts"].as_array().unwrap().iter().map(|t| t.as_str().unwrap()).collect();
assert_eq!(texts.concat(), "MMMM", "{r}");
assert!(texts.iter().any(|t| t.len() > 1), "the tracked glyphs stay one object: {r}");
}
#[test]
fn overlapping_translucent_glyphs_are_not_tracked_into_one_object() {
let mut s = session();
+8 -20
View File
@@ -3,8 +3,6 @@
//! Format Specification, version 7.0, §5.3, §5.4 and §6), and the colors they write in place of
//! the paint they can't hold.
use std::fmt::Write;
use vectorcraft_color::{Color, Gradient};
use vectorcraft_doc::{LAYER_COLORS, LayerColor, LineCap, LineJoin, StrokeLayer};
use vectorcraft_geom::{Affine, Anchor, AnchorKind, PathData, Point, Shape, SubPath};
@@ -184,25 +182,15 @@ pub(crate) fn window_samples(samples: &[u8], w: u32, channels: usize, [x0, y0, x
/// The stroke's width, cap, join, miter limit and dashes: `w J j M d`.
pub(crate) fn line_style(s: &mut String, st: &StrokeLayer) {
let cap = match st.cap {
LineCap::Butt => 0,
LineCap::Round => 1,
LineCap::Square => 2,
LineCap::Butt => ps::LineCap::Butt,
LineCap::Round => ps::LineCap::Round,
LineCap::Square => ps::LineCap::Square,
};
let join = match st.join {
LineJoin::Miter => 0,
LineJoin::Round => 1,
LineJoin::Bevel => 2,
LineJoin::Miter => ps::LineJoin::Miter,
LineJoin::Round => ps::LineJoin::Round,
LineJoin::Bevel => ps::LineJoin::Bevel,
};
ps::push_num(s, st.width);
let _ = write!(s, " w {cap} J {join} j ");
ps::push_num(s, if st.miter_limit.is_finite() { st.miter_limit.max(1.0) } else { 10.0 });
s.push_str(" M [");
let dash = st.dash.as_ref().filter(|d| d.is_dashed());
if let Some(d) = dash {
ps::push_nums(s, &d.pattern);
s.pop();
}
s.push_str("] ");
ps::push_num(s, dash.map_or(0.0, |d| d.offset));
s.push_str(" d\n");
let dash = st.dash.as_ref().filter(|d| d.is_dashed()).map(|d| (d.pattern.as_slice(), d.offset));
ps::push_line_style(s, st.width, cap, join, st.miter_limit, dash);
}
+60 -298
View File
@@ -1,253 +1,17 @@
//! The scanner: PostScript source into objects (numbers, names, strings, procedures), with the
//! position the program's own data (`currentfile`) is read from.
//!
//! Backed by `craft_ps::read::lex`.
use std::rc::Rc;
use craft_ps::read::lex::{LexError, Number, Token};
use super::obj::{Obj, PsError, Res};
use crate::ps;
/// Deepest procedure nesting the scanner reads.
const MAX_NESTING: usize = 256;
pub(crate) use craft_ps::read::lex::{IMMEDIATE, hex_decode};
pub(crate) struct Lexer<'a> {
src: &'a [u8],
pos: usize,
/// The whitespace character that ended the last token is still unread (data the program
/// reads from itself starts after it).
fresh: bool,
/// The last object read has immediately evaluated names (`//name`) in it, read as executable
/// names starting with [`IMMEDIATE`] for the interpreter to replace by their values.
pub immediate: bool,
}
/// How an immediately evaluated name (`//name`) is read, until the interpreter replaces it.
pub(crate) const IMMEDIATE: &str = "//";
fn is_space(b: u8) -> bool {
matches!(b, b' ' | b'\t' | b'\r' | b'\n' | b'\x0c' | b'\0')
}
fn is_delim(b: u8) -> bool {
matches!(b, b'(' | b')' | b'<' | b'>' | b'[' | b']' | b'{' | b'}' | b'/' | b'%')
}
fn syntax<T>(what: &str) -> Res<T> {
Err(PsError::Ps("syntaxerror", what.to_string()))
}
impl<'a> Lexer<'a> {
pub fn new(src: &'a [u8]) -> Self {
Self { src, pos: 0, fresh: false, immediate: false }
}
/// What is left to read.
pub fn rest(&self) -> &'a [u8] {
self.src.get(self.pos..).unwrap_or_default()
}
/// What is left to read as data: after the whitespace that ended the last token (a CR LF
/// pair counts as one).
pub fn data(&mut self) -> &'a [u8] {
if std::mem::take(&mut self.fresh) {
match self.peek() {
Some(b'\r') => {
self.pos += 1;
if self.peek() == Some(b'\n') {
self.pos += 1;
}
}
Some(b) if is_space(b) => self.pos += 1,
_ => {}
}
}
self.rest()
}
/// Skip `n` bytes (the data a filter or `readstring` took).
pub fn advance(&mut self, n: usize) {
self.fresh = false;
self.pos = self.pos.saturating_add(n).min(self.src.len());
}
fn peek(&self) -> Option<u8> {
self.src.get(self.pos).copied()
}
fn skip_space(&mut self) {
while let Some(b) = self.peek() {
if is_space(b) {
self.pos += 1;
} else if b == b'%' {
while let Some(c) = self.peek() {
if c == b'\n' || c == b'\r' {
break;
}
self.pos += 1;
}
} else {
break;
}
}
}
/// The next object at the top level (`None` at the end of the file).
pub fn next(&mut self) -> Res<Option<Obj>> {
self.immediate = false;
let t = self.token(0);
self.fresh = true;
t
}
fn token(&mut self, depth: usize) -> Res<Option<Obj>> {
self.skip_space();
let Some(b) = self.peek() else { return Ok(None) };
self.pos += 1;
Ok(Some(match b {
b'(' => Obj::string(self.string()?),
b'<' => match self.peek() {
Some(b'<') => {
self.pos += 1;
Obj::Exec(Rc::from("<<"))
}
Some(b'~') => {
self.pos += 1;
Obj::string(self.ascii85()?)
}
_ => Obj::string(self.hex()?),
},
b'>' => {
if self.peek() != Some(b'>') {
return syntax(">");
}
self.pos += 1;
Obj::Exec(Rc::from(">>"))
}
b'[' => Obj::Exec(Rc::from("[")),
b']' => Obj::Exec(Rc::from("]")),
b'{' => {
if depth >= MAX_NESTING {
return Err(PsError::Limit("procedures nested too deeply"));
}
let mut items = vec![];
loop {
self.skip_space();
match self.peek() {
None => return syntax("{"),
Some(b'}') => {
self.pos += 1;
break;
}
_ => match self.token(depth + 1)? {
Some(o) => items.push(o),
None => return syntax("{"),
},
}
}
Obj::proc(items)
}
b'}' | b')' => return syntax(&char::from(b).to_string()),
b'/' => {
// `//name` stands for the name's value when it is read.
let immediate = self.peek() == Some(b'/');
if immediate {
self.pos += 1;
self.immediate = true;
}
let name = self.word();
if immediate { Obj::Exec(Rc::from(format!("{IMMEDIATE}{name}").as_str())) } else { Obj::Name(Rc::from(name.as_str())) }
}
_ => {
self.pos -= 1;
let w = self.word();
number(&w).unwrap_or_else(|| Obj::Exec(Rc::from(w.as_str())))
}
}))
}
/// A regular token's characters.
fn word(&mut self) -> String {
let start = self.pos;
while let Some(b) = self.peek() {
if is_space(b) || is_delim(b) {
break;
}
self.pos += 1;
}
String::from_utf8_lossy(self.src.get(start..self.pos).unwrap_or_default()).into_owned()
}
/// A literal string after its `(`.
fn string(&mut self) -> Res<Vec<u8>> {
let mut out = vec![];
let mut depth = 0usize;
loop {
let Some(b) = self.peek() else { return syntax("(") };
self.pos += 1;
match b {
b'(' => {
depth += 1;
out.push(b);
}
b')' if depth == 0 => return Ok(out),
b')' => {
depth -= 1;
out.push(b);
}
b'\\' => {
let Some(e) = self.peek() else { return syntax("(") };
self.pos += 1;
match e {
b'n' => out.push(b'\n'),
b'r' => out.push(b'\r'),
b't' => out.push(b'\t'),
b'b' => out.push(8),
b'f' => out.push(12),
b'\r' => {
if self.peek() == Some(b'\n') {
self.pos += 1;
}
}
b'\n' => {}
b'0'..=b'7' => {
let mut v = u32::from(e - b'0');
for _ in 0..2 {
match self.peek() {
Some(d @ b'0'..=b'7') => {
v = v * 8 + u32::from(d - b'0');
self.pos += 1;
}
_ => break,
}
}
out.push((v & 0xff) as u8);
}
other => out.push(other),
}
}
_ => out.push(b),
}
}
}
/// A hexadecimal string after its `<`.
fn hex(&mut self) -> Res<Vec<u8>> {
let end = self.rest().iter().position(|b| *b == b'>').ok_or(PsError::Ps("syntaxerror", "<".into()))?;
let body = self.rest().get(..end).unwrap_or_default();
let out = hex_decode(body).ok_or(PsError::Ps("syntaxerror", "<".into()))?;
self.advance(end + 1);
Ok(out)
}
/// An ASCII85 string after its `<~`.
fn ascii85(&mut self) -> Res<Vec<u8>> {
let end = find(self.rest(), b"~>").ok_or(PsError::Ps("syntaxerror", "<~".into()))?;
let text = String::from_utf8_lossy(self.rest().get(..end + 2).unwrap_or_default()).into_owned();
self.advance(end + 2);
ps::ascii85_decode(&text).ok_or(PsError::Ps("syntaxerror", "<~".into()))
}
}
/// Where `needle` first starts in `hay`.
/// Where `needle` first starts in `hay` (uses `memmem` so large inputs stay linear-time).
pub(crate) fn find(hay: &[u8], needle: &[u8]) -> Option<usize> {
if needle.is_empty() {
return Some(0);
@@ -255,39 +19,66 @@ pub(crate) fn find(hay: &[u8], needle: &[u8]) -> Option<usize> {
memchr::memmem::find(hay, needle)
}
/// Hexadecimal digits (whitespace ignored, an odd last digit padded with 0); `None` on others.
pub(crate) fn hex_decode(body: &[u8]) -> Option<Vec<u8>> {
// Callers pass an already-delimited body. Do not let the filter decoder's EOD
// handling silently accept a stray terminator or discard bytes after it.
if body.contains(&b'>') {
return None;
pub(crate) struct Lexer<'a> {
inner: craft_ps::read::lex::Lexer<'a>,
/// The last object read has immediately evaluated names (`//name`) in it, read as executable
/// names starting with [`IMMEDIATE`] for the interpreter to replace by their values.
pub immediate: bool,
}
impl<'a> Lexer<'a> {
pub fn new(src: &'a [u8]) -> Self {
Self { inner: craft_ps::read::lex::Lexer::new(src), immediate: false }
}
/// What is left to read.
pub fn rest(&self) -> &'a [u8] {
self.inner.rest()
}
/// What is left to read as data: after the whitespace that ended the last token (a CR LF
/// pair counts as one).
pub fn data(&mut self) -> &'a [u8] {
self.inner.data()
}
/// Skip `n` bytes (the data a filter or `readstring` took).
pub fn advance(&mut self, n: usize) {
self.inner.advance(n);
}
/// The next object at the top level (`None` at the end of the file).
pub fn next(&mut self) -> Res<Option<Obj>> {
let res = self.inner.next().map(|opt| opt.map(into_obj)).map_err(into_err);
self.immediate = self.inner.immediate;
res
}
}
fn into_err(err: LexError) -> PsError {
match err {
LexError::Syntax(what) => PsError::Ps("syntaxerror", what),
LexError::Limit(msg) => PsError::Limit(msg),
}
}
fn into_obj(tok: Token) -> Obj {
match tok {
Token::Int(i) => Obj::Int(i),
Token::Real(r) => Obj::Real(r),
Token::Name(n) => Obj::Name(Rc::from(n.as_str())),
Token::Exec(n) => Obj::Exec(Rc::from(n.as_str())),
Token::Str(s) => Obj::string(s),
Token::Proc(items) => Obj::proc(items.into_iter().map(into_obj).collect()),
}
craft_stream_codecs::asciihex::decode(body, body.len().div_ceil(2)).ok()
}
/// A number token (`12`, `-3.5`, `.5`, `1e-3`, `16#ff`), or `None`.
pub(crate) fn number(w: &str) -> Option<Obj> {
let first = w.bytes().next()?;
if !(first.is_ascii_digit() || matches!(first, b'+' | b'-' | b'.')) {
return None;
match craft_ps::read::lex::number(w)? {
Number::Int(i) => Some(Obj::Int(i)),
Number::Real(r) => Some(Obj::Real(r)),
}
if let Ok(i) = w.parse::<i64>() {
return Some(Obj::Int(i));
}
if let Some((base, digits)) = w.split_once('#') {
let base: u32 = base.parse().ok().filter(|b| (2..=36).contains(b))?;
// `from_str_radix` accepts a leading sign; a PostScript radix number has digits only.
if digits.starts_with(['+', '-']) {
return None;
}
return i64::from_str_radix(digits, base).ok().map(Obj::Int);
}
// Rust reads `inf` and `nan`; PostScript doesn't.
if w.bytes().any(|b| b.is_ascii_alphabetic() && !matches!(b, b'e' | b'E')) {
return None;
}
let v: f64 = w.parse().ok()?;
v.is_finite().then_some(Obj::Real(v))
}
#[cfg(test)]
@@ -300,33 +91,4 @@ mod tests {
assert!(number("16#-ff").is_none());
assert!(matches!(number("16#ff"), Some(Obj::Int(255))));
}
#[test]
fn shared_hex_decode_keeps_body_boundaries_and_odd_nibbles() {
assert_eq!(hex_decode(b" 4\t1\n4\r2\x0c4\0"), Some(vec![0x41, 0x42, 0x40]));
assert_eq!(hex_decode(b""), Some(vec![]));
for invalid in [b"41>42".as_slice(), b">", b"4g", b"4\x0b1", b"\xff"] {
assert_eq!(hex_decode(invalid), None);
}
// Every byte pairs with each possible nibble, including all whitespace
// and invalid-byte combinations; this is the former body-only contract.
for first in 0..=255u8 {
for second in 0..=255u8 {
let input = [first, second];
let mut digits = Vec::new();
let mut valid = true;
for b in input {
if is_space(b) {
continue;
}
match char::from(b).to_digit(16) {
Some(d) => digits.push(d as u8),
None => valid = false,
}
}
let expected =
if !valid { None } else { Some(digits.chunks(2).map(|pair| (pair[0] << 4) | pair.get(1).copied().unwrap_or(0)).collect()) };
assert_eq!(hex_decode(&input), expected, "{input:?}");
}
}
}
}
+30 -1
View File
@@ -3,7 +3,10 @@
use vectorcraft_geom::{BezPath, FillRule};
pub(crate) use craft_ps::write::{bytes, deflate, inflate, matrix, num, push_num, push_num_places, push_nums, string, written};
pub(crate) use craft_ps::write::{
LineCap, LineJoin, ShadingKind, bytes, deflate, inflate, matrix, num, push_image_array_ref, push_inline_image, push_line_style, push_num,
push_num_places, push_nums, push_reusable_image_ref, push_reusable_image_resource, push_shading, string, written,
};
/// The procedures the page uses, in `VCdict`.
pub(crate) const PROLOG: &str = "/VCdict 64 dict def
@@ -121,4 +124,30 @@ mod tests {
assert_eq!(places(2.5, 7), "2.5");
assert_eq!(places(f64::NAN, 7), "0");
}
#[test]
fn shared_scene_syntax_preserves_vc_names_and_shading() {
let mut line = String::new();
super::push_line_style(&mut line, 3.0, super::LineCap::Square, super::LineJoin::Round, 4.0, Some((&[5.0, 1.5], 0.5)));
assert_eq!(line, "3 w 2 J 1 j 4 M [5 1.5] 0.5 d\n");
let mut shading = String::new();
super::push_shading(
&mut shading,
super::ShadingKind::Axial,
"/DeviceCMYK",
&[0.0, 0.0, 100.0, 0.0],
4,
&[(0.0, vec![0.0, 1.0, 1.0, 0.0]), (1.0, vec![1.0, 0.0, 1.0, 0.0])],
);
assert!(shading.contains("/ShadingType 2 /ColorSpace /DeviceCMYK"));
assert!(shading.ends_with(">> shfill\n"));
let mut inline = String::new();
super::push_inline_image(&mut inline, "VCsrc", "", "<< /ImageType 1", "/FlateDecode", "image", "~>\n");
assert_eq!(
inline,
"{ /VCsrc currentfile /ASCII85Decode filter def\n<< /ImageType 1\n/DataSource VCsrc /FlateDecode filter >> image\nVCsrc flushfile } exec\n~>\n"
);
}
}
+12 -63
View File
@@ -50,8 +50,6 @@ const SPREAD_CAPPED: &str =
"gradients that repeat or reflect are written with at most 256 runs of their stops (at most 16384 stops); they pad past those";
/// Wedges a conic gradient is written as: one a degree.
const CONIC_WEDGE_COUNT: usize = 360;
/// Decimals of a smooth shading's stitching function bounds (stop offsets, 0 to 1).
const BOUNDS_PLACES: u32 = 7;
/// The most colorants a DeviceN color space may have (PostScript's limit).
const MAX_DEVICE_N: usize = 32;
const MISSING_PATTERN: &str = "missing patterns are written as mid-grey";
@@ -63,8 +61,6 @@ const MAX_BODY: usize = 256 << 20;
/// Most compressed bytes in one string of an image's samples at Level 2 (under PostScript's
/// 65,535-byte string limit).
const IMAGE_CHUNK: usize = 48 << 10;
/// The start of the procedure that reads an image's data from the lines after it.
const INLINE_SOURCE: &str = "{ /VCsrc currentfile /ASCII85Decode filter def\n";
/// An image as written: what sets up its color, its image dictionary and its compressed samples.
/// Placed once, it is written where it is drawn, its data following the operators that read it.
@@ -108,33 +104,20 @@ impl ImageCode {
/// The operators and data that draw the image where it is placed.
fn push_inline(&self, s: &mut String) {
s.push_str(&self.prelude);
s.push_str(INLINE_SOURCE);
s.push_str(&self.dict);
s.push_str(&self.inline_read());
s.push_str(&self.ascii);
}
/// The end of the procedure [`ImageCode::push_inline`] writes. The procedure is read whole
/// before it runs: the image data follows it, and flushing the ASCII85 filter afterwards reads
/// past its end marker.
fn inline_read(&self) -> String {
format!("\n/DataSource VCsrc {} filter >> {}\nVCsrc flushfile }} exec\n", self.filter, self.op)
ps::push_inline_image(s, "VCsrc", &self.prelude, &self.dict, self.filter, self.op, &self.ascii);
}
/// The operators that draw the image `VCim<i>` holds, for an image placed more than once.
fn reference(&self, i: usize, level: Level) -> String {
let mut s = String::new();
let name = format!("VCim{i}");
match level {
// The stream is read again from its start.
Level::Three => {
format!("{}VCim{i} resetfile\n{}\n/DataSource VCim{i} {} filter >> {}\n", self.prelude, self.dict, self.filter, self.op)
}
Level::Three => ps::push_reusable_image_ref(&mut s, &name, &self.prelude, &self.dict, self.filter, self.op),
// A procedure gives the strings in turn, then an empty string: the end of the data.
Level::Two => format!(
"{}/VCi 0 def\n{}\n/DataSource {{VCi VCim{i} length lt {{VCim{i} VCi get /VCi VCi 1 add def}} {{()}} ifelse}} {} filter >> {}\n",
self.prelude, self.dict, self.filter, self.op
),
Level::Two => ps::push_image_array_ref(&mut s, "VCi", &name, &self.prelude, &self.dict, self.filter, self.op),
}
s
}
/// The setup's definition of `VCim<i>`: the image's compressed samples, once.
@@ -145,11 +128,7 @@ impl ImageCode {
// The stream reads all of its data when it is made, so the data follows the
// procedure that makes it.
let intent = if self.op == "imagemask" { 1 } else { 0 };
let _ = writeln!(
s,
"{{ /VCsrc currentfile /ASCII85Decode filter def\n/VCim{i} VCsrc << /Intent {intent} /AsyncRead false /CloseSource false >> /ReusableStreamDecode filter def\nVCsrc flushfile }} exec"
);
s.push_str(&self.ascii);
ps::push_reusable_image_resource(&mut s, "VCsrc", &format!("VCim{i}"), intent, &self.ascii);
}
Level::Two => {
let _ = writeln!(s, "/VCim{i} [");
@@ -1489,44 +1468,12 @@ impl<'a> Scene<'a> {
/// A Level 3 smooth shading of `kind` (2 axial, 3 radial) at `coords`, extended both ways.
fn shading(&mut self, kind: u8, space: &GradientSpace, coords: &[f64], stops: &[(f64, Vec<f32>)]) {
let n = space.n();
let comps = |c: &[f32]| -> String {
let mut s = String::from("[");
push_nums(&mut s, &c.iter().take(n).map(|v| f64::from(*v)).collect::<Vec<_>>());
s.pop();
s.push(']');
s
};
let segments: Vec<_> = stops.windows(2).filter(|w| w[1].0 > w[0].0).collect();
let interp = |w: &&[(f64, Vec<f32>)]| format!("<< /FunctionType 2 /Domain [0 1] /C0 {} /C1 {} /N 1 >>", comps(&w[0].1), comps(&w[1].1));
let function = match segments.as_slice() {
[one] => interp(one),
many => {
let mut f = String::from("<< /FunctionType 3 /Domain [0 1] /Functions [\n");
for w in many {
f.push_str(&interp(w));
f.push('\n');
}
f.push_str("] /Bounds [");
// Seven decimals: a gradient's stops repeated hundreds or thousands of times
// (`Gradient::padded_over`) keep their places in each run.
for w in many.iter().skip(1) {
ps::push_num_places(&mut f, w[0].0, BOUNDS_PLACES);
f.push(' ');
}
f.push_str("] /Encode [");
f.push_str(&"0 1 ".repeat(many.len()));
f.push_str("] >>");
f
}
};
let kind = if kind == 3 { ps::ShadingKind::Radial } else { ps::ShadingKind::Axial };
let name = match space {
GradientSpace::Process(s) => s.name(),
GradientSpace::Inks(name, _) => name,
};
let _ = write!(self.body, "<< /ShadingType {kind} /ColorSpace {name} /Coords [");
push_nums(&mut self.body, coords);
let _ = writeln!(self.body, "] /Extend [true true]\n/Function {function} >> shfill");
ps::push_shading(&mut self.body, kind, name, coords, space.n(), stops);
}
/// The bands of each stretch between stops: how many, for colours `a` to `b` over `length`
@@ -2090,7 +2037,9 @@ impl<'a> Scene<'a> {
/// `data`, not yet placed.
fn image_code(prelude: String, dict: String, filter: &'static str, op: &'static str, data: Vec<u8>) -> ImageCode {
let mut code = ImageCode { prelude, dict, filter, op, ascii: ps::ascii85(&data), data, uses: 0, inline_len: 0, ref_len: 0 };
code.inline_len = code.prelude.len() + INLINE_SOURCE.len() + code.dict.len() + code.inline_read().len() + code.ascii.len();
let mut inline = String::new();
ps::push_inline_image(&mut inline, "VCsrc", &code.prelude, &code.dict, code.filter, code.op, "");
code.inline_len = inline.len() + code.ascii.len();
code
}
+3
View File
@@ -56,6 +56,9 @@ serde_json = { workspace = true }
krilla = { workspace = true, features = ["simple-text"] }
# How many times the symbol list is read to find symbols by name.
vectorcraft-doc = { workspace = true, features = ["symbol-read-count"] }
# The counters vectorcraft-engine's tests turn on, also when this crate is tested without
# vectorcraft-engine (`cargo xtask ci shard`).
vectorcraft-pdf = { path = ".", features = ["read-count"] }
# An independent raster oracle for gradient placement in PDF forms. These are test-only macOS
# bindings; the exporter stays portable Rust and does not depend on an OS PDF renderer.
+9
View File
@@ -764,6 +764,15 @@ fn menu_access_stationary_pointer_repeat_and_rerun_do_not_retarget_or_double_inv
assert_eq!(s.app.ui.view.rulers, !before, "one Text/Key pair invokes exactly once across passes");
s.end_access();
// Wait for any background font scan and ensure > 20 families even on minimal runners.
let db = vectorcraft_text::FontDb::global();
let _ = db.families();
for i in 0..24 {
if db.menu_family_list_now().len() > 20 {
break;
}
db.add_font(vectorcraft_testkit::fonts::renamed(&format!("Menu Test Font {i:02}")));
}
let text = s.app.run("text.create", json!({"x": 250, "y": 200, "text": "Menu", "font": "Inter", "size": 12})).unwrap()["id"].clone();
s.app.run("select.set", json!({"ids": [text]})).unwrap();
let size = vec2(640.0, 420.0);