This article assumes you have already created a project with Nuklear integration. Once you've done so, you can return here for help with adding your own fonts via config, and utilizing those fonts code-side.
Somewhere within your config files, you will need to add a section like the following:
[Nuklear] FontSize = 13 GlobalAlpha = 1 SegmentCount = 22 FontList = SomeFont # SomeOtherFont SomeFont = path/to/SomeFont.ttf # 20 SomeOtherFont = path/to/SomeOtherFont.ttf # 60Here, FontSize, GlobalAlpha and SegmentCount override some of ORX's default Nuklear settings, and FontList is the list of all fonts (named by you) you wish to use in your project. After FontList, you need to declare attributes named after each of the fonts included in FontList; each of these must contain two elements, the first of which is the path to the TrueType font you wish to use, and the second of which is the font size you wish to set for that font.
Note that if you wish to trim the file path sizes of these TrueType fonts, all you need to do is add a “Font” attribute to your resource section, as follows:
[Resource] Font = ../data/fonts1 # ../data/fonts2where “../data/fonts1” and “../data/fonts2” are folders in which any of the TrueType fonts you wish to use can be found.
Once you've made ORX aware of the fonts you'll be using via the config work outlined above, getting Nuklear to utilize those fonts is a relatively trivial matter. Basically, any time you wish to render text with a Nuklear call like
nk_text(&sstNuklear.stContext, "Display this text.", strlen("Display this text."), NK_TEXT_ALIGN_LEFT);, you'll need to set the font you wish to use prior to doing so, and in the following way:
nk_style_set_font(&sstNuklear.stContext, &sstNuklear.apstFonts[fontIndex]->handle)with the final code looking like this:
nk_style_set_font(&sstNuklear.stContext, &sstNuklear.apstFonts[fontIndex]->handle) nk_text(&sstNuklear.stContext, "Display this text.", strlen("Display this text."), NK_TEXT_ALIGN_LEFT);Note that a font's index is determined by its placement in the [Nuklear] config section's FontList attribute, so using our config example above, SomeFont would have an index of 0, and SomeOtherFont would have an index of 1.