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]] [[package]]
name = "krilla" name = "krilla"
version = "0.4.0" 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 = [ dependencies = [
"base64", "base64",
"bumpalo", "bumpalo",
@ -1460,7 +1460,7 @@ dependencies = [
[[package]] [[package]]
name = "krilla-svg" name = "krilla-svg"
version = "0.1.0" 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 = [ dependencies = [
"flate2", "flate2",
"fontdb", "fontdb",

View File

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

View File

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

View File

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

View File

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

View File

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