diff --git a/Cargo.lock b/Cargo.lock index 5f386790f..2923c2b21 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1345,14 +1345,11 @@ dependencies = [ [[package]] name = "krilla" version = "0.3.0" -source = "git+https://github.com/LaurenzV/krilla?rev=5978f97#5978f97aaacc9233d564b76773400218a7cdc21d" dependencies = [ "base64", "bumpalo", "comemo", - "flate2", "float-cmp 0.10.0", - "fontdb", "gif", "image-webp", "imagesize", @@ -1360,20 +1357,30 @@ dependencies = [ "once_cell", "pdf-writer", "rayon", - "resvg", "rustybuzz", "siphasher", "skrifa", "subsetter", - "tiny-skia", "tiny-skia-path", - "usvg", "xmp-writer", "yoke 0.8.0", "zune-jpeg", "zune-png", ] +[[package]] +name = "krilla-svg" +version = "0.3.0" +dependencies = [ + "flate2", + "fontdb", + "krilla", + "resvg", + "tiny-skia", + "usvg", + "zune-png", +] + [[package]] name = "kurbo" version = "0.11.1" @@ -3084,6 +3091,7 @@ dependencies = [ "ecow", "image", "krilla", + "krilla-svg", "typst-assets", "typst-library", "typst-macros", diff --git a/Cargo.toml b/Cargo.toml index 5d4699609..e6b4263b2 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -70,7 +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 = { git = "https://github.com/LaurenzV/krilla", rev = "5978f97", features = ["svg", "raster-images", "comemo", "rayon"] } +krilla = { path = "../krilla/crates/krilla", features = ["raster-images", "comemo", "rayon"] } +krilla-svg = { path = "../krilla/crates/krilla-svg" } kurbo = "0.11" libfuzzer-sys = "0.4" lipsum = "0.9" diff --git a/crates/typst-pdf/Cargo.toml b/crates/typst-pdf/Cargo.toml index d9c4ea846..3deda2cc8 100644 --- a/crates/typst-pdf/Cargo.toml +++ b/crates/typst-pdf/Cargo.toml @@ -24,6 +24,7 @@ comemo = { workspace = true } ecow = { workspace = true } image = { workspace = true } krilla = { workspace = true } +krilla-svg = { workspace = true } [lints] workspace = true diff --git a/crates/typst-pdf/src/convert.rs b/crates/typst-pdf/src/convert.rs index b3ba8a650..d4dea1dfc 100644 --- a/crates/typst-pdf/src/convert.rs +++ b/crates/typst-pdf/src/convert.rs @@ -10,6 +10,7 @@ use krilla::page::PageLabel; use krilla::path::PathBuilder; use krilla::surface::Surface; use krilla::{Configuration, Document, PageSettings, SerializeSettings, ValidationError}; +use krilla_svg::render_svg_glyph; use typst_library::diag::{bail, error, SourceResult}; use typst_library::foundations::NativeElement; use typst_library::introspection::Location; @@ -46,6 +47,7 @@ pub fn convert( cmyk_profile: None, configuration, enable_tagging: false, + render_svg_glyph_fn: render_svg_glyph }; let mut document = Document::new_with(settings); @@ -302,6 +304,7 @@ pub(crate) fn handle_group( .clip .as_ref() .and_then(|p| { + let mut builder = PathBuilder::new(); convert_path(p, &mut builder); builder.finish() diff --git a/crates/typst-pdf/src/image.rs b/crates/typst-pdf/src/image.rs index 29f77131c..1648c471b 100644 --- a/crates/typst-pdf/src/image.rs +++ b/crates/typst-pdf/src/image.rs @@ -4,7 +4,7 @@ use std::sync::{Arc, OnceLock}; use image::{DynamicImage, EncodableLayout, GenericImageView, Rgba}; use krilla::image::{BitsPerComponent, CustomImage, ImageColorspace}; use krilla::surface::Surface; -use krilla::SvgSettings; +use krilla_svg::{SurfaceExt, SvgSettings}; use typst_library::diag::{bail, SourceResult}; use typst_library::foundations::Smart; use typst_library::layout::Size; diff --git a/crates/typst-pdf/src/paint.rs b/crates/typst-pdf/src/paint.rs index cce6e98be..3e02753ce 100644 --- a/crates/typst-pdf/src/paint.rs +++ b/crates/typst-pdf/src/paint.rs @@ -190,9 +190,9 @@ fn convert_gradient( cx: radial.center.x.get() as f32, cy: radial.center.y.get() as f32, cr: radial.radius.get() as f32, - transform: base_transform.to_krilla().pre_concat( - krilla::geom::Transform::from_scale(size.x.to_f32(), size.y.to_f32()), - ), + transform: base_transform.pre_concat( + Transform::scale(Ratio::new(size.x.to_f32() as f64), Ratio::new(size.y.to_f32() as f64)), + ).to_krilla(), spread_method: SpreadMethod::Pad, stops: stops.into(), anti_alias: gradient.anti_alias(),