fix wrapped text flying around

This commit is contained in:
galister 2026-07-13 10:23:02 +09:00
parent a3e3101ab0
commit a8262c1de4
3 changed files with 11 additions and 4 deletions

View File

@ -1,5 +1,4 @@
use std::{
ffi::OsStr,
io::Read,
os::unix::net::UnixStream,
path::PathBuf,

View File

@ -4,12 +4,12 @@ use crate::{
};
use super::{
ContentType, FontSystem, GlyphDetails, GpuCacheStatus, SwashCache, TextArea,
custom_glyph::{CustomGlyphCacheKey, RasterizeCustomGlyphRequest, RasterizedCustomGlyph},
text_atlas::{GlyphVertex, TextAtlas, TextPipeline},
ContentType, FontSystem, GlyphDetails, GpuCacheStatus, SwashCache, TextArea,
};
use cosmic_text::{Color, SubpixelBin, SwashContent};
use etagere::{AllocId, size2};
use etagere::{size2, AllocId};
use glam::{Mat4, Vec2, Vec3};
use std::collections::HashSet;
@ -159,6 +159,14 @@ impl TextRenderer {
start_y_physical <= text_area.bounds.bottom && text_area.bounds.top <= end_y_physical
};
// ensure layout is up to date before reading
// `set_size()` in draw() sets dirty flags but doesn't trigger shape_until_scroll
// without this, layout_runs() on &Buffer returns stale layouts
{
let mut buf = text_area.buffer.borrow_mut();
buf.shape_until_scroll(font_system, false);
}
let buffer = text_area.buffer.borrow();
let layout_runs = buffer

View File

@ -1,6 +1,6 @@
use std::{cell::RefCell, rc::Rc};
use cosmic_text::{Attrs, AttrsList, BorrowedWithFontSystem, Buffer, Metrics, Shaping, Wrap};
use cosmic_text::{Attrs, AttrsList, BorrowedWithFontSystem, Buffer, Metrics, Scroll, Shaping, Wrap};
use slotmap::Key;
use taffy::AvailableSpace;