diff --git a/wayvr/src/backend/wayvr/client.rs b/wayvr/src/backend/wayvr/client.rs index 6144a0b5..b32e8f8a 100644 --- a/wayvr/src/backend/wayvr/client.rs +++ b/wayvr/src/backend/wayvr/client.rs @@ -1,5 +1,4 @@ use std::{ - ffi::OsStr, io::Read, os::unix::net::UnixStream, path::PathBuf, diff --git a/wgui/src/renderer_vk/text/text_renderer.rs b/wgui/src/renderer_vk/text/text_renderer.rs index 27439bb0..32986287 100644 --- a/wgui/src/renderer_vk/text/text_renderer.rs +++ b/wgui/src/renderer_vk/text/text_renderer.rs @@ -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 diff --git a/wgui/src/widget/label.rs b/wgui/src/widget/label.rs index e870e201..068d9a8d 100644 --- a/wgui/src/widget/label.rs +++ b/wgui/src/widget/label.rs @@ -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;