Why does Xojo's System font look different to macOS’ natively declared font?

I wasn’t lucky with the looks of a DesktopTabPanel set to small tabs, using the System font in small size. The text is placed too far below the vertical middle, some glyphs even cutting the bottom of the tab’s frame (Tabs at the bottom).

Bild 08.02.22 um 23.15

So I tried a few declares that basically do the same: Set the control size to NSControlsize.small, set the NSFont to SystemFontOfSize(SystemSmall). To my amazement this looks much better, and I repeated the font assignment with standard size to the upper tab.
Surprise! Looks much better too! Xojo‘s system font is somewhat condensed compared to the original. Why? How? Is kerning disabled? Something else?

Bild 08.02.22 um 23.13

I’m not precisely sure why, but their font size at 0 is just wrong. I use this to fix it, which sounds similar to what you’re doing, just… differently.

Public Sub FixTabFont(Extends Panel As TabPanel)
  #if TargetCocoa
    Declare Function objc_getClass Lib "Cocoa.framework" (ClassName As CString) As Ptr
    Var NSFont As Ptr = objc_getClass("NSFont")
    If NSFont = Nil Then
    End If
    Declare Function SystemFontOfSize Lib "Cocoa.framework" Selector "systemFontOfSize:" (Target As Ptr, Size As CGFloat) As Ptr
    Var FontObject As Ptr = SystemFontOfSize(NSFont, 0)
    Declare Function GetPointSize Lib "Cocoa.framework" Selector "pointSize" (Target As Ptr) As CGFloat
    Panel.FontUnit = FontUnits.Point
    Panel.FontName = "System"
    Panel.FontSize = GetPointSize(FontObject)
    #Pragma Unused Panel
End Sub
1 Like

Thanks! On closer inspection, it’s even a different font. Look at the rounding of the P or compare the serifs of the a.
When you inspect the TabView’s font property of a Xojo DesktopTabPanel with declares, it will report Nil?!

Hmm… you’re both right. I can’t find a bug report about it.

I don’t know what Xojo is using internally, but there’s a NSFont API to get the “small” system font at the correct size.

In the Ohanaware App Kit demo application, I demo all the available system font functions I could find, maybe try the demo application and see what it says is the Small system font and compare that to what Xojo uses. TBH I would imagine it to the same thing.

I thought so too until today.
But as I said, TabView reports a Nil font when System size 0 was selected. Have not investigated further yet.

It’s not just the small fonts. The standard tab panel font is wrong. Calling the function provided by @Thom_McGrath fixes it for full size. It could easily be modified to do Small also.

I didn’t notice the font was wrong too, but I’m certain my method could be adapted.

Thanks all! Ticket has been created:

@Thom_McGrath Your code fixes both the size and the font. Very useful thanks.