The drawText() function adds emphasis to text wrapped in * or _ (bold and italics respectively). This is a helpful feature in most situations, but I'd like to be able to disable it.
I'm aware that I can..
escape these characters by doubling them (i.e. ** or __).
replace these characters at runtime with their escaped versions.
replace these characters at build/compile time with their escaped versions.
However, it would be nice to have a way to simply disable this functionality so that text is rendered plainly.
Monkey patch for those who are after this behavior now:
-- swizzle.lua
function swizzle()
local gfx <const> = playdate.graphics
local _drawText = gfx.drawText
playdate.graphics.drawText = function(text, x, y, styled)
if not styled then
gfx.getFont():drawText(text, x, y)
else
_drawText(text, x, y)
end
end
end
swizzle()
-- main.lua
import 'swizzle'
function playdate.update()
playdate.graphics.drawText("*test*", 0, 0, true)
playdate.graphics.drawText("*test*", 60, 0)
end
Just wanted to repeat this from our Discord chat for other's posterity:
Ohh thanks! I hadn't realized that font:drawText() would render text without emphasis, so this solved my problem! I think it would be helpful if this was added to the docs