Fix import errors

This commit is contained in:
Laurenz Stampfl 2025-03-18 15:34:26 +01:00
parent 78901fb248
commit 7d11b3a976
11 changed files with 39 additions and 38 deletions

2
Cargo.lock generated
View File

@ -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",

View File

@ -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"

View File

@ -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<krilla::graphics::image::Image, Span>,
pub(crate) image_to_spans: HashMap<krilla::image::Image, Span>,
pub(crate) image_spans: HashSet<Span>,
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)?;

View File

@ -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};

View File

@ -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<krilla::graphics::image::Image> {
) -> Option<krilla::image::Image> {
match raster.format() {
RasterFormat::Exchange(e) => match e {
ExchangeFormat::Jpg => {
let image_data: Arc<dyn AsRef<[u8]> + 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,
),

View File

@ -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()),
)),
)

View File

@ -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<Timezone>,
) -> Option<krilla::interchange::metadata::DateTime> {
) -> Option<krilla::metadata::DateTime> {
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);

View File

@ -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;

View File

@ -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(),

View File

@ -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};

View File

@ -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 {