MATLAB Answers

How can I add a new font to the list of available fonts in MATLAB?q

371 views (last 30 days)
I would like to add a new font to the list of available fonts in MATLAB.

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 7 Jun 2016
This change has been incorporated into the documentation in Release 14 Service Pack 3 (R14SP3). For previous releases, read below for any additional information:
Desktop components (such as the Command Window and Workspace browser), figure windows, and uicontrols support only TrueType and OpenType fonts.
However, some graphics objects such as XLABEL, YLABEL, TITLE, and TEXT can render bit-mapped fonts as well.
Windows:
To make a new compatible font available to MATLAB, install the font in Windows by opening the folder Start->Control Panel->Fonts and selecting File->Install New Font. Then restart MATLAB and the font will be available for use.
Linux:
If fonts are not available to X11, they cannot be used to plot the figure in MATLAB. To see a list of fonts available, type the following at the linux system prompt:
 
xlsfonts
 
If only a basic set of fonts is available, then it is likely that you will not be able to render the text you desire in your figure. To add fonts to X11, use the following command:
 
xset +fp <path_to_fonts_directory>
  3 Comments
Tobias Held
Tobias Held on 30 Sep 2021 at 7:14
This did not work for me, but the FiraCode installation instruction worked for me:
Summary
To use this font with MATLAB for Windows 10 64-bit:
  1. Load the font TTF files into: MATLAB\<ver>\sys\java\jre\win64\jre\lib\fonts
  2. Restart MATLAB
  3. Change the font in Preferences -> Fonts as you wish
(https://github.com/tonsky/FiraCode/wiki/MATLAB-for-Windows-Instructions)

Sign in to comment.

More Answers (4)

Kristian Jandric
Kristian Jandric on 8 Oct 2019
If you have multiple user accounts on your PC and install a font, it will only install that font for that specific user. Matlab checks for fonts in the C:\WINDOWS\FONTS directory, which is why installing the font for one user only doesn't update the list of fonts available. Make sure to install the font for all users (by rightclicking and selecting "Install for all users"). At least this worked for me.

Alex Vallmitjana
Alex Vallmitjana on 24 Nov 2018
Edited: Alex Vallmitjana on 24 Nov 2018
As a follow up for this question:
I have a font installed which I modified and updated in the system (windows). For some reason MATLAB will not update the font and even if I delete it completely from the system fonts, matlab will still be able to use it.
How does one tell matlab to update the version of a font?
  1 Comment
Kyle Perry
Kyle Perry on 29 Nov 2018
Hi Alex,
This is something that we would have to take a look at and discuss to see what is going on. Please contact the Technical support team through this link below:

Sign in to comment.


FitBoyAwe
FitBoyAwe on 25 Feb 2020
The default font is BitstreamVeraSans Roman, but we want to try out something else. You can pass fontname to .set_xlabel, .set_ylabel, .set_title, or .annotate to specify a particular font. This does not change the font for the numbers on the axes.
# Plot the median life expectancy by continent
ax = df.groupby('Continent')['Population'].median().sort_values().plot(kind='barh')
ax.set_xlabel("")
# Change the y axis label to Arial
ax.set_ylabel("Median Population", fontname="Arial", fontsize=12)
# Set the title to Comic Sans
ax.set_title("Oceania has small countries", fontname='Comic Sans MS', fontsize=18)
Changing the fonts (special font) for the labels on each axis (the numbers) is a little bit more complicated, but you can use it in combination with the content above to specify fonts for every part of your graph.
# Plot the median life expectancy by continent
ax = df.groupby('Continent')['Population'].median().sort_values().plot(kind='barh')
ax.set_xlabel("")
# Change the y axis label to Arial
ax.set_ylabel("Median Population", fontname="Arial", fontsize=12)
# Set the title to Comic Sans
ax.set_title("Oceania has small countries", fontname='Comic Sans MS', fontsize=18)
# Set the font name for axis tick labels to be Comic Sans
for tick in ax.get_xticklabels():
tick.set_fontname("Comic Sans MS")
for tick in ax.get_yticklabels():
I don’t know why, but you can only set it once. If you change your mind about what you want your default font to be you’ll have to restart your kernel.
  1 Comment
Steven Lord
Steven Lord on 25 Feb 2020
This isn't MATLAB code. Are you sure you wanted to post it here or was it intended for some other forum?

Sign in to comment.


Tobias Held
Tobias Held on 30 Sep 2021 at 7:15
The FiraCode installation instruction worked for me:
Summary
To use this font with MATLAB for Windows 10 64-bit:
  1. Load the font TTF files into: MATLAB\<ver>\sys\java\jre\win64\jre\lib\fonts
  2. Restart MATLAB
  3. Change the font in Preferences -> Fonts as you wish
(https://github.com/tonsky/FiraCode/wiki/MATLAB-for-Windows-Instructions)

Community Treasure Hunt

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

Start Hunting!