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));
|
buffer.relative_bounds.translate(Vec2::new(ls.x, 0.0));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
if image_size.x <= viewbox.x {
|
||||||
|
last_image_size = Some(image_size + Vec2::new(IMAGE_PADDING, margin));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if image_size.x > viewbox.x {
|
if image_size.x > viewbox.x {
|
||||||
let max_size = Vec2::new(viewbox.x, image_size.y);
|
let max_size = Vec2::new(viewbox.x, image_size.y);
|
||||||
let new_size = scale_to_fit(image_size, max_size, true);
|
let new_size = scale_to_fit(image_size, max_size, true);
|
||||||
buffer.relative_bounds =
|
buffer.relative_bounds =
|
||||||
Rect::from_min_size(Pos2::new(buffer.indent.indent, size.y), new_size);
|
Rect::from_min_size(Pos2::new(buffer.indent.indent, size.y), new_size);
|
||||||
|
if last_image_size.is_none() {
|
||||||
size.y += new_size.y
|
size.y += new_size.y
|
||||||
} else {
|
|
||||||
last_image_size = Some(image_size + Vec2::new(IMAGE_PADDING, margin));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[Some(buffer), None]
|
[Some(buffer), None]
|
||||||
} else if let Some(mut list_kind) = buffer.indent.modifier {
|
} else if let Some(mut list_kind) = buffer.indent.modifier {
|
||||||
if let Some(image_size) = last_image_size {
|
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);
|
size.y += buffer_size.y + (margin_top + margin);
|
||||||
last_margin = margin;
|
|
||||||
first = false;
|
|
||||||
size.x = size.x.max(buffer_size.x + buffer_indent);
|
size.x = size.x.max(buffer_size.x + buffer_indent);
|
||||||
res
|
res
|
||||||
} else {
|
} else {
|
||||||
|
@ -335,13 +338,14 @@ pub fn resolve_paragraphs<'a>(
|
||||||
|
|
||||||
in_list = false;
|
in_list = false;
|
||||||
size.y += buffer_size.y + (margin_top + margin);
|
size.y += buffer_size.y + (margin_top + margin);
|
||||||
last_margin = margin;
|
|
||||||
first = false;
|
|
||||||
size.x = size.x.max(buffer_size.x + buffer_indent);
|
size.x = size.x.max(buffer_size.x + buffer_indent);
|
||||||
|
|
||||||
[Some(buffer), None]
|
[Some(buffer), None]
|
||||||
};
|
};
|
||||||
|
|
||||||
|
last_margin = margin;
|
||||||
|
first = false;
|
||||||
|
|
||||||
result_buffers
|
result_buffers
|
||||||
})
|
})
|
||||||
.filter_map(|p| p)
|
.filter_map(|p| p)
|
||||||
|
|
Loading…
Reference in a new issue