Render native XeTeX PNG, JPEG and BMP graphics

This commit is contained in:
gloamxun committed 2026-11-21 13:58:26 +08:00
1 parent 794c2f9b2c
commit 2bd6e19519
22 files changed
+821 -120

No files matched your search

@@ -0,0 +1,24 @@
//! ICC profile metadata needed by PDF image color spaces.
pub(super) fn intent(profile: &[u8], components: u8) -> Option<&'static str> {
let header = profile.get(..128)?;
let size = u32::from_be_bytes(header[..4].try_into().unwrap()) as usize;
let signature: &[u8] = match components {
1 => b"GRAY",
3 => b"RGB ",
4 => b"CMYK",
_ => return None,
};
if size != profile.len() || &header[16..20] != signature || &header[36..40] != b"acsp" {
return None;
}
let intent = u32::from_be_bytes(header[64..68].try_into().unwrap());
[
"Perceptual",
"RelativeColorimetric",
"Saturation",
"AbsoluteColorimetric",
]
.get(intent as usize)
.copied()
}