Name and size of the system user interface font (default system font)
Updated 6 May 2021

View getOSfont on File Exchange


getOSfont returns the name and size of the system user interface font (default system font).


Graphical user interfaces developed with MATLAB often lack the look and feel of native applications, which is in part due to the fact that they do not use the user interface font of the operating system on which they are running. getOSfont resolves this issue by returning the name and size of the system UI font for a variety of platforms and OS versions, including all platforms officially supported by R2014b and above.


[OSFont, OSFontSize] = getOSfont(OS, OSVersion) returns the name and size (in points) of the system UI font of the operating system OS in version OSVersion. If the system UI font is not available to MATLAB, it is replaced by a similar font and a warning is issued. If the OS is not supported, OSFONT and OSFONTSIZE are returned empty. If the font selected by getOSfont is not available on the system, OSFONT is returned empty.

OS is a character vector containing the name of the operating system in lowercase letters. The following operating systems are supported:

  • 'windows' (starting with Windows 3.1)
  • 'macos' (all OS X and macOS versions)
  • 'ubuntu' (starting with Ubuntu 10.10)
  • 'centos' and 'redhat' (starting with version 6.8)

OSVersion is a numeric vector representing the version number of the operating system. For example, OSVersion = [6, 1, 7601] corresponds to version 6.1.7601.

getOSfont is typically used in tandem with detectOS.


% avoid error if OS cannot be determined
   [OS, OSVersion] = detectOS;
   OS = '';
   OSVersion = [];

[OSFont, OSFontSize] = getOSfont(OS, OSVersion);
% if returned empty, fall back on factory settings
if isempty(OSFont)
   OSFont = get(groot, 'factoryUicontrolFontName');
if isempty(OSFontSize)
   OSFontSize = get(groot, 'factoryUicontrolFontSize');


getOSfont is compatible with MATLAB R2013a and later releases.


Any feedback or help in extending the code to other operating systems/versions is welcome!

Cite As

Jorg Woehl (2024). getOSfont (, GitHub. Retrieved .

MATLAB Release Compatibility
Created with R2013a
Compatible with R2013a and later releases
Platform Compatibility
Windows macOS Linux

Community Treasure Hunt

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

Start Hunting!

Versions that use the GitHub default branch cannot be downloaded

Version Published Release Notes

See release notes for this release on GitHub:

Refine input validation
OSFont and OSFontSize are now treated separately. FONTEXIST is now a separate function.

Added link to detectOS
Added image

To view or report issues in this GitHub add-on, visit the GitHub Repository.
To view or report issues in this GitHub add-on, visit the GitHub Repository.