Solved: only Bitmore-Medieval font renders properly in gridview

Fix found! - Solved: only Bitmore-Medieval font renders properly in gridview - #8 by timhei

(changed title from a topic regarding System font to just about any font not working in gridview - link to info for switch in title here: Solved: only Bitmore-Medieval font renders properly in gridview - #7 by Tengu )

SDK 1.9.3, Windows 11

I'm trying to use the Playdate System font, because I want to use localized text and the system font renders both English and Hiragana really well :wink:

Well, even after banging on this for a couple of days I can't seem to get the System font to render English text at all in a gridview (simple list). It works fine with bitmapped fonts:

But switching to the System font gets nothing:

I thought it might be something I was doing wrong, so I went back and switched the gridview sample to the System font and it's showing the same issue:

No amount of fiddling with gfx.setImageDrawMode and/or gfx.setFont seems to have any effect on this.

Strangely enough, if I use the bitmap font it renders localized English (en.strings) in the bitmap font, but then some unknown mechanism turns around and automagically renders localized Hiragana (jp.strings) in the System font. This gets me almost what I want (English and Hiragana both work in gridview), but they're not in the same style/size.

tl;dr - there seems to be something about gridview that doesn't like the System font. Is this a bug, or am I doing something wrong?

Thanks for any advice/assistance :slight_smile:

Forgot to add the source for my test in the first two screenshots:
Game Template Showing System Font and Gridview.zip (6.1 KB)

To build, unzip somewhere, then:

@echo off
pdc "Game Template/Source" gt.pdx
playdatesimulator gt.pdx

Hm I have definitely made gridview with the system font. Can you log the font and see what gets returned? You also might need to specify the variant. I’ll poke around with this once I get back to my computer, but I do recall that system font wasn’t working how I had expected either.

Work around for this is to simply create a variable really early on pointed to gfx.getFont(), something like

systemFont <const> = gfx.getFont()

If you do it early then it’ll grab the current font, which is the system font.

Oh and if I’m remembering correct you might have to include the font in your Source folder in order to use it. Games don’t have access to the fonts bundled with the system directly, only by copying it in.

I don't know what this means.

Lua doesn't like '<const>', but doing 'systemFont = gfx.getFont()' early on doesn't seem to help.

I tried that, no difference.

There isn't any sort of 'system font' on disk that's obvious - there are five font files (.pft) in 'C:\PlaydateSDK\Disk\System\Fonts' directory and I copied them to my Source directory, that didn't make a difference either.

That really doesn't make any sense to me, architecturally... 'getSystemFont' doesn't return the System font? Why would Playdate do that? And I seem to have access to the System font (somehow?), as the bitmapped font doesn't have any Hiragana characters in it, yet if I do a call on 'listFont:getTextWidth' with Hiragana characters (to make my menus auto-width-sizing) the width that comes back seems to be correct.

Edit: I just recalled where I saw some Example code using the System font... I was trying to emulate that ('fast fade' example):

And that example doesn't do any font copying to it's asset folder. So... what's good for the Goose is good for the Gander, you'd think :wink: .

Anyhow, thanks for the help :slight_smile: - it just doesn't seem to be working.

After sleeping on it and poking more at font stuff, came across this post and will give things another try:

https://devforum.play.date/t/usage-of-system-font-in-a-playdate-project-sdk/3729

1 Like

Ok, after looking at Eric's kindly font suggestions, looking through docs and examples, I still haven't been able to make this work... but it doesn't, actually, seem to have anything to do with the System font.

I can't seem to get a gridview to render anything in a simple list properly unless I use the Bitmore-Medieval font - strangely enough, that's the font that the gridview example uses :face_with_spiral_eyes: ... any other font, and things just don't seem to work.

Trying to go at this methodically... first, the gridview list (the scroll whatsit on the right side) using Bitmore:

Looking good, right?

Now we switch to the 'blocky' font, which is part of the default font assets for the gridview sample:

This is starting to look strange... only one letter for each item renders, but for most we get nothing.

Then adding one of the Asheville fonts (.fnt and table .png) to the appropriate folder... and we get nothing (which matches the original behavior when trying to use the System font):

Doing the same with my simple test case based on the 'Game Template' sample, first using Bitmore:

Things render quite nicely, just as they do in the gridview sample.

Now using the blocky font:

We get the same 'some glyphs render and some don't' behavior as using blocky in the gridview list. Now we try Asheville:

Which renders in the simple round rect (showing that the font is indeed being loaded properly and is well-formed) but renders not at all in the gridview list.

So... does gridview simple list only work properly using Bitmore-Midieval? That doesn't seem right.

I was messing with the gridview example trying figure out what was happening, when I realized the solution is actually very simple. The blocky font does not have lower case characters. If you edit the menuOptions list to use all caps, or if you convert the text in the drawTextInRect function with string.upper(menuOptions[row]), then the text will render properly.

playdate-20220417-160706

Note, I also changed the selected draw mode to use gfx.kDrawModeInverted instead of gfx.kDrawModeFillWhite since the blocky font uses both black and white to create the outline around the font.

As for the problem with the Asheville font, I think that's actually an issue with the font being too big for the rect you are drawing it in. Try increasing the height parameter in gfx.drawTextInRect.

1 Like

Yes! That was the problem:

It had never occurred to me that a missing glyph wouldn't just put out a � rather than nothing, or that gfx.drawTextInRect wouldn't just clip rather than drawing nothing.

Thanks so much, timhei and Eric :slight_smile: .

2 Likes

Unrelated-ish but the system font stuff appears to be working just fine for me now. Not sure what I had been doing wrong before.

I've just verified the same... switched from Asheville back to the System font, no duplicate font in my distro required, and works like a charm (mp4):

System Font simple list for main menu, language switch.

Thanks for all your help!

1 Like