Compare commits

..

2 commits

Author SHA1 Message Date
5e16f105e0 chore: use local cosmic-text
Some checks failed
Format / all (push) Has been cancelled
Lint / all (push) Has been cancelled
Test / all (macOS-latest, beta) (push) Has been cancelled
Test / all (macOS-latest, stable) (push) Has been cancelled
Test / all (ubuntu-latest, beta) (push) Has been cancelled
Test / all (ubuntu-latest, stable) (push) Has been cancelled
Test / all (windows-latest, beta) (push) Has been cancelled
Test / all (windows-latest, stable) (push) Has been cancelled
2026-05-25 18:27:44 +02:00
Ashley Wulber
c49de15bce
fix: cosmic-text 2026-01-21 11:17:55 -05:00
6 changed files with 21 additions and 15 deletions

View file

@ -8,7 +8,7 @@ repository = "https://github.com/iced-rs/cryoglyph"
license = "MIT OR Apache-2.0 OR Zlib"
[dependencies]
wgpu = { version = "28", default-features = false, features = ["wgsl"] }
wgpu = { version = "27", default-features = false, features = ["wgsl"] }
etagere = "0.2"
cosmic-text = { path = "../cosmic-text" }
lru = { version = "0.16", default-features = false }

View file

@ -73,8 +73,8 @@ fn run_bench(ctx: &mut Criterion) {
.copied()
.map(|s| {
let mut text_buffer = Buffer::new(&mut font_system, Metrics::relative(1.0, 10.0));
text_buffer.set_size(Some(20.0), None);
text_buffer.set_text(s, &attrs, shaping, None);
text_buffer.set_size(&mut font_system, Some(20.0), None);
text_buffer.set_text(&mut font_system, s, &attrs, shaping, None);
text_buffer.shape_until_scroll(&mut font_system, false);
text_buffer
})
@ -85,7 +85,7 @@ fn run_bench(ctx: &mut Criterion) {
let text_areas: Vec<TextArea> = buffers
.iter()
.map(|b| TextArea {
text: b.layout_runs(),
buffer: b,
left: 0.0,
top: 0.0,
scale: 1.0,

View file

@ -82,8 +82,12 @@ impl WindowState {
let physical_width = (physical_size.width as f64 * scale_factor) as f32;
let physical_height = (physical_size.height as f64 * scale_factor) as f32;
text_buffer.set_size(Some(physical_width), Some(physical_height));
text_buffer.set_text("Hello world! 👋\nThis is rendered with 🦅 glyphon 🦁\nThe text below should be partially clipped.\na b c d e f g h i j k l m n o p q r s t u v w x y z", &Attrs::new().family(Family::SansSerif), Shaping::Advanced, None);
text_buffer.set_size(
&mut font_system,
Some(physical_width),
Some(physical_height),
);
text_buffer.set_text(&mut font_system, "Hello world! 👋\nThis is rendered with 🦅 glyphon 🦁\nThe text below should be partially clipped.\na b c d e f g h i j k l m n o p q r s t u v w x y z", &Attrs::new().family(Family::SansSerif), Shaping::Advanced, None);
text_buffer.shape_until_scroll(&mut font_system, false);
Self {
@ -175,7 +179,7 @@ impl winit::application::ApplicationHandler for Application {
atlas,
viewport,
[TextArea {
text: text_buffer.layout_runs(),
buffer: text_buffer,
left: 10.0,
top: 10.0,
scale: 1.0,
@ -209,7 +213,6 @@ impl winit::application::ApplicationHandler for Application {
depth_stencil_attachment: None,
timestamp_writes: None,
occlusion_query_set: None,
multiview_mask: None,
});
text_renderer.render(&atlas, &viewport, &mut pass).unwrap();

View file

@ -42,7 +42,7 @@ impl Cache {
label: Some("glyphon sampler"),
min_filter: FilterMode::Nearest,
mag_filter: FilterMode::Nearest,
mipmap_filter: wgpu::MipmapFilterMode::Nearest,
mipmap_filter: FilterMode::Nearest,
lod_min_clamp: 0f32,
lod_max_clamp: 0f32,
..Default::default()
@ -139,7 +139,7 @@ impl Cache {
let pipeline_layout = device.create_pipeline_layout(&PipelineLayoutDescriptor {
label: None,
bind_group_layouts: &[&atlas_layout, &uniforms_layout],
immediate_size: 0,
push_constant_ranges: &[],
});
Self(Arc::new(Inner {
@ -237,7 +237,7 @@ impl Cache {
},
depth_stencil: depth_stencil.clone(),
multisample,
multiview_mask: None,
multiview: None,
cache: None,
});

View file

@ -102,9 +102,10 @@ impl Default for TextBounds {
}
/// A text area containing text to be rendered along with its overflow behavior.
#[derive(Clone)]
pub struct TextArea<'a> {
/// The buffer containing the text to be rendered.
pub text: LayoutRunIter<'a>,
pub buffer: &'a Buffer,
/// The left edge of the buffer.
pub left: f32,
/// The top edge of the buffer.

View file

@ -39,7 +39,7 @@ impl TextRenderer {
let pipeline = atlas.get_or_create_pipeline(device, multisample, depth_stencil);
Self {
staging_belt: StagingBelt::new(device.clone(), vertex_buffer_size),
staging_belt: StagingBelt::new(vertex_buffer_size),
vertex_buffer,
vertex_buffer_size,
pipeline,
@ -81,7 +81,8 @@ impl TextRenderer {
};
let layout_runs = text_area
.text
.buffer
.layout_runs()
.skip_while(|run| !is_run_visible(run))
.take_while(is_run_visible);
@ -294,6 +295,7 @@ impl TextRenderer {
&self.vertex_buffer,
0,
NonZeroU64::new(vertices_raw.len() as u64).expect("Non-empty vertices"),
device,
)
.copy_from_slice(vertices_raw);
} else {
@ -310,7 +312,7 @@ impl TextRenderer {
self.vertex_buffer_size = buffer_size;
self.staging_belt.finish();
self.staging_belt = StagingBelt::new(device.clone(), buffer_size);
self.staging_belt = StagingBelt::new(buffer_size);
}
self.staging_belt.finish();