diff options
| author | Laurenz <laurmaedje@gmail.com> | 2024-02-28 11:06:54 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-02-28 10:06:54 +0000 |
| commit | e16d3f5a67a31154797b4d56cdc6ed142ee2a7cf (patch) | |
| tree | 31dcd2243c2b51bac62fe19e7e60efe5f6289281 /crates/typst-cli | |
| parent | 5036c5acebebe12cbf14338f5413514251d83d1e (diff) | |
Externalize assets (#3515)
Diffstat (limited to 'crates/typst-cli')
| -rw-r--r-- | crates/typst-cli/Cargo.toml | 1 | ||||
| -rw-r--r-- | crates/typst-cli/src/fonts.rs | 26 |
2 files changed, 3 insertions, 24 deletions
diff --git a/crates/typst-cli/Cargo.toml b/crates/typst-cli/Cargo.toml index 9f0f280e..ab9ed6f2 100644 --- a/crates/typst-cli/Cargo.toml +++ b/crates/typst-cli/Cargo.toml @@ -21,6 +21,7 @@ doc = false [dependencies] typst = { workspace = true } +typst-assets = { workspace = true, features = ["fonts"] } typst-macros = { workspace = true } typst-pdf = { workspace = true } typst-render = { workspace = true } diff --git a/crates/typst-cli/src/fonts.rs b/crates/typst-cli/src/fonts.rs index 4ea9f446..a5e454ed 100644 --- a/crates/typst-cli/src/fonts.rs +++ b/crates/typst-cli/src/fonts.rs @@ -107,8 +107,8 @@ impl FontSearcher { /// Add fonts that are embedded in the binary. #[cfg(feature = "embed-fonts")] fn add_embedded(&mut self) { - let mut process = |bytes: &'static [u8]| { - let buffer = typst::foundations::Bytes::from_static(bytes); + for data in typst_assets::fonts() { + let buffer = typst::foundations::Bytes::from_static(data); for (i, font) in Font::iter(buffer).enumerate() { self.book.push(font.info().clone()); self.fonts.push(FontSlot { @@ -117,28 +117,6 @@ impl FontSearcher { font: OnceLock::from(Some(font)), }); } - }; - - macro_rules! add { - ($filename:literal) => { - process(include_bytes!(concat!("../../../assets/fonts/", $filename))); - }; } - - // Embed default fonts. - add!("LinLibertine_R.ttf"); - add!("LinLibertine_RB.ttf"); - add!("LinLibertine_RBI.ttf"); - add!("LinLibertine_RI.ttf"); - add!("NewCMMath-Book.otf"); - add!("NewCMMath-Regular.otf"); - add!("NewCM10-Regular.otf"); - add!("NewCM10-Bold.otf"); - add!("NewCM10-Italic.otf"); - add!("NewCM10-BoldItalic.otf"); - add!("DejaVuSansMono.ttf"); - add!("DejaVuSansMono-Bold.ttf"); - add!("DejaVuSansMono-Oblique.ttf"); - add!("DejaVuSansMono-BoldOblique.ttf"); } } |
