Is Helvetica available on every MATLAB platform?
Show older comments
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}
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
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
on 10 Sep 2025
Accepted Answer
More Answers (1)
Walter Roberson
on 10 Sep 2025
0 votes
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
on 10 Sep 2025
Categories
Find more on Migrate GUIDE Apps in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!