Open Szybet opened 6 months ago
With regular eframe apps, this happens if you don't have any fonts, i.e., you don't enable the default_fonts
feature and you don't add any fonts of your own. But this feature is enabled by default, so you should have it in your repo, so I'm not sure if this is the problem in your case. Also, you have a dependency on epi, but it looks like this crate has been moved into eframe. If you look in your lockfile, you have a dependency on egui 0.17 because of epi, it is not going to work with egui 0.27. Maybe you could check out the projected listed in https://github.com/emilk/egui#3rd-party-integrations to see how integrations are supposed to work in the current version. Eventually you could add yours to the list as well, once you get this sorted out.
Bingo, fonts were missing... somehow. A warning that they are missing would be helpful... Adding fonts only fixes the galley data missing, the text is still too small:
Well anyway, I dropped epi (why was it nowhere stated that it was dropped?) and moved to eframe. Now I'm using the most recent egui for sure. The text sizes are still small and I can't change them, the pixel_per_point
value is ignored for fonts. Only the background rect changes. As for the 3rd party integrations, I did looked into them and everything magically works there ;/
I also needed to include x11 integration for winit because it needs a platform to even compile. For my use case, winit could be optional
So if you zoom the UI, (for example by calling ui.ctx().set_zoom_factor(ui.input(|i| i.time as f32 * 0.05).sin() + 1.0);
in the example code), the text size doesn't change? The Shape
variant's doc does say it needs to be recreated:
But I don't know at what level this is supposed to be done in the integration.
Well this does seem to do something. Is it really the solution? to call the zoom factor? I need to clean up and refine the code properly for this to work properly, but it does something, even if it's a work around it's something, thanks
Idk about the text shape thing
I think the integration crate just has to pass the correct native_pixels_per_point
to egui (otherwise the text might look blurry as mentioned here), and then each application can set the zoom factor and/or the text_styles so it displays well on the target screen. Maybe the default style isn't appropriate for e-readers, so you could provide a different default that looks better.
I decided zoom is the solution because text_styles will only affect text
Sadly, setting zoom affects the ui only for one frame. In Context::set_zoom_factor
is a variable used named new_zoom_factor
. In this function if I remove the if statement if ctx.memory.options.zoom_factor != zoom_factor {
the zoom factor works fine (well I still need to set the zoom factor up every frame). What is here going on?
The only thing I'm aware of doing wrong is this:
How do I create a eframe::Frame
? info
storage
from that struct are private and I need this struct for App::update
. For now I just edited the library directly, but this requires doing that on every library download
but Frame
doesn't contain any meaningful information for this issue
The zoom factor change should be permanent. If you make this change to the hello_world example, the zoom changes to 200% when you click the button and then stays that way:
M examples/hello_world/src/main.rs
@@ -46,6 +46,7 @@ impl eframe::App for MyApp {
});
ui.add(egui::Slider::new(&mut self.age, 0..=120).text("age"));
if ui.button("Increment").clicked() {
+ ui.ctx().set_zoom_factor(2.0);
self.age += 1;
}
ui.label(format!("Hello '{}', age {}", self.name, self.age));
So maybe your integration is using a new Context
every frame? And about the Frame
, I don't think integrations are supposed to depend on eframe at all. The other integrations don't (though some of them depend on egui-winit or egui-wgpu). Maybe you should just copy what you need from eframe instead of depending on it.
I don't have input yet so this example won't work. Setting zoom factor anywhere: once, every frame, only on first frame does the same thing
And no, I don't create a new context every frame
Discussed in https://github.com/emilk/egui/discussions/4440