Using system menu changes leading of game's custom font

Discovered this by pure chance.

(Leading is space between lines)

  1. Set leading on some text and check it is correct (GET READY...3, below)
  2. Press menu to open it
  3. Press menu to close it
  4. Confirm that leading of text has changed (GET READY...2, below)

This is strange, because I am not using system font to draw this, but rather a custom font.

eg.

local fnt = gfx.font.new("custom")
fnt:setTracking(2)
fnt:setLeading(5) -- this is changed after using menu
...
fnt:drawText("GET READY!\n  1", 200, 120)

Visuals

new-leading

Notes

  • sadly default leading cannot be specified in the .fnt file

Are you using gfx.setFont? I'd expect that the menu font is overwriting the game's currently loaded font, and it's somehow not restoring the state correctly.

This seems like a firmware issue.

No, I'm not using gfx.setFont at all.

My workaround is to re-set the leading in gameWillResume() like so:

function playdate.gameWillResume()
	fnt:setLeading(5)
end

weird. I'm not having any luck reproducing it this way:

gfx = playdate.graphics
font = gfx.font.new("Sasser-Small-Caps")
font:setTracking(10)
font:setLeading(10)

function playdate.update()
	gfx.clear()
	font:drawText("current time:\n\n\n"..tostring(playdate.getCurrentTimeMilliseconds()), 20,20)
end

Yes, strange! I'll try to do a reduced test case.

I think a case of me being an idiot. :man_facepalming:

Recently I'd introduced a setLeading(0) in playdate.gameWillPause() but within a pushContext

So I assumed it would only take effect during the context? I guess?

Is there a list of what functions pushContext applies to?

gfx = playdate.graphics
font = gfx.font.new("Sasser-Small-Caps")
font:setTracking(10)
font:setLeading(10)

function playdate.gameWillPause()
	local pauseImg = gfx.image.new(400,240, gfx.kColorBlack)
	gfx.pushContext(pauseImg)
		font:setLeading(0)
	gfx.popContext()
end

function playdate.update()
	gfx.clear()
	font:drawText("current time:\n\n\n"..tostring(playdate.getCurrentTimeMilliseconds()), 20,20)
end