Is NSFont.monospacedDigitSystemFontOfSizeweight broken on Monterey?

I use my own macOS declare classes for extended features of a macOS only desktop project. To make listboxes containing currency values look a bit nicer, I use the CellTextPaint event with
g.FontName = app.PropDigitFont.FontName
returning false. PropDigitFontName is an NSFont that I created with NSFont.monospacedDigitSystemFontOfSize:weight:(0.0, 0.0).

Sadly, numbers are not unproportional. The normal system font is used, which aligns with the NSFont reporting as “.SFNS-Regular 13.00 pt. P [] (0x7fd03086a230) fobj=0x7fd03086a230, spc=3.58” in its debug property, while its monospaced property is True(!)

Much unlike a NSFont created with
NSFont.monospacedSystemFontOfSize:weight:(0.0, 0.0)
which makes the text look less readable and is therefore not my weapon of choice.
Sure, I could branch in CellTextPaint event and only use the latter font where necessary. I’d still prefer to use the first font.
Anyone else having more success? System is Monterey 12.5 on an Intel iMac.

Edit: @Christian_Schmitz : NSFontMBS is missing the mentioned constructor currently, right? UserFixedPitchFontOfSize(0.0) looks exactly like my mentioned second attempt.

I use a constant for the font name that has a Windows specific mono font, and a Mac specific mono font. Not as declaresy or fancy, but doesn’t come with headaches. Is that a viable workaround?

Thanks, Tim! I’d like to stick with the system font if possible. It’s used anywhere else in this project.

It has produces bad text for several macOS versions now, making it almost useless for anything but numbers.

Give this Issue a thumbs up :+1:: macOS: Provide a way to use the monospacedDigitSystemFont

@Christian_Schmitz : Would it be possible to add both monospaced class constructors to NSFontMBS?

I’ll add them for you.

1 Like

Thank you, Christian! It’s working!
So no, it’s not broken. It is because the monospaced digit font name is the same as the normal system font and Xojo uses that for graphics output.
Bild 02.09.22 um 22.07

1 Like