mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-11-13 09:20:56 -06:00
Open: the first frame uses the layouts the open made for type objects
Opening a document laid out every type object for its bounds and baselines and threw the layouts away, and the first frame laid the same objects out again. The open now keeps them, up to 128 MiB, and a frame takes each one once. A frame takes a layout only for a text object equal to the one laid out, and only while the fonts, the system fallback setting and the hyphenation exceptions are unchanged. When the last frame being drawn ends, the rest are dropped if a frame took one, and all of them are dropped after eight frames that take none. A layout with bitmap or color glyphs and a text object with a gradient are not kept.
This commit is contained in:
@@ -298,6 +298,18 @@ pub(crate) fn refresh_bounds(t: &mut TextObject) {
|
||||
t.cached_baselines = lay.baselines();
|
||||
}
|
||||
|
||||
/// [`refresh_bounds`] for a document that is opening: the first frame takes the layout
|
||||
/// ([`vectorcraft_text::take_kept_layout`]) instead of laying the object out again.
|
||||
pub(crate) fn refresh_bounds_for_first_frame(t: &mut TextObject) {
|
||||
t.normalize_paras();
|
||||
auto_height(t);
|
||||
let stamp = vectorcraft_text::LayoutStamp::now();
|
||||
let lay = vectorcraft_text::layout(vectorcraft_text::FontDb::global(), t);
|
||||
t.cached_bounds = Some(lay.bounds);
|
||||
t.cached_baselines = lay.baselines();
|
||||
vectorcraft_text::keep_layout(t, stamp, lay);
|
||||
}
|
||||
|
||||
/// The text-space bounds of area type's frame, when Auto Size can fit it: a rectangle (one
|
||||
/// subpath, as large as its bounds) of horizontal type in one row, with some height.
|
||||
fn auto_height_frame(t: &TextObject) -> Option<vectorcraft_geom::Rect> {
|
||||
|
||||
Reference in New Issue
Block a user