You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Here it is some documentation about how to use icon fonts, as it took me a while to make it work: default values while initializing ImFontConfig struct are not expected, so we have to initialize the struct fully. You may add this to documentation or examples if you wish 😄
During initialization, load the font alongside the default one (or after any other font you already loaded):
var io = igGetIO()
io.fonts.addFontDefault()
var config = new_ImFontConfig()
config.mergeMode = true
# ranges array should be global (we need to keep it alive during the application lifetime)
# because 'addFontFromFileTTF' does not copy its values, and it needs a pointer
let ranges {.global.} = [0xf000'u16, 0xf2e0, 0]
# do not use FontAwesome 5, as it cannot be loaded (imgui crashes). Here we load version 4
io.fonts.addFontFromFileTTF("fontawesome-webfont.ttf", size, config.addr, ranges_fa[0].unsafeAddr)
Finally, pass strings using proper unicode characters to buttons, windows, etc. using an unicode literal:
if igBegin("\uf002 <- this is the search icon", ...):
(...)
igEnd()
This discussion was converted from issue #42 on December 20, 2020 01:15.
Heading
Bold
Italic
Quote
Code
Link
Numbered list
Unordered list
Task list
Attach files
Mention
Reference
Menu
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Here it is some documentation about how to use icon fonts, as it took me a while to make it work: default values while initializing ImFontConfig struct are not expected, so we have to initialize the struct fully. You may add this to documentation or examples if you wish 😄
During initialization, load the font alongside the default one (or after any other font you already loaded):
Finally, pass strings using proper unicode characters to buttons, windows, etc. using an unicode literal:
You can check the reference to know what icon corresponds to what character here: https://raw.githubusercontent.com/FortAwesome/Font-Awesome/fa-4/src/icons.yml
See a reference of unicode characters and its corresponding icons for various icon fonts in the following repo: https://github.com/juliettef/IconFontCppHeaders
Cheers!
Beta Was this translation helpful? Give feedback.
All reactions