Update glyphon version
This commit is contained in:
parent
afabca09e4
commit
a09d418a60
3 changed files with 935 additions and 802 deletions
1714
Cargo.lock
generated
1714
Cargo.lock
generated
File diff suppressed because it is too large
Load diff
|
@ -6,10 +6,10 @@ edition = "2021"
|
||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
egui = { version = "0.29.1", default-features = false }
|
egui = { version = "0.31", default-features = false }
|
||||||
egui-wgpu = "0.29.1"
|
egui-wgpu = "0.31"
|
||||||
glyphon = { git = "https://git.nations.lol/fnmain/glyphon.git" }
|
glyphon = { git = "https://git.nations.lol/fnmain/glyphon.git" }
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
eframe = { version = "0.29.1", features = ["wgpu"] }
|
eframe = { version = "0.31", features = ["wgpu"] }
|
||||||
env_logger = "0.11.3"
|
env_logger = "0.11.3"
|
||||||
|
|
|
@ -26,7 +26,7 @@ fn main() -> Result<(), eframe::Error> {
|
||||||
eframe::run_native(
|
eframe::run_native(
|
||||||
"My egui App",
|
"My egui App",
|
||||||
options,
|
options,
|
||||||
Box::new(|cc| Box::new(MyApp::new(cc))),
|
Box::new(|cc| Ok(Box::new(MyApp::new(cc)))),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -42,14 +42,14 @@ impl Default for MyApp {
|
||||||
let mut buffer =
|
let mut buffer =
|
||||||
egui_glyphon::glyphon::Buffer::new(&mut font_system, Metrics::new(30.0, 42.0));
|
egui_glyphon::glyphon::Buffer::new(&mut font_system, Metrics::new(30.0, 42.0));
|
||||||
|
|
||||||
buffer.set_size(&mut font_system, 16.0, 9.0);
|
buffer.set_size(&mut font_system, Some(16.0), Some(9.0));
|
||||||
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 fi ffi 🐕🦺 fi ffi
|
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 fi ffi 🐕🦺 fi ffi
|
||||||
fi تما 🐕🦺 ffi تما
|
fi تما 🐕🦺 ffi تما
|
||||||
ffi fi 🐕🦺 ffi fi
|
ffi fi 🐕🦺 ffi fi
|
||||||
تما تما 🐕🦺 تما
|
تما تما 🐕🦺 تما
|
||||||
تما ffi 🐕🦺 تما fi تما
|
تما ffi 🐕🦺 تما fi تما
|
||||||
تما تما 🐕🦺 تما", Attrs::new().family(Family::SansSerif), Shaping::Advanced);
|
تما تما 🐕🦺 تما", Attrs::new().family(Family::SansSerif), Shaping::Advanced);
|
||||||
buffer.shape_until_scroll(&mut font_system);
|
buffer.shape_until_scroll(&mut font_system, true);
|
||||||
Self {
|
Self {
|
||||||
font_system: Arc::new(Mutex::new(font_system)),
|
font_system: Arc::new(Mutex::new(font_system)),
|
||||||
buffer: Arc::new(RwLock::new(buffer)),
|
buffer: Arc::new(RwLock::new(buffer)),
|
||||||
|
@ -63,7 +63,9 @@ impl MyApp {
|
||||||
let app = Self::default();
|
let app = Self::default();
|
||||||
|
|
||||||
if let Some(ref wgpu) = cc.wgpu_render_state {
|
if let Some(ref wgpu) = cc.wgpu_render_state {
|
||||||
GlyphonRenderer::insert(wgpu, Arc::clone(&app.font_system));
|
let cache = glyphon::Cache::new(&wgpu.device);
|
||||||
|
let viewport = glyphon::Viewport::new(&wgpu.device, &cache);
|
||||||
|
GlyphonRenderer::insert(wgpu, Arc::clone(&app.font_system), &cache, viewport);
|
||||||
}
|
}
|
||||||
|
|
||||||
app
|
app
|
||||||
|
@ -78,19 +80,20 @@ impl eframe::App for MyApp {
|
||||||
let mut font_system = self.font_system.lock();
|
let mut font_system = self.font_system.lock();
|
||||||
let mut buffer = self.buffer.write();
|
let mut buffer = self.buffer.write();
|
||||||
buffer.set_metrics(&mut font_system, Metrics::new(self.size, self.size));
|
buffer.set_metrics(&mut font_system, Metrics::new(self.size, self.size));
|
||||||
buffer.set_size(&mut font_system, size.x, size.y);
|
buffer.set_size(&mut font_system, Some(size.x), Some(size.y));
|
||||||
buffer.shape_until_scroll(&mut font_system);
|
buffer.shape_until_scroll(&mut font_system, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
egui::CentralPanel::default().show(ctx, |ui| {
|
egui::CentralPanel::default().show(ctx, |ui| {
|
||||||
ui.add(Slider::new(&mut self.size, 0.1..=67.5));
|
ui.add(Slider::new(&mut self.size, 0.1..=67.5));
|
||||||
let rect = Rect::from_min_size(ui.cursor().min, size);
|
let rect = Rect::from_min_size(ui.cursor().min, size);
|
||||||
let buffers: Vec<BufferWithTextArea> = vec![BufferWithTextArea::new(
|
let buffers: Vec<BufferWithTextArea<()>> = vec![BufferWithTextArea::new(
|
||||||
self.buffer.clone(),
|
self.buffer.clone(),
|
||||||
rect,
|
rect,
|
||||||
1.0,
|
1.0,
|
||||||
egui_glyphon::glyphon::Color::rgb(255, 255, 255),
|
egui_glyphon::glyphon::Color::rgb(255, 255, 255),
|
||||||
ui.ctx(),
|
ui.ctx(),
|
||||||
|
(),
|
||||||
)];
|
)];
|
||||||
ui.painter().add(egui_wgpu::Callback::new_paint_callback(
|
ui.painter().add(egui_wgpu::Callback::new_paint_callback(
|
||||||
ui.max_rect(),
|
ui.max_rect(),
|
||||||
|
|
Loading…
Reference in a new issue