Draw fbox frames without a background
This commit is contained in:
1 parent
3d01fbe589
commit
994c360ec0
6 files changed
+50
-23
No files matched your search
+34
-14
@@ -6714,6 +6714,7 @@ fn split_color_runs(
|
||||
.into_iter()
|
||||
.chain(rest.find("\\colorbox").map(|index| (index, "\\colorbox")))
|
||||
.chain(rest.find("\\fcolorbox").map(|index| (index, "\\fcolorbox")))
|
||||
.chain(rest.find("\\fbox").map(|index| (index, "\\fbox")))
|
||||
.min_by_key(|(index, _)| *index);
|
||||
let Some((index, command)) = next else {
|
||||
break;
|
||||
@@ -6734,6 +6735,7 @@ fn split_color_runs(
|
||||
continue;
|
||||
}
|
||||
},
|
||||
"\\fbox" => (None, false, Some([0, 0, 0]), after_command),
|
||||
"\\colorbox" => match color_spec(&first, custom) {
|
||||
Some(color) => (Some(color), true, None, after_first),
|
||||
None => {
|
||||
@@ -6812,21 +6814,20 @@ fn inline_math_segments(
|
||||
parse_math(&piece),
|
||||
));
|
||||
} else if !piece.is_empty() {
|
||||
if let Some(rgb) = color {
|
||||
if background || frame.is_some() {
|
||||
found_color = true;
|
||||
if background {
|
||||
segments.push(
|
||||
texrra_tex_core::paragraph::InlineSegment::ColorBox(
|
||||
font, size, raise, rgb, frame, piece,
|
||||
),
|
||||
);
|
||||
} else {
|
||||
segments.push(
|
||||
texrra_tex_core::paragraph::InlineSegment::Color(
|
||||
font, size, raise, rgb, piece,
|
||||
),
|
||||
);
|
||||
}
|
||||
segments.push(
|
||||
texrra_tex_core::paragraph::InlineSegment::ColorBox(
|
||||
font, size, raise, color, frame, piece,
|
||||
),
|
||||
);
|
||||
} else if let Some(rgb) = color {
|
||||
found_color = true;
|
||||
segments.push(
|
||||
texrra_tex_core::paragraph::InlineSegment::Color(
|
||||
font, size, raise, rgb, piece,
|
||||
),
|
||||
);
|
||||
} else if raise != 0 {
|
||||
found_size = true;
|
||||
segments.push(
|
||||
@@ -12784,6 +12785,25 @@ A definition.
|
||||
assert!(text.contains("0.000 1.000 0.000 rg"), "{text}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn color_runs_recognise_fbox() {
|
||||
let runs = split_color_runs(r"\fbox{Boxed}", &[]);
|
||||
assert_eq!(runs.len(), 1);
|
||||
assert!(runs[0].2 == Some([0, 0, 0]), "{runs:?}");
|
||||
assert_eq!(runs[0].3, "Boxed");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn fbox_draws_a_frame_without_a_background() {
|
||||
let json = preview_json(r"\fbox{Boxed}").expect("preview");
|
||||
assert!(
|
||||
json.contains("stroke=") && json.contains("#000000"),
|
||||
"{json}"
|
||||
);
|
||||
assert!(json.contains(">B</text>"), "{json}");
|
||||
assert!(!json.contains("fbox"), "{json}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn colorbox_paints_a_background_rectangle() {
|
||||
let source = "Body \\colorbox{lime}{Boxed} word.";
|
||||
|
||||
Reference in new issue
Block a user