Annotate href links in route-D PDFs
This commit is contained in:
1 parent
fbb316baa9
commit
b30bafca2b
7 files changed
+315
-39
No files matched your search
@@ -6327,6 +6327,47 @@ mod tests {
|
||||
assert!(svg.contains("font-style=\"italic\""));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn linked_text_paints_link_annotations() {
|
||||
let segments = vec![
|
||||
crate::paragraph::InlineSegment::Text(ParagraphFont::Roman, "Visit ".into()),
|
||||
crate::paragraph::InlineSegment::Link {
|
||||
font: ParagraphFont::Roman,
|
||||
url: "https://example.com".into(),
|
||||
text: "the site".into(),
|
||||
},
|
||||
];
|
||||
let style = crate::paragraph::ParagraphStyle {
|
||||
line_width: 480 * 65_536,
|
||||
..crate::paragraph::ParagraphStyle::default()
|
||||
};
|
||||
let unit = Unit::paragraph_with_style_and_segments(1, "Visit the site", style, segments);
|
||||
let page = Page {
|
||||
items: unit.items,
|
||||
insertions: Vec::new(),
|
||||
marks: Vec::new(),
|
||||
floats: Vec::new(),
|
||||
sources: Vec::new(),
|
||||
hash: 0,
|
||||
};
|
||||
let list = page.display_list();
|
||||
let links: Vec<(&String, i64, i64)> = list
|
||||
.items
|
||||
.iter()
|
||||
.filter_map(|item| match item {
|
||||
crate::render::DisplayItem::Link { url, x, width, .. } => Some((url, *x, *width)),
|
||||
_ => None,
|
||||
})
|
||||
.collect();
|
||||
assert_eq!(links.len(), 1);
|
||||
assert_eq!(links[0].0, "https://example.com");
|
||||
assert!(links[0].1 > 0);
|
||||
assert!(links[0].2 > 0);
|
||||
let svg = list.to_svg();
|
||||
assert!(!svg.contains("#008000"));
|
||||
assert!(svg.contains(">s</text>"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn sized_paragraphs_paint_at_their_font_size() {
|
||||
let style = crate::paragraph::ParagraphStyle {
|
||||
|
||||
Reference in new issue
Block a user