Fix image support
This commit is contained in:
parent
dfd8e5d86c
commit
a0355d2c71
1 changed files with 15 additions and 11 deletions
16
src/lib.rs
16
src/lib.rs
|
@ -252,16 +252,21 @@ pub fn resolve_paragraphs<'a>(
|
|||
buffer.relative_bounds.translate(Vec2::new(ls.x, 0.0));
|
||||
}
|
||||
} else {
|
||||
if image_size.x <= viewbox.x {
|
||||
last_image_size = Some(image_size + Vec2::new(IMAGE_PADDING, margin));
|
||||
}
|
||||
}
|
||||
|
||||
if image_size.x > viewbox.x {
|
||||
let max_size = Vec2::new(viewbox.x, image_size.y);
|
||||
let new_size = scale_to_fit(image_size, max_size, true);
|
||||
buffer.relative_bounds =
|
||||
Rect::from_min_size(Pos2::new(buffer.indent.indent, size.y), new_size);
|
||||
if last_image_size.is_none() {
|
||||
size.y += new_size.y
|
||||
} else {
|
||||
last_image_size = Some(image_size + Vec2::new(IMAGE_PADDING, margin));
|
||||
}
|
||||
}
|
||||
|
||||
[Some(buffer), None]
|
||||
} else if let Some(mut list_kind) = buffer.indent.modifier {
|
||||
if let Some(image_size) = last_image_size {
|
||||
|
@ -319,8 +324,6 @@ pub fn resolve_paragraphs<'a>(
|
|||
}),
|
||||
];
|
||||
size.y += buffer_size.y + (margin_top + margin);
|
||||
last_margin = margin;
|
||||
first = false;
|
||||
size.x = size.x.max(buffer_size.x + buffer_indent);
|
||||
res
|
||||
} else {
|
||||
|
@ -335,13 +338,14 @@ pub fn resolve_paragraphs<'a>(
|
|||
|
||||
in_list = false;
|
||||
size.y += buffer_size.y + (margin_top + margin);
|
||||
last_margin = margin;
|
||||
first = false;
|
||||
size.x = size.x.max(buffer_size.x + buffer_indent);
|
||||
|
||||
[Some(buffer), None]
|
||||
};
|
||||
|
||||
last_margin = margin;
|
||||
first = false;
|
||||
|
||||
result_buffers
|
||||
})
|
||||
.filter_map(|p| p)
|
||||
|
|
Loading…
Reference in a new issue