Update to latest cosmic
This commit is contained in:
parent
84fb66e27e
commit
8a1153039e
3 changed files with 9 additions and 8 deletions
|
@ -10,7 +10,7 @@ license = "MIT OR Apache-2.0 OR Zlib"
|
||||||
[dependencies]
|
[dependencies]
|
||||||
wgpu = "0.14.0"
|
wgpu = "0.14.0"
|
||||||
etagere = "0.2.6"
|
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]
|
[dev-dependencies]
|
||||||
winit = "0.27.0"
|
winit = "0.27.0"
|
||||||
|
|
|
@ -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 glyphon::{Resolution, TextAtlas, TextRenderer};
|
||||||
use wgpu::{
|
use wgpu::{
|
||||||
Backends, CommandEncoderDescriptor, CompositeAlphaMode, DeviceDescriptor, Features, Instance,
|
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 cache = SwashCache::new(unsafe { FONT_SYSTEM.as_ref().unwrap() });
|
||||||
let mut atlas = TextAtlas::new(&device, &queue, swapchain_format);
|
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() },
|
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_size((width as f64 * scale_factor) as i32, (height as f64) as i32);
|
||||||
buffer.set_text(include_str!("./ligature.txt"), Attrs::new());
|
buffer.set_text(include_str!("./ligature.txt"), Attrs::new());
|
||||||
buffer.shape_until_cursor();
|
buffer.shape_until_scroll();
|
||||||
|
|
||||||
event_loop.run(move |event, _, control_flow| {
|
event_loop.run(move |event, _, control_flow| {
|
||||||
let _ = (&instance, &adapter);
|
let _ = (&instance, &adapter);
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
use cosmic_text::{CacheKey, Color, SwashCache, SwashContent, TextBuffer};
|
use cosmic_text::{CacheKey, Color, SwashCache, SwashContent};
|
||||||
use etagere::{size2, Allocation};
|
use etagere::{size2, Allocation};
|
||||||
|
|
||||||
use std::{collections::HashSet, iter, mem::size_of, num::NonZeroU32, slice};
|
use std::{collections::HashSet, iter, mem::size_of, num::NonZeroU32, slice};
|
||||||
|
@ -63,7 +63,7 @@ impl TextRenderer {
|
||||||
queue: &Queue,
|
queue: &Queue,
|
||||||
atlas: &mut TextAtlas,
|
atlas: &mut TextAtlas,
|
||||||
screen_resolution: Resolution,
|
screen_resolution: Resolution,
|
||||||
buffer: &mut TextBuffer<'a>,
|
buffer: &mut cosmic_text::Buffer<'a>,
|
||||||
default_color: Color,
|
default_color: Color,
|
||||||
cache: &mut SwashCache,
|
cache: &mut SwashCache,
|
||||||
) -> Result<(), PrepareError> {
|
) -> Result<(), PrepareError> {
|
||||||
|
@ -204,7 +204,8 @@ impl TextRenderer {
|
||||||
},
|
},
|
||||||
aspect: TextureAspect::All,
|
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 {
|
ImageDataLayout {
|
||||||
offset: 0,
|
offset: 0,
|
||||||
bytes_per_row: NonZeroU32::new(atlas.width * NUM_ATLAS_CHANNELS as u32),
|
bytes_per_row: NonZeroU32::new(atlas.width * NUM_ATLAS_CHANNELS as u32),
|
||||||
|
|
Loading…
Reference in a new issue