Font consistency across platforms

Sorry for cross-posting on https://stackoverflow.com/questions/54724212/avoid-wxpython-textctrl-differences-between-macos-and-windows but I don’t know where the wxPython community gathers these days.

What measures can I take to ensure the font in a multiline text control looks the same across OSs (macOS and Win10 in my case):

self.console_ctrl = wx.TextCtrl(panel, style=wx.TE_MULTILINE | wx.TE_READONLY | wx.HSCROLL)
self.console_ctrl.SetFont(wx.Font(13, wx.FONTFAMILY_TELETYPE, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL))
self.console_ctrl.SetBackgroundColour(wx.BLACK)
self.console_ctrl.SetForegroundColour(wx.RED)
self.console_ctrl.SetDefaultStyle(wx.TextAttr(wx.RED))

Sorry for cross-posting on https://stackoverflow.com/questions/54724212/avoid-wxpython-textctrl-differences-between-macos-and-windows but I don’t know where the wxPython community gathers these days.

What measures can I take to ensure the font in a multiline text control looks the same across OSs (macOS and Win10 in my case):

On one level, why do you care? As long as the information is being presented, the exact format shouldn’t really matter.

self.console_ctrl.SetFont(wx.Font(13, wx.FONTFAMILY_TELETYPE, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL))

You aren’t specifying a font here, you’re telling the operating system to choose a font on its own that looks kind of like teletypes. If you want an exact look, then you should specify the exact font name that you want. Also, by setting the size in points, you are leaving it up to the operating system to convert points to pixels. Again, if you want an exact look, you should use a wx.Size structure to specify the font size in pixels.

···

On Feb 16, 2019, at 10:46 AM, Marcel Stör marcel@frightanic.com wrote:


Tim Roberts, timr@probo.com
Providenza & Boekelheide, Inc.

On one level, why do you care? As long as the information is being presented, the exact format shouldn’t really matter.

Oh well, how about ensuring consistent user experience? The screen shots I posted on SO show that due to font inconsistencies the text control on Windows looks pretty awful.

self.console_ctrl.SetFont(wx.Font(13, wx.FONTFAMILY_TELETYPE, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL))

You aren’t specifying a font here, you’re telling the operating system to choose a font on its own that looks kind of like teletypes.

I know it’s just the font family but I though it were wxPython which chooses the effective font face and not the OS. Thanks for clarifying.

If you want an exact look, then you should specify the exact font name that you want.

My app is packaged / distributed with PyInstaller. Hence, I could add .ttf files to the deliverable to ensure the font I select will actually be available at runtime. Looking at https://github.com/wxWidgets/wxWidgets/pull/591 I see there’s a method to add “private” fonts to wxWidgets but I don’t anything similar in the wx.Font class documentation.

Also, by setting the size in points, you are leaving it up to the operating system to convert points to pixels. Again, if you want an exact look, you should use a wx.Size structure to specify the font size in pixels.

Good point, thanks.

···

On Sunday, February 17, 2019 at 4:26:50 AM UTC+1, Tim Roberts wrote:

On one level, why do you care? As long as the information is being presented, the exact format
shouldn't really matter.

Oh well, how about ensuring consistent user experience? The screen shots I posted on SO
show that due to font inconsistencies the text control on Windows looks pretty awful.

There are at least two sides to consistency:

   Consistency across several apps under one platform.

   Consistency within one app across platforms.

Users will want it either way.

Karsten

There are at least two sides to consistency:

Certainly. It’s ok that a wxPython app will never 100% look like a native app on any platform. That’s a compromise you need to accept whenever you work with a cross-platform UI-abstraction framework.

Also, I don’t mind that the app on Windows does not look 100% like the app on macOS. In fact, it shouldn’t - it should look more like a native app (see above). It’s extremely unlikely that A) one of my users will open the app on both platforms and B) then complain that they look differently.

I’m merely looking to improve the appearance of the text control on Windows. Ideally I wouldn’t have to introduce platform switches in the code (if Windows then do this, else do that).

Also, by setting the size in points, you are leaving it up to the operating system to convert points to pixels. Again, if you want an exact look, you should use a wx.Size structure to specify the font size in pixels.

Good point, thanks.

In the end using pixels instead of points gave me the desired improvement. Thanks again.