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 = "fontProfileCachePath")]
43 pub font_profile_cache_path: PathBuf,
44
45 #[serde(rename = "fontPaths")]
47 pub font_paths: Vec<PathBuf>,
48
49 #[serde(rename = "noSystemFonts")]
51 pub no_system_fonts: bool,
52
53 #[serde(rename = "withEmbeddedFonts")]
55 #[serde_as(as = "Vec<AsCowBytes>")]
56 pub with_embedded_fonts: Vec<Cow<'static, [u8]>>,
57}
58
59impl From<CompileOpts> for CompileFontOpts {
60 fn from(opts: CompileOpts) -> Self {
61 Self {
62 font_profile_cache_path: opts.font_profile_cache_path,
63 font_paths: opts.font_paths,
64 no_system_fonts: opts.no_system_fonts,
65 with_embedded_fonts: opts.with_embedded_fonts,
66 }
67 }
68}