From e678014586b1800d4c7956a50d9d4030f6ceddf6 Mon Sep 17 00:00:00 2001 From: Andrej Shadura Date: Wed, 18 Nov 2020 14:12:02 +0100 Subject: Don't build raqote or skia backends yet Gbp-Pq: Name no-raqote-or-skia.patch --- Cargo.toml | 9 --------- capi/Cargo.toml | 4 ++-- tools/rendersvg/Cargo.toml | 4 ++-- usvg/Cargo.toml | 6 +++--- 4 files changed, 7 insertions(+), 16 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 14b203f..72be109 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -14,7 +14,6 @@ categories = ["multimedia::images"] [workspace] members = [ "bindings/resvg-qt", - "bindings/resvg-skia", "capi", "tools/rendersvg", "tools/usvg", @@ -37,17 +36,9 @@ cairo-rs = { version = "0.7.1", default-features = false, features = ["png"], op # qt backend resvg-qt = { path = "bindings/resvg-qt", version = "0.8", optional = true } -# raqote backend -raqote = { version = "0.6.1", default-features = false, optional = true } - -# skia backend -resvg-skia = { path = "bindings/resvg-skia", version = "0.8", optional = true } - [features] cairo-backend = ["cairo-rs", "png/png-encoding"] qt-backend = ["resvg-qt"] -raqote-backend = ["raqote"] -skia-backend = ["resvg-skia"] [package.metadata.docs.rs] all-features = true diff --git a/capi/Cargo.toml b/capi/Cargo.toml index 72221ef..87608b9 100644 --- a/capi/Cargo.toml +++ b/capi/Cargo.toml @@ -21,5 +21,5 @@ cairo-sys-rs = { version = "0.9.0", optional = true } [features] cairo-backend = ["resvg/cairo-backend", "cairo-sys-rs"] qt-backend = ["resvg/qt-backend"] -skia-backend = ["resvg/skia-backend"] -raqote-backend = ["resvg/raqote-backend"] +# skia-backend = ["resvg/skia-backend"] +# raqote-backend = ["resvg/raqote-backend"] diff --git a/tools/rendersvg/Cargo.toml b/tools/rendersvg/Cargo.toml index 257a658..b2c0a48 100644 --- a/tools/rendersvg/Cargo.toml +++ b/tools/rendersvg/Cargo.toml @@ -17,5 +17,5 @@ time = "0.1" [features] cairo-backend = ["resvg/cairo-backend"] qt-backend = ["resvg/qt-backend"] -raqote-backend = ["resvg/raqote-backend"] -skia-backend = ["resvg/skia-backend"] +# raqote-backend = ["resvg/raqote-backend"] +# skia-backend = ["resvg/skia-backend"] diff --git a/usvg/Cargo.toml b/usvg/Cargo.toml index 57a6956..f921a4d 100644 --- a/usvg/Cargo.toml +++ b/usvg/Cargo.toml @@ -17,9 +17,9 @@ workspace = ".." travis-ci = { repository = "RazrFalcon/resvg" } [dependencies] -base64 = "0.10" -data-url = "0.1" -kurbo = "0.2.3" +base64 = "0" +data-url = "0" +kurbo = "0.2" libflate = "0.1.25" log = "0.4" rctree = "0.3" -- cgit v1.2.3 From ab68486318210350612777d8400f33a630cf4fe9 Mon Sep 17 00:00:00 2001 From: Evgeniy Reizner Date: Mon, 23 Dec 2019 01:54:04 +0200 Subject: Update or relax dependencies Gbp-Pq: Name deps.patch --- usvg/Cargo.toml | 6 +-- usvg/src/convert/text/shaper.rs | 17 ++++---- usvg/src/tree/pathdata.rs | 86 +++++++++++++++++++---------------------- 3 files changed, 50 insertions(+), 59 deletions(-) diff --git a/usvg/Cargo.toml b/usvg/Cargo.toml index f921a4d..f873052 100644 --- a/usvg/Cargo.toml +++ b/usvg/Cargo.toml @@ -19,7 +19,7 @@ travis-ci = { repository = "RazrFalcon/resvg" } [dependencies] base64 = "0" data-url = "0" -kurbo = "0.2" +kurbo = "0.7" libflate = "0.1.25" log = "0.4" rctree = "0.3" @@ -28,13 +28,13 @@ xmlwriter = "0.1" # for svgtree roxmltree = "0.7" simplecss = "0.2" -siphasher = "0.2.3" +siphasher = "0.3" svgtypes = "0.5" # for text to path harfbuzz_rs = "1.0" memmap = "0.7" -ttf-parser = "0.2.2" +ttf-parser = "0.3" unicode-bidi = "0.3" unicode-script = "0.3" unicode-vo = "0.1" diff --git a/usvg/src/convert/text/shaper.rs b/usvg/src/convert/text/shaper.rs index cf320f6..8b07967 100644 --- a/usvg/src/convert/text/shaper.rs +++ b/usvg/src/convert/text/shaper.rs @@ -6,7 +6,6 @@ use kurbo::{ParamCurveArclen, ParamCurve, ParamCurveDeriv}; use harfbuzz_rs as harfbuzz; use unicode_vo::Orientation as CharOrientation; use ttf_parser::GlyphId; -use kurbo::Vec2; use crate::{tree, fontdb, convert::prelude::*}; use super::convert::{ @@ -547,7 +546,7 @@ fn resolve_clusters_positions_path( // Shift only by `dy` since we already applied `dx` // during offset along the path calculation. if !dy.is_fuzzy_zero() || !baseline_shift.is_fuzzy_zero() { - let shift = Vec2::from_angle(angle) + Vec2::new(0.0, dy - baseline_shift); + let shift = kurbo::Vec2::from_angle(angle) + kurbo::Vec2::new(0.0, dy - baseline_shift); cluster.transform.translate(shift.x, shift.y); } @@ -635,10 +634,10 @@ fn collect_normals( -> kurbo::CubicBez { kurbo::CubicBez { - p0: Vec2::new(px, py), - p1: Vec2::new(x1, y1), - p2: Vec2::new(x2, y2), - p3: Vec2::new(x, y), + p0: kurbo::Point::new(px, py), + p1: kurbo::Point::new(x1, y1), + p2: kurbo::Point::new(x2, y2), + p3: kurbo::Point::new(x, y), } } @@ -646,8 +645,8 @@ fn collect_normals( -> kurbo::CubicBez { let line = kurbo::Line { - p0: Vec2::new(px, py), - p1: Vec2::new(x, y), + p0: kurbo::Point::new(px, py), + p1: kurbo::Point::new(x, y), }; let p1 = line.eval(0.33); let p2 = line.eval(0.66); @@ -684,7 +683,7 @@ fn collect_normals( let pos = curve.eval(offset); let d = curve.deriv().eval(offset); - let d = Vec2::new(-d.y, d.x); // tangent + let d = kurbo::Vec2::new(-d.y, d.x); // tangent let angle = d.atan2().to_degrees() - 90.0; normals.push(Some(PathNormal { diff --git a/usvg/src/tree/pathdata.rs b/usvg/src/tree/pathdata.rs index 703492d..c148b76 100644 --- a/usvg/src/tree/pathdata.rs +++ b/usvg/src/tree/pathdata.rs @@ -66,21 +66,9 @@ impl PathData { /// Creates a path from a rect. #[inline] pub fn from_rect(rect: Rect) -> Self { - PathData(vec![ - PathSegment::MoveTo { - x: rect.x(), y: rect.y() - }, - PathSegment::LineTo { - x: rect.right(), y: rect.y() - }, - PathSegment::LineTo { - x: rect.right(), y: rect.bottom() - }, - PathSegment::LineTo { - x: rect.x(), y: rect.bottom() - }, - PathSegment::ClosePath, - ]) + let mut path = PathData::with_capacity(5); + path.push_rect(rect); + path } /// Pushes a MoveTo segment to the path. @@ -124,8 +112,8 @@ impl PathData { let (prev_x, prev_y) = self.last_pos(); let svg_arc = kurbo::SvgArc { - from: kurbo::Vec2::new(prev_x, prev_y), - to: kurbo::Vec2::new(x, y), + from: kurbo::Point::new(prev_x, prev_y), + to: kurbo::Point::new(x, y), radii: kurbo::Vec2::new(rx, ry), x_rotation: x_axis_rotation.to_radians(), large_arc, @@ -150,6 +138,18 @@ impl PathData { self.push(PathSegment::ClosePath); } + /// Pushes a rect to the path. + #[inline] + pub fn push_rect(&mut self, rect: Rect) { + self.extend_from_slice(&[ + PathSegment::MoveTo { x: rect.x(), y: rect.y() }, + PathSegment::LineTo { x: rect.right(), y: rect.y() }, + PathSegment::LineTo { x: rect.right(), y: rect.bottom() }, + PathSegment::LineTo { x: rect.x(), y: rect.bottom() }, + PathSegment::ClosePath, + ]); + } + #[inline] fn last_pos(&self) -> (f64, f64) { let seg = self.last().expect("path must not be empty").clone(); @@ -356,7 +356,7 @@ fn calc_bbox(segments: &[PathSegment]) -> Option { for seg in segments.iter().cloned() { match seg { - PathSegment::MoveTo { x, y } + PathSegment::MoveTo { x, y } | PathSegment::LineTo { x, y } => { prev_x = x; prev_y = y; @@ -368,13 +368,7 @@ fn calc_bbox(segments: &[PathSegment]) -> Option { else if y < miny { miny = y; } } PathSegment::CurveTo { x1, y1, x2, y2, x, y } => { - let curve = kurbo::CubicBez { - p0: kurbo::Vec2::new(prev_x, prev_y), - p1: kurbo::Vec2::new(x1, y1), - p2: kurbo::Vec2::new(x2, y2), - p3: kurbo::Vec2::new(x, y), - }; - + let curve = kurbo::CubicBez::from_points(prev_x, prev_y, x1, y1, x2, y2, x, y); let r = curve.bounding_box(); if r.x0 < minx { minx = r.x0; } @@ -417,7 +411,7 @@ fn calc_bbox_with_transform( for seg in TransformedPath::new(segments, ts) { match seg { - PathSegment::MoveTo { x, y } + PathSegment::MoveTo { x, y } | PathSegment::LineTo { x, y } => { prev_x = x; prev_y = y; @@ -429,13 +423,7 @@ fn calc_bbox_with_transform( else if y < miny { miny = y; } } PathSegment::CurveTo { x1, y1, x2, y2, x, y } => { - let curve = kurbo::CubicBez { - p0: kurbo::Vec2::new(prev_x, prev_y), - p1: kurbo::Vec2::new(x1, y1), - p2: kurbo::Vec2::new(x2, y2), - p3: kurbo::Vec2::new(x, y), - }; - + let curve = kurbo::CubicBez::from_points(prev_x, prev_y, x1, y1, x2, y2, x, y); let r = curve.bounding_box(); if r.x0 < minx { minx = r.x0; } @@ -496,13 +484,7 @@ fn has_bbox(segments: &[PathSegment]) -> bool { else if y < miny { miny = y; } } PathSegment::CurveTo { x1, y1, x2, y2, x, y } => { - let curve = kurbo::CubicBez { - p0: kurbo::Vec2::new(prev_x, prev_y), - p1: kurbo::Vec2::new(x1, y1), - p2: kurbo::Vec2::new(x2, y2), - p3: kurbo::Vec2::new(x, y), - }; - + let curve = kurbo::CubicBez::from_points(prev_x, prev_y, x1, y1, x2, y2, x, y); let r = curve.bounding_box(); if r.x0 < minx { minx = r.x0; } @@ -553,13 +535,7 @@ fn calc_length(segments: &[PathSegment]) -> f64 { prev_y = y; } PathSegment::CurveTo { x1, y1, x2, y2, x, y } => { - let curve = kurbo::CubicBez { - p0: kurbo::Vec2::new(prev_x, prev_y), - p1: kurbo::Vec2::new(x1, y1), - p2: kurbo::Vec2::new(x2, y2), - p3: kurbo::Vec2::new(x, y), - }; - + let curve = kurbo::CubicBez::from_points(prev_x, prev_y, x1, y1, x2, y2, x, y); length += curve.arclen(1.0); prev_x = x; @@ -659,3 +635,19 @@ fn quad_to_curve(px: f64, py: f64, x1: f64, y1: f64, x: f64, y: f64) -> PathSegm x, y, } } + + +pub(crate) trait CubicBezExt { + fn from_points(px: f64, py: f64, x1: f64, y1: f64, x2: f64, y2: f64, x: f64, y: f64) -> Self; +} + +impl CubicBezExt for kurbo::CubicBez { + fn from_points(px: f64, py: f64, x1: f64, y1: f64, x2: f64, y2: f64, x: f64, y: f64) -> Self { + kurbo::CubicBez { + p0: kurbo::Point::new(px, py), + p1: kurbo::Point::new(x1, y1), + p2: kurbo::Point::new(x2, y2), + p3: kurbo::Point::new(x, y), + } + } +} -- cgit v1.2.3 From 80b80b9320a907a1e7a235d480ec92172f3c0b73 Mon Sep 17 00:00:00 2001 From: Andrej Shadura Date: Sat, 21 Nov 2020 22:23:59 +0100 Subject: rgb compat Gbp-Pq: Name rgb-compat.patch --- src/filter.rs | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/src/filter.rs b/src/filter.rs index 68f3703..21e7924 100644 --- a/src/filter.rs +++ b/src/filter.rs @@ -664,8 +664,8 @@ pub mod box_blur { let mut li = ti; let mut ri = ti + blur_radius * width; - let fv: RGBA8 = [0,0,0,0].into(); - let lv: RGBA8 = [0,0,0,0].into(); + let fv: RGBA8 = (0,0,0,0).into(); + let lv: RGBA8 = (0,0,0,0).into(); let mut val_r = blur_radius_next * (fv.r as isize); let mut val_g = blur_radius_next * (fv.g as isize); @@ -714,12 +714,12 @@ pub mod box_blur { val_b += sub(bb.b, fv.b); val_a += sub(bb.a, fv.a); - frontbuf[ti] = [ + frontbuf[ti] = ( round(val_r as f32 * iarr) as u8, round(val_g as f32 * iarr) as u8, round(val_b as f32 * iarr) as u8, round(val_a as f32 * iarr) as u8, - ].into(); + ).into(); ti += width; } @@ -739,12 +739,12 @@ pub mod box_blur { val_b += sub(bb1.b, bb2.b); val_a += sub(bb1.a, bb2.a); - frontbuf[ti] = [ + frontbuf[ti] = ( round(val_r as f32 * iarr) as u8, round(val_g as f32 * iarr) as u8, round(val_b as f32 * iarr) as u8, round(val_a as f32 * iarr) as u8, - ].into(); + ).into(); ti += width; } @@ -757,12 +757,12 @@ pub mod box_blur { val_b += sub(lv.b, bb.b); val_a += sub(lv.a, bb.a); - frontbuf[ti] = [ + frontbuf[ti] = ( round(val_r as f32 * iarr) as u8, round(val_g as f32 * iarr) as u8, round(val_b as f32 * iarr) as u8, round(val_a as f32 * iarr) as u8, - ].into(); + ).into(); ti += width; } } @@ -792,8 +792,8 @@ pub mod box_blur { let mut li = ti; let mut ri = ti + blur_radius; - let fv: RGBA8 = [0,0,0,0].into(); - let lv: RGBA8 = [0,0,0,0].into(); + let fv: RGBA8 = (0,0,0,0).into(); + let lv: RGBA8 = (0,0,0,0).into(); let mut val_r = blur_radius_next * (fv.r as isize); let mut val_g = blur_radius_next * (fv.g as isize); @@ -843,12 +843,12 @@ pub mod box_blur { val_b += sub(bb.b, fv.b); val_a += sub(bb.a, fv.a); - frontbuf[ti] = [ + frontbuf[ti] = ( round(val_r as f32 * iarr) as u8, round(val_g as f32 * iarr) as u8, round(val_b as f32 * iarr) as u8, round(val_a as f32 * iarr) as u8, - ].into(); + ).into(); ti += 1; // VERTICAL : ti += width, same with the other areas } @@ -870,12 +870,12 @@ pub mod box_blur { val_b += sub(bb1.b, bb2.b); val_a += sub(bb1.a, bb2.a); - frontbuf[ti] = [ + frontbuf[ti] = ( round(val_r as f32 * iarr) as u8, round(val_g as f32 * iarr) as u8, round(val_b as f32 * iarr) as u8, round(val_a as f32 * iarr) as u8, - ].into(); + ).into(); ti += 1; } @@ -889,12 +889,12 @@ pub mod box_blur { val_b += sub(lv.b, bb.b); val_a += sub(lv.a, bb.a); - frontbuf[ti] = [ + frontbuf[ti] = ( round(val_r as f32 * iarr) as u8, round(val_g as f32 * iarr) as u8, round(val_b as f32 * iarr) as u8, round(val_a as f32 * iarr) as u8, - ].into(); + ).into(); ti += 1; } } -- cgit v1.2.3 From 08770d061dd7369393db88007f63b94dfbace5e3 Mon Sep 17 00:00:00 2001 From: Andrej Shadura Date: Sat, 21 Nov 2020 22:24:22 +0100 Subject: pico-args 0.3 Gbp-Pq: Name pico-args-0.3.patch --- tools/rendersvg/Cargo.toml | 2 +- tools/rendersvg/src/args.rs | 28 ++++++++++++++-------------- tools/usvg/Cargo.toml | 2 +- tools/usvg/src/main.rs | 18 +++++++++--------- 4 files changed, 25 insertions(+), 25 deletions(-) diff --git a/tools/rendersvg/Cargo.toml b/tools/rendersvg/Cargo.toml index b2c0a48..211e531 100644 --- a/tools/rendersvg/Cargo.toml +++ b/tools/rendersvg/Cargo.toml @@ -10,7 +10,7 @@ workspace = "../../" [dependencies] fern = "0.5" log = "0.4" -pico-args = "0.2" +pico-args = "0.3" resvg = { path = "../../" } time = "0.1" diff --git a/tools/rendersvg/src/args.rs b/tools/rendersvg/src/args.rs index 976d4bf..95211c5 100644 --- a/tools/rendersvg/src/args.rs +++ b/tools/rendersvg/src/args.rs @@ -104,26 +104,26 @@ fn collect_args() -> Result { Ok(CliArgs { help: input.contains("--help"), version: input.contains(["-V", "--version"]), - backend: input.value_from_str("--backend")?.unwrap_or(default_backend()), - width: input.value_from_fn(["-w", "--width"], parse_length)?, - height: input.value_from_fn(["-h", "--height"], parse_length)?, - zoom: input.value_from_fn(["-z", "--zoom"], parse_zoom)?, - dpi: input.value_from_fn("--dpi", parse_dpi)?.unwrap_or(96), - background: input.value_from_str("--background")?, - font_family: input.value_from_str("--font-family")? + backend: input.opt_value_from_str("--backend")?.unwrap_or(default_backend()), + width: input.opt_value_from_fn(["-w", "--width"], parse_length)?, + height: input.opt_value_from_fn(["-h", "--height"], parse_length)?, + zoom: input.opt_value_from_fn(["-z", "--zoom"], parse_zoom)?, + dpi: input.opt_value_from_fn("--dpi", parse_dpi)?.unwrap_or(96), + background: input.opt_value_from_str("--background")?, + font_family: input.opt_value_from_str("--font-family")? .unwrap_or_else(|| "Times New Roman".to_string()), - font_size: input.value_from_fn("--font-size", parse_font_size)?.unwrap_or(12), - languages: input.value_from_fn("--languages", parse_languages)? + font_size: input.opt_value_from_fn("--font-size", parse_font_size)?.unwrap_or(12), + languages: input.opt_value_from_fn("--languages", parse_languages)? .unwrap_or(vec!["en".to_string()]), // TODO: use system language - shape_rendering: input.value_from_str("--shape-rendering")?.unwrap_or_default(), - text_rendering: input.value_from_str("--text-rendering")?.unwrap_or_default(), - image_rendering: input.value_from_str("--image-rendering")?.unwrap_or_default(), + shape_rendering: input.opt_value_from_str("--shape-rendering")?.unwrap_or_default(), + text_rendering: input.opt_value_from_str("--text-rendering")?.unwrap_or_default(), + image_rendering: input.opt_value_from_str("--image-rendering")?.unwrap_or_default(), query_all: input.contains("--query-all"), - export_id: input.value_from_str("--export-id")?, + export_id: input.opt_value_from_str("--export-id")?, perf: input.contains("--perf"), pretend: input.contains("--pretend"), quiet: input.contains("--quiet"), - dump_svg: input.value_from_str("--dump-svg")?, + dump_svg: input.opt_value_from_str("--dump-svg")?, free: input.free()?, }) } diff --git a/tools/usvg/Cargo.toml b/tools/usvg/Cargo.toml index 1e046fc..e54d92f 100644 --- a/tools/usvg/Cargo.toml +++ b/tools/usvg/Cargo.toml @@ -15,7 +15,7 @@ travis-ci = { repository = "RazrFalcon/resvg" } [dependencies] fern = "0.5" log = "0.4" -pico-args = "0.2" +pico-args = "0.3" usvg = { version = "0.8", path = "../../usvg" } [[bin]] diff --git a/tools/usvg/src/main.rs b/tools/usvg/src/main.rs index 01437c4..4e09775 100644 --- a/tools/usvg/src/main.rs +++ b/tools/usvg/src/main.rs @@ -87,18 +87,18 @@ fn collect_args() -> Result { version: input.contains(["-V", "--version"]), stdout: input.contains("-c"), keep_named_groups: input.contains("--keep-named-groups"), - dpi: input.value_from_fn("--dpi", parse_dpi)?.unwrap_or(96), - font_family: input.value_from_str("--font-family")? + dpi: input.opt_value_from_fn("--dpi", parse_dpi)?.unwrap_or(96), + font_family: input.opt_value_from_str("--font-family")? .unwrap_or_else(|| "Times New Roman".to_string()), - font_size: input.value_from_fn("--font-size", parse_font_size)?.unwrap_or(12), - languages: input.value_from_fn("--languages", parse_languages)? + font_size: input.opt_value_from_fn("--font-size", parse_font_size)?.unwrap_or(12), + languages: input.opt_value_from_fn("--languages", parse_languages)? .unwrap_or(vec!["en".to_string()]), // TODO: use system language - shape_rendering: input.value_from_str("--shape-rendering")?.unwrap_or_default(), - text_rendering: input.value_from_str("--text-rendering")?.unwrap_or_default(), - image_rendering: input.value_from_str("--image-rendering")?.unwrap_or_default(), - indent: input.value_from_fn("--indent", parse_indent)? + shape_rendering: input.opt_value_from_str("--shape-rendering")?.unwrap_or_default(), + text_rendering: input.opt_value_from_str("--text-rendering")?.unwrap_or_default(), + image_rendering: input.opt_value_from_str("--image-rendering")?.unwrap_or_default(), + indent: input.opt_value_from_fn("--indent", parse_indent)? .unwrap_or(usvg::XmlIndent::Spaces(4)), - attrs_indent: input.value_from_fn("--attrs-indent", parse_indent)? + attrs_indent: input.opt_value_from_fn("--attrs-indent", parse_indent)? .unwrap_or(usvg::XmlIndent::None), quiet: input.contains("--quiet"), free: input.free()?, -- cgit v1.2.3 From f4a2286e63ba911b6a2b6cf9e9289868f569902c Mon Sep 17 00:00:00 2001 From: Andrej Shadura Date: Sat, 21 Nov 2020 22:24:49 +0100 Subject: unicode-script 0.5 Gbp-Pq: Name unicode-script-0.5.patch --- usvg/Cargo.toml | 2 +- usvg/src/convert/text/shaper.rs | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/usvg/Cargo.toml b/usvg/Cargo.toml index f873052..92a1299 100644 --- a/usvg/Cargo.toml +++ b/usvg/Cargo.toml @@ -36,5 +36,5 @@ harfbuzz_rs = "1.0" memmap = "0.7" ttf-parser = "0.3" unicode-bidi = "0.3" -unicode-script = "0.3" +unicode-script = "0.5" unicode-vo = "0.1" diff --git a/usvg/src/convert/text/shaper.rs b/usvg/src/convert/text/shaper.rs index 8b07967..d73885c 100644 --- a/usvg/src/convert/text/shaper.rs +++ b/usvg/src/convert/text/shaper.rs @@ -5,6 +5,7 @@ use kurbo::{ParamCurveArclen, ParamCurve, ParamCurveDeriv}; use harfbuzz_rs as harfbuzz; use unicode_vo::Orientation as CharOrientation; +use unicode_script::UnicodeScript; use ttf_parser::GlyphId; use crate::{tree, fontdb, convert::prelude::*}; @@ -727,7 +728,7 @@ pub fn apply_letter_spacing( // Spacing must be applied only to characters that belongs to the script // that supports spacing. // We are checking only the first code point, since it should be enough. - let script = unicode_script::get_script(cluster.codepoint); + let script = cluster.codepoint.script(); if script_supports_letter_spacing(script) { if let Some(span) = chunk.span_at(cluster.byte_idx) { // Technically, we should ignore spacing on the last character, -- cgit v1.2.3 From 0a583f631eb46054686592c60333f44a89cc5d5d Mon Sep 17 00:00:00 2001 From: Evgeniy Reizner Date: Mon, 23 Dec 2019 01:11:07 +0200 Subject: (resvg-qt) Do not use a deprecated method. Gbp-Pq: Name 0006-resvg-qt-Do-not-use-a-deprecated-method.patch --- bindings/resvg-qt/cpp/qt_capi.cpp | 4 ++-- bindings/resvg-qt/cpp/qt_capi.hpp | 2 +- bindings/resvg-qt/src/ffi.rs | 2 +- bindings/resvg-qt/src/lib.rs | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/bindings/resvg-qt/cpp/qt_capi.cpp b/bindings/resvg-qt/cpp/qt_capi.cpp index 5ffe45b..1b63aba 100644 --- a/bindings/resvg-qt/cpp/qt_capi.cpp +++ b/bindings/resvg-qt/cpp/qt_capi.cpp @@ -46,9 +46,9 @@ uint8_t* qtc_qimage_get_data(qtc_qimage *c_img) return IMAGE_CAST->bits(); } -uint32_t qtc_qimage_get_byte_count(qtc_qimage *c_img) +uint32_t qtc_qimage_get_size_in_bytes(qtc_qimage *c_img) { - return IMAGE_CAST->byteCount(); + return IMAGE_CAST->sizeInBytes(); } qtc_qimage* qtc_qimage_resize(qtc_qimage *c_img, uint32_t width, uint32_t height, AspectRatioMode ratio, diff --git a/bindings/resvg-qt/cpp/qt_capi.hpp b/bindings/resvg-qt/cpp/qt_capi.hpp index d9a982a..d3e07f3 100644 --- a/bindings/resvg-qt/cpp/qt_capi.hpp +++ b/bindings/resvg-qt/cpp/qt_capi.hpp @@ -97,7 +97,7 @@ extern "C" { qtc_qimage* qtc_qimage_create_rgba_premultiplied(uint32_t width, uint32_t height); qtc_qimage* qtc_qimage_create_rgba(uint32_t width, uint32_t height); uint8_t* qtc_qimage_get_data(qtc_qimage *c_img); -uint32_t qtc_qimage_get_byte_count(qtc_qimage *c_img); +uint32_t qtc_qimage_get_size_in_bytes(qtc_qimage *c_img); qtc_qimage* qtc_qimage_resize(qtc_qimage *c_img, uint32_t width, uint32_t height, AspectRatioMode ratio, bool smoothTransformation); qtc_qimage* qtc_qimage_copy(qtc_qimage *c_img, uint32_t x, uint32_t y, uint32_t width, uint32_t height); diff --git a/bindings/resvg-qt/src/ffi.rs b/bindings/resvg-qt/src/ffi.rs index f4349b2..d887177 100644 --- a/bindings/resvg-qt/src/ffi.rs +++ b/bindings/resvg-qt/src/ffi.rs @@ -418,7 +418,7 @@ extern "C" { pub fn qtc_qimage_get_data(c_img: *mut qtc_qimage) -> *mut u8; } extern "C" { - pub fn qtc_qimage_get_byte_count(c_img: *mut qtc_qimage) -> u32; + pub fn qtc_qimage_get_size_in_bytes(c_img: *mut qtc_qimage) -> u32; } extern "C" { pub fn qtc_qimage_resize( diff --git a/bindings/resvg-qt/src/lib.rs b/bindings/resvg-qt/src/lib.rs index d19cbf9..97a137d 100644 --- a/bindings/resvg-qt/src/lib.rs +++ b/bindings/resvg-qt/src/lib.rs @@ -131,7 +131,7 @@ impl Image { pub fn data(&self) -> ImageData { unsafe { let ptr = ffi::qtc_qimage_get_data(self.0); - let len = ffi::qtc_qimage_get_byte_count(self.0) as usize; + let len = ffi::qtc_qimage_get_size_in_bytes(self.0) as usize; ImageData { slice: slice::from_raw_parts_mut(ptr, len), @@ -142,7 +142,7 @@ impl Image { pub fn data_mut(&mut self) -> ImageData { unsafe { let ptr = ffi::qtc_qimage_get_data(self.0); - let len = ffi::qtc_qimage_get_byte_count(self.0) as usize; + let len = ffi::qtc_qimage_get_size_in_bytes(self.0) as usize; ImageData { slice: slice::from_raw_parts_mut(ptr, len), -- cgit v1.2.3 From e45855dabdb40ba65774a92d73d17f8c90738030 Mon Sep 17 00:00:00 2001 From: Evgeniy Reizner Date: Mon, 23 Dec 2019 01:25:41 +0200 Subject: (resvg-qt) Check Qt version before using modern API. Gbp-Pq: Name 0007-resvg-qt-Check-Qt-version-before-using-modern-API.patch --- bindings/resvg-qt/cpp/qt_capi.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/bindings/resvg-qt/cpp/qt_capi.cpp b/bindings/resvg-qt/cpp/qt_capi.cpp index 1b63aba..cabda9d 100644 --- a/bindings/resvg-qt/cpp/qt_capi.cpp +++ b/bindings/resvg-qt/cpp/qt_capi.cpp @@ -48,7 +48,11 @@ uint8_t* qtc_qimage_get_data(qtc_qimage *c_img) uint32_t qtc_qimage_get_size_in_bytes(qtc_qimage *c_img) { +#if QT_VERSION >= QT_VERSION_CHECK(5,10,0) return IMAGE_CAST->sizeInBytes(); +#else + return IMAGE_CAST->byteCount(); +#endif } qtc_qimage* qtc_qimage_resize(qtc_qimage *c_img, uint32_t width, uint32_t height, AspectRatioMode ratio, -- cgit v1.2.3 From 968e8bfceb37bcec60004e019056f3d76774d921 Mon Sep 17 00:00:00 2001 From: Evgeniy Reizner Date: Thu, 4 Jun 2020 19:21:10 +0300 Subject: (qt-backend) Fix building with Qt >= 5.15 Closes #294 Gbp-Pq: Name 0008-qt-backend-Fix-building-with-Qt-5.15.patch --- bindings/resvg-qt/cpp/qt_capi.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/bindings/resvg-qt/cpp/qt_capi.cpp b/bindings/resvg-qt/cpp/qt_capi.cpp index cabda9d..952d975 100644 --- a/bindings/resvg-qt/cpp/qt_capi.cpp +++ b/bindings/resvg-qt/cpp/qt_capi.cpp @@ -1,6 +1,7 @@ #include #include #include +#include #include #include -- cgit v1.2.3 From 63c49c1bb18ec1c2e9a9d4e155bfeedfd945cf11 Mon Sep 17 00:00:00 2001 From: Andrej Shadura Date: Wed, 18 Nov 2020 14:12:02 +0100 Subject: Don't build raqote or skia backends yet Gbp-Pq: Name no-raqote-or-skia.patch --- Cargo.toml | 9 --------- capi/Cargo.toml | 4 ++-- tools/rendersvg/Cargo.toml | 4 ++-- usvg/Cargo.toml | 6 +++--- 4 files changed, 7 insertions(+), 16 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 14b203f..72be109 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -14,7 +14,6 @@ categories = ["multimedia::images"] [workspace] members = [ "bindings/resvg-qt", - "bindings/resvg-skia", "capi", "tools/rendersvg", "tools/usvg", @@ -37,17 +36,9 @@ cairo-rs = { version = "0.7.1", default-features = false, features = ["png"], op # qt backend resvg-qt = { path = "bindings/resvg-qt", version = "0.8", optional = true } -# raqote backend -raqote = { version = "0.6.1", default-features = false, optional = true } - -# skia backend -resvg-skia = { path = "bindings/resvg-skia", version = "0.8", optional = true } - [features] cairo-backend = ["cairo-rs", "png/png-encoding"] qt-backend = ["resvg-qt"] -raqote-backend = ["raqote"] -skia-backend = ["resvg-skia"] [package.metadata.docs.rs] all-features = true diff --git a/capi/Cargo.toml b/capi/Cargo.toml index 72221ef..87608b9 100644 --- a/capi/Cargo.toml +++ b/capi/Cargo.toml @@ -21,5 +21,5 @@ cairo-sys-rs = { version = "0.9.0", optional = true } [features] cairo-backend = ["resvg/cairo-backend", "cairo-sys-rs"] qt-backend = ["resvg/qt-backend"] -skia-backend = ["resvg/skia-backend"] -raqote-backend = ["resvg/raqote-backend"] +# skia-backend = ["resvg/skia-backend"] +# raqote-backend = ["resvg/raqote-backend"] diff --git a/tools/rendersvg/Cargo.toml b/tools/rendersvg/Cargo.toml index 257a658..b2c0a48 100644 --- a/tools/rendersvg/Cargo.toml +++ b/tools/rendersvg/Cargo.toml @@ -17,5 +17,5 @@ time = "0.1" [features] cairo-backend = ["resvg/cairo-backend"] qt-backend = ["resvg/qt-backend"] -raqote-backend = ["resvg/raqote-backend"] -skia-backend = ["resvg/skia-backend"] +# raqote-backend = ["resvg/raqote-backend"] +# skia-backend = ["resvg/skia-backend"] diff --git a/usvg/Cargo.toml b/usvg/Cargo.toml index 57a6956..f921a4d 100644 --- a/usvg/Cargo.toml +++ b/usvg/Cargo.toml @@ -17,9 +17,9 @@ workspace = ".." travis-ci = { repository = "RazrFalcon/resvg" } [dependencies] -base64 = "0.10" -data-url = "0.1" -kurbo = "0.2.3" +base64 = "0" +data-url = "0" +kurbo = "0.2" libflate = "0.1.25" log = "0.4" rctree = "0.3" -- cgit v1.2.3 From 21fc2539b48280b5207b267c88e8a59b9907feab Mon Sep 17 00:00:00 2001 From: Evgeniy Reizner Date: Mon, 23 Dec 2019 01:54:04 +0200 Subject: Update or relax dependencies Gbp-Pq: Name deps.patch --- usvg/Cargo.toml | 6 +-- usvg/src/convert/text/shaper.rs | 17 ++++---- usvg/src/tree/pathdata.rs | 86 +++++++++++++++++++---------------------- 3 files changed, 50 insertions(+), 59 deletions(-) diff --git a/usvg/Cargo.toml b/usvg/Cargo.toml index f921a4d..f873052 100644 --- a/usvg/Cargo.toml +++ b/usvg/Cargo.toml @@ -19,7 +19,7 @@ travis-ci = { repository = "RazrFalcon/resvg" } [dependencies] base64 = "0" data-url = "0" -kurbo = "0.2" +kurbo = "0.7" libflate = "0.1.25" log = "0.4" rctree = "0.3" @@ -28,13 +28,13 @@ xmlwriter = "0.1" # for svgtree roxmltree = "0.7" simplecss = "0.2" -siphasher = "0.2.3" +siphasher = "0.3" svgtypes = "0.5" # for text to path harfbuzz_rs = "1.0" memmap = "0.7" -ttf-parser = "0.2.2" +ttf-parser = "0.3" unicode-bidi = "0.3" unicode-script = "0.3" unicode-vo = "0.1" diff --git a/usvg/src/convert/text/shaper.rs b/usvg/src/convert/text/shaper.rs index cf320f6..8b07967 100644 --- a/usvg/src/convert/text/shaper.rs +++ b/usvg/src/convert/text/shaper.rs @@ -6,7 +6,6 @@ use kurbo::{ParamCurveArclen, ParamCurve, ParamCurveDeriv}; use harfbuzz_rs as harfbuzz; use unicode_vo::Orientation as CharOrientation; use ttf_parser::GlyphId; -use kurbo::Vec2; use crate::{tree, fontdb, convert::prelude::*}; use super::convert::{ @@ -547,7 +546,7 @@ fn resolve_clusters_positions_path( // Shift only by `dy` since we already applied `dx` // during offset along the path calculation. if !dy.is_fuzzy_zero() || !baseline_shift.is_fuzzy_zero() { - let shift = Vec2::from_angle(angle) + Vec2::new(0.0, dy - baseline_shift); + let shift = kurbo::Vec2::from_angle(angle) + kurbo::Vec2::new(0.0, dy - baseline_shift); cluster.transform.translate(shift.x, shift.y); } @@ -635,10 +634,10 @@ fn collect_normals( -> kurbo::CubicBez { kurbo::CubicBez { - p0: Vec2::new(px, py), - p1: Vec2::new(x1, y1), - p2: Vec2::new(x2, y2), - p3: Vec2::new(x, y), + p0: kurbo::Point::new(px, py), + p1: kurbo::Point::new(x1, y1), + p2: kurbo::Point::new(x2, y2), + p3: kurbo::Point::new(x, y), } } @@ -646,8 +645,8 @@ fn collect_normals( -> kurbo::CubicBez { let line = kurbo::Line { - p0: Vec2::new(px, py), - p1: Vec2::new(x, y), + p0: kurbo::Point::new(px, py), + p1: kurbo::Point::new(x, y), }; let p1 = line.eval(0.33); let p2 = line.eval(0.66); @@ -684,7 +683,7 @@ fn collect_normals( let pos = curve.eval(offset); let d = curve.deriv().eval(offset); - let d = Vec2::new(-d.y, d.x); // tangent + let d = kurbo::Vec2::new(-d.y, d.x); // tangent let angle = d.atan2().to_degrees() - 90.0; normals.push(Some(PathNormal { diff --git a/usvg/src/tree/pathdata.rs b/usvg/src/tree/pathdata.rs index 703492d..c148b76 100644 --- a/usvg/src/tree/pathdata.rs +++ b/usvg/src/tree/pathdata.rs @@ -66,21 +66,9 @@ impl PathData { /// Creates a path from a rect. #[inline] pub fn from_rect(rect: Rect) -> Self { - PathData(vec![ - PathSegment::MoveTo { - x: rect.x(), y: rect.y() - }, - PathSegment::LineTo { - x: rect.right(), y: rect.y() - }, - PathSegment::LineTo { - x: rect.right(), y: rect.bottom() - }, - PathSegment::LineTo { - x: rect.x(), y: rect.bottom() - }, - PathSegment::ClosePath, - ]) + let mut path = PathData::with_capacity(5); + path.push_rect(rect); + path } /// Pushes a MoveTo segment to the path. @@ -124,8 +112,8 @@ impl PathData { let (prev_x, prev_y) = self.last_pos(); let svg_arc = kurbo::SvgArc { - from: kurbo::Vec2::new(prev_x, prev_y), - to: kurbo::Vec2::new(x, y), + from: kurbo::Point::new(prev_x, prev_y), + to: kurbo::Point::new(x, y), radii: kurbo::Vec2::new(rx, ry), x_rotation: x_axis_rotation.to_radians(), large_arc, @@ -150,6 +138,18 @@ impl PathData { self.push(PathSegment::ClosePath); } + /// Pushes a rect to the path. + #[inline] + pub fn push_rect(&mut self, rect: Rect) { + self.extend_from_slice(&[ + PathSegment::MoveTo { x: rect.x(), y: rect.y() }, + PathSegment::LineTo { x: rect.right(), y: rect.y() }, + PathSegment::LineTo { x: rect.right(), y: rect.bottom() }, + PathSegment::LineTo { x: rect.x(), y: rect.bottom() }, + PathSegment::ClosePath, + ]); + } + #[inline] fn last_pos(&self) -> (f64, f64) { let seg = self.last().expect("path must not be empty").clone(); @@ -356,7 +356,7 @@ fn calc_bbox(segments: &[PathSegment]) -> Option { for seg in segments.iter().cloned() { match seg { - PathSegment::MoveTo { x, y } + PathSegment::MoveTo { x, y } | PathSegment::LineTo { x, y } => { prev_x = x; prev_y = y; @@ -368,13 +368,7 @@ fn calc_bbox(segments: &[PathSegment]) -> Option { else if y < miny { miny = y; } } PathSegment::CurveTo { x1, y1, x2, y2, x, y } => { - let curve = kurbo::CubicBez { - p0: kurbo::Vec2::new(prev_x, prev_y), - p1: kurbo::Vec2::new(x1, y1), - p2: kurbo::Vec2::new(x2, y2), - p3: kurbo::Vec2::new(x, y), - }; - + let curve = kurbo::CubicBez::from_points(prev_x, prev_y, x1, y1, x2, y2, x, y); let r = curve.bounding_box(); if r.x0 < minx { minx = r.x0; } @@ -417,7 +411,7 @@ fn calc_bbox_with_transform( for seg in TransformedPath::new(segments, ts) { match seg { - PathSegment::MoveTo { x, y } + PathSegment::MoveTo { x, y } | PathSegment::LineTo { x, y } => { prev_x = x; prev_y = y; @@ -429,13 +423,7 @@ fn calc_bbox_with_transform( else if y < miny { miny = y; } } PathSegment::CurveTo { x1, y1, x2, y2, x, y } => { - let curve = kurbo::CubicBez { - p0: kurbo::Vec2::new(prev_x, prev_y), - p1: kurbo::Vec2::new(x1, y1), - p2: kurbo::Vec2::new(x2, y2), - p3: kurbo::Vec2::new(x, y), - }; - + let curve = kurbo::CubicBez::from_points(prev_x, prev_y, x1, y1, x2, y2, x, y); let r = curve.bounding_box(); if r.x0 < minx { minx = r.x0; } @@ -496,13 +484,7 @@ fn has_bbox(segments: &[PathSegment]) -> bool { else if y < miny { miny = y; } } PathSegment::CurveTo { x1, y1, x2, y2, x, y } => { - let curve = kurbo::CubicBez { - p0: kurbo::Vec2::new(prev_x, prev_y), - p1: kurbo::Vec2::new(x1, y1), - p2: kurbo::Vec2::new(x2, y2), - p3: kurbo::Vec2::new(x, y), - }; - + let curve = kurbo::CubicBez::from_points(prev_x, prev_y, x1, y1, x2, y2, x, y); let r = curve.bounding_box(); if r.x0 < minx { minx = r.x0; } @@ -553,13 +535,7 @@ fn calc_length(segments: &[PathSegment]) -> f64 { prev_y = y; } PathSegment::CurveTo { x1, y1, x2, y2, x, y } => { - let curve = kurbo::CubicBez { - p0: kurbo::Vec2::new(prev_x, prev_y), - p1: kurbo::Vec2::new(x1, y1), - p2: kurbo::Vec2::new(x2, y2), - p3: kurbo::Vec2::new(x, y), - }; - + let curve = kurbo::CubicBez::from_points(prev_x, prev_y, x1, y1, x2, y2, x, y); length += curve.arclen(1.0); prev_x = x; @@ -659,3 +635,19 @@ fn quad_to_curve(px: f64, py: f64, x1: f64, y1: f64, x: f64, y: f64) -> PathSegm x, y, } } + + +pub(crate) trait CubicBezExt { + fn from_points(px: f64, py: f64, x1: f64, y1: f64, x2: f64, y2: f64, x: f64, y: f64) -> Self; +} + +impl CubicBezExt for kurbo::CubicBez { + fn from_points(px: f64, py: f64, x1: f64, y1: f64, x2: f64, y2: f64, x: f64, y: f64) -> Self { + kurbo::CubicBez { + p0: kurbo::Point::new(px, py), + p1: kurbo::Point::new(x1, y1), + p2: kurbo::Point::new(x2, y2), + p3: kurbo::Point::new(x, y), + } + } +} -- cgit v1.2.3 From 6476061f8451289e2ffe200d9de12da310c07e10 Mon Sep 17 00:00:00 2001 From: Andrej Shadura Date: Sat, 21 Nov 2020 22:23:59 +0100 Subject: rgb compat Gbp-Pq: Name rgb-compat.patch --- src/filter.rs | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/src/filter.rs b/src/filter.rs index 68f3703..21e7924 100644 --- a/src/filter.rs +++ b/src/filter.rs @@ -664,8 +664,8 @@ pub mod box_blur { let mut li = ti; let mut ri = ti + blur_radius * width; - let fv: RGBA8 = [0,0,0,0].into(); - let lv: RGBA8 = [0,0,0,0].into(); + let fv: RGBA8 = (0,0,0,0).into(); + let lv: RGBA8 = (0,0,0,0).into(); let mut val_r = blur_radius_next * (fv.r as isize); let mut val_g = blur_radius_next * (fv.g as isize); @@ -714,12 +714,12 @@ pub mod box_blur { val_b += sub(bb.b, fv.b); val_a += sub(bb.a, fv.a); - frontbuf[ti] = [ + frontbuf[ti] = ( round(val_r as f32 * iarr) as u8, round(val_g as f32 * iarr) as u8, round(val_b as f32 * iarr) as u8, round(val_a as f32 * iarr) as u8, - ].into(); + ).into(); ti += width; } @@ -739,12 +739,12 @@ pub mod box_blur { val_b += sub(bb1.b, bb2.b); val_a += sub(bb1.a, bb2.a); - frontbuf[ti] = [ + frontbuf[ti] = ( round(val_r as f32 * iarr) as u8, round(val_g as f32 * iarr) as u8, round(val_b as f32 * iarr) as u8, round(val_a as f32 * iarr) as u8, - ].into(); + ).into(); ti += width; } @@ -757,12 +757,12 @@ pub mod box_blur { val_b += sub(lv.b, bb.b); val_a += sub(lv.a, bb.a); - frontbuf[ti] = [ + frontbuf[ti] = ( round(val_r as f32 * iarr) as u8, round(val_g as f32 * iarr) as u8, round(val_b as f32 * iarr) as u8, round(val_a as f32 * iarr) as u8, - ].into(); + ).into(); ti += width; } } @@ -792,8 +792,8 @@ pub mod box_blur { let mut li = ti; let mut ri = ti + blur_radius; - let fv: RGBA8 = [0,0,0,0].into(); - let lv: RGBA8 = [0,0,0,0].into(); + let fv: RGBA8 = (0,0,0,0).into(); + let lv: RGBA8 = (0,0,0,0).into(); let mut val_r = blur_radius_next * (fv.r as isize); let mut val_g = blur_radius_next * (fv.g as isize); @@ -843,12 +843,12 @@ pub mod box_blur { val_b += sub(bb.b, fv.b); val_a += sub(bb.a, fv.a); - frontbuf[ti] = [ + frontbuf[ti] = ( round(val_r as f32 * iarr) as u8, round(val_g as f32 * iarr) as u8, round(val_b as f32 * iarr) as u8, round(val_a as f32 * iarr) as u8, - ].into(); + ).into(); ti += 1; // VERTICAL : ti += width, same with the other areas } @@ -870,12 +870,12 @@ pub mod box_blur { val_b += sub(bb1.b, bb2.b); val_a += sub(bb1.a, bb2.a); - frontbuf[ti] = [ + frontbuf[ti] = ( round(val_r as f32 * iarr) as u8, round(val_g as f32 * iarr) as u8, round(val_b as f32 * iarr) as u8, round(val_a as f32 * iarr) as u8, - ].into(); + ).into(); ti += 1; } @@ -889,12 +889,12 @@ pub mod box_blur { val_b += sub(lv.b, bb.b); val_a += sub(lv.a, bb.a); - frontbuf[ti] = [ + frontbuf[ti] = ( round(val_r as f32 * iarr) as u8, round(val_g as f32 * iarr) as u8, round(val_b as f32 * iarr) as u8, round(val_a as f32 * iarr) as u8, - ].into(); + ).into(); ti += 1; } } -- cgit v1.2.3 From 466c3062da7d8684cdadd431adb7d3131943cb6a Mon Sep 17 00:00:00 2001 From: Andrej Shadura Date: Sat, 21 Nov 2020 22:24:22 +0100 Subject: pico-args 0.3 Gbp-Pq: Name pico-args-0.3.patch --- tools/rendersvg/Cargo.toml | 2 +- tools/rendersvg/src/args.rs | 28 ++++++++++++++-------------- tools/usvg/Cargo.toml | 2 +- tools/usvg/src/main.rs | 18 +++++++++--------- 4 files changed, 25 insertions(+), 25 deletions(-) diff --git a/tools/rendersvg/Cargo.toml b/tools/rendersvg/Cargo.toml index b2c0a48..211e531 100644 --- a/tools/rendersvg/Cargo.toml +++ b/tools/rendersvg/Cargo.toml @@ -10,7 +10,7 @@ workspace = "../../" [dependencies] fern = "0.5" log = "0.4" -pico-args = "0.2" +pico-args = "0.3" resvg = { path = "../../" } time = "0.1" diff --git a/tools/rendersvg/src/args.rs b/tools/rendersvg/src/args.rs index 976d4bf..95211c5 100644 --- a/tools/rendersvg/src/args.rs +++ b/tools/rendersvg/src/args.rs @@ -104,26 +104,26 @@ fn collect_args() -> Result { Ok(CliArgs { help: input.contains("--help"), version: input.contains(["-V", "--version"]), - backend: input.value_from_str("--backend")?.unwrap_or(default_backend()), - width: input.value_from_fn(["-w", "--width"], parse_length)?, - height: input.value_from_fn(["-h", "--height"], parse_length)?, - zoom: input.value_from_fn(["-z", "--zoom"], parse_zoom)?, - dpi: input.value_from_fn("--dpi", parse_dpi)?.unwrap_or(96), - background: input.value_from_str("--background")?, - font_family: input.value_from_str("--font-family")? + backend: input.opt_value_from_str("--backend")?.unwrap_or(default_backend()), + width: input.opt_value_from_fn(["-w", "--width"], parse_length)?, + height: input.opt_value_from_fn(["-h", "--height"], parse_length)?, + zoom: input.opt_value_from_fn(["-z", "--zoom"], parse_zoom)?, + dpi: input.opt_value_from_fn("--dpi", parse_dpi)?.unwrap_or(96), + background: input.opt_value_from_str("--background")?, + font_family: input.opt_value_from_str("--font-family")? .unwrap_or_else(|| "Times New Roman".to_string()), - font_size: input.value_from_fn("--font-size", parse_font_size)?.unwrap_or(12), - languages: input.value_from_fn("--languages", parse_languages)? + font_size: input.opt_value_from_fn("--font-size", parse_font_size)?.unwrap_or(12), + languages: input.opt_value_from_fn("--languages", parse_languages)? .unwrap_or(vec!["en".to_string()]), // TODO: use system language - shape_rendering: input.value_from_str("--shape-rendering")?.unwrap_or_default(), - text_rendering: input.value_from_str("--text-rendering")?.unwrap_or_default(), - image_rendering: input.value_from_str("--image-rendering")?.unwrap_or_default(), + shape_rendering: input.opt_value_from_str("--shape-rendering")?.unwrap_or_default(), + text_rendering: input.opt_value_from_str("--text-rendering")?.unwrap_or_default(), + image_rendering: input.opt_value_from_str("--image-rendering")?.unwrap_or_default(), query_all: input.contains("--query-all"), - export_id: input.value_from_str("--export-id")?, + export_id: input.opt_value_from_str("--export-id")?, perf: input.contains("--perf"), pretend: input.contains("--pretend"), quiet: input.contains("--quiet"), - dump_svg: input.value_from_str("--dump-svg")?, + dump_svg: input.opt_value_from_str("--dump-svg")?, free: input.free()?, }) } diff --git a/tools/usvg/Cargo.toml b/tools/usvg/Cargo.toml index 1e046fc..e54d92f 100644 --- a/tools/usvg/Cargo.toml +++ b/tools/usvg/Cargo.toml @@ -15,7 +15,7 @@ travis-ci = { repository = "RazrFalcon/resvg" } [dependencies] fern = "0.5" log = "0.4" -pico-args = "0.2" +pico-args = "0.3" usvg = { version = "0.8", path = "../../usvg" } [[bin]] diff --git a/tools/usvg/src/main.rs b/tools/usvg/src/main.rs index 01437c4..4e09775 100644 --- a/tools/usvg/src/main.rs +++ b/tools/usvg/src/main.rs @@ -87,18 +87,18 @@ fn collect_args() -> Result { version: input.contains(["-V", "--version"]), stdout: input.contains("-c"), keep_named_groups: input.contains("--keep-named-groups"), - dpi: input.value_from_fn("--dpi", parse_dpi)?.unwrap_or(96), - font_family: input.value_from_str("--font-family")? + dpi: input.opt_value_from_fn("--dpi", parse_dpi)?.unwrap_or(96), + font_family: input.opt_value_from_str("--font-family")? .unwrap_or_else(|| "Times New Roman".to_string()), - font_size: input.value_from_fn("--font-size", parse_font_size)?.unwrap_or(12), - languages: input.value_from_fn("--languages", parse_languages)? + font_size: input.opt_value_from_fn("--font-size", parse_font_size)?.unwrap_or(12), + languages: input.opt_value_from_fn("--languages", parse_languages)? .unwrap_or(vec!["en".to_string()]), // TODO: use system language - shape_rendering: input.value_from_str("--shape-rendering")?.unwrap_or_default(), - text_rendering: input.value_from_str("--text-rendering")?.unwrap_or_default(), - image_rendering: input.value_from_str("--image-rendering")?.unwrap_or_default(), - indent: input.value_from_fn("--indent", parse_indent)? + shape_rendering: input.opt_value_from_str("--shape-rendering")?.unwrap_or_default(), + text_rendering: input.opt_value_from_str("--text-rendering")?.unwrap_or_default(), + image_rendering: input.opt_value_from_str("--image-rendering")?.unwrap_or_default(), + indent: input.opt_value_from_fn("--indent", parse_indent)? .unwrap_or(usvg::XmlIndent::Spaces(4)), - attrs_indent: input.value_from_fn("--attrs-indent", parse_indent)? + attrs_indent: input.opt_value_from_fn("--attrs-indent", parse_indent)? .unwrap_or(usvg::XmlIndent::None), quiet: input.contains("--quiet"), free: input.free()?, -- cgit v1.2.3 From ed06f78c028bf99a0ba248d4db397cd499e7dbc0 Mon Sep 17 00:00:00 2001 From: Andrej Shadura Date: Sat, 21 Nov 2020 22:24:49 +0100 Subject: unicode-script 0.5 Gbp-Pq: Name unicode-script-0.5.patch --- usvg/Cargo.toml | 2 +- usvg/src/convert/text/shaper.rs | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/usvg/Cargo.toml b/usvg/Cargo.toml index f873052..92a1299 100644 --- a/usvg/Cargo.toml +++ b/usvg/Cargo.toml @@ -36,5 +36,5 @@ harfbuzz_rs = "1.0" memmap = "0.7" ttf-parser = "0.3" unicode-bidi = "0.3" -unicode-script = "0.3" +unicode-script = "0.5" unicode-vo = "0.1" diff --git a/usvg/src/convert/text/shaper.rs b/usvg/src/convert/text/shaper.rs index 8b07967..d73885c 100644 --- a/usvg/src/convert/text/shaper.rs +++ b/usvg/src/convert/text/shaper.rs @@ -5,6 +5,7 @@ use kurbo::{ParamCurveArclen, ParamCurve, ParamCurveDeriv}; use harfbuzz_rs as harfbuzz; use unicode_vo::Orientation as CharOrientation; +use unicode_script::UnicodeScript; use ttf_parser::GlyphId; use crate::{tree, fontdb, convert::prelude::*}; @@ -727,7 +728,7 @@ pub fn apply_letter_spacing( // Spacing must be applied only to characters that belongs to the script // that supports spacing. // We are checking only the first code point, since it should be enough. - let script = unicode_script::get_script(cluster.codepoint); + let script = cluster.codepoint.script(); if script_supports_letter_spacing(script) { if let Some(span) = chunk.span_at(cluster.byte_idx) { // Technically, we should ignore spacing on the last character, -- cgit v1.2.3 From 3f9b30fc150aaad8218ab75071485b7c726b32f0 Mon Sep 17 00:00:00 2001 From: Evgeniy Reizner Date: Mon, 23 Dec 2019 01:11:07 +0200 Subject: (resvg-qt) Do not use a deprecated method. Gbp-Pq: Name 0006-resvg-qt-Do-not-use-a-deprecated-method.patch --- bindings/resvg-qt/cpp/qt_capi.cpp | 4 ++-- bindings/resvg-qt/cpp/qt_capi.hpp | 2 +- bindings/resvg-qt/src/ffi.rs | 2 +- bindings/resvg-qt/src/lib.rs | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/bindings/resvg-qt/cpp/qt_capi.cpp b/bindings/resvg-qt/cpp/qt_capi.cpp index 5ffe45b..1b63aba 100644 --- a/bindings/resvg-qt/cpp/qt_capi.cpp +++ b/bindings/resvg-qt/cpp/qt_capi.cpp @@ -46,9 +46,9 @@ uint8_t* qtc_qimage_get_data(qtc_qimage *c_img) return IMAGE_CAST->bits(); } -uint32_t qtc_qimage_get_byte_count(qtc_qimage *c_img) +uint32_t qtc_qimage_get_size_in_bytes(qtc_qimage *c_img) { - return IMAGE_CAST->byteCount(); + return IMAGE_CAST->sizeInBytes(); } qtc_qimage* qtc_qimage_resize(qtc_qimage *c_img, uint32_t width, uint32_t height, AspectRatioMode ratio, diff --git a/bindings/resvg-qt/cpp/qt_capi.hpp b/bindings/resvg-qt/cpp/qt_capi.hpp index d9a982a..d3e07f3 100644 --- a/bindings/resvg-qt/cpp/qt_capi.hpp +++ b/bindings/resvg-qt/cpp/qt_capi.hpp @@ -97,7 +97,7 @@ extern "C" { qtc_qimage* qtc_qimage_create_rgba_premultiplied(uint32_t width, uint32_t height); qtc_qimage* qtc_qimage_create_rgba(uint32_t width, uint32_t height); uint8_t* qtc_qimage_get_data(qtc_qimage *c_img); -uint32_t qtc_qimage_get_byte_count(qtc_qimage *c_img); +uint32_t qtc_qimage_get_size_in_bytes(qtc_qimage *c_img); qtc_qimage* qtc_qimage_resize(qtc_qimage *c_img, uint32_t width, uint32_t height, AspectRatioMode ratio, bool smoothTransformation); qtc_qimage* qtc_qimage_copy(qtc_qimage *c_img, uint32_t x, uint32_t y, uint32_t width, uint32_t height); diff --git a/bindings/resvg-qt/src/ffi.rs b/bindings/resvg-qt/src/ffi.rs index f4349b2..d887177 100644 --- a/bindings/resvg-qt/src/ffi.rs +++ b/bindings/resvg-qt/src/ffi.rs @@ -418,7 +418,7 @@ extern "C" { pub fn qtc_qimage_get_data(c_img: *mut qtc_qimage) -> *mut u8; } extern "C" { - pub fn qtc_qimage_get_byte_count(c_img: *mut qtc_qimage) -> u32; + pub fn qtc_qimage_get_size_in_bytes(c_img: *mut qtc_qimage) -> u32; } extern "C" { pub fn qtc_qimage_resize( diff --git a/bindings/resvg-qt/src/lib.rs b/bindings/resvg-qt/src/lib.rs index d19cbf9..97a137d 100644 --- a/bindings/resvg-qt/src/lib.rs +++ b/bindings/resvg-qt/src/lib.rs @@ -131,7 +131,7 @@ impl Image { pub fn data(&self) -> ImageData { unsafe { let ptr = ffi::qtc_qimage_get_data(self.0); - let len = ffi::qtc_qimage_get_byte_count(self.0) as usize; + let len = ffi::qtc_qimage_get_size_in_bytes(self.0) as usize; ImageData { slice: slice::from_raw_parts_mut(ptr, len), @@ -142,7 +142,7 @@ impl Image { pub fn data_mut(&mut self) -> ImageData { unsafe { let ptr = ffi::qtc_qimage_get_data(self.0); - let len = ffi::qtc_qimage_get_byte_count(self.0) as usize; + let len = ffi::qtc_qimage_get_size_in_bytes(self.0) as usize; ImageData { slice: slice::from_raw_parts_mut(ptr, len), -- cgit v1.2.3 From 1c05ff4d98b848de3aa19fbf6ed7c1dc021c0b49 Mon Sep 17 00:00:00 2001 From: Evgeniy Reizner Date: Mon, 23 Dec 2019 01:25:41 +0200 Subject: (resvg-qt) Check Qt version before using modern API. Gbp-Pq: Name 0007-resvg-qt-Check-Qt-version-before-using-modern-API.patch --- bindings/resvg-qt/cpp/qt_capi.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/bindings/resvg-qt/cpp/qt_capi.cpp b/bindings/resvg-qt/cpp/qt_capi.cpp index 1b63aba..cabda9d 100644 --- a/bindings/resvg-qt/cpp/qt_capi.cpp +++ b/bindings/resvg-qt/cpp/qt_capi.cpp @@ -48,7 +48,11 @@ uint8_t* qtc_qimage_get_data(qtc_qimage *c_img) uint32_t qtc_qimage_get_size_in_bytes(qtc_qimage *c_img) { +#if QT_VERSION >= QT_VERSION_CHECK(5,10,0) return IMAGE_CAST->sizeInBytes(); +#else + return IMAGE_CAST->byteCount(); +#endif } qtc_qimage* qtc_qimage_resize(qtc_qimage *c_img, uint32_t width, uint32_t height, AspectRatioMode ratio, -- cgit v1.2.3 From 384e4009b08ce55c78e36a813cceaaa00b363a5c Mon Sep 17 00:00:00 2001 From: Evgeniy Reizner Date: Thu, 4 Jun 2020 19:21:10 +0300 Subject: (qt-backend) Fix building with Qt >= 5.15 Closes #294 Gbp-Pq: Name 0008-qt-backend-Fix-building-with-Qt-5.15.patch --- bindings/resvg-qt/cpp/qt_capi.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/bindings/resvg-qt/cpp/qt_capi.cpp b/bindings/resvg-qt/cpp/qt_capi.cpp index cabda9d..952d975 100644 --- a/bindings/resvg-qt/cpp/qt_capi.cpp +++ b/bindings/resvg-qt/cpp/qt_capi.cpp @@ -1,6 +1,7 @@ #include #include #include +#include #include #include -- cgit v1.2.3 From 41eff53e7649b976c49174d80862c3866868928e Mon Sep 17 00:00:00 2001 From: Andrej Shadura Date: Wed, 18 Nov 2020 14:12:02 +0100 Subject: Don't build raqote or skia backends yet Gbp-Pq: Name no-raqote-or-skia.patch --- Cargo.toml | 9 --------- capi/Cargo.toml | 4 ++-- tools/rendersvg/Cargo.toml | 4 ++-- usvg/Cargo.toml | 6 +++--- 4 files changed, 7 insertions(+), 16 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 14b203f..72be109 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -14,7 +14,6 @@ categories = ["multimedia::images"] [workspace] members = [ "bindings/resvg-qt", - "bindings/resvg-skia", "capi", "tools/rendersvg", "tools/usvg", @@ -37,17 +36,9 @@ cairo-rs = { version = "0.7.1", default-features = false, features = ["png"], op # qt backend resvg-qt = { path = "bindings/resvg-qt", version = "0.8", optional = true } -# raqote backend -raqote = { version = "0.6.1", default-features = false, optional = true } - -# skia backend -resvg-skia = { path = "bindings/resvg-skia", version = "0.8", optional = true } - [features] cairo-backend = ["cairo-rs", "png/png-encoding"] qt-backend = ["resvg-qt"] -raqote-backend = ["raqote"] -skia-backend = ["resvg-skia"] [package.metadata.docs.rs] all-features = true diff --git a/capi/Cargo.toml b/capi/Cargo.toml index 72221ef..87608b9 100644 --- a/capi/Cargo.toml +++ b/capi/Cargo.toml @@ -21,5 +21,5 @@ cairo-sys-rs = { version = "0.9.0", optional = true } [features] cairo-backend = ["resvg/cairo-backend", "cairo-sys-rs"] qt-backend = ["resvg/qt-backend"] -skia-backend = ["resvg/skia-backend"] -raqote-backend = ["resvg/raqote-backend"] +# skia-backend = ["resvg/skia-backend"] +# raqote-backend = ["resvg/raqote-backend"] diff --git a/tools/rendersvg/Cargo.toml b/tools/rendersvg/Cargo.toml index 257a658..b2c0a48 100644 --- a/tools/rendersvg/Cargo.toml +++ b/tools/rendersvg/Cargo.toml @@ -17,5 +17,5 @@ time = "0.1" [features] cairo-backend = ["resvg/cairo-backend"] qt-backend = ["resvg/qt-backend"] -raqote-backend = ["resvg/raqote-backend"] -skia-backend = ["resvg/skia-backend"] +# raqote-backend = ["resvg/raqote-backend"] +# skia-backend = ["resvg/skia-backend"] diff --git a/usvg/Cargo.toml b/usvg/Cargo.toml index 57a6956..f921a4d 100644 --- a/usvg/Cargo.toml +++ b/usvg/Cargo.toml @@ -17,9 +17,9 @@ workspace = ".." travis-ci = { repository = "RazrFalcon/resvg" } [dependencies] -base64 = "0.10" -data-url = "0.1" -kurbo = "0.2.3" +base64 = "0" +data-url = "0" +kurbo = "0.2" libflate = "0.1.25" log = "0.4" rctree = "0.3" -- cgit v1.2.3 From d05a719fea98a0df3944fd813ca83b2491d3ab5b Mon Sep 17 00:00:00 2001 From: Evgeniy Reizner Date: Mon, 23 Dec 2019 01:54:04 +0200 Subject: Update or relax dependencies Gbp-Pq: Name deps.patch --- usvg/Cargo.toml | 6 +-- usvg/src/convert/text/shaper.rs | 17 ++++---- usvg/src/tree/pathdata.rs | 86 +++++++++++++++++++---------------------- 3 files changed, 50 insertions(+), 59 deletions(-) diff --git a/usvg/Cargo.toml b/usvg/Cargo.toml index f921a4d..f873052 100644 --- a/usvg/Cargo.toml +++ b/usvg/Cargo.toml @@ -19,7 +19,7 @@ travis-ci = { repository = "RazrFalcon/resvg" } [dependencies] base64 = "0" data-url = "0" -kurbo = "0.2" +kurbo = "0.7" libflate = "0.1.25" log = "0.4" rctree = "0.3" @@ -28,13 +28,13 @@ xmlwriter = "0.1" # for svgtree roxmltree = "0.7" simplecss = "0.2" -siphasher = "0.2.3" +siphasher = "0.3" svgtypes = "0.5" # for text to path harfbuzz_rs = "1.0" memmap = "0.7" -ttf-parser = "0.2.2" +ttf-parser = "0.3" unicode-bidi = "0.3" unicode-script = "0.3" unicode-vo = "0.1" diff --git a/usvg/src/convert/text/shaper.rs b/usvg/src/convert/text/shaper.rs index cf320f6..8b07967 100644 --- a/usvg/src/convert/text/shaper.rs +++ b/usvg/src/convert/text/shaper.rs @@ -6,7 +6,6 @@ use kurbo::{ParamCurveArclen, ParamCurve, ParamCurveDeriv}; use harfbuzz_rs as harfbuzz; use unicode_vo::Orientation as CharOrientation; use ttf_parser::GlyphId; -use kurbo::Vec2; use crate::{tree, fontdb, convert::prelude::*}; use super::convert::{ @@ -547,7 +546,7 @@ fn resolve_clusters_positions_path( // Shift only by `dy` since we already applied `dx` // during offset along the path calculation. if !dy.is_fuzzy_zero() || !baseline_shift.is_fuzzy_zero() { - let shift = Vec2::from_angle(angle) + Vec2::new(0.0, dy - baseline_shift); + let shift = kurbo::Vec2::from_angle(angle) + kurbo::Vec2::new(0.0, dy - baseline_shift); cluster.transform.translate(shift.x, shift.y); } @@ -635,10 +634,10 @@ fn collect_normals( -> kurbo::CubicBez { kurbo::CubicBez { - p0: Vec2::new(px, py), - p1: Vec2::new(x1, y1), - p2: Vec2::new(x2, y2), - p3: Vec2::new(x, y), + p0: kurbo::Point::new(px, py), + p1: kurbo::Point::new(x1, y1), + p2: kurbo::Point::new(x2, y2), + p3: kurbo::Point::new(x, y), } } @@ -646,8 +645,8 @@ fn collect_normals( -> kurbo::CubicBez { let line = kurbo::Line { - p0: Vec2::new(px, py), - p1: Vec2::new(x, y), + p0: kurbo::Point::new(px, py), + p1: kurbo::Point::new(x, y), }; let p1 = line.eval(0.33); let p2 = line.eval(0.66); @@ -684,7 +683,7 @@ fn collect_normals( let pos = curve.eval(offset); let d = curve.deriv().eval(offset); - let d = Vec2::new(-d.y, d.x); // tangent + let d = kurbo::Vec2::new(-d.y, d.x); // tangent let angle = d.atan2().to_degrees() - 90.0; normals.push(Some(PathNormal { diff --git a/usvg/src/tree/pathdata.rs b/usvg/src/tree/pathdata.rs index 703492d..c148b76 100644 --- a/usvg/src/tree/pathdata.rs +++ b/usvg/src/tree/pathdata.rs @@ -66,21 +66,9 @@ impl PathData { /// Creates a path from a rect. #[inline] pub fn from_rect(rect: Rect) -> Self { - PathData(vec![ - PathSegment::MoveTo { - x: rect.x(), y: rect.y() - }, - PathSegment::LineTo { - x: rect.right(), y: rect.y() - }, - PathSegment::LineTo { - x: rect.right(), y: rect.bottom() - }, - PathSegment::LineTo { - x: rect.x(), y: rect.bottom() - }, - PathSegment::ClosePath, - ]) + let mut path = PathData::with_capacity(5); + path.push_rect(rect); + path } /// Pushes a MoveTo segment to the path. @@ -124,8 +112,8 @@ impl PathData { let (prev_x, prev_y) = self.last_pos(); let svg_arc = kurbo::SvgArc { - from: kurbo::Vec2::new(prev_x, prev_y), - to: kurbo::Vec2::new(x, y), + from: kurbo::Point::new(prev_x, prev_y), + to: kurbo::Point::new(x, y), radii: kurbo::Vec2::new(rx, ry), x_rotation: x_axis_rotation.to_radians(), large_arc, @@ -150,6 +138,18 @@ impl PathData { self.push(PathSegment::ClosePath); } + /// Pushes a rect to the path. + #[inline] + pub fn push_rect(&mut self, rect: Rect) { + self.extend_from_slice(&[ + PathSegment::MoveTo { x: rect.x(), y: rect.y() }, + PathSegment::LineTo { x: rect.right(), y: rect.y() }, + PathSegment::LineTo { x: rect.right(), y: rect.bottom() }, + PathSegment::LineTo { x: rect.x(), y: rect.bottom() }, + PathSegment::ClosePath, + ]); + } + #[inline] fn last_pos(&self) -> (f64, f64) { let seg = self.last().expect("path must not be empty").clone(); @@ -356,7 +356,7 @@ fn calc_bbox(segments: &[PathSegment]) -> Option { for seg in segments.iter().cloned() { match seg { - PathSegment::MoveTo { x, y } + PathSegment::MoveTo { x, y } | PathSegment::LineTo { x, y } => { prev_x = x; prev_y = y; @@ -368,13 +368,7 @@ fn calc_bbox(segments: &[PathSegment]) -> Option { else if y < miny { miny = y; } } PathSegment::CurveTo { x1, y1, x2, y2, x, y } => { - let curve = kurbo::CubicBez { - p0: kurbo::Vec2::new(prev_x, prev_y), - p1: kurbo::Vec2::new(x1, y1), - p2: kurbo::Vec2::new(x2, y2), - p3: kurbo::Vec2::new(x, y), - }; - + let curve = kurbo::CubicBez::from_points(prev_x, prev_y, x1, y1, x2, y2, x, y); let r = curve.bounding_box(); if r.x0 < minx { minx = r.x0; } @@ -417,7 +411,7 @@ fn calc_bbox_with_transform( for seg in TransformedPath::new(segments, ts) { match seg { - PathSegment::MoveTo { x, y } + PathSegment::MoveTo { x, y } | PathSegment::LineTo { x, y } => { prev_x = x; prev_y = y; @@ -429,13 +423,7 @@ fn calc_bbox_with_transform( else if y < miny { miny = y; } } PathSegment::CurveTo { x1, y1, x2, y2, x, y } => { - let curve = kurbo::CubicBez { - p0: kurbo::Vec2::new(prev_x, prev_y), - p1: kurbo::Vec2::new(x1, y1), - p2: kurbo::Vec2::new(x2, y2), - p3: kurbo::Vec2::new(x, y), - }; - + let curve = kurbo::CubicBez::from_points(prev_x, prev_y, x1, y1, x2, y2, x, y); let r = curve.bounding_box(); if r.x0 < minx { minx = r.x0; } @@ -496,13 +484,7 @@ fn has_bbox(segments: &[PathSegment]) -> bool { else if y < miny { miny = y; } } PathSegment::CurveTo { x1, y1, x2, y2, x, y } => { - let curve = kurbo::CubicBez { - p0: kurbo::Vec2::new(prev_x, prev_y), - p1: kurbo::Vec2::new(x1, y1), - p2: kurbo::Vec2::new(x2, y2), - p3: kurbo::Vec2::new(x, y), - }; - + let curve = kurbo::CubicBez::from_points(prev_x, prev_y, x1, y1, x2, y2, x, y); let r = curve.bounding_box(); if r.x0 < minx { minx = r.x0; } @@ -553,13 +535,7 @@ fn calc_length(segments: &[PathSegment]) -> f64 { prev_y = y; } PathSegment::CurveTo { x1, y1, x2, y2, x, y } => { - let curve = kurbo::CubicBez { - p0: kurbo::Vec2::new(prev_x, prev_y), - p1: kurbo::Vec2::new(x1, y1), - p2: kurbo::Vec2::new(x2, y2), - p3: kurbo::Vec2::new(x, y), - }; - + let curve = kurbo::CubicBez::from_points(prev_x, prev_y, x1, y1, x2, y2, x, y); length += curve.arclen(1.0); prev_x = x; @@ -659,3 +635,19 @@ fn quad_to_curve(px: f64, py: f64, x1: f64, y1: f64, x: f64, y: f64) -> PathSegm x, y, } } + + +pub(crate) trait CubicBezExt { + fn from_points(px: f64, py: f64, x1: f64, y1: f64, x2: f64, y2: f64, x: f64, y: f64) -> Self; +} + +impl CubicBezExt for kurbo::CubicBez { + fn from_points(px: f64, py: f64, x1: f64, y1: f64, x2: f64, y2: f64, x: f64, y: f64) -> Self { + kurbo::CubicBez { + p0: kurbo::Point::new(px, py), + p1: kurbo::Point::new(x1, y1), + p2: kurbo::Point::new(x2, y2), + p3: kurbo::Point::new(x, y), + } + } +} -- cgit v1.2.3 From bf92a18547c02896f59d309657eec78d97f3cd36 Mon Sep 17 00:00:00 2001 From: Andrej Shadura Date: Sat, 21 Nov 2020 22:23:59 +0100 Subject: rgb compat Gbp-Pq: Name rgb-compat.patch --- src/filter.rs | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/src/filter.rs b/src/filter.rs index 68f3703..21e7924 100644 --- a/src/filter.rs +++ b/src/filter.rs @@ -664,8 +664,8 @@ pub mod box_blur { let mut li = ti; let mut ri = ti + blur_radius * width; - let fv: RGBA8 = [0,0,0,0].into(); - let lv: RGBA8 = [0,0,0,0].into(); + let fv: RGBA8 = (0,0,0,0).into(); + let lv: RGBA8 = (0,0,0,0).into(); let mut val_r = blur_radius_next * (fv.r as isize); let mut val_g = blur_radius_next * (fv.g as isize); @@ -714,12 +714,12 @@ pub mod box_blur { val_b += sub(bb.b, fv.b); val_a += sub(bb.a, fv.a); - frontbuf[ti] = [ + frontbuf[ti] = ( round(val_r as f32 * iarr) as u8, round(val_g as f32 * iarr) as u8, round(val_b as f32 * iarr) as u8, round(val_a as f32 * iarr) as u8, - ].into(); + ).into(); ti += width; } @@ -739,12 +739,12 @@ pub mod box_blur { val_b += sub(bb1.b, bb2.b); val_a += sub(bb1.a, bb2.a); - frontbuf[ti] = [ + frontbuf[ti] = ( round(val_r as f32 * iarr) as u8, round(val_g as f32 * iarr) as u8, round(val_b as f32 * iarr) as u8, round(val_a as f32 * iarr) as u8, - ].into(); + ).into(); ti += width; } @@ -757,12 +757,12 @@ pub mod box_blur { val_b += sub(lv.b, bb.b); val_a += sub(lv.a, bb.a); - frontbuf[ti] = [ + frontbuf[ti] = ( round(val_r as f32 * iarr) as u8, round(val_g as f32 * iarr) as u8, round(val_b as f32 * iarr) as u8, round(val_a as f32 * iarr) as u8, - ].into(); + ).into(); ti += width; } } @@ -792,8 +792,8 @@ pub mod box_blur { let mut li = ti; let mut ri = ti + blur_radius; - let fv: RGBA8 = [0,0,0,0].into(); - let lv: RGBA8 = [0,0,0,0].into(); + let fv: RGBA8 = (0,0,0,0).into(); + let lv: RGBA8 = (0,0,0,0).into(); let mut val_r = blur_radius_next * (fv.r as isize); let mut val_g = blur_radius_next * (fv.g as isize); @@ -843,12 +843,12 @@ pub mod box_blur { val_b += sub(bb.b, fv.b); val_a += sub(bb.a, fv.a); - frontbuf[ti] = [ + frontbuf[ti] = ( round(val_r as f32 * iarr) as u8, round(val_g as f32 * iarr) as u8, round(val_b as f32 * iarr) as u8, round(val_a as f32 * iarr) as u8, - ].into(); + ).into(); ti += 1; // VERTICAL : ti += width, same with the other areas } @@ -870,12 +870,12 @@ pub mod box_blur { val_b += sub(bb1.b, bb2.b); val_a += sub(bb1.a, bb2.a); - frontbuf[ti] = [ + frontbuf[ti] = ( round(val_r as f32 * iarr) as u8, round(val_g as f32 * iarr) as u8, round(val_b as f32 * iarr) as u8, round(val_a as f32 * iarr) as u8, - ].into(); + ).into(); ti += 1; } @@ -889,12 +889,12 @@ pub mod box_blur { val_b += sub(lv.b, bb.b); val_a += sub(lv.a, bb.a); - frontbuf[ti] = [ + frontbuf[ti] = ( round(val_r as f32 * iarr) as u8, round(val_g as f32 * iarr) as u8, round(val_b as f32 * iarr) as u8, round(val_a as f32 * iarr) as u8, - ].into(); + ).into(); ti += 1; } } -- cgit v1.2.3 From 4f85a9a175ff659eee0d23ec0458b92644038922 Mon Sep 17 00:00:00 2001 From: Andrej Shadura Date: Sat, 21 Nov 2020 22:24:22 +0100 Subject: pico-args 0.3 Gbp-Pq: Name pico-args-0.3.patch --- tools/rendersvg/Cargo.toml | 2 +- tools/rendersvg/src/args.rs | 28 ++++++++++++++-------------- tools/usvg/Cargo.toml | 2 +- tools/usvg/src/main.rs | 18 +++++++++--------- 4 files changed, 25 insertions(+), 25 deletions(-) diff --git a/tools/rendersvg/Cargo.toml b/tools/rendersvg/Cargo.toml index b2c0a48..211e531 100644 --- a/tools/rendersvg/Cargo.toml +++ b/tools/rendersvg/Cargo.toml @@ -10,7 +10,7 @@ workspace = "../../" [dependencies] fern = "0.5" log = "0.4" -pico-args = "0.2" +pico-args = "0.3" resvg = { path = "../../" } time = "0.1" diff --git a/tools/rendersvg/src/args.rs b/tools/rendersvg/src/args.rs index 976d4bf..95211c5 100644 --- a/tools/rendersvg/src/args.rs +++ b/tools/rendersvg/src/args.rs @@ -104,26 +104,26 @@ fn collect_args() -> Result { Ok(CliArgs { help: input.contains("--help"), version: input.contains(["-V", "--version"]), - backend: input.value_from_str("--backend")?.unwrap_or(default_backend()), - width: input.value_from_fn(["-w", "--width"], parse_length)?, - height: input.value_from_fn(["-h", "--height"], parse_length)?, - zoom: input.value_from_fn(["-z", "--zoom"], parse_zoom)?, - dpi: input.value_from_fn("--dpi", parse_dpi)?.unwrap_or(96), - background: input.value_from_str("--background")?, - font_family: input.value_from_str("--font-family")? + backend: input.opt_value_from_str("--backend")?.unwrap_or(default_backend()), + width: input.opt_value_from_fn(["-w", "--width"], parse_length)?, + height: input.opt_value_from_fn(["-h", "--height"], parse_length)?, + zoom: input.opt_value_from_fn(["-z", "--zoom"], parse_zoom)?, + dpi: input.opt_value_from_fn("--dpi", parse_dpi)?.unwrap_or(96), + background: input.opt_value_from_str("--background")?, + font_family: input.opt_value_from_str("--font-family")? .unwrap_or_else(|| "Times New Roman".to_string()), - font_size: input.value_from_fn("--font-size", parse_font_size)?.unwrap_or(12), - languages: input.value_from_fn("--languages", parse_languages)? + font_size: input.opt_value_from_fn("--font-size", parse_font_size)?.unwrap_or(12), + languages: input.opt_value_from_fn("--languages", parse_languages)? .unwrap_or(vec!["en".to_string()]), // TODO: use system language - shape_rendering: input.value_from_str("--shape-rendering")?.unwrap_or_default(), - text_rendering: input.value_from_str("--text-rendering")?.unwrap_or_default(), - image_rendering: input.value_from_str("--image-rendering")?.unwrap_or_default(), + shape_rendering: input.opt_value_from_str("--shape-rendering")?.unwrap_or_default(), + text_rendering: input.opt_value_from_str("--text-rendering")?.unwrap_or_default(), + image_rendering: input.opt_value_from_str("--image-rendering")?.unwrap_or_default(), query_all: input.contains("--query-all"), - export_id: input.value_from_str("--export-id")?, + export_id: input.opt_value_from_str("--export-id")?, perf: input.contains("--perf"), pretend: input.contains("--pretend"), quiet: input.contains("--quiet"), - dump_svg: input.value_from_str("--dump-svg")?, + dump_svg: input.opt_value_from_str("--dump-svg")?, free: input.free()?, }) } diff --git a/tools/usvg/Cargo.toml b/tools/usvg/Cargo.toml index 1e046fc..e54d92f 100644 --- a/tools/usvg/Cargo.toml +++ b/tools/usvg/Cargo.toml @@ -15,7 +15,7 @@ travis-ci = { repository = "RazrFalcon/resvg" } [dependencies] fern = "0.5" log = "0.4" -pico-args = "0.2" +pico-args = "0.3" usvg = { version = "0.8", path = "../../usvg" } [[bin]] diff --git a/tools/usvg/src/main.rs b/tools/usvg/src/main.rs index 01437c4..4e09775 100644 --- a/tools/usvg/src/main.rs +++ b/tools/usvg/src/main.rs @@ -87,18 +87,18 @@ fn collect_args() -> Result { version: input.contains(["-V", "--version"]), stdout: input.contains("-c"), keep_named_groups: input.contains("--keep-named-groups"), - dpi: input.value_from_fn("--dpi", parse_dpi)?.unwrap_or(96), - font_family: input.value_from_str("--font-family")? + dpi: input.opt_value_from_fn("--dpi", parse_dpi)?.unwrap_or(96), + font_family: input.opt_value_from_str("--font-family")? .unwrap_or_else(|| "Times New Roman".to_string()), - font_size: input.value_from_fn("--font-size", parse_font_size)?.unwrap_or(12), - languages: input.value_from_fn("--languages", parse_languages)? + font_size: input.opt_value_from_fn("--font-size", parse_font_size)?.unwrap_or(12), + languages: input.opt_value_from_fn("--languages", parse_languages)? .unwrap_or(vec!["en".to_string()]), // TODO: use system language - shape_rendering: input.value_from_str("--shape-rendering")?.unwrap_or_default(), - text_rendering: input.value_from_str("--text-rendering")?.unwrap_or_default(), - image_rendering: input.value_from_str("--image-rendering")?.unwrap_or_default(), - indent: input.value_from_fn("--indent", parse_indent)? + shape_rendering: input.opt_value_from_str("--shape-rendering")?.unwrap_or_default(), + text_rendering: input.opt_value_from_str("--text-rendering")?.unwrap_or_default(), + image_rendering: input.opt_value_from_str("--image-rendering")?.unwrap_or_default(), + indent: input.opt_value_from_fn("--indent", parse_indent)? .unwrap_or(usvg::XmlIndent::Spaces(4)), - attrs_indent: input.value_from_fn("--attrs-indent", parse_indent)? + attrs_indent: input.opt_value_from_fn("--attrs-indent", parse_indent)? .unwrap_or(usvg::XmlIndent::None), quiet: input.contains("--quiet"), free: input.free()?, -- cgit v1.2.3 From 95c5994064c0ba4481f0270efb28565b8972e8d9 Mon Sep 17 00:00:00 2001 From: Andrej Shadura Date: Sat, 21 Nov 2020 22:24:49 +0100 Subject: unicode-script 0.5 Gbp-Pq: Name unicode-script-0.5.patch --- usvg/Cargo.toml | 2 +- usvg/src/convert/text/shaper.rs | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/usvg/Cargo.toml b/usvg/Cargo.toml index f873052..92a1299 100644 --- a/usvg/Cargo.toml +++ b/usvg/Cargo.toml @@ -36,5 +36,5 @@ harfbuzz_rs = "1.0" memmap = "0.7" ttf-parser = "0.3" unicode-bidi = "0.3" -unicode-script = "0.3" +unicode-script = "0.5" unicode-vo = "0.1" diff --git a/usvg/src/convert/text/shaper.rs b/usvg/src/convert/text/shaper.rs index 8b07967..d73885c 100644 --- a/usvg/src/convert/text/shaper.rs +++ b/usvg/src/convert/text/shaper.rs @@ -5,6 +5,7 @@ use kurbo::{ParamCurveArclen, ParamCurve, ParamCurveDeriv}; use harfbuzz_rs as harfbuzz; use unicode_vo::Orientation as CharOrientation; +use unicode_script::UnicodeScript; use ttf_parser::GlyphId; use crate::{tree, fontdb, convert::prelude::*}; @@ -727,7 +728,7 @@ pub fn apply_letter_spacing( // Spacing must be applied only to characters that belongs to the script // that supports spacing. // We are checking only the first code point, since it should be enough. - let script = unicode_script::get_script(cluster.codepoint); + let script = cluster.codepoint.script(); if script_supports_letter_spacing(script) { if let Some(span) = chunk.span_at(cluster.byte_idx) { // Technically, we should ignore spacing on the last character, -- cgit v1.2.3 From 9b4a9c53355849d93b009ed9010423de5c5042a8 Mon Sep 17 00:00:00 2001 From: Evgeniy Reizner Date: Mon, 23 Dec 2019 01:11:07 +0200 Subject: (resvg-qt) Do not use a deprecated method. Gbp-Pq: Name 0006-resvg-qt-Do-not-use-a-deprecated-method.patch --- bindings/resvg-qt/cpp/qt_capi.cpp | 4 ++-- bindings/resvg-qt/cpp/qt_capi.hpp | 2 +- bindings/resvg-qt/src/ffi.rs | 2 +- bindings/resvg-qt/src/lib.rs | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/bindings/resvg-qt/cpp/qt_capi.cpp b/bindings/resvg-qt/cpp/qt_capi.cpp index 5ffe45b..1b63aba 100644 --- a/bindings/resvg-qt/cpp/qt_capi.cpp +++ b/bindings/resvg-qt/cpp/qt_capi.cpp @@ -46,9 +46,9 @@ uint8_t* qtc_qimage_get_data(qtc_qimage *c_img) return IMAGE_CAST->bits(); } -uint32_t qtc_qimage_get_byte_count(qtc_qimage *c_img) +uint32_t qtc_qimage_get_size_in_bytes(qtc_qimage *c_img) { - return IMAGE_CAST->byteCount(); + return IMAGE_CAST->sizeInBytes(); } qtc_qimage* qtc_qimage_resize(qtc_qimage *c_img, uint32_t width, uint32_t height, AspectRatioMode ratio, diff --git a/bindings/resvg-qt/cpp/qt_capi.hpp b/bindings/resvg-qt/cpp/qt_capi.hpp index d9a982a..d3e07f3 100644 --- a/bindings/resvg-qt/cpp/qt_capi.hpp +++ b/bindings/resvg-qt/cpp/qt_capi.hpp @@ -97,7 +97,7 @@ extern "C" { qtc_qimage* qtc_qimage_create_rgba_premultiplied(uint32_t width, uint32_t height); qtc_qimage* qtc_qimage_create_rgba(uint32_t width, uint32_t height); uint8_t* qtc_qimage_get_data(qtc_qimage *c_img); -uint32_t qtc_qimage_get_byte_count(qtc_qimage *c_img); +uint32_t qtc_qimage_get_size_in_bytes(qtc_qimage *c_img); qtc_qimage* qtc_qimage_resize(qtc_qimage *c_img, uint32_t width, uint32_t height, AspectRatioMode ratio, bool smoothTransformation); qtc_qimage* qtc_qimage_copy(qtc_qimage *c_img, uint32_t x, uint32_t y, uint32_t width, uint32_t height); diff --git a/bindings/resvg-qt/src/ffi.rs b/bindings/resvg-qt/src/ffi.rs index f4349b2..d887177 100644 --- a/bindings/resvg-qt/src/ffi.rs +++ b/bindings/resvg-qt/src/ffi.rs @@ -418,7 +418,7 @@ extern "C" { pub fn qtc_qimage_get_data(c_img: *mut qtc_qimage) -> *mut u8; } extern "C" { - pub fn qtc_qimage_get_byte_count(c_img: *mut qtc_qimage) -> u32; + pub fn qtc_qimage_get_size_in_bytes(c_img: *mut qtc_qimage) -> u32; } extern "C" { pub fn qtc_qimage_resize( diff --git a/bindings/resvg-qt/src/lib.rs b/bindings/resvg-qt/src/lib.rs index d19cbf9..97a137d 100644 --- a/bindings/resvg-qt/src/lib.rs +++ b/bindings/resvg-qt/src/lib.rs @@ -131,7 +131,7 @@ impl Image { pub fn data(&self) -> ImageData { unsafe { let ptr = ffi::qtc_qimage_get_data(self.0); - let len = ffi::qtc_qimage_get_byte_count(self.0) as usize; + let len = ffi::qtc_qimage_get_size_in_bytes(self.0) as usize; ImageData { slice: slice::from_raw_parts_mut(ptr, len), @@ -142,7 +142,7 @@ impl Image { pub fn data_mut(&mut self) -> ImageData { unsafe { let ptr = ffi::qtc_qimage_get_data(self.0); - let len = ffi::qtc_qimage_get_byte_count(self.0) as usize; + let len = ffi::qtc_qimage_get_size_in_bytes(self.0) as usize; ImageData { slice: slice::from_raw_parts_mut(ptr, len), -- cgit v1.2.3 From 321628c393c027406c5d81cb50ea126a156e7a34 Mon Sep 17 00:00:00 2001 From: Evgeniy Reizner Date: Mon, 23 Dec 2019 01:25:41 +0200 Subject: (resvg-qt) Check Qt version before using modern API. Gbp-Pq: Name 0007-resvg-qt-Check-Qt-version-before-using-modern-API.patch --- bindings/resvg-qt/cpp/qt_capi.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/bindings/resvg-qt/cpp/qt_capi.cpp b/bindings/resvg-qt/cpp/qt_capi.cpp index 1b63aba..cabda9d 100644 --- a/bindings/resvg-qt/cpp/qt_capi.cpp +++ b/bindings/resvg-qt/cpp/qt_capi.cpp @@ -48,7 +48,11 @@ uint8_t* qtc_qimage_get_data(qtc_qimage *c_img) uint32_t qtc_qimage_get_size_in_bytes(qtc_qimage *c_img) { +#if QT_VERSION >= QT_VERSION_CHECK(5,10,0) return IMAGE_CAST->sizeInBytes(); +#else + return IMAGE_CAST->byteCount(); +#endif } qtc_qimage* qtc_qimage_resize(qtc_qimage *c_img, uint32_t width, uint32_t height, AspectRatioMode ratio, -- cgit v1.2.3 From f6a72fb25f53fe58e8a043969c18628eb25b240a Mon Sep 17 00:00:00 2001 From: Evgeniy Reizner Date: Thu, 4 Jun 2020 19:21:10 +0300 Subject: (qt-backend) Fix building with Qt >= 5.15 Closes #294 Gbp-Pq: Name 0008-qt-backend-Fix-building-with-Qt-5.15.patch --- bindings/resvg-qt/cpp/qt_capi.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/bindings/resvg-qt/cpp/qt_capi.cpp b/bindings/resvg-qt/cpp/qt_capi.cpp index cabda9d..952d975 100644 --- a/bindings/resvg-qt/cpp/qt_capi.cpp +++ b/bindings/resvg-qt/cpp/qt_capi.cpp @@ -1,6 +1,7 @@ #include #include #include +#include #include #include -- cgit v1.2.3