mirror of
https://github.com/typst/typst
synced 2025-06-08 13:16:24 +08:00
Re-add CLI supports for many standards at the same time
This commit is contained in:
parent
1ac74d472d
commit
c14cddd55a
152
Cargo.lock
generated
152
Cargo.lock
generated
@ -806,6 +806,20 @@ dependencies = [
|
|||||||
"roxmltree",
|
"roxmltree",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "fontdb"
|
||||||
|
version = "0.21.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "37be9fc20d966be438cd57a45767f73349477fb0f85ce86e000557f787298afb"
|
||||||
|
dependencies = [
|
||||||
|
"fontconfig-parser",
|
||||||
|
"log",
|
||||||
|
"memmap2",
|
||||||
|
"slotmap",
|
||||||
|
"tinyvec",
|
||||||
|
"ttf-parser",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "fontdb"
|
name = "fontdb"
|
||||||
version = "0.22.0"
|
version = "0.22.0"
|
||||||
@ -1319,23 +1333,23 @@ dependencies = [
|
|||||||
"comemo",
|
"comemo",
|
||||||
"flate2",
|
"flate2",
|
||||||
"float-cmp 0.10.0",
|
"float-cmp 0.10.0",
|
||||||
"fontdb",
|
"fontdb 0.22.0",
|
||||||
"gif",
|
"gif",
|
||||||
"image-webp",
|
"image-webp",
|
||||||
"imagesize",
|
"imagesize",
|
||||||
"miniz_oxide",
|
"miniz_oxide",
|
||||||
"once_cell",
|
"once_cell",
|
||||||
"pdf-writer",
|
"pdf-writer 0.12.0 (git+https://github.com/LaurenzV/pdf-writer?rev=f95a19c)",
|
||||||
"rayon",
|
"rayon",
|
||||||
"resvg",
|
"resvg 0.44.0",
|
||||||
"rustybuzz",
|
"rustybuzz",
|
||||||
"siphasher 1.0.1",
|
"siphasher 1.0.1",
|
||||||
"skrifa",
|
"skrifa",
|
||||||
"subsetter",
|
"subsetter 0.2.0 (git+https://github.com/typst/subsetter?rev=172416a)",
|
||||||
"tiny-skia",
|
"tiny-skia",
|
||||||
"tiny-skia-path",
|
"tiny-skia-path",
|
||||||
"usvg",
|
"usvg 0.44.0",
|
||||||
"xmp-writer",
|
"xmp-writer 0.3.0 (git+https://github.com/LaurenzV/xmp-writer?rev=1c2b8ae9)",
|
||||||
"yoke",
|
"yoke",
|
||||||
"zune-jpeg",
|
"zune-jpeg",
|
||||||
"zune-png",
|
"zune-png",
|
||||||
@ -1767,6 +1781,18 @@ version = "0.2.1"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "8835116a5c179084a830efb3adc117ab007512b535bc1a21c991d3b32a6b44dd"
|
checksum = "8835116a5c179084a830efb3adc117ab007512b535bc1a21c991d3b32a6b44dd"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "pdf-writer"
|
||||||
|
version = "0.12.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "be17f48d7fbbd22c6efedb58af5d409aa578e407f40b29a0bcb4e66ed84c5c98"
|
||||||
|
dependencies = [
|
||||||
|
"bitflags 2.6.0",
|
||||||
|
"itoa",
|
||||||
|
"memchr",
|
||||||
|
"ryu",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "pdf-writer"
|
name = "pdf-writer"
|
||||||
version = "0.12.0"
|
version = "0.12.0"
|
||||||
@ -2086,6 +2112,23 @@ version = "0.8.5"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c"
|
checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "resvg"
|
||||||
|
version = "0.43.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "c7314563c59c7ce31c18e23ad3dd092c37b928a0fa4e1c0a1a6504351ab411d1"
|
||||||
|
dependencies = [
|
||||||
|
"gif",
|
||||||
|
"image-webp",
|
||||||
|
"log",
|
||||||
|
"pico-args",
|
||||||
|
"rgb",
|
||||||
|
"svgtypes",
|
||||||
|
"tiny-skia",
|
||||||
|
"usvg 0.43.0",
|
||||||
|
"zune-jpeg",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "resvg"
|
name = "resvg"
|
||||||
version = "0.44.0"
|
version = "0.44.0"
|
||||||
@ -2099,7 +2142,7 @@ dependencies = [
|
|||||||
"rgb",
|
"rgb",
|
||||||
"svgtypes",
|
"svgtypes",
|
||||||
"tiny-skia",
|
"tiny-skia",
|
||||||
"usvg",
|
"usvg 0.44.0",
|
||||||
"zune-jpeg",
|
"zune-jpeg",
|
||||||
]
|
]
|
||||||
|
|
||||||
@ -2468,11 +2511,37 @@ dependencies = [
|
|||||||
"syn",
|
"syn",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "subsetter"
|
||||||
|
version = "0.2.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "74f98178f34057d4d4de93d68104007c6dea4dfac930204a69ab4622daefa648"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "subsetter"
|
name = "subsetter"
|
||||||
version = "0.2.0"
|
version = "0.2.0"
|
||||||
source = "git+https://github.com/typst/subsetter?rev=172416a#172416a806246e6e9010d400d5690ca7a026e53d"
|
source = "git+https://github.com/typst/subsetter?rev=172416a#172416a806246e6e9010d400d5690ca7a026e53d"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "svg2pdf"
|
||||||
|
version = "0.12.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "5014c9dadcf318fb7ef8c16438e95abcc9de1ae24d60d5bccc64c55100c50364"
|
||||||
|
dependencies = [
|
||||||
|
"fontdb 0.21.0",
|
||||||
|
"image",
|
||||||
|
"log",
|
||||||
|
"miniz_oxide",
|
||||||
|
"once_cell",
|
||||||
|
"pdf-writer 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
"resvg 0.43.0",
|
||||||
|
"siphasher 1.0.1",
|
||||||
|
"subsetter 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
"tiny-skia",
|
||||||
|
"ttf-parser",
|
||||||
|
"usvg 0.43.0",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "svgtypes"
|
name = "svgtypes"
|
||||||
version = "0.15.2"
|
version = "0.15.2"
|
||||||
@ -2919,7 +2988,7 @@ dependencies = [
|
|||||||
"ecow",
|
"ecow",
|
||||||
"env_proxy",
|
"env_proxy",
|
||||||
"flate2",
|
"flate2",
|
||||||
"fontdb",
|
"fontdb 0.22.0",
|
||||||
"native-tls",
|
"native-tls",
|
||||||
"once_cell",
|
"once_cell",
|
||||||
"openssl",
|
"openssl",
|
||||||
@ -2976,7 +3045,7 @@ dependencies = [
|
|||||||
"csv",
|
"csv",
|
||||||
"ecow",
|
"ecow",
|
||||||
"flate2",
|
"flate2",
|
||||||
"fontdb",
|
"fontdb 0.22.0",
|
||||||
"hayagriva",
|
"hayagriva",
|
||||||
"icu_properties",
|
"icu_properties",
|
||||||
"icu_provider",
|
"icu_provider",
|
||||||
@ -3015,7 +3084,7 @@ dependencies = [
|
|||||||
"unicode-math-class",
|
"unicode-math-class",
|
||||||
"unicode-segmentation",
|
"unicode-segmentation",
|
||||||
"unscanny",
|
"unscanny",
|
||||||
"usvg",
|
"usvg 0.44.0",
|
||||||
"wasmi",
|
"wasmi",
|
||||||
"xmlwriter",
|
"xmlwriter",
|
||||||
]
|
]
|
||||||
@ -3047,6 +3116,32 @@ dependencies = [
|
|||||||
"typst-utils",
|
"typst-utils",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "typst-pdf-old"
|
||||||
|
version = "0.12.0"
|
||||||
|
dependencies = [
|
||||||
|
"arrayvec",
|
||||||
|
"base64",
|
||||||
|
"bytemuck",
|
||||||
|
"comemo",
|
||||||
|
"ecow",
|
||||||
|
"image",
|
||||||
|
"indexmap 2.6.0",
|
||||||
|
"miniz_oxide",
|
||||||
|
"pdf-writer 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
"serde",
|
||||||
|
"subsetter 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
"svg2pdf",
|
||||||
|
"ttf-parser",
|
||||||
|
"typst-assets",
|
||||||
|
"typst-library",
|
||||||
|
"typst-macros",
|
||||||
|
"typst-syntax",
|
||||||
|
"typst-timing",
|
||||||
|
"typst-utils",
|
||||||
|
"xmp-writer 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "typst-realize"
|
name = "typst-realize"
|
||||||
version = "0.12.0"
|
version = "0.12.0"
|
||||||
@ -3071,7 +3166,7 @@ dependencies = [
|
|||||||
"comemo",
|
"comemo",
|
||||||
"image",
|
"image",
|
||||||
"pixglyph",
|
"pixglyph",
|
||||||
"resvg",
|
"resvg 0.44.0",
|
||||||
"tiny-skia",
|
"tiny-skia",
|
||||||
"ttf-parser",
|
"ttf-parser",
|
||||||
"typst-library",
|
"typst-library",
|
||||||
@ -3293,6 +3388,33 @@ dependencies = [
|
|||||||
"serde",
|
"serde",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "usvg"
|
||||||
|
version = "0.43.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "6803057b5cbb426e9fb8ce2216f3a9b4ca1dd2c705ba3cbebc13006e437735fd"
|
||||||
|
dependencies = [
|
||||||
|
"base64",
|
||||||
|
"data-url",
|
||||||
|
"flate2",
|
||||||
|
"fontdb 0.21.0",
|
||||||
|
"imagesize",
|
||||||
|
"kurbo",
|
||||||
|
"log",
|
||||||
|
"pico-args",
|
||||||
|
"roxmltree",
|
||||||
|
"rustybuzz",
|
||||||
|
"simplecss",
|
||||||
|
"siphasher 1.0.1",
|
||||||
|
"strict-num",
|
||||||
|
"svgtypes",
|
||||||
|
"tiny-skia-path",
|
||||||
|
"unicode-bidi",
|
||||||
|
"unicode-script",
|
||||||
|
"unicode-vo",
|
||||||
|
"xmlwriter",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "usvg"
|
name = "usvg"
|
||||||
version = "0.44.0"
|
version = "0.44.0"
|
||||||
@ -3302,7 +3424,7 @@ dependencies = [
|
|||||||
"base64",
|
"base64",
|
||||||
"data-url",
|
"data-url",
|
||||||
"flate2",
|
"flate2",
|
||||||
"fontdb",
|
"fontdb 0.22.0",
|
||||||
"imagesize",
|
"imagesize",
|
||||||
"kurbo",
|
"kurbo",
|
||||||
"log",
|
"log",
|
||||||
@ -3687,6 +3809,12 @@ version = "0.1.0"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "ec7a2a501ed189703dba8b08142f057e887dfc4b2cc4db2d343ac6376ba3e0b9"
|
checksum = "ec7a2a501ed189703dba8b08142f057e887dfc4b2cc4db2d343ac6376ba3e0b9"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "xmp-writer"
|
||||||
|
version = "0.3.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "8254499146a4fd0c86e3e99cf4a9f468f595808fb49ff8f3e495f2b117bf4ebc"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "xmp-writer"
|
name = "xmp-writer"
|
||||||
version = "0.3.0"
|
version = "0.3.0"
|
||||||
|
@ -245,10 +245,11 @@ pub struct CompileArgs {
|
|||||||
#[arg(long = "pdf-version")]
|
#[arg(long = "pdf-version")]
|
||||||
pub pdf_version: Option<PdfVersion>,
|
pub pdf_version: Option<PdfVersion>,
|
||||||
|
|
||||||
/// A PDF standard that Typst will enforce
|
/// A number of PDF standards that Typst will enforce
|
||||||
/// conformance with.
|
/// conformance with (currently, only one standard at a time
|
||||||
#[arg(long = "pdf-standard")]
|
/// is supported).
|
||||||
pub pdf_standard: Option<PdfStandard>,
|
#[arg(long = "pdf-standard", value_delimiter = ',')]
|
||||||
|
pub pdf_standard: Vec<PdfStandard>,
|
||||||
|
|
||||||
/// The PPI (pixels per inch) to use for PNG export.
|
/// The PPI (pixels per inch) to use for PNG export.
|
||||||
#[arg(long = "ppi", default_value_t = 144.0)]
|
#[arg(long = "ppi", default_value_t = 144.0)]
|
||||||
|
@ -64,8 +64,8 @@ pub struct CompileConfig {
|
|||||||
pub open: Option<Option<String>>,
|
pub open: Option<Option<String>>,
|
||||||
/// The version that should be used to export the PDF.
|
/// The version that should be used to export the PDF.
|
||||||
pub pdf_version: Option<PdfVersion>,
|
pub pdf_version: Option<PdfVersion>,
|
||||||
/// A standard the PDF should conform to.
|
/// A list of standards the PDF should conform to.
|
||||||
pub pdf_standard: Option<PdfStandard>,
|
pub pdf_standard: Vec<PdfStandard>,
|
||||||
/// A path to write a Makefile rule describing the current compilation.
|
/// A path to write a Makefile rule describing the current compilation.
|
||||||
pub make_deps: Option<PathBuf>,
|
pub make_deps: Option<PathBuf>,
|
||||||
/// The PPI (pixels per inch) to use for PNG export.
|
/// The PPI (pixels per inch) to use for PNG export.
|
||||||
@ -155,7 +155,7 @@ impl CompileConfig {
|
|||||||
export_cache: ExportCache::new(),
|
export_cache: ExportCache::new(),
|
||||||
#[cfg(feature = "http-server")]
|
#[cfg(feature = "http-server")]
|
||||||
server,
|
server,
|
||||||
pdf_standard: args.pdf_standard,
|
pdf_standard: args.pdf_standard.clone(),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -276,6 +276,25 @@ fn export_pdf(document: &PagedDocument, config: &CompileConfig) -> SourceResult<
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
let validator = match config.pdf_standard.first() {
|
||||||
|
None => Validator::None,
|
||||||
|
Some(s) => {
|
||||||
|
if config.pdf_standard.len() > 1 {
|
||||||
|
bail!(Span::detached(), "cannot export using more than one PDF standard";
|
||||||
|
hint: "typst currently only supports export using \
|
||||||
|
one standard at the same time");
|
||||||
|
} else {
|
||||||
|
match s {
|
||||||
|
PdfStandard::A_1b => Validator::A1_B,
|
||||||
|
PdfStandard::A_2b => Validator::A2_B,
|
||||||
|
PdfStandard::A_2u => Validator::A2_U,
|
||||||
|
PdfStandard::A_3b => Validator::A3_B,
|
||||||
|
PdfStandard::A_3u => Validator::A3_U,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
let options = PdfOptions {
|
let options = PdfOptions {
|
||||||
ident: Smart::Auto,
|
ident: Smart::Auto,
|
||||||
timestamp,
|
timestamp,
|
||||||
@ -286,16 +305,7 @@ fn export_pdf(document: &PagedDocument, config: &CompileConfig) -> SourceResult<
|
|||||||
PdfVersion::V_1_6 => typst_pdf::PdfVersion::Pdf16,
|
PdfVersion::V_1_6 => typst_pdf::PdfVersion::Pdf16,
|
||||||
PdfVersion::V_1_7 => typst_pdf::PdfVersion::Pdf17,
|
PdfVersion::V_1_7 => typst_pdf::PdfVersion::Pdf17,
|
||||||
}),
|
}),
|
||||||
validator: config
|
validator,
|
||||||
.pdf_standard
|
|
||||||
.map(|s| match s {
|
|
||||||
PdfStandard::A_1b => Validator::A1_B,
|
|
||||||
PdfStandard::A_2b => Validator::A2_B,
|
|
||||||
PdfStandard::A_2u => Validator::A2_U,
|
|
||||||
PdfStandard::A_3b => Validator::A3_B,
|
|
||||||
PdfStandard::A_3u => Validator::A3_U,
|
|
||||||
})
|
|
||||||
.unwrap_or(Validator::None),
|
|
||||||
};
|
};
|
||||||
let buffer = typst_pdf::pdf(document, &options)?;
|
let buffer = typst_pdf::pdf(document, &options)?;
|
||||||
config
|
config
|
||||||
|
Loading…
x
Reference in New Issue
Block a user