Open steventrouble opened 2 years ago
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")] // hide console window on Windows in release
use eframe::egui;
use egui::Color32;
use egui::FontFamily::Monospace;
use egui::FontId;
use egui::TextStyle::*;
fn main() {
let options = eframe::NativeOptions::default();
eframe::run_native(
"My egui App",
options,
Box::new(|_cc| Box::new(MyApp::default())),
);
}
struct MyApp;
impl Default for MyApp {
fn default() -> Self {
Self
}
}
impl eframe::App for MyApp {
fn update(&mut self, ctx: &egui::Context, _frame: &mut eframe::Frame) {
let mut visuals = egui::Visuals::light();
visuals.widgets.inactive.bg_fill = Color32::WHITE;
visuals.widgets.inactive.bg_stroke.color = Color32::RED;
visuals.widgets.inactive.fg_stroke.color = Color32::BLACK;
visuals.widgets.inactive.rounding = 1.0.into();
visuals.widgets.hovered.bg_fill = Color32::WHITE;
visuals.widgets.hovered.bg_stroke.color = Color32::RED;
visuals.widgets.hovered.fg_stroke.color = Color32::BLACK;
visuals.widgets.hovered.rounding = 1.0.into();
let mut style = (*ctx.style()).clone();
style.text_styles = [(Button, FontId::new(25.0, Monospace))].into();
ctx.set_style(style);
ctx.set_visuals(visuals);
egui::CentralPanel::default().show(ctx, |ui| ui.button("click me!"));
}
}
@steventrouble Hi, please try this.
All of those together fix it, but when I lower the font size the text becomes grey again.
All of the above:
With the font back to normal:
Is this an issue with font aliasing? Any way I can turn that off or tweak the antialiasing method?
@steventrouble please try latest master
- I recently improved text rendering in https://github.com/emilk/egui/pull/2071
Describe the bug When I set the text color to black (#000), the text does not turn black. Instead, it is #585858.
I'm trying to make my text darker so it meets accessibility standards:
https://webaim.org/resources/contrastchecker/?fcolor=585858&bcolor=E6E6E6
But the text isn't getting darker.
Button:
To Reproduce Steps to reproduce the behavior:
Set the visuals to the following:
Create a button (or any widget).
Expected behavior The text color should be black, not grey.
Desktop: