diff --git a/Cargo.toml b/Cargo.toml index f475145..75aaf83 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -10,7 +10,7 @@ license = "MIT OR Apache-2.0 OR Zlib" [dependencies] wgpu = "0.14.0" etagere = "0.2.6" -cosmic-text = { git = "https://github.com/pop-os/cosmic-text", rev = "a1f7675" } +cosmic-text = { git = "https://github.com/pop-os/cosmic-text", rev = "9e389b6" } [dev-dependencies] winit = "0.27.0" diff --git a/examples/hello-world.rs b/examples/hello-world.rs index 56dfaef..1cd361b 100644 --- a/examples/hello-world.rs +++ b/examples/hello-world.rs @@ -1,4 +1,4 @@ -use cosmic_text::{Attrs, Color, FontSystem, SwashCache, TextBuffer, TextMetrics}; +use cosmic_text::{Attrs, Buffer, Color, FontSystem, Metrics, SwashCache}; use glyphon::{Resolution, TextAtlas, TextRenderer}; use wgpu::{ Backends, CommandEncoderDescriptor, CompositeAlphaMode, DeviceDescriptor, Features, Instance, @@ -68,13 +68,13 @@ async fn run() { } let mut cache = SwashCache::new(unsafe { FONT_SYSTEM.as_ref().unwrap() }); let mut atlas = TextAtlas::new(&device, &queue, swapchain_format); - let mut buffer = TextBuffer::new( + let mut buffer = Buffer::new( unsafe { FONT_SYSTEM.as_ref().unwrap() }, - TextMetrics::new(32, 44), + Metrics::new(32, 44), ); buffer.set_size((width as f64 * scale_factor) as i32, (height as f64) as i32); buffer.set_text(include_str!("./ligature.txt"), Attrs::new()); - buffer.shape_until_cursor(); + buffer.shape_until_scroll(); event_loop.run(move |event, _, control_flow| { let _ = (&instance, &adapter); diff --git a/src/text_render.rs b/src/text_render.rs index 34a3186..1e898fb 100644 --- a/src/text_render.rs +++ b/src/text_render.rs @@ -1,4 +1,4 @@ -use cosmic_text::{CacheKey, Color, SwashCache, SwashContent, TextBuffer}; +use cosmic_text::{CacheKey, Color, SwashCache, SwashContent}; use etagere::{size2, Allocation}; use std::{collections::HashSet, iter, mem::size_of, num::NonZeroU32, slice}; @@ -63,7 +63,7 @@ impl TextRenderer { queue: &Queue, atlas: &mut TextAtlas, screen_resolution: Resolution, - buffer: &mut TextBuffer<'a>, + buffer: &mut cosmic_text::Buffer<'a>, default_color: Color, cache: &mut SwashCache, ) -> Result<(), PrepareError> { @@ -204,7 +204,8 @@ impl TextRenderer { }, aspect: TextureAspect::All, }, - &atlas.texture_pending[ub.y_min * atlas.width as usize + ub.x_min..], + &atlas.texture_pending + [ub.y_min * atlas.width as usize + ub.x_min * NUM_ATLAS_CHANNELS..], ImageDataLayout { offset: 0, bytes_per_row: NonZeroU32::new(atlas.width * NUM_ATLAS_CHANNELS as u32),