Update cosmic-text to 0.19
This commit is contained in:
parent
1d68895e9c
commit
e429a025df
5 changed files with 9 additions and 15 deletions
|
|
@ -10,7 +10,7 @@ license = "MIT OR Apache-2.0 OR Zlib"
|
||||||
[dependencies]
|
[dependencies]
|
||||||
wgpu = { version = "28", default-features = false, features = ["wgsl"] }
|
wgpu = { version = "28", default-features = false, features = ["wgsl"] }
|
||||||
etagere = "0.2"
|
etagere = "0.2"
|
||||||
cosmic-text = "0.18"
|
cosmic-text = "0.19"
|
||||||
lru = { version = "0.16", default-features = false }
|
lru = { version = "0.16", default-features = false }
|
||||||
rustc-hash = "2"
|
rustc-hash = "2"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -73,8 +73,8 @@ fn run_bench(ctx: &mut Criterion) {
|
||||||
.copied()
|
.copied()
|
||||||
.map(|s| {
|
.map(|s| {
|
||||||
let mut text_buffer = Buffer::new(&mut font_system, Metrics::relative(1.0, 10.0));
|
let mut text_buffer = Buffer::new(&mut font_system, Metrics::relative(1.0, 10.0));
|
||||||
text_buffer.set_size(&mut font_system, Some(20.0), None);
|
text_buffer.set_size(Some(20.0), None);
|
||||||
text_buffer.set_text(&mut font_system, s, &attrs, shaping, None);
|
text_buffer.set_text(s, &attrs, shaping, None);
|
||||||
text_buffer.shape_until_scroll(&mut font_system, false);
|
text_buffer.shape_until_scroll(&mut font_system, false);
|
||||||
text_buffer
|
text_buffer
|
||||||
})
|
})
|
||||||
|
|
@ -85,7 +85,7 @@ fn run_bench(ctx: &mut Criterion) {
|
||||||
let text_areas: Vec<TextArea> = buffers
|
let text_areas: Vec<TextArea> = buffers
|
||||||
.iter()
|
.iter()
|
||||||
.map(|b| TextArea {
|
.map(|b| TextArea {
|
||||||
buffer: b,
|
text: b.layout_runs(),
|
||||||
left: 0.0,
|
left: 0.0,
|
||||||
top: 0.0,
|
top: 0.0,
|
||||||
scale: 1.0,
|
scale: 1.0,
|
||||||
|
|
|
||||||
|
|
@ -82,12 +82,8 @@ impl WindowState {
|
||||||
let physical_width = (physical_size.width as f64 * scale_factor) as f32;
|
let physical_width = (physical_size.width as f64 * scale_factor) as f32;
|
||||||
let physical_height = (physical_size.height as f64 * scale_factor) as f32;
|
let physical_height = (physical_size.height as f64 * scale_factor) as f32;
|
||||||
|
|
||||||
text_buffer.set_size(
|
text_buffer.set_size(Some(physical_width), Some(physical_height));
|
||||||
&mut font_system,
|
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);
|
||||||
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);
|
text_buffer.shape_until_scroll(&mut font_system, false);
|
||||||
|
|
||||||
Self {
|
Self {
|
||||||
|
|
@ -179,7 +175,7 @@ impl winit::application::ApplicationHandler for Application {
|
||||||
atlas,
|
atlas,
|
||||||
viewport,
|
viewport,
|
||||||
[TextArea {
|
[TextArea {
|
||||||
buffer: text_buffer,
|
text: text_buffer.layout_runs(),
|
||||||
left: 10.0,
|
left: 10.0,
|
||||||
top: 10.0,
|
top: 10.0,
|
||||||
scale: 1.0,
|
scale: 1.0,
|
||||||
|
|
|
||||||
|
|
@ -102,10 +102,9 @@ impl Default for TextBounds {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A text area containing text to be rendered along with its overflow behavior.
|
/// A text area containing text to be rendered along with its overflow behavior.
|
||||||
#[derive(Clone)]
|
|
||||||
pub struct TextArea<'a> {
|
pub struct TextArea<'a> {
|
||||||
/// The buffer containing the text to be rendered.
|
/// The buffer containing the text to be rendered.
|
||||||
pub buffer: &'a Buffer,
|
pub text: LayoutRunIter<'a>,
|
||||||
/// The left edge of the buffer.
|
/// The left edge of the buffer.
|
||||||
pub left: f32,
|
pub left: f32,
|
||||||
/// The top edge of the buffer.
|
/// The top edge of the buffer.
|
||||||
|
|
|
||||||
|
|
@ -81,8 +81,7 @@ impl TextRenderer {
|
||||||
};
|
};
|
||||||
|
|
||||||
let layout_runs = text_area
|
let layout_runs = text_area
|
||||||
.buffer
|
.text
|
||||||
.layout_runs()
|
|
||||||
.skip_while(|run| !is_run_visible(run))
|
.skip_while(|run| !is_run_visible(run))
|
||||||
.take_while(is_run_visible);
|
.take_while(is_run_visible);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue