-- Text that falls back to an app-supplied font and truncates with an ellipsis.
-- Pass the path of a CJK font as the first argument to see kana and kanji;
-- without one they show as the bundled font's missing-glyph boxes.
local ui = require("@neyuki/ui")
local os = require("@neyuki/os")
local win = ui.open({ title = "Neyuki UI text", width = 480, height = 200 })
local fontPath = os.args()[1]
if (fontPath != nil) then
ui.setFallbackFonts({ ui.loadFont(fontPath) })
end
local title = "ループザルーム (feat. 初音ミク) - a very long track title"
ui.run(function(events: {Event}, dt: number)
for _, event in events do
if (event.kind == "keydown" and event.key == "escape") then
win:close()
return
end
end
win:clear("#1e1e2e")
win:text(20, 20, title, { size = 18, color = "#cdd6f4", maxWidth = 280, overflow = "ellipsis" })
win:text(20, 60, title, { size = 14, color = "#a6adc8", maxWidth = 200 })
win:text(20, 150, "centered", { size = 14, color = "#f9e2af", maxWidth = 440, align = "center", letterSpacing = 2 })
win:present()
end)