round font size earlier
This commit is contained in:
parent
1aceaefba3
commit
bb7ff84db5
1 changed files with 18 additions and 10 deletions
|
@ -472,7 +472,12 @@ impl FontsImpl {
|
||||||
|
|
||||||
let fonts: Vec<Arc<FontImpl>> = fonts
|
let fonts: Vec<Arc<FontImpl>> = fonts
|
||||||
.iter()
|
.iter()
|
||||||
.map(|font_name| self.font_impl_cache.font_impl(*scale_in_points, font_name))
|
.map(|font_name| {
|
||||||
|
let scale_in_pixels = self
|
||||||
|
.font_impl_cache
|
||||||
|
.scale_as_pixels(*scale_in_points, font_name);
|
||||||
|
self.font_impl_cache.font_impl(scale_in_pixels, font_name)
|
||||||
|
})
|
||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
Font::new(fonts)
|
Font::new(fonts)
|
||||||
|
@ -571,14 +576,7 @@ impl FontImplCache {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn font_impl(&mut self, scale_in_points: f32, font_name: &str) -> Arc<FontImpl> {
|
pub fn scale_as_pixels(&self, scale_in_points: f32, font_name: &str) -> u32 {
|
||||||
let y_offset = if font_name == "emoji-icon-font" {
|
|
||||||
scale_in_points * 0.235 // TODO: remove font alignment hack
|
|
||||||
} else {
|
|
||||||
0.0
|
|
||||||
};
|
|
||||||
let y_offset = y_offset - 3.0; // Tweaked to make text look centered in buttons and text edit fields
|
|
||||||
|
|
||||||
let scale_in_points = if font_name == "emoji-icon-font" {
|
let scale_in_points = if font_name == "emoji-icon-font" {
|
||||||
scale_in_points * 0.8 // TODO: remove HACK!
|
scale_in_points * 0.8 // TODO: remove HACK!
|
||||||
} else {
|
} else {
|
||||||
|
@ -589,7 +587,17 @@ impl FontImplCache {
|
||||||
|
|
||||||
// Round to an even number of physical pixels to get even kerning.
|
// Round to an even number of physical pixels to get even kerning.
|
||||||
// See https://github.com/emilk/egui/issues/382
|
// See https://github.com/emilk/egui/issues/382
|
||||||
let scale_in_pixels = scale_in_pixels.round() as u32;
|
scale_in_pixels.round() as u32
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn font_impl(&mut self, scale_in_pixels: u32, font_name: &str) -> Arc<FontImpl> {
|
||||||
|
let y_offset = if font_name == "emoji-icon-font" {
|
||||||
|
let scale_in_points = scale_in_pixels as f32 / self.pixels_per_point;
|
||||||
|
scale_in_points * 0.29375 // TODO: remove font alignment hack
|
||||||
|
} else {
|
||||||
|
0.0
|
||||||
|
};
|
||||||
|
let y_offset = y_offset - 3.0; // Tweaked to make text look centered in buttons and text edit fields
|
||||||
|
|
||||||
self.cache
|
self.cache
|
||||||
.entry((scale_in_pixels, font_name.to_owned()))
|
.entry((scale_in_pixels, font_name.to_owned()))
|
||||||
|
|
Loading…
Reference in a new issue