mirror of
https://github.com/typst/typst
synced 2025-08-15 15:38:33 +08:00
Add alt text
This commit is contained in:
parent
2ffbabe7c9
commit
9285a352d0
4
Cargo.lock
generated
4
Cargo.lock
generated
@ -1345,7 +1345,7 @@ dependencies = [
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "krilla"
|
name = "krilla"
|
||||||
version = "0.3.0"
|
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 = [
|
dependencies = [
|
||||||
"base64",
|
"base64",
|
||||||
"bumpalo",
|
"bumpalo",
|
||||||
@ -1372,7 +1372,7 @@ dependencies = [
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "krilla-svg"
|
name = "krilla-svg"
|
||||||
version = "0.3.0"
|
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 = [
|
dependencies = [
|
||||||
"flate2",
|
"flate2",
|
||||||
"fontdb",
|
"fontdb",
|
||||||
|
@ -71,8 +71,8 @@ if_chain = "1"
|
|||||||
image = { version = "0.25.5", default-features = false, features = ["png", "jpeg", "gif"] }
|
image = { version = "0.25.5", default-features = false, features = ["png", "jpeg", "gif"] }
|
||||||
indexmap = { version = "2", features = ["serde"] }
|
indexmap = { version = "2", features = ["serde"] }
|
||||||
kamadak-exif = "0.6"
|
kamadak-exif = "0.6"
|
||||||
krilla = { git = "https://github.com/LaurenzV/krilla", rev = "5a8af84", default-features = false, features = ["raster-images", "comemo", "rayon"] }
|
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 = "5a8af84" }
|
krilla-svg = { git = "https://github.com/LaurenzV/krilla", rev = "6136d31" }
|
||||||
kurbo = "0.11"
|
kurbo = "0.11"
|
||||||
libfuzzer-sys = "0.4"
|
libfuzzer-sys = "0.4"
|
||||||
lipsum = "0.9"
|
lipsum = "0.9"
|
||||||
|
@ -539,6 +539,11 @@ fn finish(
|
|||||||
hint: "set the title of the document"
|
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<_>>();
|
.collect::<EcoVec<_>>();
|
||||||
@ -549,6 +554,11 @@ fn finish(
|
|||||||
let span = gc.image_to_spans.get(&i).unwrap();
|
let span = gc.image_to_spans.get(&i).unwrap();
|
||||||
bail!(*span, "failed to process image");
|
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")
|
||||||
|
}
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -29,6 +29,10 @@ pub(crate) fn handle_image(
|
|||||||
|
|
||||||
let interpolate = image.scaling() == Smart::Custom(ImageScaling::Smooth);
|
let interpolate = image.scaling() == Smart::Custom(ImageScaling::Smooth);
|
||||||
|
|
||||||
|
if let Some(alt) = image.alt() {
|
||||||
|
surface.start_alt_text(alt);
|
||||||
|
}
|
||||||
|
|
||||||
match image.kind() {
|
match image.kind() {
|
||||||
ImageKind::Raster(raster) => {
|
ImageKind::Raster(raster) => {
|
||||||
let (exif_transform, new_size) = exif_transform(raster, size);
|
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.pop();
|
||||||
surface.reset_location();
|
surface.reset_location();
|
||||||
|
|
||||||
|
@ -53,7 +53,7 @@ pub(crate) fn build_metadata(gc: &GlobalContext) -> Metadata {
|
|||||||
};
|
};
|
||||||
|
|
||||||
if let Some(date) = date.and_then(|d| convert_date(d, tz)) {
|
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);
|
metadata = metadata.text_direction(dir);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user