Update glyphon and cosmic-text
This commit is contained in:
parent
267dbf34e9
commit
0c65936664
3 changed files with 15 additions and 20 deletions
|
|
@ -24,7 +24,7 @@ features = ["tiny-skia"]
|
|||
|
||||
[dependencies.cosmic-text]
|
||||
git = "https://github.com/hecrj/cosmic-text.git"
|
||||
rev = "b85d6a4f2376f8a8a7dadc0f8bcb89d4db10a1c9"
|
||||
rev = "e8b10fd675832cb9c1cc9de30922beb4cf883876"
|
||||
|
||||
[dependencies.twox-hash]
|
||||
version = "1.6"
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@ path = "../graphics"
|
|||
[dependencies.glyphon]
|
||||
version = "0.2"
|
||||
git = "https://github.com/hecrj/glyphon.git"
|
||||
rev = "26f92369da3704988e3e27f0b35e705c6b2de203"
|
||||
rev = "8dbf36020e5759fa9144517b321372266160113e"
|
||||
|
||||
[dependencies.glam]
|
||||
version = "0.24"
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@ impl Pipeline {
|
|||
}
|
||||
|
||||
pub fn load_font(&mut self, bytes: Cow<'static, [u8]>) {
|
||||
self.font_system.get_mut().db_mut().load_font_source(
|
||||
let _ = self.font_system.get_mut().db_mut().load_font_source(
|
||||
glyphon::fontdb::Source::Binary(Arc::new(bytes.into_owned())),
|
||||
);
|
||||
}
|
||||
|
|
@ -116,15 +116,7 @@ impl Pipeline {
|
|||
let buffer =
|
||||
self.render_cache.get(key).expect("Get cached buffer");
|
||||
|
||||
let (total_lines, max_width) = buffer
|
||||
.layout_runs()
|
||||
.enumerate()
|
||||
.fold((0, 0.0), |(_, max), (i, buffer)| {
|
||||
(i + 1, buffer.line_w.max(max))
|
||||
});
|
||||
|
||||
let total_height =
|
||||
total_lines as f32 * buffer.metrics().line_height;
|
||||
let (max_width, total_height) = measure(buffer);
|
||||
|
||||
let x = section.bounds.x * scale_factor;
|
||||
let y = section.bounds.y * scale_factor;
|
||||
|
|
@ -265,14 +257,7 @@ impl Pipeline {
|
|||
},
|
||||
);
|
||||
|
||||
let (total_lines, max_width) = paragraph
|
||||
.layout_runs()
|
||||
.enumerate()
|
||||
.fold((0, 0.0), |(_, max), (i, buffer)| {
|
||||
(i + 1, buffer.line_w.max(max))
|
||||
});
|
||||
|
||||
(max_width, line_height * total_lines as f32)
|
||||
measure(paragraph)
|
||||
}
|
||||
|
||||
pub fn hit_test(
|
||||
|
|
@ -312,6 +297,16 @@ impl Pipeline {
|
|||
}
|
||||
}
|
||||
|
||||
fn measure(buffer: &glyphon::Buffer) -> (f32, f32) {
|
||||
let (width, total_lines) = buffer
|
||||
.layout_runs()
|
||||
.fold((0.0, 0usize), |(width, total_lines), run| {
|
||||
(run.line_w.max(width), total_lines + 1)
|
||||
});
|
||||
|
||||
(width, total_lines as f32 * buffer.metrics().line_height)
|
||||
}
|
||||
|
||||
fn to_family(family: font::Family) -> glyphon::Family<'static> {
|
||||
match family {
|
||||
font::Family::Name(name) => glyphon::Family::Name(name),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue