feat: update krilla

This commit is contained in:
Tobias Schmitz 2025-07-28 11:51:48 +02:00
parent 5ebe5490b5
commit be04cdb029
No known key found for this signature in database
8 changed files with 17 additions and 17 deletions

4
Cargo.lock generated
View File

@ -1430,7 +1430,7 @@ dependencies = [
[[package]]
name = "krilla"
version = "0.4.0"
source = "git+https://github.com/LaurenzV/krilla?branch=main#9e825532895036c7dfb440710d19271c6ad0473a"
source = "git+https://github.com/LaurenzV/krilla?branch=main#9bfd3adc167080017c6e90a5447b83b376c881ff"
dependencies = [
"base64",
"bumpalo",
@ -1460,7 +1460,7 @@ dependencies = [
[[package]]
name = "krilla-svg"
version = "0.1.0"
source = "git+https://github.com/LaurenzV/krilla?branch=main#9e825532895036c7dfb440710d19271c6ad0473a"
source = "git+https://github.com/LaurenzV/krilla?branch=main#9bfd3adc167080017c6e90a5447b83b376c881ff"
dependencies = [
"flate2",
"fontdb",

View File

@ -1,5 +1,4 @@
use std::collections::{BTreeMap, HashMap, HashSet};
use std::num::NonZeroU64;
use ecow::{EcoVec, eco_format};
use krilla::configure::{Configuration, ValidationError, Validator};
@ -667,8 +666,7 @@ fn convert_error(
/// Convert a krilla location to a span.
fn to_span(loc: Option<krilla::surface::Location>) -> Span {
loc.map(|l| Span::from_raw(NonZeroU64::new(l).unwrap()))
.unwrap_or(Span::detached())
loc.map(Span::from_raw).unwrap_or(Span::detached())
}
fn collect_named_destinations(

View File

@ -47,7 +47,7 @@ pub(crate) fn embed_files(
association_kind,
data: data.into(),
compress,
location: Some(span.into_raw().get()),
location: Some(span.into_raw()),
};
if document.embed_file(file).is_none() {

View File

@ -29,7 +29,7 @@ pub(crate) fn handle_image(
span: Span,
) -> SourceResult<()> {
surface.push_transform(&fc.state().transform().to_krilla());
surface.set_location(span.into_raw().get());
surface.set_location(span.into_raw());
let interpolate = image.scaling() == Smart::Custom(ImageScaling::Smooth);

View File

@ -22,7 +22,7 @@ pub(crate) fn handle_shape(
let mut handle = tags::start_artifact(gc, surface, ArtifactKind::Other);
let surface = handle.surface();
surface.set_location(span.into_raw().get());
surface.set_location(span.into_raw());
surface.push_transform(&fc.state().transform().to_krilla());
if let Some(path) = convert_geometry(&shape.geometry) {

View File

@ -113,8 +113,7 @@ pub(crate) fn handle_start(
// Wrap the figure tag and the sibling caption in a container, if the
// caption is contained within the figure like recommended for tables
// screen readers might ignore it.
// TODO: maybe this could be a `NonStruct` tag?
Tag::P.into()
Tag::NonStruct.into()
} else if let Some(_) = elem.to_packed::<FigureCaption>() {
Tag::Caption.into()
} else if let Some(image) = elem.to_packed::<ImageElem>() {
@ -186,7 +185,7 @@ pub(crate) fn handle_start(
return Ok(());
};
tag.set_location(Some(elem.span().into_raw().get()));
tag.set_location(Some(elem.span().into_raw()));
push_stack(gc, elem, StackEntryKind::Standard(tag))?;
Ok(())
@ -341,7 +340,7 @@ fn pop_stack(gc: &mut GlobalContext, loc: Location, entry: StackEntry) {
// PDF/UA compliance of the structure hierarchy is checked
// elsewhere. While this doesn't make a lot of sense, just
// avoid crashing here.
let tag = Tag::TD.with_location(Some(cell.span().into_raw().get()));
let tag = Tag::TD.with_location(Some(cell.span().into_raw()));
gc.tags.push(TagNode::Group(tag.into(), entry.nodes));
return;
};
@ -791,6 +790,7 @@ impl StackEntryKind {
TagKind::Part(_) => !is_pdf_ua,
TagKind::Article(_) => !is_pdf_ua,
TagKind::Section(_) => !is_pdf_ua,
TagKind::Div(_) => !is_pdf_ua,
TagKind::BlockQuote(_) => !is_pdf_ua,
TagKind::Caption(_) => !is_pdf_ua,
TagKind::TOC(_) => false,
@ -810,6 +810,7 @@ impl StackEntryKind {
TagKind::THead(_) => false,
TagKind::TBody(_) => false,
TagKind::TFoot(_) => false,
TagKind::Span(_) => false,
TagKind::InlineQuote(_) => !is_pdf_ua,
TagKind::Note(_) => !is_pdf_ua,
TagKind::Reference(_) => !is_pdf_ua,
@ -819,6 +820,7 @@ impl StackEntryKind {
TagKind::Annot(_) => !is_pdf_ua,
TagKind::Figure(_) => !is_pdf_ua,
TagKind::Formula(_) => !is_pdf_ua,
TagKind::NonStruct(_) => !is_pdf_ua,
TagKind::Datetime(_) => !is_pdf_ua,
TagKind::Terms(_) => !is_pdf_ua,
TagKind::Title(_) => !is_pdf_ua,

View File

@ -182,14 +182,14 @@ impl TableCtx {
.with_headers(cell.headers)
.with_row_span(rowspan)
.with_col_span(colspan)
.with_location(Some(cell.span.into_raw().get()))
.with_location(Some(cell.span.into_raw()))
.into()
}
TableCellKind::Footer | TableCellKind::Data => Tag::TD
.with_headers(cell.headers)
.with_row_span(rowspan)
.with_col_span(colspan)
.with_location(Some(cell.span.into_raw().get()))
.with_location(Some(cell.span.into_raw()))
.into(),
};
Some(TagNode::Group(tag, cell.nodes))
@ -421,7 +421,7 @@ mod tests {
Tag::TH(scope)
.with_id(Some(id))
.with_headers(ids)
.with_location(Some(Span::detached().into_raw().get()))
.with_location(Some(Span::detached().into_raw()))
.into(),
Vec::new(),
)
@ -432,7 +432,7 @@ mod tests {
TagNode::Group(
Tag::TD
.with_headers(ids)
.with_location(Some(Span::detached().into_raw().get()))
.with_location(Some(Span::detached().into_raw()))
.into(),
Vec::new(),
)

View File

@ -138,6 +138,6 @@ impl krilla::text::Glyph for PdfGlyph {
}
fn location(&self) -> Option<Location> {
Some(self.0.span.0.into_raw().get())
Some(self.0.span.0.into_raw())
}
}