[librsvg: 7/15] layout::TextSpan - store the PDF link target here
- From: Marge Bot <marge-bot src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [librsvg: 7/15] layout::TextSpan - store the PDF link target here
- Date: Mon, 18 Oct 2021 23:15:47 +0000 (UTC)
commit 6aff484d19c26579abe6636e6e530b9691176d4c
Author: Federico Mena Quintero <federico gnome org>
Date: Mon Oct 18 12:23:03 2021 -0500
layout::TextSpan - store the PDF link target here
And process it in DrawingCtx::draw_text_span.
Part-of: <https://gitlab.gnome.org/GNOME/librsvg/-/merge_requests/613>
src/drawing_ctx.rs | 8 ++++++++
src/layout.rs | 1 +
src/text.rs | 9 +++------
3 files changed, 12 insertions(+), 6 deletions(-)
---
diff --git a/src/drawing_ctx.rs b/src/drawing_ctx.rs
index cfde44e1..6e76c922 100644
--- a/src/drawing_ctx.rs
+++ b/src/drawing_ctx.rs
@@ -1410,6 +1410,10 @@ impl DrawingCtx {
}
if span.is_visible {
+ if let Some(ref link_target) = span.link_target {
+ self.link_tag_begin(&link_target);
+ }
+
for &target in &paint_order.targets {
match target {
PaintTarget::Fill => {
@@ -1469,6 +1473,10 @@ impl DrawingCtx {
PaintTarget::Markers => {}
}
}
+
+ if span.link_target.is_some() {
+ self.link_tag_end();
+ }
}
Ok(bbox)
diff --git a/src/layout.rs b/src/layout.rs
index 085cf584..956fec3a 100644
--- a/src/layout.rs
+++ b/src/layout.rs
@@ -106,6 +106,7 @@ pub struct TextSpan {
pub stroke_paint: PaintSource,
pub fill_paint: PaintSource,
pub text_rendering: TextRendering,
+ pub link_target: Option<String>,
}
/// Font-related properties extracted from `ComputedValues`.
diff --git a/src/text.rs b/src/text.rs
index 285b59b0..216a521b 100644
--- a/src/text.rs
+++ b/src/text.rs
@@ -333,6 +333,7 @@ impl PositionedSpan {
acquired_nodes: &mut AcquiredNodes<'_>,
draw_ctx: &mut DrawingCtx,
clipping: bool,
+ link_target: Option<String>,
) -> Result<BoundingBox, RenderingError> {
let view_params = draw_ctx.get_view_params();
let params = NormalizeParams::new(&self.values, &view_params);
@@ -376,6 +377,7 @@ impl PositionedSpan {
stroke_paint,
fill_paint,
text_rendering,
+ link_target,
};
draw_ctx.draw_text_span(&view_params, &span, acquired_nodes, &self.values, clipping)
@@ -677,12 +679,7 @@ impl Draw for Text {
for chunk in &positioned_chunks {
for span in &chunk.spans {
- let span_bbox = match chunk.link.as_ref() {
- Some(l) if !l.is_empty() => {
- dc.with_link_tag(l.as_str(), &mut |dc| span.draw(an, dc, clipping))?
- }
- _ => span.draw(an, dc, clipping)?,
- };
+ let span_bbox = span.draw(an, dc, clipping, chunk.link.clone())?;
bbox.insert(&span_bbox);
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]