-
Notifications
You must be signed in to change notification settings - Fork 21
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
Support multiple fonts #8
Comments
This raises a couple interesting questions. How much should
At the same time, I think that it makes the most ergonomic sense to have access to let mut yak = yakui::State::new();
// load a font from some bytes
let my_font = yak.add_font(yakui::Font::from_bytes(include_bytes!("my-font.ttf")));
// set the default font by using an enum? maybe this could
// be a struct with fields that you can get mutable access
// to instead.
yak.set_font(yakui::Font::Default, my_font);
// ...
// the user can always directly assign a font on a text widget
let mut text = yakui::Text::new("Hello, world!");
text.font = my_font;
text.font_size = 18.0;
text.show(); |
Banged out a prototype for this. It isn't super pretty, but you can do this now: // Add a custom font for some of the examples.
let fonts = yak.dom().get_global_or_init(Fonts::default);
let font = Font::from_bytes(
include_bytes!("../assets/Hack-Regular.ttf").as_slice(),
FontSettings::default(),
)
.unwrap();
fonts.add(font, Some("monospace"));
// Using fonts.add(font, Some("default")) will replace the default font. You can also turn off the |
just want to drop in that i'd strongly prefer doing all the font rendering myself. if that involves replacing the text widget, that's not a problem, but since the engine i'm going to try adding yakui too has font rendering done already, i don't see a reason to double up on it |
The goal is that this should be no problem. You've got a couple options right now, but maybe we can do better:
Maybe we could introduce some way to hook into the text rendering so that you can provide yakui the metrics it wants and then paint text when asked to. I'd be a little worried about slowing down the common path, but this seems like a good possibility. One trick we could employ is to move the text rendering code into a new crate, like |
I'm going to mark this closed. I opened #17 for @sanbox-irl's concern. |
No description provided.
The text was updated successfully, but these errors were encountered: