From 7d11b3a97667694abf855a464d68c16ffcedfae8 Mon Sep 17 00:00:00 2001 From: Laurenz Stampfl Date: Tue, 18 Mar 2025 15:34:26 +0100 Subject: [PATCH] Fix import errors --- Cargo.lock | 2 ++ Cargo.toml | 4 ++-- crates/typst-pdf/src/convert.rs | 17 +++++++++-------- crates/typst-pdf/src/embed.rs | 2 +- crates/typst-pdf/src/image.rs | 10 +++++----- crates/typst-pdf/src/link.rs | 10 +++++----- crates/typst-pdf/src/metadata.rs | 6 +++--- crates/typst-pdf/src/outline.rs | 4 ++-- crates/typst-pdf/src/paint.rs | 12 ++++++------ crates/typst-pdf/src/shape.rs | 3 +-- crates/typst-pdf/src/util.rs | 7 +++---- 11 files changed, 39 insertions(+), 38 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 2923c2b21..c7dff8ec9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1345,6 +1345,7 @@ dependencies = [ [[package]] name = "krilla" version = "0.3.0" +source = "git+https://github.com/LaurenzV/krilla?rev=3bf71bb#3bf71bb21606700a8685c63a750f2c1a3640c785" dependencies = [ "base64", "bumpalo", @@ -1371,6 +1372,7 @@ dependencies = [ [[package]] name = "krilla-svg" version = "0.3.0" +source = "git+https://github.com/LaurenzV/krilla?rev=3bf71bb#3bf71bb21606700a8685c63a750f2c1a3640c785" dependencies = [ "flate2", "fontdb", diff --git a/Cargo.toml b/Cargo.toml index e6b4263b2..b225a5a0c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -70,8 +70,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 = { path = "../krilla/crates/krilla", features = ["raster-images", "comemo", "rayon"] } -krilla-svg = { path = "../krilla/crates/krilla-svg" } +krilla = { git = "https://github.com/LaurenzV/krilla", rev = "3bf71bb", default-features = false, features = ["raster-images", "comemo", "rayon"] } +krilla-svg = { git = "https://github.com/LaurenzV/krilla", rev = "3bf71bb" } kurbo = "0.11" libfuzzer-sys = "0.4" lipsum = "0.9" diff --git a/crates/typst-pdf/src/convert.rs b/crates/typst-pdf/src/convert.rs index c284a0d87..527ebb07f 100644 --- a/crates/typst-pdf/src/convert.rs +++ b/crates/typst-pdf/src/convert.rs @@ -3,13 +3,14 @@ use std::num::NonZeroU64; use ecow::EcoVec; use krilla::error::KrillaError; -use krilla::interactive::annotation::Annotation; -use krilla::interactive::destination::{NamedDestination, XyzDestination}; -use krilla::interchange::embed::EmbedError; -use krilla::page::PageLabel; -use krilla::path::PathBuilder; +use krilla::annotation::Annotation; +use krilla::destination::{NamedDestination, XyzDestination}; +use krilla::embed::EmbedError; +use krilla::page::{PageLabel, PageSettings}; use krilla::surface::Surface; -use krilla::{Configuration, Document, PageSettings, SerializeSettings, ValidationError}; +use krilla::{Document, SerializeSettings}; +use krilla::configure::{Configuration, ValidationError}; +use krilla::geom::PathBuilder; use krilla_svg::render_svg_glyph; use typst_library::diag::{bail, error, SourceResult}; use typst_library::foundations::NativeElement; @@ -214,7 +215,7 @@ pub(crate) struct GlobalContext<'a> { // Note: In theory, the same image can have multiple spans // if it appears in the document multiple times. We just store the // first appearance, though. - pub(crate) image_to_spans: HashMap, + pub(crate) image_to_spans: HashMap, pub(crate) image_spans: HashSet, pub(crate) document: &'a PagedDocument, pub(crate) options: &'a PdfOptions<'a>, @@ -311,7 +312,7 @@ pub(crate) fn handle_group( .and_then(|p| p.transform(fc.state().transform.to_krilla())); if let Some(clip_path) = &clip_path { - surface.push_clip_path(clip_path, &krilla::graphics::paint::FillRule::NonZero); + surface.push_clip_path(clip_path, &krilla::paint::FillRule::NonZero); } handle_frame(fc, &group.frame, None, surface, context)?; diff --git a/crates/typst-pdf/src/embed.rs b/crates/typst-pdf/src/embed.rs index 6604fe5de..0d501184a 100644 --- a/crates/typst-pdf/src/embed.rs +++ b/crates/typst-pdf/src/embed.rs @@ -1,6 +1,6 @@ use std::sync::Arc; -use krilla::interchange::embed::{AssociationKind, EmbeddedFile}; +use krilla::embed::{AssociationKind, EmbeddedFile}; use krilla::Document; use typst_library::diag::{bail, SourceResult}; use typst_library::foundations::{NativeElement, StyleChain}; diff --git a/crates/typst-pdf/src/image.rs b/crates/typst-pdf/src/image.rs index 055781f16..a43c72c89 100644 --- a/crates/typst-pdf/src/image.rs +++ b/crates/typst-pdf/src/image.rs @@ -2,7 +2,7 @@ use std::hash::{Hash, Hasher}; use std::sync::{Arc, OnceLock}; use image::{DynamicImage, EncodableLayout, GenericImageView, Rgba}; -use krilla::graphics::image::{BitsPerComponent, CustomImage, ImageColorspace}; +use krilla::image::{BitsPerComponent, CustomImage, ImageColorspace}; use krilla::surface::Surface; use krilla_svg::{SurfaceExt, SvgSettings}; use typst_library::diag::{bail, SourceResult}; @@ -167,20 +167,20 @@ impl CustomImage for PdfImage { fn convert_raster( raster: RasterImage, interpolate: bool, -) -> Option { +) -> Option { match raster.format() { RasterFormat::Exchange(e) => match e { ExchangeFormat::Jpg => { let image_data: Arc + Send + Sync> = Arc::new(raster.data().clone()); - krilla::graphics::image::Image::from_jpeg(image_data.into(), interpolate) + krilla::image::Image::from_jpeg(image_data.into(), interpolate) } - _ => krilla::graphics::image::Image::from_custom( + _ => krilla::image::Image::from_custom( PdfImage::new(raster), interpolate, ), }, - RasterFormat::Pixel(_) => krilla::graphics::image::Image::from_custom( + RasterFormat::Pixel(_) => krilla::image::Image::from_custom( PdfImage::new(raster), interpolate, ), diff --git a/crates/typst-pdf/src/link.rs b/crates/typst-pdf/src/link.rs index 65a3d363b..a8f95098d 100644 --- a/crates/typst-pdf/src/link.rs +++ b/crates/typst-pdf/src/link.rs @@ -1,7 +1,7 @@ use krilla::geom::Rect; -use krilla::interactive::action::{Action, LinkAction}; -use krilla::interactive::annotation::{LinkAnnotation, Target}; -use krilla::interactive::destination::XyzDestination; +use krilla::action::{Action, LinkAction}; +use krilla::annotation::{LinkAnnotation, Target}; +use krilla::destination::XyzDestination; use typst_library::layout::{Abs, Point, Size}; use typst_library::model::Destination; @@ -66,7 +66,7 @@ pub(crate) fn handle_link( rect, None, Target::Destination( - krilla::interactive::destination::Destination::Named( + krilla::destination::Destination::Named( nd.clone(), ), ), @@ -86,7 +86,7 @@ pub(crate) fn handle_link( LinkAnnotation::new( rect, None, - Target::Destination(krilla::interactive::destination::Destination::Xyz( + Target::Destination(krilla::destination::Destination::Xyz( XyzDestination::new(page_index, pos.point.to_krilla()), )), ) diff --git a/crates/typst-pdf/src/metadata.rs b/crates/typst-pdf/src/metadata.rs index b22f7c646..004d3263f 100644 --- a/crates/typst-pdf/src/metadata.rs +++ b/crates/typst-pdf/src/metadata.rs @@ -1,7 +1,7 @@ use crate::convert::GlobalContext; use crate::Timezone; use ecow::EcoString; -use krilla::interchange::metadata::{Metadata, TextDirection}; +use krilla::metadata::{Metadata, TextDirection}; use typst_library::foundations::{Datetime, Smart}; use typst_library::layout::Dir; use typst_library::text::Lang; @@ -64,10 +64,10 @@ pub(crate) fn build_metadata(gc: &GlobalContext) -> Metadata { fn convert_date( datetime: Datetime, tz: Option, -) -> Option { +) -> Option { let year = datetime.year().filter(|&y| y >= 0)? as u16; - let mut kd = krilla::interchange::metadata::DateTime::new(year); + let mut kd = krilla::metadata::DateTime::new(year); if let Some(month) = datetime.month() { kd = kd.month(month); diff --git a/crates/typst-pdf/src/outline.rs b/crates/typst-pdf/src/outline.rs index 9e3ccd0bb..f252d52d1 100644 --- a/crates/typst-pdf/src/outline.rs +++ b/crates/typst-pdf/src/outline.rs @@ -1,5 +1,5 @@ -use krilla::interactive::destination::XyzDestination; -use krilla::interchange::outline::{Outline, OutlineNode}; +use krilla::destination::XyzDestination; +use krilla::outline::{Outline, OutlineNode}; use std::num::NonZeroUsize; use typst_library::foundations::{NativeElement, Packed, StyleChain}; use typst_library::layout::Abs; diff --git a/crates/typst-pdf/src/paint.rs b/crates/typst-pdf/src/paint.rs index 7d488b60a..bbdbfc114 100644 --- a/crates/typst-pdf/src/paint.rs +++ b/crates/typst-pdf/src/paint.rs @@ -1,8 +1,8 @@ //! Convert paint types from typst to krilla. -use krilla::geom::NormalizedF32; -use krilla::graphics::color::{self, cmyk, luma, rgb}; -use krilla::graphics::paint::{ +use krilla::num::NormalizedF32; +use krilla::color::{self, cmyk, luma, rgb}; +use krilla::paint::{ Fill, LinearGradient, Pattern, RadialGradient, SpreadMethod, Stop, Stroke, StrokeDash, SweepGradient, }; @@ -65,7 +65,7 @@ fn convert_paint( surface: &mut Surface, state: &State, mut size: Size, -) -> SourceResult<(krilla::graphics::paint::Paint, u8)> { +) -> SourceResult<(krilla::paint::Paint, u8)> { // Edge cases for strokes. if size.x.is_zero() { size.x = Abs::pt(1.0); @@ -129,7 +129,7 @@ fn convert_pattern( on_text: bool, surface: &mut Surface, state: &State, -) -> SourceResult<(krilla::graphics::paint::Paint, u8)> { +) -> SourceResult<(krilla::paint::Paint, u8)> { let transform = correct_transform(state, pattern.unwrap_relative(on_text)); let mut stream_builder = surface.stream_builder(); @@ -153,7 +153,7 @@ fn convert_gradient( on_text: bool, state: &State, size: Size, -) -> (krilla::graphics::paint::Paint, u8) { +) -> (krilla::paint::Paint, u8) { let size = match gradient.unwrap_relative(on_text) { RelativeTo::Self_ => size, RelativeTo::Parent => state.container_size(), diff --git a/crates/typst-pdf/src/shape.rs b/crates/typst-pdf/src/shape.rs index e658ff8fc..2ab00c63f 100644 --- a/crates/typst-pdf/src/shape.rs +++ b/crates/typst-pdf/src/shape.rs @@ -1,5 +1,4 @@ -use krilla::geom::Rect; -use krilla::path::{Path, PathBuilder}; +use krilla::geom::{Path, PathBuilder, Rect}; use krilla::surface::Surface; use typst_library::diag::SourceResult; use typst_library::visualize::{Geometry, Shape}; diff --git a/crates/typst-pdf/src/util.rs b/crates/typst-pdf/src/util.rs index ff6fc07fb..aa122582c 100644 --- a/crates/typst-pdf/src/util.rs +++ b/crates/typst-pdf/src/util.rs @@ -1,13 +1,12 @@ //! Basic utilities for converting typst types to krilla. use krilla::geom as kg; -use krilla::graphics::color::rgb as kr; -use krilla::graphics::paint as kp; -use krilla::path::PathBuilder; +use krilla::geom::PathBuilder; +use krilla::paint as kp; use typst_library::layout::{Abs, Point, Size, Transform}; use typst_library::text::Font; use typst_library::visualize::{ - Color, ColorSpace, Curve, CurveItem, FillRule, LineCap, LineJoin, + Curve, CurveItem, FillRule, LineCap, LineJoin, }; pub(crate) trait SizeExt {