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