You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently, egui provides two APIs for modifying fonts:
add_font: Adds a new font to the existing font definitions.
set_fonts: Replaces the entire font definitions with a new set.
However, these APIs have a high degree of code overlap, and their usage is not clearly documented. Additionally, set_fonts has a performance overhead due to an expensive comparison check, and its behavior is not fully intuitive.
Problems
API Overlap:
Both add_font and set_fonts can be used to modify fonts, but their use cases and differences are not clearly explained in the documentation.
This can lead to confusion for users who are unsure which API to use.
Performance Overhead:
set_fonts performs an expensive comparison to check if the new font definitions are identical to the current ones. This is unnecessary in most cases, especially when the goal is to reset fonts or textures. As mentioned in Fix: ctx.set_fonts() Doesn't Apply Fonts with Same Name #5345.
For example, state that it will replace the existing font definitions with the provided ones.
Code Overlap:
Both add_font and set_fonts share significant code overlap, particularly in font data insertion, font family definitions, and update logic. This duplication increases maintenance complexity and raises the risk of inconsistencies or subtle bugs.
Description
Currently,
egui
provides two APIs for modifying fonts:add_font
: Adds a new font to the existing font definitions.set_fonts
: Replaces the entire font definitions with a new set.However, these APIs have a high degree of code overlap, and their usage is not clearly documented. Additionally,
set_fonts
has a performance overhead due to an expensive comparison check, and its behavior is not fully intuitive.Problems
API Overlap:
add_font
andset_fonts
can be used to modify fonts, but their use cases and differences are not clearly explained in the documentation.Performance Overhead:
set_fonts
performs an expensive comparison to check if the new font definitions are identical to the current ones. This is unnecessary in most cases, especially when the goal is to reset fonts or textures. As mentioned in Fix: ctx.set_fonts() Doesn't Apply Fonts with Same Name #5345.egui/crates/egui/src/context.rs
Lines 1767 to 1771 in 4784136
add_font
andset_fonts
.egui/examples/custom_font/src/main.rs
Lines 42 to 45 in 4784136
set_fonts
could be cleareregui/crates/egui/src/context.rs
Lines 1759 to 1760 in 4784136
add_font
andset_fonts
share significant code overlap, particularly in font data insertion, font family definitions, and update logic. This duplication increases maintenance complexity and raises the risk of inconsistencies or subtle bugs.egui/crates/egui/src/context.rs
Lines 1788 to 1808 in 4784136
egui/crates/egui/src/context.rs
Lines 1760 to 1774 in 4784136
This issue was translated by AI.
The text was updated successfully, but these errors were encountered: