summaryrefslogtreecommitdiff
path: root/crates/typst-cli/src/compile.rs
diff options
context:
space:
mode:
authorLaurenz Stampfl <47084093+LaurenzV@users.noreply.github.com>2025-04-01 16:42:52 +0200
committerGitHub <noreply@github.com>2025-04-01 14:42:52 +0000
commit96dd67e011bb317cf78683bcf1edfdfca5e7b6b3 (patch)
tree900a0c4e7723af4289685af35d788041055ad4a2 /crates/typst-cli/src/compile.rs
parent012e14d40cb44997630cf6469a446f217f2e9057 (diff)
Switch PDF backend to `krilla` (#5420)
Co-authored-by: Laurenz <laurmaedje@gmail.com>
Diffstat (limited to 'crates/typst-cli/src/compile.rs')
-rw-r--r--crates/typst-cli/src/compile.rs39
1 files changed, 25 insertions, 14 deletions
diff --git a/crates/typst-cli/src/compile.rs b/crates/typst-cli/src/compile.rs
index ae71e298..4edb4c32 100644
--- a/crates/typst-cli/src/compile.rs
+++ b/crates/typst-cli/src/compile.rs
@@ -63,8 +63,7 @@ pub struct CompileConfig {
/// Opens the output file with the default viewer or a specific program after
/// compilation.
pub open: Option<Option<String>>,
- /// One (or multiple comma-separated) PDF standards that Typst will enforce
- /// conformance with.
+ /// A list of standards the PDF should conform to.
pub pdf_standards: PdfStandards,
/// A path to write a Makefile rule describing the current compilation.
pub make_deps: Option<PathBuf>,
@@ -130,18 +129,9 @@ impl CompileConfig {
PageRanges::new(export_ranges.iter().map(|r| r.0.clone()).collect())
});
- let pdf_standards = {
- let list = args
- .pdf_standard
- .iter()
- .map(|standard| match standard {
- PdfStandard::V_1_7 => typst_pdf::PdfStandard::V_1_7,
- PdfStandard::A_2b => typst_pdf::PdfStandard::A_2b,
- PdfStandard::A_3b => typst_pdf::PdfStandard::A_3b,
- })
- .collect::<Vec<_>>();
- PdfStandards::new(&list)?
- };
+ let pdf_standards = PdfStandards::new(
+ &args.pdf_standard.iter().copied().map(Into::into).collect::<Vec<_>>(),
+ )?;
#[cfg(feature = "http-server")]
let server = match watch {
@@ -295,6 +285,7 @@ fn export_pdf(document: &PagedDocument, config: &CompileConfig) -> SourceResult<
})
}
};
+
let options = PdfOptions {
ident: Smart::Auto,
timestamp,
@@ -765,3 +756,23 @@ impl<'a> codespan_reporting::files::Files<'a> for SystemWorld {
})
}
}
+
+impl From<PdfStandard> for typst_pdf::PdfStandard {
+ fn from(standard: PdfStandard) -> Self {
+ match standard {
+ PdfStandard::V_1_4 => typst_pdf::PdfStandard::V_1_4,
+ PdfStandard::V_1_5 => typst_pdf::PdfStandard::V_1_5,
+ PdfStandard::V_1_6 => typst_pdf::PdfStandard::V_1_6,
+ PdfStandard::V_1_7 => typst_pdf::PdfStandard::V_1_7,
+ PdfStandard::V_2_0 => typst_pdf::PdfStandard::V_2_0,
+ PdfStandard::A_1b => typst_pdf::PdfStandard::A_1b,
+ PdfStandard::A_2b => typst_pdf::PdfStandard::A_2b,
+ PdfStandard::A_2u => typst_pdf::PdfStandard::A_2u,
+ PdfStandard::A_3b => typst_pdf::PdfStandard::A_3b,
+ PdfStandard::A_3u => typst_pdf::PdfStandard::A_3u,
+ PdfStandard::A_4 => typst_pdf::PdfStandard::A_4,
+ PdfStandard::A_4f => typst_pdf::PdfStandard::A_4f,
+ PdfStandard::A_4e => typst_pdf::PdfStandard::A_4e,
+ }
+ }
+}