We have both the Material Design and Font Awesome fonts included in our ImGui integration. But I wanted an easy way to display fonts for buttons and displays in my Lua scripts.
I tracked down some old C header files for Material Design and Font Awesome (much easier to work with UTF-8 than Unicode in Lua). Took those and converted them. This file, when included (and you have some kind of autocompletion in VSCode will provide an easy way to choose and use icons in your ImGui apps.
Put the file in the "lib" subdirectory in your Lua script folder and include the file
You'll get a full list of available Icons.
Here's a quick loop to run through them all and display them in a window,
Which gives us output like this:
I tracked down some old C header files for Material Design and Font Awesome (much easier to work with UTF-8 than Unicode in Lua). Took those and converted them. This file, when included (and you have some kind of autocompletion in VSCode will provide an easy way to choose and use icons in your ImGui apps.
Put the file in the "lib" subdirectory in your Lua script folder and include the file
Lua include example:
local require ICON = require('lib.icons')
You'll get a full list of available Icons.
Here's a quick loop to run through them all and display them in a window,
Icon Display Gui:
--- @type Mq
local mq = require('mq')
--- @type ImGui
require 'ImGui'
local ICON = require('lib.icons')
local openGUI = true
local shouldDrawGUI = true
local searchText = ""
local function DrawMainWindow()
if not openGUI then return end
openGUI, shouldDrawGUI = ImGui.Begin('Example Icon App', openGUI)
if shouldDrawGUI then
searchText = ImGui.InputText("Filter Icons", searchText, 100)
searchText = trim(searchText)
for key, value in pairs(ICON) do
if string.len(searchText) <= 0 or string.match(key, searchText) then
ImGui.Text(string.format('%s : %s', value, key))
end
end
end
ImGui.End()
end
function trim(s)
return (s:gsub("^%s*(.-)%s*$", "%1"))
end
mq.imgui.init('Icon Example', DrawMainWindow)
while openGUI do
mq.delay(1000)
end
Which gives us output like this: