Wingdings (and other symbol fonts) appear as default font

19 views (last 30 days)
I am using Matlab R2011b on OS X 10.6.8.
The listfonts command shows that Wingdings is available, but when I try to use it in a figure, it appears as the default font. This seems to be true of other symbol fonts like Symbol and Zapf Dingbats.
The fonts work fine on another machine running the latest version of OS X but I can't figure out what is different between them. Both machines are running the same version of Java.
Any ideas?
  1 Comment
Karthick SK
Karthick SK on 25 Aug 2021
Edited: Karthick SK on 25 Aug 2021
Running out of ‘Markers’ while plotting is a common problem in MATLAB.
One way to overcome the problem is to use different letters from a particular font name (like Wingdings, or Zapf Dingbats). However, there is an issue to this solution. The problem arise from the inability of MATLAB to print letters from fonts like Wingdings.
A simple command
listfonts
ans = 39×1 cell array
{'AvantGarde' } {'Bookman' } {'Courier' } {'DejaVu Sans' } {'DejaVu Sans Mono' } {'DejaVu Serif' } {'Dialog' } {'DialogInput' } {'Helvetica' } {'Helvetica-Narrow' } {'Liberation Mono' } {'Liberation Sans' } {'Liberation Sans Narrow'} {'Liberation Serif' } {'Lucida Bright' } {'Lucida Sans' } {'Lucida Sans Typewriter'} {'Monospaced' } {'NanumBarunGothic' } {'NanumGothic' } {'NanumMyeongjo' } {'NewCenturySchoolBook' } {'Palatino' } {'SansSerif' } {'Serif' } {'Symbol' } {'Symbola' } {'TakaoExGothic' } {'TakaoExMincho' } {'TakaoGothic' }
will reveal that ‘Wingdings’ font types are not available in the bucket. Even when you add it, ‘Windows’ operating system containing Matlabmachine only print ‘rectangles’ again and again. In MAC OS it works fine apparently.
The alternative suggestion is to use one of the default fonts available in Matlab like ‘Zapf Dingbats’.
By using the decimal code, Matlabprints the actual text. On the other hand, while using the hexadecimal code, it prints the corresponding symbol.
For example,
figure;
text(0.5,0.5,char(065),'fontname','ZapfDingbats','fontsize',30); % char in decimal code
hold on;
prints the corresponding ZapfDingbats character, whereas
text(0.4,0.5,char(0x2721),'fontname','ZapfDingbats','fontsize',30); % char in hexadecimal code
hold off;
prints the corresponding ZapfDingbats graphic text.
The relevant decimal and hexadecimal values can be found in the following links:
Use the table given in the Unicode blocks for ‘Zapf Dingbats’ .
  1. https://en.wikipedia.org/wiki/Zapf_Dingbats
  2. https://help.adobe.com/en_US/framemaker/2015/using/using-framemaker-2015/Appendix/frm_character_sets_cs/frm_character_sets_cs-5.htm
Later, while using some of the legend modifiers methods as given below, a desired plot can be generated.
  1. https://www.mathworks.com/matlabcentral/answers/277438-marker-and-line-in-legend-in-matlab-plot#answer_216684
  2. https://www.mathworks.com/matlabcentral/answers/402235-how-can-i-use-a-custom-marker-for-plot-or-alternatively-add-a-text-item-in-the-legend
A detailed code to generate a plot with letters as markers from different fonts is given below. The code works fine for both linear and log scale plots.
% sample code to plot letters from a font as markers
clc; clearvars;
% Make some arbitrary data - linear scale
x = linspace(1,10,10);
y = x;
% Use TEXT to plot the character along the data
figure; subplot(121); % linear scale
l = plot(nan, nan); % creating an empty line before
text(x,y,char(0x2721),'fontname','ZapfDingbats','fontsize',10); % add the actual data
% Manually set axis limits, since TEXT does not do this for you
xlim([min(x)-1 max(x)+1])
ylim([min(y)-1 max(y)+1])
% legend change
l.XData = []; % remove its points from the axes
l.YData = [];
l.Color = [0 0 0]; l.LineStyle = 'none'; l.Marker = 'none';
leg = legend(l,strcat(char(0x2721),' Data'),'location','northwest');
set(leg,'fontname','ZapfDingbats','fontsize',10);
% finish
axis square; grid on; box on;
% Make some arbitrary data - log scale
x = linspace(1,10,10);
y = logspace(1,10,10);
subplot(122); % figure
l = plot(nan, nan); % creating an empty line before
text(x,y,char(0x2721),'fontname','ZapfDingbats','fontsize',10); % add the actual data
% Manually set axis limits, since TEXT does not do this for you
xlim([min(x)-1 max(x)+1])
ylim([min(y)-1 max(y)+1])
% legend change
l.XData = []; % remove its points from the axes
l.YData = [];
l.Color = [0 0 0]; l.LineStyle = 'none'; l.Marker = 'none';
leg = legend(l,strcat(char(0x2721),' Data'),'location','northwest');
set(leg,'fontname','ZapfDingbats','fontsize',10);
% finish
set(gca,'YScale','log');
axis square; grid on; box on;
(Credits: Kannan Munusamy. My friends found this way as efficient and the credits go to him)

Sign in to comment.

Answers (1)

Image Analyst
Image Analyst on 15 Dec 2012
I can't get it working with Windows 7 and MATLAB R2012b either. For example
listfonts
uicontrol('Style','text',...
'Position',[40 45 620 120],...
'FontSize', 20,...
'FontName', 'Wingdings',...
'String','ABCDEFGHIJKLMNabcdefgijklmn')
just shows up as a bunch of empty rectangles even though it shows up with the proper symbols/pictures in Microsoft Word. It would be nice if someone knew why it's not working or knew of a workaround.
  6 Comments
Howard Park
Howard Park on 18 Feb 2019
Sorry - It doesn't work anymore even with text objects Feb., 2019. Any workaround anyone?
Walter Roberson
Walter Roberson on 18 Feb 2019
R2018b on Mac, both annotation and text() are showing wingdings font when I test.
Howard Park, perhaps you do not have the font installed ?

Sign in to comment.

Categories

Find more on Interactive Control and Callbacks in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!