mirror of
https://github.com/emilk/egui.git
synced 2026-08-31 13:50:04 -04:00
Misc code cleanup (#3398)
* eframe README: explain how to enable copy/paste * Implement Debug for a couple of structs * Code cleanup * Better docs * profile ron serialization * CI: Allow "exclude from changelog" as the only label
This commit is contained in:
@@ -498,6 +498,8 @@ pub struct RectShape {
|
||||
///
|
||||
/// To display a texture, set [`Self::fill_texture_id`],
|
||||
/// and set this to `Rect::from_min_max(pos2(0.0, 0.0), pos2(1.0, 1.0))`.
|
||||
///
|
||||
/// Use [`Rect::ZERO`] to turn off texturing.
|
||||
pub uv: Rect,
|
||||
}
|
||||
|
||||
|
||||
@@ -72,7 +72,7 @@ pub struct FontImpl {
|
||||
height_in_points: f32,
|
||||
|
||||
// move each character by this much (hack)
|
||||
y_offset: f32,
|
||||
y_offset_in_points: f32,
|
||||
|
||||
ascent: f32,
|
||||
pixels_per_point: f32,
|
||||
@@ -111,22 +111,23 @@ impl FontImpl {
|
||||
scale_in_points * tweak.y_offset_factor
|
||||
} + tweak.y_offset;
|
||||
|
||||
// center scaled glyphs properly
|
||||
let y_offset_points = y_offset_points + (tweak.scale - 1.0) * 0.5 * (ascent + descent);
|
||||
// Center scaled glyphs properly:
|
||||
let height = ascent + descent;
|
||||
let y_offset_points = y_offset_points - (1.0 - tweak.scale) * 0.5 * height;
|
||||
|
||||
// Round to an even number of physical pixels to get even kerning.
|
||||
// See https://github.com/emilk/egui/issues/382
|
||||
let scale_in_pixels = scale_in_pixels.round() as u32;
|
||||
|
||||
// Round to closest pixel:
|
||||
let y_offset = (y_offset_points * pixels_per_point).round() / pixels_per_point;
|
||||
let y_offset_in_points = (y_offset_points * pixels_per_point).round() / pixels_per_point;
|
||||
|
||||
Self {
|
||||
name,
|
||||
ab_glyph_font,
|
||||
scale_in_pixels,
|
||||
height_in_points: ascent - descent + line_gap,
|
||||
y_offset,
|
||||
y_offset_in_points,
|
||||
ascent: ascent + baseline_offset,
|
||||
pixels_per_point,
|
||||
glyph_info_cache: Default::default(),
|
||||
@@ -283,7 +284,8 @@ impl FontImpl {
|
||||
});
|
||||
|
||||
let offset_in_pixels = vec2(bb.min.x, bb.min.y);
|
||||
let offset = offset_in_pixels / self.pixels_per_point + self.y_offset * Vec2::Y;
|
||||
let offset =
|
||||
offset_in_pixels / self.pixels_per_point + self.y_offset_in_points * Vec2::Y;
|
||||
UvRect {
|
||||
offset,
|
||||
size: vec2(glyph_width as f32, glyph_height as f32) / self.pixels_per_point,
|
||||
|
||||
Reference in New Issue
Block a user