close
The Wayback Machine - https://web.archive.org/web/20220213214714/https://github.com/emilk/egui/pull/1241
Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make v-align and scale of user fonts tweakable #1241

Merged
merged 4 commits into from Feb 12, 2022
Merged

Make v-align and scale of user fonts tweakable #1241

merged 4 commits into from Feb 12, 2022

Conversation

@emilk
Copy link
Owner

@emilk emilk commented Feb 12, 2022

Some fonts sit higher on a line, and some lower.

This PR allows users to tweak the vertical alignment and scale of each font to match it better with other fonts and the rest of the UI, like so:

font_data.insert(
    "emoji-icon-font".to_owned(),
    FontData::from_static(include_bytes!("../../fonts/emoji-icon-font.ttf")).tweak(
        FontTweak {
            scale: 0.8, // make it smaller
            y_offset_factor: 0.1, // move it down slightly
            y_offset: 0.0,
        },
    ),
);

This PR also changes those values slightly for the default fonts.

This moves some text by a pixel or so, especially small and large text, but the difference i minimal:

Before:

fonts-master

After:

fonts-tweaked

After plus text bounding boxes (text should be centered vertically in each green box):
fonts-tweaked-bb

@juancampa
Copy link
Contributor

@juancampa juancampa commented Feb 12, 2022

Not sure if just me. But in the "after" screenshot, the top-right heading "egui demos", seems to be less vertically centered than before. Higher, to be specific.

@emilk
Copy link
Owner Author

@emilk emilk commented Feb 12, 2022

Not sure if just me. But in the "after" screenshot, the top-right heading "egui demos", seems to be less vertically centered than before. Higher, to be specific.

That's because of how the text is placed within the panel, not how the text is centered within the label. I've added another screenshot with the text boxes drawn out - text should now be better centered vertically in those green boxes than before, including the "egui demos" bit.

I will need to tweak the margins for the side panels to make "egui demos" center better.

@emilk emilk merged commit 6962629 into master Feb 12, 2022
20 checks passed
@emilk emilk deleted the font-tweak branch Feb 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

2 participants