Update to latest cosmic

This commit is contained in:
grovesNL 2022-11-03 21:05:21 -02:30 committed by Josh Groves
parent 84fb66e27e
commit 8a1153039e
3 changed files with 9 additions and 8 deletions

View file

@ -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"

View file

@ -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);

View file

@ -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),