Move assets
20
NOTICE
@ -65,19 +65,19 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
================================================================================
|
||||
The SIL Open Font License Version 1.1 applies to:
|
||||
|
||||
* IBM Plex fonts in tests/fonts/IBMPlex*.ttf
|
||||
* IBM Plex fonts in assets/fonts/IBMPlex*.ttf
|
||||
Copyright © 2017 IBM Corp. with Reserved Font Name "Plex"
|
||||
(https://github.com/IBM/plex)
|
||||
|
||||
* Noto fonts in tests/fonts/Noto*.ttf
|
||||
* Noto fonts in assets/fonts/Noto*.ttf
|
||||
Copyright 2018 The Noto Project Authors
|
||||
(https://github.com/googlei18n/noto-fonts)
|
||||
|
||||
* PT Sans fonts in tests/fonts/PTSans*.ttf
|
||||
* PT Sans fonts in assets/fonts/PTSans*.ttf
|
||||
Copyright (c) 2010, ParaType Ltd. (http://www.paratype.com/public),
|
||||
with Reserved Font Names "PT Sans" and "ParaType".
|
||||
|
||||
* Fira math fonts in tests/fonts/FiraMath*.otf
|
||||
* Fira math fonts in assets/fonts/FiraMath*.otf
|
||||
Copyright (C) 2018--2021 by Xiangdong Zeng <xdzeng96@gmail.com>
|
||||
(https://github.com/firamath/firamath)
|
||||
|
||||
@ -172,7 +172,7 @@ OTHER DEALINGS IN THE FONT SOFTWARE.
|
||||
================================================================================
|
||||
The Apache License Version 2.0 applies to:
|
||||
|
||||
* Roboto fonts in tests/fonts/Roboto*.ttf
|
||||
* Roboto fonts in assets/fonts/Roboto*.ttf
|
||||
(https://github.com/googlefonts/roboto)
|
||||
|
||||
Apache License
|
||||
@ -356,7 +356,7 @@ The Apache License Version 2.0 applies to:
|
||||
================================================================================
|
||||
The Ubuntu Font License Version 1.0 applies to:
|
||||
|
||||
* Ubuntu fonts in tests/fonts/Ubuntu*.ttf
|
||||
* Ubuntu fonts in assets/fonts/Ubuntu*.ttf
|
||||
(https://design.ubuntu.com/font/)
|
||||
|
||||
-------------------------------
|
||||
@ -461,10 +461,10 @@ DEALINGS IN THE FONT SOFTWARE.
|
||||
================================================================================
|
||||
The GUST Font License Version 1.0 applies to:
|
||||
|
||||
* Latin Modern fonts in tests/fonts/LatinModern*.otf
|
||||
* Latin Modern fonts in assets/fonts/LatinModern*.otf
|
||||
(http://www.gust.org.pl/projects/e-foundry/lm-math)
|
||||
|
||||
* NewComputerModern fonts in tests/fonts/NewCM*.otf
|
||||
* NewComputerModern fonts in assets/fonts/NewCM*.otf
|
||||
|
||||
% This is version 1.0, dated 22 June 2009, of the GUST Font License.
|
||||
% (GUST is the Polish TeX Users Group, http://www.gust.org.pl)
|
||||
@ -499,7 +499,7 @@ The GUST Font License Version 1.0 applies to:
|
||||
================================================================================
|
||||
The Creative Commons Attribution 4.0 International License applies to:
|
||||
|
||||
* Twitter Color Emoji font in tests/fonts/TwitterColorEmoji.ttf
|
||||
* Twitter Color Emoji font in assets/fonts/TwitterColorEmoji.ttf
|
||||
Copyright 2016 Brad Erickson
|
||||
Copyright 2016 Twitter, Inc.
|
||||
(https://github.com/eosrei/twemoji-color-font)
|
||||
@ -509,7 +509,7 @@ The Creative Commons Attribution 4.0 International License applies to:
|
||||
Copyright 2020 Twitter, Inc and other contributors
|
||||
(https://github.com/twitter/twemoji)
|
||||
|
||||
* Monkey emoji in tests/res/monkey.svg
|
||||
* Monkey emoji in assets/files/monkey.svg
|
||||
Copyright 2018 Vincent Le Moign, Streamline Emoji Project
|
||||
Via Wikimedia Commons
|
||||
(https://commons.wikimedia.org/wiki/File:440-monkey.svg)
|
||||
|
Before Width: | Height: | Size: 118 B After Width: | Height: | Size: 118 B |
Before Width: | Height: | Size: 18 KiB After Width: | Height: | Size: 18 KiB |
Before Width: | Height: | Size: 4.5 KiB After Width: | Height: | Size: 4.5 KiB |
Before Width: | Height: | Size: 983 B After Width: | Height: | Size: 983 B |
Before Width: | Height: | Size: 227 KiB After Width: | Height: | Size: 227 KiB |
Before Width: | Height: | Size: 114 KiB After Width: | Height: | Size: 114 KiB |
@ -75,7 +75,11 @@ pub fn compile(world: &(dyn World + 'static), source: &Source) -> SourceResult<D
|
||||
#[comemo::track]
|
||||
pub trait World {
|
||||
/// The path relative to which absolute paths are.
|
||||
fn root(&self) -> &Path;
|
||||
///
|
||||
/// Defaults to the empty path.
|
||||
fn root(&self) -> &Path {
|
||||
Path::new("")
|
||||
}
|
||||
|
||||
/// The standard library.
|
||||
fn library(&self) -> &Prehashed<Library>;
|
||||
|
@ -10,8 +10,6 @@ Top level directory structure:
|
||||
a test passed or failed.
|
||||
- `png`: PNG files produced by tests.
|
||||
- `pdf`: PDF files produced by tests.
|
||||
- `res`: Resource files used by tests.
|
||||
- `fonts`: Font files used for tests.
|
||||
|
||||
## Running the tests
|
||||
Running all tests (including unit tests):
|
||||
|
@ -11,7 +11,7 @@ use typst::World;
|
||||
use unscanny::Scanner;
|
||||
|
||||
const TEXT: &str = include_str!("../typ/compiler/bench.typ");
|
||||
const FONT: &[u8] = include_bytes!("../fonts/IBMPlexSans-Regular.ttf");
|
||||
const FONT: &[u8] = include_bytes!("../../assets/fonts/IBMPlexSans-Regular.ttf");
|
||||
|
||||
main!(
|
||||
bench_decode,
|
||||
@ -124,10 +124,6 @@ impl BenchWorld {
|
||||
}
|
||||
|
||||
impl World for BenchWorld {
|
||||
fn root(&self) -> &Path {
|
||||
Path::new("")
|
||||
}
|
||||
|
||||
fn library(&self) -> &Prehashed<Library> {
|
||||
&self.library
|
||||
}
|
||||
|
@ -28,7 +28,8 @@ const TYP_DIR: &str = "typ";
|
||||
const REF_DIR: &str = "ref";
|
||||
const PNG_DIR: &str = "png";
|
||||
const PDF_DIR: &str = "pdf";
|
||||
const FONT_DIR: &str = "fonts";
|
||||
const FONT_DIR: &str = "../assets/fonts";
|
||||
const FILE_DIR: &str = "../assets/files";
|
||||
|
||||
fn main() {
|
||||
let args = Args::new(env::args().skip(1));
|
||||
@ -240,7 +241,7 @@ impl TestWorld {
|
||||
|
||||
impl World for TestWorld {
|
||||
fn root(&self) -> &Path {
|
||||
Path::new("")
|
||||
Path::new(FILE_DIR)
|
||||
}
|
||||
|
||||
fn library(&self) -> &Prehashed<Library> {
|
||||
@ -306,10 +307,15 @@ impl TestWorld {
|
||||
}
|
||||
}
|
||||
|
||||
/// Read a file.
|
||||
/// Read as file.
|
||||
fn read(path: &Path) -> FileResult<Vec<u8>> {
|
||||
let f = |e| FileError::from_io(e, path);
|
||||
let mut file = File::open(path).map_err(f)?;
|
||||
let suffix = path
|
||||
.strip_prefix(FILE_DIR)
|
||||
.map(|suffix| Path::new("/").join(suffix))
|
||||
.unwrap_or_else(|_| path.into());
|
||||
|
||||
let f = |e| FileError::from_io(e, &suffix);
|
||||
let mut file = File::open(&path).map_err(f)?;
|
||||
if file.metadata().map_err(f)?.is_file() {
|
||||
let mut data = vec![];
|
||||
file.read_to_end(&mut data).map_err(f)?;
|
||||
|
@ -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("../res/graph.png", width: 75%))
|
||||
#align(center, image("/graph.png", width: 75%))
|
||||
|
@ -69,8 +69,8 @@
|
||||
|
||||
---
|
||||
// Some non-text stuff.
|
||||
// Error: 9-30 file is not valid utf-8
|
||||
#import "../../res/rhino.png"
|
||||
// Error: 9-21 file is not valid utf-8
|
||||
#import "/rhino.png"
|
||||
|
||||
---
|
||||
// Unresolved import.
|
||||
|
@ -6,7 +6,7 @@
|
||||
= Document
|
||||
|
||||
// Include a file
|
||||
#include "/typ/compiler/modules/chap1.typ"
|
||||
#include "modules/chap1.typ"
|
||||
|
||||
// Expression as a file name.
|
||||
#let chap2 = include "modu" + "les/chap" + "2.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 = "../../res/" + choice.at(n - 1)
|
||||
let path = "/" + choice.at(n - 1)
|
||||
move(dy: -0.15em, image(path, width: 1em, height: 1em))
|
||||
})
|
||||
|
||||
|
@ -54,6 +54,6 @@ World
|
||||
---
|
||||
// Test absolute path in layout phase.
|
||||
|
||||
#show "GRAPH": image("/res/graph.png")
|
||||
#show "GRAPH": image("/graph.png")
|
||||
|
||||
The GRAPH has nodes.
|
||||
|
@ -3,22 +3,22 @@
|
||||
|
||||
---
|
||||
// Test reading plain text files
|
||||
#let data = read("../../res/hello.txt")
|
||||
#let data = read("/hello.txt")
|
||||
#test(data, "Hello, world!")
|
||||
|
||||
---
|
||||
// Error: 18-41 file not found (searched at res/missing.txt)
|
||||
#let data = read("../../res/missing.txt")
|
||||
// Error: 18-32 file not found (searched at /missing.txt)
|
||||
#let data = read("/missing.txt")
|
||||
|
||||
---
|
||||
// Error: 18-46 file is not valid utf-8
|
||||
#let data = read("../../res/invalid-utf8.txt")
|
||||
// Error: 18-37 file is not valid utf-8
|
||||
#let data = read("/invalid-utf8.txt")
|
||||
|
||||
---
|
||||
// Test reading CSV data.
|
||||
// Ref: true
|
||||
#set page(width: auto)
|
||||
#let data = csv("/res/zoo.csv")
|
||||
#let data = csv("/zoo.csv")
|
||||
#let cells = data.at(0).map(strong) + data.slice(1).flatten()
|
||||
#table(columns: data.at(0).len(), ..cells)
|
||||
|
||||
@ -27,23 +27,23 @@
|
||||
#csv("nope.csv")
|
||||
|
||||
---
|
||||
// Error: 6-20 failed to parse csv file: found 3 instead of 2 fields in line 3
|
||||
#csv("/res/bad.csv")
|
||||
// Error: 6-16 failed to parse csv file: found 3 instead of 2 fields in line 3
|
||||
#csv("/bad.csv")
|
||||
|
||||
---
|
||||
// Test reading JSON data.
|
||||
#let data = json("/res/zoo.json")
|
||||
#let data = json("/zoo.json")
|
||||
#test(data.len(), 3)
|
||||
#test(data.at(0).name, "Debby")
|
||||
#test(data.at(2).weight, 150)
|
||||
|
||||
---
|
||||
// Error: 7-22 failed to parse json file: syntax error in line 3
|
||||
#json("/res/bad.json")
|
||||
// Error: 7-18 failed to parse json file: syntax error in line 3
|
||||
#json("/bad.json")
|
||||
|
||||
---
|
||||
// Test reading XML data.
|
||||
#let data = xml("/res/data.xml")
|
||||
#let data = xml("/data.xml")
|
||||
#test(data, ((
|
||||
tag: "data",
|
||||
attrs: (:),
|
||||
@ -67,5 +67,5 @@
|
||||
),))
|
||||
|
||||
---
|
||||
// Error: 6-20 failed to parse xml file: found closing tag 'data' instead of 'hello' in line 3
|
||||
#xml("/res/bad.xml")
|
||||
// Error: 6-16 failed to parse xml file: found closing tag 'data' instead of 'hello' in line 3
|
||||
#xml("/bad.xml")
|
||||
|
@ -51,15 +51,15 @@ Blue #move(dy: -0.15em)[🌊]
|
||||
#eval("#include \"../coma.typ\"")
|
||||
|
||||
---
|
||||
// Error: 7-35 cannot access file system from here
|
||||
#eval("#image(\"/res/tiger.jpg\")")
|
||||
// Error: 7-31 cannot access file system from here
|
||||
#eval("#image(\"/tiger.jpg\")")
|
||||
|
||||
---
|
||||
// Error: 23-30 cannot access file system from here
|
||||
#show raw: it => eval(it.text)
|
||||
|
||||
```
|
||||
#image("/res/tiger.jpg")
|
||||
#image("/tiger.jpg")
|
||||
```
|
||||
|
||||
---
|
||||
@ -67,7 +67,7 @@ Blue #move(dy: -0.15em)[🌊]
|
||||
#show raw: it => eval(it.text)
|
||||
|
||||
```
|
||||
#show emph: _ => image("../../res/giraffe.jpg")
|
||||
#show emph: _ => image("/giraffe.jpg")
|
||||
_No relative giraffe!_
|
||||
```
|
||||
|
||||
|
@ -23,7 +23,7 @@
|
||||
columns: 4 * (1fr,),
|
||||
row-gutter: 10pt,
|
||||
column-gutter: (0pt, 10%),
|
||||
align(top, image("/res/rhino.png")),
|
||||
align(top, image("/rhino.png")),
|
||||
align(top, rect(inset: 0pt, fill: eastern, align(right)[LoL])),
|
||||
[rofl],
|
||||
[\ A] * 3,
|
||||
|
@ -22,7 +22,7 @@ Hi #box(pad(left: 10pt)[A]) there
|
||||
// Test that the pad node doesn't consume the whole region.
|
||||
#set page(height: 6cm)
|
||||
#align(left)[Before]
|
||||
#pad(10pt, image("/res/tiger.jpg"))
|
||||
#pad(10pt, image("/tiger.jpg"))
|
||||
#align(right)[After]
|
||||
|
||||
---
|
||||
|
@ -43,7 +43,7 @@ Lריווח #h(1cm) R
|
||||
---
|
||||
// Test inline object.
|
||||
#set text(lang: "he", "IBM Plex Serif")
|
||||
קרנפיםRh#image("/res/rhino.png", height: 11pt)inoחיים
|
||||
קרנפיםRh#image("/rhino.png", height: 11pt)inoחיים
|
||||
|
||||
---
|
||||
// Test whether L1 whitespace resetting destroys stuff.
|
||||
|
@ -9,10 +9,10 @@ The first paragraph has no indent.
|
||||
|
||||
But the second one does.
|
||||
|
||||
#image("/res/tiger.jpg", height: 6pt)
|
||||
#image("/tiger.jpg", height: 6pt)
|
||||
starts a paragraph without indent.
|
||||
|
||||
#align(center, image("/res/rhino.png", width: 1cm))
|
||||
#align(center, image("/rhino.png", width: 1cm))
|
||||
|
||||
= Headings
|
||||
- And lists.
|
||||
|
@ -7,7 +7,7 @@
|
||||
dx: -10pt,
|
||||
dy: -10pt,
|
||||
image(
|
||||
"/res/tiger.jpg",
|
||||
"/tiger.jpg",
|
||||
fit: "cover",
|
||||
width: 100% + 20pt,
|
||||
height: 100% + 20pt,
|
||||
|
@ -5,7 +5,7 @@
|
||||
#place(bottom + center)[© Typst]
|
||||
|
||||
= Placement
|
||||
#place(right, image("/res/tiger.jpg", width: 1.8cm))
|
||||
#place(right, image("/tiger.jpg", width: 1.8cm))
|
||||
Hi there. This is \
|
||||
a placed node. \
|
||||
Unfortunately, \
|
||||
|
@ -31,13 +31,13 @@ nor #xetex!
|
||||
// Test combination of scaling and rotation.
|
||||
#set page(height: 80pt)
|
||||
#align(center + horizon,
|
||||
rotate(20deg, scale(70%, image("/res/tiger.jpg")))
|
||||
rotate(20deg, scale(70%, image("/tiger.jpg")))
|
||||
)
|
||||
|
||||
---
|
||||
// Test setting rotation origin.
|
||||
#rotate(10deg, origin: top + left,
|
||||
image("/res/tiger.jpg", width: 50%)
|
||||
image("/tiger.jpg", width: 50%)
|
||||
)
|
||||
|
||||
---
|
||||
|
@ -38,7 +38,7 @@ My cool #move(dx: 0.7cm, dy: 0.7cm, rotate(10deg, scale(200%, mylink)))
|
||||
// Link containing a block.
|
||||
#link("https://example.com/", block[
|
||||
My cool rhino
|
||||
#move(dx: 10pt, image("/res/rhino.png", width: 1cm))
|
||||
#move(dx: 10pt, image("/rhino.png", width: 1cm))
|
||||
])
|
||||
|
||||
---
|
||||
|
@ -4,24 +4,24 @@
|
||||
// Test loading different image formats.
|
||||
|
||||
// Load an RGBA PNG image.
|
||||
#image("/res/rhino.png")
|
||||
#image("/rhino.png")
|
||||
|
||||
// Load an RGB JPEG image.
|
||||
#set page(height: 60pt)
|
||||
#image("../../res/tiger.jpg")
|
||||
#image("/tiger.jpg")
|
||||
|
||||
---
|
||||
// Test configuring the size and fitting behaviour of images.
|
||||
|
||||
// Set width and height explicitly.
|
||||
#image("/res/rhino.png", width: 30pt)
|
||||
#image("/res/rhino.png", height: 30pt)
|
||||
#image("/rhino.png", width: 30pt)
|
||||
#image("/rhino.png", height: 30pt)
|
||||
|
||||
// Set width and height explicitly and force stretching.
|
||||
#image("/res/monkey.svg", width: 100%, height: 20pt, fit: "stretch")
|
||||
#image("/monkey.svg", width: 100%, height: 20pt, fit: "stretch")
|
||||
|
||||
// Make sure the bounding-box of the image is correct.
|
||||
#align(bottom + right, image("/res/tiger.jpg", width: 40pt))
|
||||
#align(bottom + right, image("/tiger.jpg", width: 40pt))
|
||||
|
||||
---
|
||||
// Test all three fit modes.
|
||||
@ -30,9 +30,9 @@
|
||||
columns: (1fr, 1fr, 1fr),
|
||||
rows: 100%,
|
||||
gutter: 3pt,
|
||||
image("/res/tiger.jpg", width: 100%, height: 100%, fit: "contain"),
|
||||
image("/res/tiger.jpg", width: 100%, height: 100%, fit: "cover"),
|
||||
image("/res/monkey.svg", width: 100%, height: 100%, fit: "stretch"),
|
||||
image("/tiger.jpg", width: 100%, height: 100%, fit: "contain"),
|
||||
image("/tiger.jpg", width: 100%, height: 100%, fit: "cover"),
|
||||
image("/monkey.svg", width: 100%, height: 100%, fit: "stretch"),
|
||||
)
|
||||
|
||||
---
|
||||
@ -40,15 +40,15 @@
|
||||
#set page(height: 60pt)
|
||||
Stuff #parbreak()
|
||||
Stuff
|
||||
#image("/res/rhino.png")
|
||||
#image("/rhino.png")
|
||||
|
||||
---
|
||||
// Test baseline.
|
||||
A #image("/res/tiger.jpg", height: 1cm, width: 80%) B
|
||||
A #image("/tiger.jpg", height: 1cm, width: 80%) B
|
||||
|
||||
---
|
||||
// Test advanced SVG features.
|
||||
#image("/res/pattern.svg")
|
||||
#image("/pattern.svg")
|
||||
|
||||
---
|
||||
// Error: 8-29 file not found (searched at typ/visualize/path/does/not/exist)
|
||||
@ -59,5 +59,5 @@ A #image("/res/tiger.jpg", height: 1cm, width: 80%) B
|
||||
#image("./image.typ")
|
||||
|
||||
---
|
||||
// Error: 8-22 failed to parse svg: found closing tag 'g' instead of 'style' in line 4
|
||||
#image("/res/bad.svg")
|
||||
// Error: 8-18 failed to parse svg: found closing tag 'g' instead of 'style' in line 4
|
||||
#image("/bad.svg")
|
||||
|