I got interested, and generally never need much of an excuse to go poking into code, so took a look... all this should be taken with a very large grain of salt
.
but the getTextTracking()
seems to only be exposed via lua.
That seems to be the case (../PlaydateSDK/C_API/pd_api/pd_api_gfx.h):
However:
From the various docs, it looks like there are two sorts of 'tracking' values - the first is a global value not related to any specific font (from what I can tell the default value is 0.0), which gets added to an (optional) font-specific tracking value (can be specified in the font file itself, or can be set on a per-font basis in Lua via font:setFontTracking()).
So, it looks like C and Lua are (functionally? indirectly?) nearly equivalent, just not quite the same.
You can set the global 'tracking' in C via setTextTracking(), and you can 'set' (in effect, in terms of results) the additional tracking for the font used with each getTextWidth() invocation via the 'tracking' parm in its signature.
The difference between the two APIs seems to be that there's no way in C to query a font for its (optional) tracking value. I'm assuming that that information is tucked away in either the font's LCDFont struct or its internal LCDFontData struct, but since there's no definition of those structs in the SDK headers it looks like you're not meant to know, meaning that from the perspective of the SDK user those are just opaque pointers to be passed around and the SDK internals handle the details.
So, summary:
The global default 'tracking' value seems to be 0.0. So, if it's going to be anything besides that it's because you set it yourself via 'setTextTracking()', so you should know what it is without a direct 'getTextTracking()' query for the global value.
For any particular font, in C there's no way to know what (if any) its internal tracking value is, but you get to set the tracking with each individual invocation of 'getTextWidth' (which is a transient sorta-equivalent of the Lua font:setTracking() method).
A bit more detail:
All of the fonts shipped with the SDK have tracking values (when there are any specified at all) between 0 (which would mean tracking is pretty much cooked into the glyph widths/painting themselves) and 4 (for really large characters, like the ones used for the clockface).
Is that a bug?
If you're talking about on a per-font basis, perhaps more of an 'oversight'? Maybe something for a feature request
.
Is there a default value I can assume?
For individual fonts, there doesn't seem to be one (it's likely '0' if not defined in the font, but you can't know that... though since you know the path to the font you could roll your own way to find out, processing the font file as text and looking for a line that begins with 'tracking='. And if that's something you need to do for whatever reason I'd say that was pretty good justification for asking for a font-specific tracking query method for enhancement for C).
For the global tracking value, from what I could tell (a mixed Lua/C project):
print("tracking:")
print(tostring(playdate.graphics.getFontTracking()))

the default value is 0, and if it's anything else than that it's because you set it, so you should know what it is
.
I don't know if this was helpful at all, but thanks for an excuse to look over some code during lunch
.