From e16d3f5a67a31154797b4d56cdc6ed142ee2a7cf Mon Sep 17 00:00:00 2001 From: Laurenz Date: Wed, 28 Feb 2024 11:06:54 +0100 Subject: Externalize assets (#3515) --- tests/Cargo.toml | 2 ++ tests/fuzz/Cargo.toml | 1 + tests/fuzz/src/compile.rs | 5 ++-- tests/src/benches.rs | 5 ++-- tests/src/tests.rs | 39 +++++++++++++------------- tests/typ/bugs/1597-cite-footnote.typ | 2 +- tests/typ/bugs/870-image-rotation.typ | 4 +-- tests/typ/bugs/bibliography-math.typ | 2 +- tests/typ/bugs/cite-locate.typ | 2 +- tests/typ/bugs/cite-show-set.typ | 2 +- tests/typ/bugs/hide-meta.typ | 2 +- tests/typ/bugs/new-cm-svg.typ | 2 +- tests/typ/bugs/pagebreak-bibliography.typ | 2 +- tests/typ/coma.typ | 2 +- tests/typ/compiler/bytes.typ | 2 +- tests/typ/compiler/import.typ | 4 +-- tests/typ/compiler/plugin-oob.typ | 4 +-- tests/typ/compiler/plugin.typ | 10 +++---- tests/typ/compiler/set.typ | 2 +- tests/typ/compiler/show-text.typ | 2 +- tests/typ/compute/data.typ | 46 +++++++++++++++---------------- tests/typ/compute/eval-path.typ | 4 +-- tests/typ/layout/clip.typ | 4 +-- tests/typ/layout/grid-3.typ | 2 +- tests/typ/layout/hide.typ | 14 +++++----- tests/typ/layout/pad.typ | 2 +- tests/typ/layout/par-bidi.typ | 2 +- tests/typ/layout/par-indent.typ | 4 +-- tests/typ/layout/place-background.typ | 2 +- tests/typ/layout/place-float-columns.typ | 2 +- tests/typ/layout/place-float-figure.typ | 4 +-- tests/typ/layout/place.typ | 2 +- tests/typ/layout/transform.typ | 4 +-- tests/typ/math/content.typ | 2 +- tests/typ/meta/bibliography-full.typ | 2 +- tests/typ/meta/bibliography-ordering.typ | 2 +- tests/typ/meta/bibliography.typ | 12 ++++---- tests/typ/meta/cite-footnote.typ | 2 +- tests/typ/meta/cite-form.typ | 2 +- tests/typ/meta/cite-group.typ | 2 +- tests/typ/meta/figure.typ | 4 +-- tests/typ/meta/footnote-container.typ | 2 +- tests/typ/meta/footnote-table.typ | 2 +- tests/typ/meta/link.typ | 2 +- tests/typ/meta/query-figure.typ | 4 +-- tests/typ/meta/ref.typ | 4 +-- tests/typ/text/baseline.typ | 2 +- tests/typ/text/linebreak-obj.typ | 2 +- tests/typ/text/quote.typ | 8 +++--- tests/typ/text/raw-syntaxes.typ | 2 +- tests/typ/text/raw-theme.typ | 2 +- tests/typ/text/shaping.typ | 5 ++-- tests/typ/visualize/image.typ | 36 ++++++++++++------------ tests/typ/visualize/svg-text.typ | 4 +-- 54 files changed, 146 insertions(+), 145 deletions(-) (limited to 'tests') diff --git a/tests/Cargo.toml b/tests/Cargo.toml index 92c72f56..2a121067 100644 --- a/tests/Cargo.toml +++ b/tests/Cargo.toml @@ -8,6 +8,8 @@ publish = false [dev-dependencies] typst = { workspace = true } +typst-assets = { workspace = true, features = ["fonts"] } +typst-dev-assets = { workspace = true } typst-pdf = { workspace = true } typst-render = { workspace = true } typst-svg = { workspace = true } diff --git a/tests/fuzz/Cargo.toml b/tests/fuzz/Cargo.toml index 1b9e6b26..ddad37d6 100644 --- a/tests/fuzz/Cargo.toml +++ b/tests/fuzz/Cargo.toml @@ -9,6 +9,7 @@ cargo-fuzz = true [dependencies] typst = { workspace = true } +typst-assets = { workspace = true, features = ["fonts"] } typst-render = { workspace = true } typst-syntax = { workspace = true } comemo = { workspace = true } diff --git a/tests/fuzz/src/compile.rs b/tests/fuzz/src/compile.rs index 883b9ea3..2d445bf5 100644 --- a/tests/fuzz/src/compile.rs +++ b/tests/fuzz/src/compile.rs @@ -10,8 +10,6 @@ use typst::text::{Font, FontBook}; use typst::visualize::Color; use typst::{Library, World}; -const FONT: &[u8] = include_bytes!("../../../assets/fonts/LinLibertine_R.ttf"); - struct FuzzWorld { library: Prehashed, book: Prehashed, @@ -21,7 +19,8 @@ struct FuzzWorld { impl FuzzWorld { fn new(text: &str) -> Self { - let font = Font::new(FONT.into(), 0).unwrap(); + let data = typst_assets::fonts().next().unwrap(); + let font = Font::new(Bytes::from_static(data), 0).unwrap(); let book = FontBook::from_fonts([&font]); Self { library: Prehashed::new(Library::default()), diff --git a/tests/src/benches.rs b/tests/src/benches.rs index 8a521419..1bcdb528 100644 --- a/tests/src/benches.rs +++ b/tests/src/benches.rs @@ -10,7 +10,6 @@ use typst::{Library, World}; use unscanny::Scanner; const TEXT: &str = include_str!("../typ/compiler/bench.typ"); -const FONT: &[u8] = include_bytes!("../../assets/fonts/LinLibertine_R.ttf"); main!( bench_decode, @@ -87,9 +86,9 @@ struct BenchWorld { impl BenchWorld { fn new() -> Self { - let font = Font::new(FONT.into(), 0).unwrap(); + let data = typst_assets::fonts().next().unwrap(); + let font = Font::new(Bytes::from_static(data), 0).unwrap(); let book = FontBook::from_fonts([&font]); - Self { library: Prehashed::new(Library::default()), book: Prehashed::new(book), diff --git a/tests/src/tests.rs b/tests/src/tests.rs index 05b53a73..2be5bc18 100644 --- a/tests/src/tests.rs +++ b/tests/src/tests.rs @@ -15,6 +15,7 @@ mod metadata; use self::metadata::*; +use std::borrow::Cow; use std::collections::{HashMap, HashSet}; use std::ffi::OsStr; use std::fmt::Write as _; @@ -47,8 +48,6 @@ const REF_DIR: &str = "ref"; const PNG_DIR: &str = "png"; const PDF_DIR: &str = "pdf"; const SVG_DIR: &str = "svg"; -const FONT_DIR: &str = "../assets/fonts"; -const ASSET_DIR: &str = "../assets"; /// Arguments that modify test behaviour. /// @@ -269,17 +268,10 @@ struct FileSlot { impl TestWorld { fn new(print: PrintConfig) -> Self { - // Search for fonts. - let mut fonts = vec![]; - for entry in WalkDir::new(FONT_DIR) - .sort_by_file_name() - .into_iter() - .filter_map(|e| e.ok()) - .filter(|entry| entry.file_type().is_file()) - { - let data = fs::read(entry.path()).unwrap(); - fonts.extend(Font::iter(data.into())); - } + let fonts: Vec<_> = typst_assets::fonts() + .chain(typst_dev_assets::fonts()) + .flat_map(|data| Font::iter(Bytes::from_static(data))) + .collect(); Self { print, @@ -310,7 +302,7 @@ impl World for TestWorld { slot.source .get_or_init(|| { let buf = read(&system_path(id)?)?; - let text = String::from_utf8(buf)?; + let text = String::from_utf8(buf.into_owned())?; Ok(Source::new(id, text)) }) .clone() @@ -320,7 +312,12 @@ impl World for TestWorld { fn file(&self, id: FileId) -> FileResult { self.slot(id, |slot| { slot.buffer - .get_or_init(|| read(&system_path(id)?).map(Bytes::from)) + .get_or_init(|| { + read(&system_path(id)?).map(|cow| match cow { + Cow::Owned(buf) => buf.into(), + Cow::Borrowed(buf) => Bytes::from_static(buf), + }) + }) .clone() }) } @@ -379,19 +376,21 @@ fn system_path(id: FileId) -> FileResult { } /// Read a file. -fn read(path: &Path) -> FileResult> { +fn read(path: &Path) -> FileResult> { // Basically symlinks `assets/files` to `tests/files` so that the assets // are within the test project root. - let mut resolved = path.to_path_buf(); - if path.starts_with("files/") { - resolved = Path::new(ASSET_DIR).join(path); + let resolved = path.to_path_buf(); + if let Ok(suffix) = path.strip_prefix("assets/") { + return typst_dev_assets::get(&suffix.to_string_lossy()) + .map(Cow::Borrowed) + .ok_or_else(|| FileError::NotFound(path.into())); } let f = |e| FileError::from_io(e, path); if fs::metadata(&resolved).map_err(f)?.is_dir() { Err(FileError::IsDirectory) } else { - fs::read(&resolved).map_err(f) + fs::read(&resolved).map(Cow::Owned).map_err(f) } } diff --git a/tests/typ/bugs/1597-cite-footnote.typ b/tests/typ/bugs/1597-cite-footnote.typ index 394f7ea9..cc231e2a 100644 --- a/tests/typ/bugs/1597-cite-footnote.typ +++ b/tests/typ/bugs/1597-cite-footnote.typ @@ -9,4 +9,4 @@ #footnote[@netwok] #show bibliography: none -#bibliography("/files/works.bib") +#bibliography("/assets/bib/works.bib") diff --git a/tests/typ/bugs/870-image-rotation.typ b/tests/typ/bugs/870-image-rotation.typ index 56c3da1d..5d7b5597 100644 --- a/tests/typ/bugs/870-image-rotation.typ +++ b/tests/typ/bugs/870-image-rotation.typ @@ -2,5 +2,5 @@ // https://github.com/image-rs/image/issues/1045 --- -// Files is from https://magnushoff.com/articles/jpeg-orientation/ -#image("/files/f2t.jpg", width: 10pt) +// File is from https://magnushoff.com/articles/jpeg-orientation/ +#image("/assets/images/f2t.jpg", width: 10pt) diff --git a/tests/typ/bugs/bibliography-math.typ b/tests/typ/bugs/bibliography-math.typ index 2f3dabcd..3aab4b88 100644 --- a/tests/typ/bugs/bibliography-math.typ +++ b/tests/typ/bugs/bibliography-math.typ @@ -1,4 +1,4 @@ #set page(width: 200pt) @Zee04 -#bibliography("/files/works_too.bib", style: "mla") +#bibliography("/assets/bib/works_too.bib", style: "mla") diff --git a/tests/typ/bugs/cite-locate.typ b/tests/typ/bugs/cite-locate.typ index c576c45e..699bb085 100644 --- a/tests/typ/bugs/cite-locate.typ +++ b/tests/typ/bugs/cite-locate.typ @@ -20,4 +20,4 @@ #context [Citation @distress on page #here().page()] #pagebreak() -#bibliography("/files/works.bib", style: "chicago-notes") +#bibliography("/assets/bib/works.bib", style: "chicago-notes") diff --git a/tests/typ/bugs/cite-show-set.typ b/tests/typ/bugs/cite-show-set.typ index a4111c9a..f476dd49 100644 --- a/tests/typ/bugs/cite-show-set.typ +++ b/tests/typ/bugs/cite-show-set.typ @@ -6,4 +6,4 @@ A @netwok @arrgh. B #cite() #cite(). #show bibliography: none -#bibliography("/files/works.bib") +#bibliography("/assets/bib/works.bib") diff --git a/tests/typ/bugs/hide-meta.typ b/tests/typ/bugs/hide-meta.typ index 10c95e59..8d2c7cb6 100644 --- a/tests/typ/bugs/hide-meta.typ +++ b/tests/typ/bugs/hide-meta.typ @@ -7,7 +7,7 @@ A pirate. @arrgh \ #set text(2pt) #hide[ A @arrgh pirate. - #bibliography("/files/works.bib") + #bibliography("/assets/bib/works.bib") ] --- diff --git a/tests/typ/bugs/new-cm-svg.typ b/tests/typ/bugs/new-cm-svg.typ index 06cd4532..eeafcbbd 100644 --- a/tests/typ/bugs/new-cm-svg.typ +++ b/tests/typ/bugs/new-cm-svg.typ @@ -1,2 +1,2 @@ #set text(font: "New Computer Modern") -#image("/files/diagram.svg") +#image("/assets/images/diagram.svg") diff --git a/tests/typ/bugs/pagebreak-bibliography.typ b/tests/typ/bugs/pagebreak-bibliography.typ index bfc78250..257043a3 100644 --- a/tests/typ/bugs/pagebreak-bibliography.typ +++ b/tests/typ/bugs/pagebreak-bibliography.typ @@ -2,4 +2,4 @@ --- #pagebreak(weak: true) -#bibliography("/files/works.bib") +#bibliography("/assets/bib/works.bib") diff --git a/tests/typ/coma.typ b/tests/typ/coma.typ index 32a68308..8ca08ddb 100644 --- a/tests/typ/coma.typ +++ b/tests/typ/coma.typ @@ -21,4 +21,4 @@ Die Tiefe eines Knotens _v_ ist die Länge des eindeutigen Weges von der Wurzel zu _v_, und die Höhe von _v_ ist die Länge eines längsten (absteigenden) Weges von _v_ zu einem Blatt. Die Höhe des Baumes ist die Höhe der Wurzel. -#align(center, image("/files/graph.png", width: 75%)) +#align(center, image("/assets/images/graph.png", width: 75%)) diff --git a/tests/typ/compiler/bytes.typ b/tests/typ/compiler/bytes.typ index 284ef773..a9249bdd 100644 --- a/tests/typ/compiler/bytes.typ +++ b/tests/typ/compiler/bytes.typ @@ -2,7 +2,7 @@ // Ref: false --- -#let data = read("/files/rhino.png", encoding: none) +#let data = read("/assets/images/rhino.png", encoding: none) #test(data.len(), 232243) #test(data.slice(0, count: 5), bytes((137, 80, 78, 71, 13))) #test(str(data.slice(1, 4)), "PNG") diff --git a/tests/typ/compiler/import.typ b/tests/typ/compiler/import.typ index fb7a06b8..5c3a05c9 100644 --- a/tests/typ/compiler/import.typ +++ b/tests/typ/compiler/import.typ @@ -189,8 +189,8 @@ --- // Some non-text stuff. -// Error: 9-27 file is not valid utf-8 -#import "/files/rhino.png" +// Error: 9-35 file is not valid utf-8 +#import "/assets/images/rhino.png" --- // Unresolved import. diff --git a/tests/typ/compiler/plugin-oob.typ b/tests/typ/compiler/plugin-oob.typ index 4bc16212..4d1ba205 100644 --- a/tests/typ/compiler/plugin-oob.typ +++ b/tests/typ/compiler/plugin-oob.typ @@ -2,13 +2,13 @@ // Ref: false --- -#let p = plugin("/files/plugin-oob.wasm") +#let p = plugin("/assets/plugins/plugin-oob.wasm") // Error: 2-14 plugin tried to read out of bounds: pointer 0x40000000 is out of bounds for read of length 1 #p.read_oob() --- -#let p = plugin("/files/plugin-oob.wasm") +#let p = plugin("/assets/plugins/plugin-oob.wasm") // Error: 2-27 plugin tried to write out of bounds: pointer 0x40000000 is out of bounds for write of length 3 #p.write_oob(bytes("xyz")) diff --git a/tests/typ/compiler/plugin.typ b/tests/typ/compiler/plugin.typ index 53d96f71..e727355f 100644 --- a/tests/typ/compiler/plugin.typ +++ b/tests/typ/compiler/plugin.typ @@ -2,7 +2,7 @@ // Ref: false --- -#let p = plugin("/files/hello.wasm") +#let p = plugin("/assets/plugins/hello.wasm") #test(p.hello(), bytes("Hello from wasm!!!")) #test(p.double_it(bytes("hey!")), bytes("hey!.hey!")) #test( @@ -11,26 +11,26 @@ ) --- -#let p = plugin("/files/hello.wasm") +#let p = plugin("/assets/plugins/hello.wasm") // Error: 2-20 plugin function takes 0 arguments, but 1 was given #p.hello(bytes("")) --- -#let p = plugin("/files/hello.wasm") +#let p = plugin("/assets/plugins/hello.wasm") // Error: 10-14 expected bytes, found boolean // Error: 27-29 expected bytes, found integer #p.hello(true, bytes(()), 10) --- -#let p = plugin("/files/hello.wasm") +#let p = plugin("/assets/plugins/hello.wasm") // Error: 2-17 plugin errored with: This is an `Err` #p.returns_err() --- -#let p = plugin("/files/hello.wasm") +#let p = plugin("/assets/plugins/hello.wasm") // Error: 2-16 plugin panicked: wasm `unreachable` instruction executed #p.will_panic() diff --git a/tests/typ/compiler/set.typ b/tests/typ/compiler/set.typ index b317e60c..23b3a7c6 100644 --- a/tests/typ/compiler/set.typ +++ b/tests/typ/compiler/set.typ @@ -40,7 +40,7 @@ Hello *#x* // Test relative path resolving in layout phase. #let choice = ("monkey.svg", "rhino.png", "tiger.jpg") #set enum(numbering: n => { - let path = "/files/" + choice.at(n - 1) + let path = "/assets/images/" + choice.at(n - 1) move(dy: -0.15em, image(path, width: 1em, height: 1em)) }) diff --git a/tests/typ/compiler/show-text.typ b/tests/typ/compiler/show-text.typ index 7837bb46..a42abfb2 100644 --- a/tests/typ/compiler/show-text.typ +++ b/tests/typ/compiler/show-text.typ @@ -88,6 +88,6 @@ World --- // Test absolute path in layout phase. -#show "GRAPH": image("/files/graph.png") +#show "GRAPH": image("/assets/images/graph.png") The GRAPH has nodes. diff --git a/tests/typ/compute/data.typ b/tests/typ/compute/data.typ index ae964b3d..03b17aed 100644 --- a/tests/typ/compute/data.typ +++ b/tests/typ/compute/data.typ @@ -3,28 +3,28 @@ --- // Test reading plain text files -#let data = read("/files/hello.txt") +#let data = read("/assets/text/hello.txt") #test(data, "Hello, world!\n") --- -// Error: 18-38 file not found (searched at files/missing.txt) -#let data = read("/files/missing.txt") +// Error: 18-44 file not found (searched at assets/text/missing.txt) +#let data = read("/assets/text/missing.txt") --- -// Error: 18-34 file is not valid utf-8 -#let data = read("/files/bad.txt") +// Error: 18-40 file is not valid utf-8 +#let data = read("/assets/text/bad.txt") --- // Test reading CSV data. // Ref: true #set page(width: auto) -#let data = csv("/files/zoo.csv") +#let data = csv("/assets/data/zoo.csv") #let cells = data.at(0).map(strong) + data.slice(1).flatten() #table(columns: data.at(0).len(), ..cells) --- // Test reading CSV data with dictionary rows enabled. -#let data = csv("/files/zoo.csv", row-type: dictionary) +#let data = csv("/assets/data/zoo.csv", row-type: dictionary) #test(data.len(), 3) #test(data.at(0).Name, "Debby") #test(data.at(2).Weight, "150kg") @@ -35,28 +35,28 @@ #csv("nope.csv") --- -// Error: 6-22 failed to parse CSV (found 3 instead of 2 fields in line 3) -#csv("/files/bad.csv") +// Error: 6-28 failed to parse CSV (found 3 instead of 2 fields in line 3) +#csv("/assets/data/bad.csv") --- // Test error numbering with dictionary rows. -// Error: 6-22 failed to parse CSV (found 3 instead of 2 fields in line 3) -#csv("/files/bad.csv", row-type: dictionary) +// Error: 6-28 failed to parse CSV (found 3 instead of 2 fields in line 3) +#csv("/assets/data/bad.csv", row-type: dictionary) --- // Test reading JSON data. -#let data = json("/files/zoo.json") +#let data = json("/assets/data/zoo.json") #test(data.len(), 3) #test(data.at(0).name, "Debby") #test(data.at(2).weight, 150) --- -// Error: 7-24 failed to parse JSON (expected value at line 3 column 14) -#json("/files/bad.json") +// Error: 7-30 failed to parse JSON (expected value at line 3 column 14) +#json("/assets/data/bad.json") --- // Test reading TOML data. -#let data = toml("/files/toml-types.toml") +#let data = toml("/assets/data/toml-types.toml") #test(data.string, "wonderful") #test(data.integer, 42) #test(data.float, 3.14) @@ -93,12 +93,12 @@ )) --- -// Error: 7-24 failed to parse TOML (expected `.`, `=` at line 1 column 16) -#toml("/files/bad.toml") +// Error: 7-30 failed to parse TOML (expected `.`, `=` at line 1 column 16) +#toml("/assets/data/bad.toml") --- // Test reading YAML data -#let data = yaml("/files/yaml-types.yaml") +#let data = yaml("/assets/data/yaml-types.yaml") #test(data.len(), 9) #test(data.null_key, (none, none)) #test(data.string, "text") @@ -111,12 +111,12 @@ #test(data.at("1"), "ok") --- -// Error: 7-24 failed to parse YAML (did not find expected ',' or ']' at line 2 column 1, while parsing a flow sequence at line 1 column 18) -#yaml("/files/bad.yaml") +// Error: 7-30 failed to parse YAML (did not find expected ',' or ']' at line 2 column 1, while parsing a flow sequence at line 1 column 18) +#yaml("/assets/data/bad.yaml") --- // Test reading XML data. -#let data = xml("/files/data.xml") +#let data = xml("/assets/data/hello.xml") #test(data, (( tag: "data", attrs: (:), @@ -140,5 +140,5 @@ ),)) --- -// Error: 6-22 failed to parse XML (found closing tag 'data' instead of 'hello' in line 3) -#xml("/files/bad.xml") +// Error: 6-28 failed to parse XML (found closing tag 'data' instead of 'hello' in line 3) +#xml("/assets/data/bad.xml") diff --git a/tests/typ/compute/eval-path.typ b/tests/typ/compute/eval-path.typ index c02bdfb1..863b6203 100644 --- a/tests/typ/compute/eval-path.typ +++ b/tests/typ/compute/eval-path.typ @@ -2,13 +2,13 @@ --- // Test absolute path. -#eval("image(\"/files/tiger.jpg\", width: 50%)") +#eval("image(\"/assets/images/tiger.jpg\", width: 50%)") --- #show raw: it => eval(it.text, mode: "markup") ``` -#show emph: image("/files/tiger.jpg", width: 50%) +#show emph: image("/assets/images/tiger.jpg", width: 50%) _Tiger!_ ``` diff --git a/tests/typ/layout/clip.typ b/tests/typ/layout/clip.typ index d20609d8..3ca74556 100644 --- a/tests/typ/layout/clip.typ +++ b/tests/typ/layout/clip.typ @@ -52,7 +52,7 @@ First! width: 20pt, height: 20pt, clip: true, - image("/files/rhino.png", width: 30pt) + image("/assets/images/rhino.png", width: 30pt) ) --- // Test clipping with `radius`, but without `stroke`. @@ -64,5 +64,5 @@ First! width: 20pt, height: 20pt, clip: true, - image("/files/rhino.png", width: 30pt) + image("/assets/images/rhino.png", width: 30pt) ) diff --git a/tests/typ/layout/grid-3.typ b/tests/typ/layout/grid-3.typ index 89bcb90f..a6c72d6c 100644 --- a/tests/typ/layout/grid-3.typ +++ b/tests/typ/layout/grid-3.typ @@ -23,7 +23,7 @@ columns: 4 * (1fr,), row-gutter: 10pt, column-gutter: (0pt, 10%), - align(top, image("/files/rhino.png")), + align(top, image("/assets/images/rhino.png")), align(top, rect(inset: 0pt, fill: eastern, align(right)[LoL])), [rofl], [\ A] * 3, diff --git a/tests/typ/layout/hide.typ b/tests/typ/layout/hide.typ index 2cd8333e..ede65c70 100644 --- a/tests/typ/layout/hide.typ +++ b/tests/typ/layout/hide.typ @@ -4,15 +4,15 @@ AB #h(1fr) CD \ #hide[A]B #h(1fr) C#hide[D] --- -Hidden: +Hidden: #hide[#line(length: 100%)] #line(length: 100%) --- -Hidden: +Hidden: #hide(table(rows: 2, columns: 2)[a][b][c][d]) #table(rows: 2, columns: 2)[a][b][c][d] --- -Hidden: +Hidden: #hide[ #polygon((20%, 0pt), (60%, 0pt), @@ -30,7 +30,7 @@ Hidden: width: 100%, ) -Hidden: +Hidden: #hide[ #grid( columns: (1fr, 1fr, 2fr), @@ -53,7 +53,7 @@ Hidden: ) --- -Hidden: +Hidden: #hide[ - 1 - 2 @@ -71,6 +71,6 @@ Hidden: --- Hidden: -#hide(image("/files/tiger.jpg", width: 5cm, height: 1cm,)) +#hide(image("/assets/images/tiger.jpg", width: 5cm, height: 1cm,)) -#image("/files/tiger.jpg", width: 5cm, height: 1cm,) +#image("/assets/images/tiger.jpg", width: 5cm, height: 1cm,) diff --git a/tests/typ/layout/pad.typ b/tests/typ/layout/pad.typ index f7b47142..0eff5876 100644 --- a/tests/typ/layout/pad.typ +++ b/tests/typ/layout/pad.typ @@ -22,7 +22,7 @@ Hi #box(pad(left: 10pt)[A]) there // Test that the pad element doesn't consume the whole region. #set page(height: 6cm) #align(left)[Before] -#pad(10pt, image("/files/tiger.jpg")) +#pad(10pt, image("/assets/images/tiger.jpg")) #align(right)[After] --- diff --git a/tests/typ/layout/par-bidi.typ b/tests/typ/layout/par-bidi.typ index ea3711ab..f708df6a 100644 --- a/tests/typ/layout/par-bidi.typ +++ b/tests/typ/layout/par-bidi.typ @@ -41,7 +41,7 @@ Lריווח #h(1cm) R --- // Test inline object. #set text(lang: "he") -קרנפיםRh#box(image("/files/rhino.png", height: 11pt))inoחיים +קרנפיםRh#box(image("/assets/images/rhino.png", height: 11pt))inoחיים --- // Test whether L1 whitespace resetting destroys stuff. diff --git a/tests/typ/layout/par-indent.typ b/tests/typ/layout/par-indent.typ index 324ff44a..e807d74d 100644 --- a/tests/typ/layout/par-indent.typ +++ b/tests/typ/layout/par-indent.typ @@ -9,10 +9,10 @@ The first paragraph has no indent. But the second one does. -#box(image("/files/tiger.jpg", height: 6pt)) +#box(image("/assets/images/tiger.jpg", height: 6pt)) starts a paragraph, also with indent. -#align(center, image("/files/rhino.png", width: 1cm)) +#align(center, image("/assets/images/rhino.png", width: 1cm)) = Headings - And lists. diff --git a/tests/typ/layout/place-background.typ b/tests/typ/layout/place-background.typ index 3a7a06b9..afee0622 100644 --- a/tests/typ/layout/place-background.typ +++ b/tests/typ/layout/place-background.typ @@ -7,7 +7,7 @@ dx: -10pt, dy: -10pt, image( - "/files/tiger.jpg", + "/assets/images/tiger.jpg", fit: "cover", width: 100% + 20pt, height: 100% + 20pt, diff --git a/tests/typ/layout/place-float-columns.typ b/tests/typ/layout/place-float-columns.typ index 0e5c6d0c..e2b88d46 100644 --- a/tests/typ/layout/place-float-columns.typ +++ b/tests/typ/layout/place-float-columns.typ @@ -8,7 +8,7 @@ #figure( placement: bottom, caption: [A glacier], - image("/files/glacier.jpg", width: 50%), + image("/assets/images/glacier.jpg", width: 50%), ) #lorem(45) #figure( diff --git a/tests/typ/layout/place-float-figure.typ b/tests/typ/layout/place-float-figure.typ index 7256a4eb..4d76fd8f 100644 --- a/tests/typ/layout/place-float-figure.typ +++ b/tests/typ/layout/place-float-figure.typ @@ -9,7 +9,7 @@ #figure( placement: bottom, caption: [A glacier #footnote[Lots of Ice]], - image("/files/glacier.jpg", width: 80%), + image("/assets/images/glacier.jpg", width: 80%), ) #lorem(40) @@ -17,5 +17,5 @@ #figure( placement: top, caption: [An important], - image("/files/diagram.svg", width: 80%), + image("/assets/images/diagram.svg", width: 80%), ) diff --git a/tests/typ/layout/place.typ b/tests/typ/layout/place.typ index 6f79e3e1..d426e07f 100644 --- a/tests/typ/layout/place.typ +++ b/tests/typ/layout/place.typ @@ -5,7 +5,7 @@ #place(bottom + center)[© Typst] = Placement -#place(right, image("/files/tiger.jpg", width: 1.8cm)) +#place(right, image("/assets/images/tiger.jpg", width: 1.8cm)) Hi there. This is \ a placed element. \ Unfortunately, \ diff --git a/tests/typ/layout/transform.typ b/tests/typ/layout/transform.typ index 3a674282..f74ec2b0 100644 --- a/tests/typ/layout/transform.typ +++ b/tests/typ/layout/transform.typ @@ -31,13 +31,13 @@ nor #xetex! // Test combination of scaling and rotation. #set page(height: 80pt) #align(center + horizon, - rotate(20deg, scale(70%, image("/files/tiger.jpg"))) + rotate(20deg, scale(70%, image("/assets/images/tiger.jpg"))) ) --- // Test setting rotation origin. #rotate(10deg, origin: top + left, - image("/files/tiger.jpg", width: 50%) + image("/assets/images/tiger.jpg", width: 50%) ) --- diff --git a/tests/typ/math/content.typ b/tests/typ/math/content.typ index e04ebb30..739377ae 100644 --- a/tests/typ/math/content.typ +++ b/tests/typ/math/content.typ @@ -2,7 +2,7 @@ --- // Test images and font fallback. -#let monkey = move(dy: 0.2em, image("/files/monkey.svg", height: 1em)) +#let monkey = move(dy: 0.2em, image("/assets/images/monkey.svg", height: 1em)) $ sum_(i=#emoji.apple)^#emoji.apple.red i + monkey/2 $ --- diff --git a/tests/typ/meta/bibliography-full.typ b/tests/typ/meta/bibliography-full.typ index cebe7e0d..9b652cd2 100644 --- a/tests/typ/meta/bibliography-full.typ +++ b/tests/typ/meta/bibliography-full.typ @@ -2,4 +2,4 @@ --- #set page(paper: "a6", height: 170mm) -#bibliography("/files/works.bib", full: true) +#bibliography("/assets/bib/works.bib", full: true) diff --git a/tests/typ/meta/bibliography-ordering.typ b/tests/typ/meta/bibliography-ordering.typ index 970d66d0..4732ad68 100644 --- a/tests/typ/meta/bibliography-ordering.typ +++ b/tests/typ/meta/bibliography-ordering.typ @@ -13,4 +13,4 @@ @sharing @restful -#bibliography("/files/works.bib") +#bibliography("/assets/bib/works.bib") diff --git a/tests/typ/meta/bibliography.typ b/tests/typ/meta/bibliography.typ index 0ce4b7f7..107f790e 100644 --- a/tests/typ/meta/bibliography.typ +++ b/tests/typ/meta/bibliography.typ @@ -5,13 +5,13 @@ = Details See also @arrgh #cite(, supplement: [p.~22]), @arrgh[p.~4], and @distress[p.~5]. -#bibliography("/files/works.bib") +#bibliography("/assets/bib/works.bib") --- // Test unconventional order. #set page(width: 200pt) #bibliography( - "/files/works.bib", + "/assets/bib/works.bib", title: [Works to be cited], style: "chicago-author-date", ) @@ -29,7 +29,7 @@ And quark! @quark = Multiple Bibs Now we have multiple bibliographies containing @glacier-melt @keshav2007read -#bibliography(("/files/works.bib", "/files/works_too.bib")) +#bibliography(("/assets/bib/works.bib", "/assets/bib/works_too.bib")) --- // Test ambiguous reference. @@ -37,8 +37,8 @@ Now we have multiple bibliographies containing @glacier-melt @keshav2007read // Error: 1-7 label occurs in the document and its bibliography @arrgh -#bibliography("/files/works.bib") +#bibliography("/assets/bib/works.bib") --- -// Error: 15-55 duplicate bibliography keys: netwok, issue201, arrgh, quark, distress, glacier-melt, tolkien54, DBLP:books/lib/Knuth86a, sharing, restful, mcintosh_anxiety, psychology25 -#bibliography(("/files/works.bib", "/files/works.bib")) +// Error: 15-65 duplicate bibliography keys: netwok, issue201, arrgh, quark, distress, glacier-melt, tolkien54, DBLP:books/lib/Knuth86a, sharing, restful, mcintosh_anxiety, psychology25 +#bibliography(("/assets/bib/works.bib", "/assets/bib/works.bib")) diff --git a/tests/typ/meta/cite-footnote.typ b/tests/typ/meta/cite-footnote.typ index 071a68d7..c6eff59d 100644 --- a/tests/typ/meta/cite-footnote.typ +++ b/tests/typ/meta/cite-footnote.typ @@ -2,4 +2,4 @@ Hello @netwok And again: @netwok #pagebreak() -#bibliography("/files/works.bib", style: "chicago-notes") +#bibliography("/assets/bib/works.bib", style: "chicago-notes") diff --git a/tests/typ/meta/cite-form.typ b/tests/typ/meta/cite-form.typ index 3c11e1f6..343981d7 100644 --- a/tests/typ/meta/cite-form.typ +++ b/tests/typ/meta/cite-form.typ @@ -7,4 +7,4 @@ Nothing: #cite(, form: none) #cite(, form: "prose") say stuff. -#bibliography("/files/works.bib", style: "apa") +#bibliography("/assets/bib/works.bib", style: "apa") diff --git a/tests/typ/meta/cite-group.typ b/tests/typ/meta/cite-group.typ index 3bb0046d..331c87ca 100644 --- a/tests/typ/meta/cite-group.typ +++ b/tests/typ/meta/cite-group.typ @@ -16,4 +16,4 @@ A @netwok @arrgh @quark B. \ A @netwok @arrgh @quark, B. #set text(0pt) -#bibliography("/files/works.bib") +#bibliography("/assets/bib/works.bib") diff --git a/tests/typ/meta/figure.typ b/tests/typ/meta/figure.typ index 7d618d06..b6c1bfd6 100644 --- a/tests/typ/meta/figure.typ +++ b/tests/typ/meta/figure.typ @@ -13,7 +13,7 @@ We can clearly see that @fig-cylinder and ) #figure( - pad(y: -6pt, image("/files/cylinder.svg", height: 2cm)), + pad(y: -6pt, image("/assets/images/cylinder.svg", height: 2cm)), caption: [The basic shapes.], numbering: "I", ) @@ -30,7 +30,7 @@ We can clearly see that @fig-cylinder and table( columns: 2, [Second cylinder], - image("/files/cylinder.svg"), + image("/assets/images/cylinder.svg"), ), caption: "A table containing images." ) diff --git a/tests/typ/meta/footnote-container.typ b/tests/typ/meta/footnote-container.typ index 562831a9..2fa14fac 100644 --- a/tests/typ/meta/footnote-container.typ +++ b/tests/typ/meta/footnote-container.typ @@ -4,7 +4,7 @@ // Test footnote in caption. Read the docs #footnote[https://typst.app/docs]! #figure( - image("/files/graph.png", width: 70%), + image("/assets/images/graph.png", width: 70%), caption: [ A graph #footnote[A _graph_ is a structure with nodes and edges.] ] diff --git a/tests/typ/meta/footnote-table.typ b/tests/typ/meta/footnote-table.typ index 8256dc58..a52d28ba 100644 --- a/tests/typ/meta/footnote-table.typ +++ b/tests/typ/meta/footnote-table.typ @@ -12,7 +12,7 @@ [This cell #footnote[This footnote is not on the same page] breaks over multiple pages.], - image("/files/tiger.jpg"), + image("/assets/images/tiger.jpg"), ) #table( diff --git a/tests/typ/meta/link.typ b/tests/typ/meta/link.typ index f93189cb..dd5bffa8 100644 --- a/tests/typ/meta/link.typ +++ b/tests/typ/meta/link.typ @@ -54,7 +54,7 @@ My cool #box(move(dx: 0.7cm, dy: 0.7cm, rotate(10deg, scale(200%, mylink)))) // Link containing a block. #link("https://example.com/", block[ My cool rhino - #box(move(dx: 10pt, image("/files/rhino.png", width: 1cm))) + #box(move(dx: 10pt, image("/assets/images/rhino.png", width: 1cm))) ]) --- diff --git a/tests/typ/meta/query-figure.typ b/tests/typ/meta/query-figure.typ index 590c8e87..1fe82372 100644 --- a/tests/typ/meta/query-figure.typ +++ b/tests/typ/meta/query-figure.typ @@ -24,7 +24,7 @@ } #figure( - image("/files/glacier.jpg"), + image("/assets/images/glacier.jpg"), caption: [Glacier melting], ) @@ -36,6 +36,6 @@ ) #figure( - image("/files/tiger.jpg"), + image("/assets/images/tiger.jpg"), caption: [Tiger world], ) diff --git a/tests/typ/meta/ref.typ b/tests/typ/meta/ref.typ index e01bc941..4cc824d7 100644 --- a/tests/typ/meta/ref.typ +++ b/tests/typ/meta/ref.typ @@ -26,13 +26,13 @@ As seen in @intro, we proceed. = Intro #figure( - image("/files/cylinder.svg", height: 1cm), + image("/assets/images/cylinder.svg", height: 1cm), caption: [A cylinder.], supplement: "Fig", ) #figure( - image("/files/tiger.jpg", height: 1cm), + image("/assets/images/tiger.jpg", height: 1cm), caption: [A tiger.], supplement: "Tig", ) diff --git a/tests/typ/text/baseline.typ b/tests/typ/text/baseline.typ index e00e9230..c8fbb19d 100644 --- a/tests/typ/text/baseline.typ +++ b/tests/typ/text/baseline.typ @@ -9,4 +9,4 @@ Our cockatoo was one of the that ever learned to mimic a human voice. --- -Hey #box(baseline: 40%, image("/files/tiger.jpg", width: 1.5cm)) there! +Hey #box(baseline: 40%, image("/assets/images/tiger.jpg", width: 1.5cm)) there! diff --git a/tests/typ/text/linebreak-obj.typ b/tests/typ/text/linebreak-obj.typ index 50254df1..ebf55f15 100644 --- a/tests/typ/text/linebreak-obj.typ +++ b/tests/typ/text/linebreak-obj.typ @@ -7,7 +7,7 @@ They can look for the details in @netwok, which is the authoritative source. -#bibliography("/files/works.bib") +#bibliography("/assets/bib/works.bib") --- // Test punctuation after math equations. diff --git a/tests/typ/text/quote.typ b/tests/typ/text/quote.typ index 0fd96ff5..1573438c 100644 --- a/tests/typ/text/quote.typ +++ b/tests/typ/text/quote.typ @@ -30,7 +30,7 @@ And I quote: #quote(attribution: [René Descartes])[cogito, ergo sum]. #quote(attribution: )[In a hole in the ground there lived a hobbit.] #set text(0pt) -#bibliography("/files/works.bib") +#bibliography("/assets/bib/works.bib") --- // Citation-format: label or numeric @@ -39,7 +39,7 @@ And I quote: #quote(attribution: [René Descartes])[cogito, ergo sum]. #quote(attribution: )[In a hole in the ground there lived a hobbit.] #set text(0pt) -#bibliography("/files/works.bib", style: "ieee") +#bibliography("/assets/bib/works.bib", style: "ieee") --- // Citation-format: note @@ -48,7 +48,7 @@ And I quote: #quote(attribution: [René Descartes])[cogito, ergo sum]. #quote(attribution: )[In a hole in the ground there lived a hobbit.] #set text(0pt) -#bibliography("/files/works.bib", style: "chicago-notes") +#bibliography("/assets/bib/works.bib", style: "chicago-notes") --- // Citation-format: author-date or author @@ -57,4 +57,4 @@ And I quote: #quote(attribution: [René Descartes])[cogito, ergo sum]. #quote(attribution: )[In a hole in the ground there lived a hobbit.] #set text(0pt) -#bibliography("/files/works.bib", style: "apa") +#bibliography("/assets/bib/works.bib", style: "apa") diff --git a/tests/typ/text/raw-syntaxes.typ b/tests/typ/text/raw-syntaxes.typ index 5863e648..e6c46924 100644 --- a/tests/typ/text/raw-syntaxes.typ +++ b/tests/typ/text/raw-syntaxes.typ @@ -3,7 +3,7 @@ --- #set page(width: 180pt) #set text(6pt) -#set raw(syntaxes: "/files/SExpressions.sublime-syntax") +#set raw(syntaxes: "/assets/syntaxes/SExpressions.sublime-syntax") ```sexp (defun factorial (x) diff --git a/tests/typ/text/raw-theme.typ b/tests/typ/text/raw-theme.typ index 71b59688..d6cda221 100644 --- a/tests/typ/text/raw-theme.typ +++ b/tests/typ/text/raw-theme.typ @@ -3,7 +3,7 @@ --- #set page(width: 180pt) #set text(6pt) -#set raw(theme: "/files/halcyon.tmTheme") +#set raw(theme: "/assets/themes/halcyon.tmTheme") #show raw: it => { set text(fill: rgb("a2aabc")) rect( diff --git a/tests/typ/text/shaping.typ b/tests/typ/text/shaping.typ index 3a8d5411..4a2b4f1e 100644 --- a/tests/typ/text/shaping.typ +++ b/tests/typ/text/shaping.typ @@ -2,6 +2,7 @@ --- // Test separation by script. +#set text(font: ("Linux Libertine", "IBM Plex Sans Devanagari")) ABCअपार्टमेंट // This is how it should look like. @@ -13,12 +14,12 @@ ABCअपार्टमेंट --- // A forced `latn` script inhibits Devanagari font features. -#set text(script: "latn") +#set text(font: ("Linux Libertine", "IBM Plex Sans Devanagari"), script: "latn") ABCअपार्टमेंट --- // A forced `deva` script enables Devanagari font features. -#set text(script: "deva") +#set text(font: ("Linux Libertine", "IBM Plex Sans Devanagari"), script: "deva") ABCअपार्टमेंट --- diff --git a/tests/typ/visualize/image.typ b/tests/typ/visualize/image.typ index 0e256eb8..a7965b2d 100644 --- a/tests/typ/visualize/image.typ +++ b/tests/typ/visualize/image.typ @@ -4,24 +4,24 @@ // Test loading different image formats. // Load an RGBA PNG image. -#image("/files/rhino.png") +#image("/assets/images/rhino.png") // Load an RGB JPEG image. #set page(height: 60pt) -#image("../../files/tiger.jpg") +#image("../../assets/images/tiger.jpg") --- // Test configuring the size and fitting behaviour of images. // Set width and height explicitly. -#box(image("/files/rhino.png", width: 30pt)) -#box(image("/files/rhino.png", height: 30pt)) +#box(image("/assets/images/rhino.png", width: 30pt)) +#box(image("/assets/images/rhino.png", height: 30pt)) // Set width and height explicitly and force stretching. -#image("/files/monkey.svg", width: 100%, height: 20pt, fit: "stretch") +#image("/assets/images/monkey.svg", width: 100%, height: 20pt, fit: "stretch") // Make sure the bounding-box of the image is correct. -#align(bottom + right, image("/files/tiger.jpg", width: 40pt, alt: "A tiger")) +#align(bottom + right, image("/assets/images/tiger.jpg", width: 40pt, alt: "A tiger")) --- // Test all three fit modes. @@ -30,24 +30,24 @@ columns: (1fr, 1fr, 1fr), rows: 100%, gutter: 3pt, - image("/files/tiger.jpg", width: 100%, height: 100%, fit: "contain"), - image("/files/tiger.jpg", width: 100%, height: 100%, fit: "cover"), - image("/files/monkey.svg", width: 100%, height: 100%, fit: "stretch"), + image("/assets/images/tiger.jpg", width: 100%, height: 100%, fit: "contain"), + image("/assets/images/tiger.jpg", width: 100%, height: 100%, fit: "cover"), + image("/assets/images/monkey.svg", width: 100%, height: 100%, fit: "stretch"), ) --- // Does not fit to remaining height of page. #set page(height: 60pt) Stuff -#image("/files/rhino.png") +#image("/assets/images/rhino.png") --- // Test baseline. -A #box(image("/files/tiger.jpg", height: 1cm, width: 80%)) B +A #box(image("/assets/images/tiger.jpg", height: 1cm, width: 80%)) B --- // Test advanced SVG features. -#image("/files/pattern.svg") +#image("/assets/images/pattern.svg") --- // Error: 8-29 file not found (searched at typ/visualize/path/does/not/exist) @@ -58,8 +58,8 @@ A #box(image("/files/tiger.jpg", height: 1cm, width: 80%)) B #image("./image.typ") --- -// Error: 2-25 failed to parse SVG (found closing tag 'g' instead of 'style' in line 4) -#image("/files/bad.svg") +// Error: 2-33 failed to parse SVG (found closing tag 'g' instead of 'style' in line 4) +#image("/assets/images/bad.svg") --- // Test parsing from svg data @@ -71,12 +71,12 @@ A #box(image("/files/tiger.jpg", height: 1cm, width: 80%)) B --- // Test format auto detect -#image.decode(read("/files/tiger.jpg", encoding: none), width: 80%) +#image.decode(read("/assets/images/tiger.jpg", encoding: none), width: 80%) --- // Test format manual -#image.decode(read("/files/tiger.jpg", encoding: none), format: "jpg", width: 80%) +#image.decode(read("/assets/images/tiger.jpg", encoding: none), format: "jpg", width: 80%) --- -// Error: 2-83 failed to decode image (Format error decoding Png: Invalid PNG signature.) -#image.decode(read("/files/tiger.jpg", encoding: none), format: "png", width: 80%) +// Error: 2-91 failed to decode image (Format error decoding Png: Invalid PNG signature.) +#image.decode(read("/assets/images/tiger.jpg", encoding: none), format: "png", width: 80%) diff --git a/tests/typ/visualize/svg-text.typ b/tests/typ/visualize/svg-text.typ index 11283a76..6f0a758e 100644 --- a/tests/typ/visualize/svg-text.typ +++ b/tests/typ/visualize/svg-text.typ @@ -4,7 +4,7 @@ #set page(width: 250pt) #figure( - image("/files/diagram.svg"), + image("/assets/images/diagram.svg"), caption: [A textful diagram], ) @@ -13,6 +13,6 @@ #show image: set text(font: ("Roboto", "Noto Serif CJK SC")) #figure( - image("/files/chinese.svg"), + image("/assets/images/chinese.svg"), caption: [Bilingual text] ) -- cgit v1.2.3