RobLoach / nuklear_console

Console-like user interface for Nuklear with gamepad, keyboard or mouse support
https://robloach.github.io/nuklear_console/
MIT License
13 stars 3 forks source link

Any way to set font for individual widgets or windows? #104

Open StrikerMan780 opened 2 months ago

StrikerMan780 commented 2 months ago

Just wondering if there's a way to set the font for individual widgets in a window, or for a whole window, and if not, is it alright if I request this as a feature?

RobLoach commented 2 months ago

Possibly could accomplish having different color styles by having a pointer to a style for each widget, and apply it to the Nuklear styles when rendering.

Not sure how to have different fonts displayed in the same context though. Have you done this before?

StrikerMan780 commented 2 months ago

Yes. You can push/pop fonts in Nuklear, (nk_style_push/pop_font)

I've used it in my own menus before. For example, to use different fonts for the title and menu itself. Like so:

image

(It's meant to mimic the look of the original Terminal Velocity menu, but a bit more streamlined)

Another way is to use nk_style_set_font, which sets it directly, but clears the push/pop stack.

RobLoach commented 2 months ago

Looks great! Does look like the original. Something like this should allow setting a different font on a per-widget basis, but I'm unsure it's the best design. Also, would love a demonstration of using them in the demos https://github.com/RobLoach/nuklear_console/pull/107

StrikerMan780 commented 2 months ago

I mean, that would do the trick. Looks good to me, but I'm also no expert so I can't really judge the design.

There's also nk_style_push/pop_style_item, which would let you set style stuff in general per-widget. Dunno how best you'd write an API for that in nuklear_console, but might be something worth considering.