Commit d19573d4 authored by RazrFalcon's avatar RazrFalcon

(qt-backend) Fixed stroking of LineTo specified as CurveTo.

parent 0b52312a
......@@ -22,6 +22,7 @@ This changelog also contains important changes in dependencies.
- (usvg) Paths without stroke and fill will no longer be removed.
Required for a proper bbox resolving.
- (usvg) Coordinates resolving when units are `userSpaceOnUse`.
- (qt-backend) Stroking of LineTo specified as CurveTo.
- (svgdom) `stroke-miterlimit` attribute parsing.
- (svgdom) `length` and `number` attribute types parsing.
- (svgdom) `offset` attribute parsing.
......
......@@ -64,7 +64,8 @@ fn apply_ts(
brush: &mut qt::Brush,
) {
// We don't use `QGradient::setCoordinateMode` because it works incorrectly.
// https://bugreports.qt.io/browse/QTBUG-67995
//
// See QTBUG-67995
if g.units == usvg::Units::ObjectBoundingBox {
let mut ts = usvg::Transform::from_bbox(bbox);
......
......@@ -61,6 +61,8 @@ fn convert_path(
let mut prev_mx = 0.0;
let mut prev_my = 0.0;
let mut prev_x = 0.0;
let mut prev_y = 0.0;
let len = list.len();
let mut i = 0;
......@@ -87,6 +89,8 @@ fn convert_path(
// Remember subpath start position.
prev_mx = x;
prev_my = y;
prev_x = x;
prev_y = y;
}
usvg::PathSegment::LineTo { mut x, y } => {
if is_last_subpath_seg {
......@@ -98,6 +102,9 @@ fn convert_path(
}
p_path.line_to(x, y);
prev_x = x;
prev_y = y;
}
usvg::PathSegment::CurveTo { x1, y1, x2, y2, mut x, y } => {
if is_last_subpath_seg {
......@@ -106,7 +113,14 @@ fn convert_path(
}
}
p_path.curve_to(x1, y1, x2, y2, x, y);
if is_line(prev_x, prev_y, x1, y1, x2, y2, x, y) {
p_path.line_to(x, y);
} else {
p_path.curve_to(x1, y1, x2, y2, x, y);
}
prev_x = x;
prev_y = y;
}
usvg::PathSegment::ClosePath => {
p_path.close_path();
......@@ -121,3 +135,14 @@ fn convert_path(
usvg::FillRule::EvenOdd => p_path.set_fill_rule(qt::FillRule::OddEven),
}
}
// If CurveTo is approximately a LineTo than we should draw it as LineTo,
// otherwise Qt will draw it incorrectly.
//
// See QTBUG-72796
fn is_line(px: f64, py: f64, x1: f64, y1: f64, x2: f64, y2: f64, x: f64, y: f64) -> bool {
(px - x1).abs() < 0.001
&& (py - y1).abs() < 0.001
&& (x2 - x).abs() < 0.001
&& (y2 - y).abs() < 0.001
}
......@@ -57,7 +57,6 @@ Full spec can be found [here](docs/usvg_spec.adoc).
- Unsupported elements:
- some filter-based elements
- font-based elements
- `marker`
## Dependency
......
......@@ -933,3 +933,10 @@ e-filter-057,a2b786f1
e-linearGradient-031,3fd79268
e-pattern-027,f3fbe960
e-radialGradient-039,f0ad4b80
a-stroke-016,22e89c3a
a-stroke-017,1d037a5f
a-stroke-018,e9ed7186
a-stroke-019,5a6c1265
e-stop-028,d17c95f8
e-stop-029,219b53c7
e-stop-030,99767fc0
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment