Font size issue on MacOS

I wrote some software many years ago, and while it’s had small updates over the years, not much else has changed. It’s been downloaded and installed 1000’s of times by users around the world, but today I had a customer report an issue I’ve never seen before.
Some of the font sizes in my app are larger on his computer than on mine, and they’re messing up the layout. I’ve seen this issue with many programs under Windows, when people set their fonts to 125% and so on, but this issue is on MacOS.
He is running Sonoma, as am I, and I cannot reproduce the issue. I don’t see any settings in Sonoma that allow for larger text except in specific Apple-only applications, so I don’t think it’s that. Could it be HiDPI settings? The app doesn’t look great with HiDPI disabled, so hopefully not!

Here’s what it’s supposed to look like:

Here’s what it looks like on his machine:

Note that ONLY the Listbox column headers and Tab header text is larger. Other fonts are (from what I can see) the same size. The whole listbox is in Courier, with the header bolded, but the Tab labels are just system font. All fonts are set to “0” for size.

Scratching my head on this one!

Another pic with the 2 windows the same size.
Clearly everything in the Tabs control is larger (Tab text and Listbox text), but the rest of the window is normal.

This is possible and I’ll be honest, I never looked for the settings myself, but I often get e-mails about text being cut off and things just looking like crap, because the font is way too big.

I am thankful that with SwiftUI, you don’t layout things out by pixel, so if the user has overridden the font size, the UI still works, unless you force it not too!

Here’s an Apple guide on how to do it.

Thanks, Sam, but that’s not it. There’s settings for only a few Apple programs - Calendar, Mail, etc, but no others.
Other apps have to handle it within that app if they want to give that control.
On my computer, here’s the only 5 programs that allow for text size to be adjusted:

Check that he actually has the font. He might have removed or disabled it, so you’ll get font substitution.

Well, that could happen for the courier font, but there’s a couple of things:

  1. The font on his screen is still courier, just larger.
  2. The tab control font is “system” and still shows larger.
  3. The other fonts on that window are all “system” and are not larger.

When you select a font size of 0, will that ALWAYS translate to 12 points (Mac & Windows) or does a user have control over that?
If it’s not ALWAYS 12 points, then how do you get what size the user has selected?

Size 0 is “the systems default size” in Xojo
And this varies depending on whether you you Small System or System as the font (Small system on macOS seems to be about 9 point and System seems to be about 11 pt)
Users have some control over that in various appearance panes
System Settings > Accessibility > Display > Text
Not sure where that is on Windows TBH

What I’ve seen people do to get the actual selected size is

  1. declares
  2. plugins
  3. graphics.textsize (see SmallSystem font size - Windows - Xojo Programming Forum)
  4. other silly hackery to draw text in to a picture then measure the height in pixels

Personally 1 or 2 is the most likely to be accurate

EDIT : I suspect its something like

Function TextSizeToUse( font_name as string, text_size as integer) as double

	dim font_size_to_use as double = text_size
	if font_name = "System" or font_name = "" then
		if font_size_to_use = 0 then
			font_size_to_use = declare into [NSFont systemFontSizeForControlSize:NSRegularControlSize]
		end if
	elseif font_name = "SmallSystem" then
		if font_size_to_use = 0
			font_size_to_use = declare into [NSFont systemFontSizeForControlSize:NSSmallControlSize];
		end if
	end if	

	return font_size_to_use
end Function

and this along with the font name is then used to get the right font at the right size using one of NSFont functions like

[NSFont systemFontSizeForControlSize:NSRegularControlSize]; // font name = "System" or ""
[NSFont systemFontSizeForControlSize:NSSmallControlSize]; // font name = "SmallSystem"
[NSFont fontWithName:font_name size:text_size]; // for any other font & size 

see NSFont | Apple Developer Documentation

In Xojo… Declares.



In SwiftUI virtually everything that can be modified at code level is conveniently accessible through modifiers.

It is unfortunate that Xojo does not offer the same RAD environment and everyone needs to dabble in declares.

1 Like

Adjusting that doesn’t seem to change anything within the Xojo app. Should it?

That’s the kicker, I don’t know. First of all, I don’t know what information that option changes and secondly, we don’t know where Xojo is getting the font size from, and thirdly Xojo likes to cache things, so you may have to restart your app to see any difference (like date and time formatting).

Next time I get a customer feedback (where they’ve made the fonts ginormous), I’mma gonna have to ask how they did it.

Well assuming Xojo is using the correct macOS functions for getting the right size I might assume it would