Skip to content

Commit e2f6ba4

Browse files
committed
More granular font insertion control
1 parent 6dfdef1 commit e2f6ba4

File tree

3 files changed

+25
-1
lines changed

3 files changed

+25
-1
lines changed

crates/egui/src/context.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -575,6 +575,20 @@ impl ContextImpl {
575575
match family.priority {
576576
FontPriority::Highest => fam.insert(0, font.name.clone()),
577577
FontPriority::Lowest => fam.push(font.name.clone()),
578+
FontPriority::Above(name) => {
579+
let position = fam
580+
.iter()
581+
.position(|f| f == name.as_ref())
582+
.unwrap_or(fam.len());
583+
fam.insert(position, font.name.clone());
584+
}
585+
FontPriority::Below(name) => {
586+
let position = fam
587+
.iter()
588+
.position(|f| f == name.as_ref())
589+
.unwrap_or(fam.len() - 1);
590+
fam.insert(position + 1, font.name.clone());
591+
}
578592
}
579593
}
580594
font_definitions

crates/epaint/src/text/fonts.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,16 @@ pub enum FontPriority {
209209
///
210210
/// This font will only be used if the glyph is not found in any of the previously installed fonts.
211211
Lowest,
212+
213+
/// Insert this font above the given family in the priority stack.
214+
///
215+
/// If the given family cannot be found, this font will be placed at the lowest priority.
216+
Above(Cow<'static, str>),
217+
218+
/// Insert this font below the given family in the priority stack.
219+
///
220+
/// If the given family cannot be found, this font will be placed at the lowest priority.
221+
Below(Cow<'static, str>),
212222
}
213223

214224
impl FontInsert {

crates/epaint/src/text/style.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -599,7 +599,7 @@ pub mod named_variants {
599599
/// Enables display of font-specific alternate annotation forms.
600600
pub annotation: u16,
601601
/// Selects the way East Asian glyphs are rendered.
602-
east_asian_variant: EastAsianVariant,
602+
pub east_asian_variant: EastAsianVariant,
603603
/// Selects the width variants of East Asian glyphs.
604604
pub east_asian_width: Option<EastAsianWidth>,
605605
/// Enables display of ruby (superscript-like annotations) variant glyphs.

0 commit comments

Comments
 (0)