Is Helvetica available on every MATLAB platform?

7 views (last 30 days)
I am programmatically building graphical interfaces and was wondering how universal Helvetica is on various platforms. A quick test:
Q=listfonts();k=contains(Q,'Helvetica');Q{k}
ans = 'Helvetica'
verifies if one or more Helvetica font are available. I can confirm than this font is available in R2025a (presumably previous releases as well) on the Mac and Windows. It also appears to be present on MATLAB Online. What I am less clear about is the many different flavors of Linux.
The underlying problem is that horizontal space requirements vary wildly between different font types. I have enabled a system where interfaces can be tailored around the end user's font size preference, but allowing the font itself to change is much tricker. For example, suppose you want to have an edit box wide enough to fit 20 characters. This is straightforward for a fixed with font, such as Monaco or Consolas. The default choice seems to be Helvetica, where the "W" and "i" characters are vastly different. A graphic sized for one font can appear much wider than necessary in some cases or not wide enough in others. If one were certain that Helvetica is always availble, it would make sense to base the design around that font. If not, one could rely on a fixed with font, although not everyone appreciates their appearance.
  2 Comments
Rik
Rik on 10 Sep 2025
Fonts are a pain. In my GUIs I generally allow for very large margins (i.e. 2x-3x of what I think will be needed) or I hardcode a font I pixelized myself (see text2im). It is a bit of a cludge, but I often see huge companies with entire departments focused on UI design mess up, so I don't fret too much.
Also, you should be careful assuming any defaults, since people can change them, which would break your carefully calibrated solution.
Dan Dolan
Dan Dolan on 10 Sep 2025
You are spot on about fonts being a pain. Sometimes I go to great lengths to avoid putting uicontrols or components (uilabel, etc.) on a graphical interface to avoid dealing with variations across different systems. The problem is that uimenus, context menus, and various action callbacks only get one so far. When I have no choice but to use controls, they are usually based on the requirements of repeated "W" characters. Oversizing is less bad than undersizing--at least you can always read the text--but sometimes the result is garish.
Although I don't use the App Designer, presumably its existence suggests some degree of font portability. One of my gripes with this approach is that the interface is explicitly tied to a specific font name and size, but in order for that to work, presumably the default (Helvetica 12 point) has to be available on all platforms? Then again, the font might be embedded somewhere in the *.mlapp file.

Sign in to comment.

Accepted Answer

Star Strider
Star Strider on 9 Sep 2025
On my Ubuntu 24.04 installation (latest updates), using yur example code, 'Helvetica' is the 12th entry in 'k'.
Proportional fonts are exactly that -- proportional. There are probably ways of calculating the pixel width of each letter in a specific font size, or the pixel width of a character array in a specific proportional font. Searching the File Exchange on 'font width' brings up three contributions, however none of them appear to calculate the pixel widths of either individual letters or a character array. You might consider doing a wider interweb search for that.
  4 Comments
Dan Dolan
Dan Dolan on 12 Sep 2025
This core set of fonts appears on MATAB Moble as well.
Star Strider
Star Strider on 12 Sep 2025
Noted! Thank you!
I believe everything in MathWorks uses Ubuntu, however I know of no further details. The ver command will list some of those details in its OS section.

Sign in to comment.

More Answers (1)

Walter Roberson
Walter Roberson on 10 Sep 2025
The traditional way of handling this was to create a uicontrol and set the text string and font properties of the uicontrol, and then query the Extent property of the uicontrol, which would return the width and height actually needed to represent the text string with those properties. And then to use that information to set the size of the target control.
The main alternative to this is to get the Extent property of a text() object.
There is a File Exchange contribution that automates getting the extent from a text object; see https://www.mathworks.com/matlabcentral/fileexchange/168156-gettextextent
  1 Comment
Dan Dolan
Dan Dolan on 10 Sep 2025
I to feel the pain at the loss of Extent properties--that's what I have traditionally done. I had considered the approach you suggest, relying on a hidden figure with a legacy text field for Extent calculations, but there's a problem. Axes text and uicontrols fonts are scaled by 1.33x (starting in 2025a), but new components (uilabels, uibutton, etc.) are not. That means the extent values calculated this way are systematically too large. I conceed that oversizing is less dangerous than undersizing a component, at least in terms of readability, but now the question is whether this arrangment changes in a future release. Objects where Units/FontUnits can be something other than pixel are scaled, and for now the newer components do not qualify.

Sign in to comment.

Categories

Find more on Migrate GUIDE Apps in Help Center and File Exchange

Tags

Products


Release

R2025a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!