mirror of
https://github.com/emilk/egui.git
synced 2026-06-26 22:53:14 -04:00
Change argument order
This commit is contained in:
committed by
valadaptive
parent
e372ffe99a
commit
58cbca1016
@@ -215,10 +215,10 @@ impl FontImpl {
|
||||
#[inline]
|
||||
pub fn pair_kerning(
|
||||
&self,
|
||||
pixels_per_point: f32,
|
||||
last_glyph_id: ab_glyph::GlyphId,
|
||||
glyph_id: ab_glyph::GlyphId,
|
||||
font_size: f32,
|
||||
pixels_per_point: f32,
|
||||
) -> f32 {
|
||||
// Round to an even number of physical pixels to get even kerning.
|
||||
// See https://github.com/emilk/egui/issues/382
|
||||
@@ -248,10 +248,10 @@ impl FontImpl {
|
||||
|
||||
pub fn allocate_glyph(
|
||||
&mut self,
|
||||
glyph_info: GlyphInfo,
|
||||
atlas: &mut TextureAtlas,
|
||||
font_size: f32,
|
||||
pixels_per_point: f32,
|
||||
glyph_info: GlyphInfo,
|
||||
font_size: f32,
|
||||
) -> GlyphAllocation {
|
||||
let Some(glyph_id) = glyph_info.id else {
|
||||
// Invisible.
|
||||
@@ -450,9 +450,9 @@ impl Font<'_> {
|
||||
#[inline]
|
||||
pub(crate) fn font_impl_and_glyph_alloc(
|
||||
&mut self,
|
||||
pixels_per_point: f32,
|
||||
c: char,
|
||||
font_size: f32,
|
||||
pixels_per_point: f32,
|
||||
) -> (Option<&FontImpl>, GlyphAllocation) {
|
||||
if self.cached_family.fonts.is_empty() {
|
||||
return (None, Default::default());
|
||||
@@ -460,7 +460,7 @@ impl Font<'_> {
|
||||
let (key, glyph_info) = self.glyph_info(c);
|
||||
let font_impl = self.fonts_by_id.get_mut(&key).expect("Nonexistent font ID");
|
||||
let allocated_glyph =
|
||||
font_impl.allocate_glyph(glyph_info, self.atlas, font_size, pixels_per_point);
|
||||
font_impl.allocate_glyph(self.atlas, pixels_per_point, glyph_info, font_size);
|
||||
(Some(font_impl), allocated_glyph)
|
||||
}
|
||||
|
||||
|
||||
@@ -175,14 +175,14 @@ fn layout_section(
|
||||
paragraph.empty_paragraph_height = line_height; // TODO(emilk): replace this hack with actually including `\n` in the glyphs?
|
||||
} else {
|
||||
let (font_impl, glyph_alloc) =
|
||||
font.font_impl_and_glyph_alloc(chr, font_size, pixels_per_point);
|
||||
font.font_impl_and_glyph_alloc(pixels_per_point, chr, font_size);
|
||||
|
||||
if let (Some(font_impl), Some(last_glyph_id)) = (font_impl, last_glyph_id) {
|
||||
paragraph.cursor_x += font_impl.pair_kerning(
|
||||
pixels_per_point,
|
||||
last_glyph_id,
|
||||
glyph_alloc.id,
|
||||
font_size,
|
||||
pixels_per_point,
|
||||
);
|
||||
paragraph.cursor_x += extra_letter_spacing;
|
||||
}
|
||||
@@ -448,17 +448,17 @@ fn replace_last_glyph_with_overflow_character(
|
||||
let mut x = last_glyph.pos.x + last_glyph.advance_width;
|
||||
|
||||
let (font_impl, replacement_glyph_alloc) =
|
||||
font.font_impl_and_glyph_alloc(overflow_character, font_size, pixels_per_point);
|
||||
font.font_impl_and_glyph_alloc(pixels_per_point, overflow_character, font_size);
|
||||
|
||||
// Kerning:
|
||||
x += section.format.extra_letter_spacing;
|
||||
if let Some(font_impl) = font_impl {
|
||||
if let Some(last_glyph_id) = last_glyph_info.id {
|
||||
x += font_impl.pair_kerning(
|
||||
pixels_per_point,
|
||||
last_glyph_id,
|
||||
replacement_glyph_alloc.id,
|
||||
section.format.font_id.size,
|
||||
pixels_per_point,
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -485,7 +485,7 @@ fn replace_last_glyph_with_overflow_character(
|
||||
let x = 0.0; // TODO(emilk): heed paragraph leading_space 😬
|
||||
|
||||
let (mut font_impl, replacement_glyph_alloc) =
|
||||
font.font_impl_and_glyph_alloc(overflow_character, font_size, pixels_per_point);
|
||||
font.font_impl_and_glyph_alloc(pixels_per_point, overflow_character, font_size);
|
||||
|
||||
row.glyphs.push(Glyph {
|
||||
chr: overflow_character,
|
||||
@@ -527,27 +527,27 @@ fn replace_last_glyph_with_overflow_character(
|
||||
|
||||
if let Some(prev_glyph) = prev_glyph {
|
||||
let prev_glyph_id = font
|
||||
.font_impl_and_glyph_alloc(prev_glyph.chr, font_size, pixels_per_point)
|
||||
.font_impl_and_glyph_alloc(pixels_per_point, prev_glyph.chr, font_size)
|
||||
.1
|
||||
.id;
|
||||
|
||||
// Undo kerning with previous glyph:
|
||||
let (font_impl, glyph_alloc) =
|
||||
font.font_impl_and_glyph_alloc(last_glyph.chr, font_size, pixels_per_point);
|
||||
font.font_impl_and_glyph_alloc(pixels_per_point, last_glyph.chr, font_size);
|
||||
last_glyph.pos.x -= extra_letter_spacing;
|
||||
if let Some(font_impl) = font_impl {
|
||||
last_glyph.pos.x -= font_impl.pair_kerning(
|
||||
pixels_per_point,
|
||||
prev_glyph_id,
|
||||
glyph_alloc.id,
|
||||
font_size,
|
||||
pixels_per_point,
|
||||
);
|
||||
}
|
||||
|
||||
// Replace the glyph:
|
||||
last_glyph.chr = overflow_character;
|
||||
let (font_impl, glyph_alloc) =
|
||||
font.font_impl_and_glyph_alloc(last_glyph.chr, font_size, pixels_per_point);
|
||||
font.font_impl_and_glyph_alloc(pixels_per_point, last_glyph.chr, font_size);
|
||||
last_glyph.advance_width = glyph_alloc.advance_width;
|
||||
last_glyph.font_impl_ascent = font_impl.map_or(0.0, |f| f.ascent(font_size));
|
||||
last_glyph.font_impl_height = font_impl.map_or(0.0, |f| f.row_height(font_size));
|
||||
@@ -557,10 +557,10 @@ fn replace_last_glyph_with_overflow_character(
|
||||
last_glyph.pos.x += extra_letter_spacing;
|
||||
if let Some(font_impl) = font_impl {
|
||||
last_glyph.pos.x += font_impl.pair_kerning(
|
||||
pixels_per_point,
|
||||
prev_glyph_id,
|
||||
glyph_alloc.id,
|
||||
font_size,
|
||||
pixels_per_point,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -580,7 +580,7 @@ fn replace_last_glyph_with_overflow_character(
|
||||
// Just replace and be done with it.
|
||||
last_glyph.chr = overflow_character;
|
||||
let (font_impl, glyph_alloc) =
|
||||
font.font_impl_and_glyph_alloc(last_glyph.chr, font_size, pixels_per_point);
|
||||
font.font_impl_and_glyph_alloc(pixels_per_point, last_glyph.chr, font_size);
|
||||
last_glyph.advance_width = glyph_alloc.advance_width;
|
||||
last_glyph.font_impl_ascent = font_impl.map_or(0.0, |f| f.ascent(font_size));
|
||||
last_glyph.font_impl_height = font_impl.map_or(0.0, |f| f.row_height(font_size));
|
||||
|
||||
Reference in New Issue
Block a user