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

add Fontweight to fontid #3218

Open
Omicronlawful opened this issue Aug 9, 2023 · 4 comments
Open

add Fontweight to fontid #3218

Omicronlawful opened this issue Aug 9, 2023 · 4 comments

Comments

@Omicronlawful
Copy link

It would be usefull if the font weight could be set when creating a fontid. Im not sure if there is another way, like it is solved for italics, but i would put it into fontid

@abey79
Copy link
Collaborator

abey79 commented Sep 6, 2023

In particular, support for variable font weight would be nice.

@emilk
Copy link
Owner

emilk commented Sep 6, 2023

First of all: italics in epaint is a hack. We just skew the glyphs when we paint them. Ideally we should instead switch to an italic font of the same family instead.

To fully support font weights and italics we need to have better support for selecting font families. For example: Inter is a font family with many different fonts for different weights and styles (Thin, Thin Italics, Bold, Bold Italics, etc).

A font family can be stored in several .ttf files, or in the same one. To know what we have loaded, we would need to read it at some sort of font meta-data (was the loaded font thin, italics, …?). I don't think ab_glyph supports this at the moment: https://docs.rs/ab_glyph/latest/ab_glyph/trait.Font.html

Once that all is done, then yes, FontId would be the right place to add weight and italics.

So: if someone is interested in working on this, please help research how we can read the style metadata out of a .ttf file (i.e. thin vs bold, and italics vs normal), and maybe add that feature to ab_glyph!

@abey79
Copy link
Collaborator

abey79 commented Sep 6, 2023

I believe there are actually two stories here:

The latter would be very nice to have as I understand designers rely on it more and more. As it turns out, the font we're using for Rerun is variable (https://fonts.google.com/specimen/Inter).

@JustFrederik
Copy link
Contributor

@emilk not sure if this is helpful, but ttf parser has an example for handling metadata: https://github.com/RazrFalcon/ttf-parser/blob/master/examples/font-info.rs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants