Skip to content

Commit 42a66e6

Browse files
committed
Change argument order
1 parent 60dd292 commit 42a66e6

File tree

2 files changed

+16
-16
lines changed

2 files changed

+16
-16
lines changed

crates/epaint/src/text/font.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -215,10 +215,10 @@ impl FontImpl {
215215
#[inline]
216216
pub fn pair_kerning(
217217
&self,
218+
pixels_per_point: f32,
218219
last_glyph_id: ab_glyph::GlyphId,
219220
glyph_id: ab_glyph::GlyphId,
220221
font_size: f32,
221-
pixels_per_point: f32,
222222
) -> f32 {
223223
// Round to an even number of physical pixels to get even kerning.
224224
// See https://github.com/emilk/egui/issues/382
@@ -248,10 +248,10 @@ impl FontImpl {
248248

249249
pub fn allocate_glyph(
250250
&mut self,
251-
glyph_info: GlyphInfo,
252251
atlas: &mut TextureAtlas,
253-
font_size: f32,
254252
pixels_per_point: f32,
253+
glyph_info: GlyphInfo,
254+
font_size: f32,
255255
) -> GlyphAllocation {
256256
let Some(glyph_id) = glyph_info.id else {
257257
// Invisible.
@@ -450,17 +450,17 @@ impl Font<'_> {
450450
#[inline]
451451
pub(crate) fn font_impl_and_glyph_alloc(
452452
&mut self,
453+
pixels_per_point: f32,
453454
c: char,
454455
font_size: f32,
455-
pixels_per_point: f32,
456456
) -> (Option<&FontImpl>, GlyphAllocation) {
457457
if self.cached_family.fonts.is_empty() {
458458
return (None, Default::default());
459459
}
460460
let (key, glyph_info) = self.glyph_info(c);
461461
let font_impl = self.fonts_by_id.get_mut(&key).expect("Nonexistent font ID");
462462
let allocated_glyph =
463-
font_impl.allocate_glyph(glyph_info, self.atlas, font_size, pixels_per_point);
463+
font_impl.allocate_glyph(self.atlas, pixels_per_point, glyph_info, font_size);
464464
(Some(font_impl), allocated_glyph)
465465
}
466466

crates/epaint/src/text/text_layout.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -175,14 +175,14 @@ fn layout_section(
175175
paragraph.empty_paragraph_height = line_height; // TODO(emilk): replace this hack with actually including `\n` in the glyphs?
176176
} else {
177177
let (font_impl, glyph_alloc) =
178-
font.font_impl_and_glyph_alloc(chr, font_size, pixels_per_point);
178+
font.font_impl_and_glyph_alloc(pixels_per_point, chr, font_size);
179179

180180
if let (Some(font_impl), Some(last_glyph_id)) = (font_impl, last_glyph_id) {
181181
paragraph.cursor_x += font_impl.pair_kerning(
182+
pixels_per_point,
182183
last_glyph_id,
183184
glyph_alloc.id,
184185
font_size,
185-
pixels_per_point,
186186
);
187187
paragraph.cursor_x += extra_letter_spacing;
188188
}
@@ -448,17 +448,17 @@ fn replace_last_glyph_with_overflow_character(
448448
let mut x = last_glyph.pos.x + last_glyph.advance_width;
449449

450450
let (font_impl, replacement_glyph_alloc) =
451-
font.font_impl_and_glyph_alloc(overflow_character, font_size, pixels_per_point);
451+
font.font_impl_and_glyph_alloc(pixels_per_point, overflow_character, font_size);
452452

453453
// Kerning:
454454
x += section.format.extra_letter_spacing;
455455
if let Some(font_impl) = font_impl {
456456
if let Some(last_glyph_id) = last_glyph_info.id {
457457
x += font_impl.pair_kerning(
458+
pixels_per_point,
458459
last_glyph_id,
459460
replacement_glyph_alloc.id,
460461
section.format.font_id.size,
461-
pixels_per_point,
462462
);
463463
}
464464
}
@@ -485,7 +485,7 @@ fn replace_last_glyph_with_overflow_character(
485485
let x = 0.0; // TODO(emilk): heed paragraph leading_space 😬
486486

487487
let (mut font_impl, replacement_glyph_alloc) =
488-
font.font_impl_and_glyph_alloc(overflow_character, font_size, pixels_per_point);
488+
font.font_impl_and_glyph_alloc(pixels_per_point, overflow_character, font_size);
489489

490490
row.glyphs.push(Glyph {
491491
chr: overflow_character,
@@ -527,27 +527,27 @@ fn replace_last_glyph_with_overflow_character(
527527

528528
if let Some(prev_glyph) = prev_glyph {
529529
let prev_glyph_id = font
530-
.font_impl_and_glyph_alloc(prev_glyph.chr, font_size, pixels_per_point)
530+
.font_impl_and_glyph_alloc(pixels_per_point, prev_glyph.chr, font_size)
531531
.1
532532
.id;
533533

534534
// Undo kerning with previous glyph:
535535
let (font_impl, glyph_alloc) =
536-
font.font_impl_and_glyph_alloc(last_glyph.chr, font_size, pixels_per_point);
536+
font.font_impl_and_glyph_alloc(pixels_per_point, last_glyph.chr, font_size);
537537
last_glyph.pos.x -= extra_letter_spacing;
538538
if let Some(font_impl) = font_impl {
539539
last_glyph.pos.x -= font_impl.pair_kerning(
540+
pixels_per_point,
540541
prev_glyph_id,
541542
glyph_alloc.id,
542543
font_size,
543-
pixels_per_point,
544544
);
545545
}
546546

547547
// Replace the glyph:
548548
last_glyph.chr = overflow_character;
549549
let (font_impl, glyph_alloc) =
550-
font.font_impl_and_glyph_alloc(last_glyph.chr, font_size, pixels_per_point);
550+
font.font_impl_and_glyph_alloc(pixels_per_point, last_glyph.chr, font_size);
551551
last_glyph.advance_width = glyph_alloc.advance_width;
552552
last_glyph.font_impl_ascent = font_impl.map_or(0.0, |f| f.ascent(font_size));
553553
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(
557557
last_glyph.pos.x += extra_letter_spacing;
558558
if let Some(font_impl) = font_impl {
559559
last_glyph.pos.x += font_impl.pair_kerning(
560+
pixels_per_point,
560561
prev_glyph_id,
561562
glyph_alloc.id,
562563
font_size,
563-
pixels_per_point,
564564
);
565565
}
566566

@@ -580,7 +580,7 @@ fn replace_last_glyph_with_overflow_character(
580580
// Just replace and be done with it.
581581
last_glyph.chr = overflow_character;
582582
let (font_impl, glyph_alloc) =
583-
font.font_impl_and_glyph_alloc(last_glyph.chr, font_size, pixels_per_point);
583+
font.font_impl_and_glyph_alloc(pixels_per_point, last_glyph.chr, font_size);
584584
last_glyph.advance_width = glyph_alloc.advance_width;
585585
last_glyph.font_impl_ascent = font_impl.map_or(0.0, |f| f.ascent(font_size));
586586
last_glyph.font_impl_height = font_impl.map_or(0.0, |f| f.row_height(font_size));

0 commit comments

Comments
 (0)