Add alt text

This commit is contained in:
Laurenz Stampfl 2025-03-19 12:02:09 +01:00
parent 2ffbabe7c9
commit 9285a352d0
5 changed files with 23 additions and 5 deletions

4
Cargo.lock generated
View File

@ -1345,7 +1345,7 @@ dependencies = [
[[package]]
name = "krilla"
version = "0.3.0"
source = "git+https://github.com/LaurenzV/krilla?rev=5a8af84#5a8af8490a5f908cb5b4cf552037c226f59f0823"
source = "git+https://github.com/LaurenzV/krilla?rev=6136d31#6136d31338eebb1d0e3d213f9be7fa3ce68b877e"
dependencies = [
"base64",
"bumpalo",
@ -1372,7 +1372,7 @@ dependencies = [
[[package]]
name = "krilla-svg"
version = "0.3.0"
source = "git+https://github.com/LaurenzV/krilla?rev=5a8af84#5a8af8490a5f908cb5b4cf552037c226f59f0823"
source = "git+https://github.com/LaurenzV/krilla?rev=6136d31#6136d31338eebb1d0e3d213f9be7fa3ce68b877e"
dependencies = [
"flate2",
"fontdb",

View File

@ -71,8 +71,8 @@ if_chain = "1"
image = { version = "0.25.5", default-features = false, features = ["png", "jpeg", "gif"] }
indexmap = { version = "2", features = ["serde"] }
kamadak-exif = "0.6"
krilla = { git = "https://github.com/LaurenzV/krilla", rev = "5a8af84", default-features = false, features = ["raster-images", "comemo", "rayon"] }
krilla-svg = { git = "https://github.com/LaurenzV/krilla", rev = "5a8af84" }
krilla = { git = "https://github.com/LaurenzV/krilla", rev = "6136d31", default-features = false, features = ["raster-images", "comemo", "rayon"] }
krilla-svg = { git = "https://github.com/LaurenzV/krilla", rev = "6136d31" }
kurbo = "0.11"
libfuzzer-sys = "0.4"
lipsum = "0.9"

View File

@ -539,6 +539,11 @@ fn finish(
hint: "set the title of the document"
)
}
ValidationError::MissingDocumentDate => {
error!(Span::detached(), "{prefix} missing document date";
hint: "set the date of the document"
)
}
}
})
.collect::<EcoVec<_>>();
@ -549,6 +554,11 @@ fn finish(
let span = gc.image_to_spans.get(&i).unwrap();
bail!(*span, "failed to process image");
}
KrillaError::SixteenBitImage(image, _) => {
let span = gc.image_to_spans.get(&image).unwrap();
bail!(*span, "16 bit images are not supported in this export mode";
hint: "convert the image to 8 bit instead")
}
},
}
}

View File

@ -29,6 +29,10 @@ pub(crate) fn handle_image(
let interpolate = image.scaling() == Smart::Custom(ImageScaling::Smooth);
if let Some(alt) = image.alt() {
surface.start_alt_text(alt);
}
match image.kind() {
ImageKind::Raster(raster) => {
let (exif_transform, new_size) = exif_transform(raster, size);
@ -56,6 +60,10 @@ pub(crate) fn handle_image(
}
}
if image.alt().is_some() {
surface.end_alt_text();
}
surface.pop();
surface.reset_location();

View File

@ -53,7 +53,7 @@ pub(crate) fn build_metadata(gc: &GlobalContext) -> Metadata {
};
if let Some(date) = date.and_then(|d| convert_date(d, tz)) {
metadata = metadata.modification_date(date).creation_date(date);
metadata = metadata.creation_date(date);
}
metadata = metadata.text_direction(dir);