mirror of
https://github.com/emilk/egui.git
synced 2026-08-30 21:30:03 -04:00
Improve text contrast in bright mode (#1412)
* Rename AlphaImage to FontImage to discourage any other use for it * Encode FontImage as f32 and postpone the alpha correction * Interpret alpha coverage in a new, making dark text darker, improving contrast in bright mode
This commit is contained in:
@@ -377,7 +377,7 @@ fn allocate_glyph(
|
||||
if v > 0.0 {
|
||||
let px = glyph_pos.0 + x as usize;
|
||||
let py = glyph_pos.1 + y as usize;
|
||||
image[(px, py)] = fast_round(v * 255.0);
|
||||
image[(px, py)] = v;
|
||||
}
|
||||
});
|
||||
|
||||
@@ -405,7 +405,3 @@ fn allocate_glyph(
|
||||
uv_rect,
|
||||
}
|
||||
}
|
||||
|
||||
fn fast_round(r: f32) -> u8 {
|
||||
(r + 0.5).floor() as _ // rust does a saturating cast since 1.45
|
||||
}
|
||||
|
||||
@@ -539,7 +539,7 @@ impl FontsImpl {
|
||||
// Make the top left pixel fully white:
|
||||
let (pos, image) = atlas.allocate((1, 1));
|
||||
assert_eq!(pos, (0, 0));
|
||||
image[pos] = 255;
|
||||
image[pos] = 1.0;
|
||||
}
|
||||
|
||||
let atlas = Arc::new(Mutex::new(atlas));
|
||||
|
||||
Reference in New Issue
Block a user