1use std::borrow::Cow;
2use std::path::PathBuf;
3
4use serde::{Deserialize, Serialize};
5use serde_with::serde_as;
6use tinymist_std::AsCowBytes;
7use typst::foundations::Dict;
8
9use crate::EntryOpts;
10
11#[serde_as]
12#[derive(Debug, Clone, PartialEq, Default, Serialize, Deserialize)]
13pub struct CompileOpts {
14 pub entry: EntryOpts,
16
17 pub inputs: Dict,
19
20 #[serde(rename = "fontProfileCachePath")]
22 pub font_profile_cache_path: PathBuf,
23
24 #[serde(rename = "fontPaths")]
26 pub font_paths: Vec<PathBuf>,
27
28 #[serde(rename = "noSystemFonts")]
30 pub no_system_fonts: bool,
31
32 #[serde(rename = "withEmbeddedFonts")]
34 #[serde_as(as = "Vec<AsCowBytes>")]
35 pub with_embedded_fonts: Vec<Cow<'static, [u8]>>,
36}
37
38#[serde_as]
39#[derive(Debug, Clone, PartialEq, Default, Serialize, Deserialize)]
40pub struct CompileFontOpts {
41 #[serde(rename = "fontPaths")]
43 pub font_paths: Vec<PathBuf>,
44
45 #[serde(rename = "noSystemFonts")]
47 pub no_system_fonts: bool,
48
49 #[serde(rename = "withEmbeddedFonts")]
51 #[serde_as(as = "Vec<AsCowBytes>")]
52 pub with_embedded_fonts: Vec<Cow<'static, [u8]>>,
53}
54
55impl From<CompileOpts> for CompileFontOpts {
56 fn from(opts: CompileOpts) -> Self {
57 Self {
58 font_paths: opts.font_paths,
59 no_system_fonts: opts.no_system_fonts,
60 with_embedded_fonts: opts.with_embedded_fonts,
61 }
62 }
63}