I would like to use a new, custom font within an app designed using app designer

16 views (last 30 days)
My question was asked at the end of this previous question:
I want to display text in app designer components using a custom font. For now I want to display using an LCD font to appear like a digital readout on a clock or digital meter. I downloaded a font in a file called LCD Normal.ttf and did 3 things based on question/answers I saw
  1. I installed the font in my Windows 10 system via the control settings font installation window, by dragging the .ttf file into the drag/drop area and the font now appears when I search in that same settings window for available fonts.
  2. I pasted the .ttf file into the E:\Program Files\Matlab2023a\sys\java\jre\win64\jre\lib\fonts folder
  3. I restarted my computer.
Now, when MATLAB is running and I paste into the command window the following commands:
figure
axes
t1 = text(.5,.5,'Example 123','FontName','LCD');
I get this:
Now I have opened a test app to see if the font is available in the app. In the design view I dragged an axes component into the app window with the title "Title" and used the font dropdown to change the font to "LCD" but the title display font did not change, appearing like this
When I changed the font using the dropdown to another distinctly different font, Courier, the displayed text "Title" did indeed change display font. When I used the dropdown to go back to "LCD" font, the "Title" changed back to the way it appears in the screenshot, which looks like Times New Roman.
I created a startup function for the test app as follows:
function StartUp(app)
app.UIAxes.Color = [.3333 .3333 .3333];
set(app.UIAxes,'XColor', 'none','YColor','none');
text(app.UIAxes,.1,.8,'Heart Rate:','FontName','LCD','FontSize',...
24,'Color',[0.5556 0.4444 0]);
end
and ran the app, producing the following screenshot
which does not display the text in the LCD font as the command line commands did.
So the bottom line is that I have been able to install and use a new font in the matlab command line environment, but not in the app designer. Although the font name appears in the output of "listfonts" entered in the command line as well as entered within the debugger using the app, having placed a breakpoint at the text call in the startup function, the new font is only applied in the command line environment, not the app designer.
I have a crude workaround I prefer not to use. I plan to display in the app some vital signs data as a function of time at intervals of one minute, for individuals performing activities. I want the display to look like the standard hospital vitals display, hence the LCD font. I can generate the needed displays in figures for each minute using the command line, then save each of those figures as images and display those image sequentially in the app axes. That is tedious but it will work for now, but in the longer term I want to display the vitals in real time, not pre-processed.
How do I install a new font so that an app created via the app designer can access the new font?
MATLAB Version: 9.14.0.2206163 (R2023a)
Operating System: Microsoft Windows 10 Pro Version 10.0 (Build 19044)
Java Version: Java 1.8.0_202-b08 with Oracle Corporation Java HotSpot(TM) 64-Bit Server VM mixed mode
  3 Comments
Frank
Frank on 26 Jun 2023
Thanks. Must be something I am doing or peculiar to my OS. It is good to know that it should work.
Frank
Frank on 27 Jun 2023
Kevin, thanks so much really. I worked through it on another computer I use for MATLAB, a laptop, and the problem did not occur. Then I went back and re-did the font installation on my main computer and it worked fine. I still have no idea why previously the font name appeared in the drop down but did not show up on the text in the plot. It seems to work fine now.
But thanks very much for confirming for me that it should work. This illustrates why I am such a strong supporter of MATLAB. I have incorporated it into the classes I teach and push its use among my collaborators. Many folks will tell me that "you can do anything MATLAB does with python, C++ and javascript for free" or some such, which for some problems might be plausible. But what MATLAB has that no other product in its class has is the support of people like you. I have had a fair number of problems developing apps for my students and classes, many involving multiple computers or web based applications, and in every case, MATLAB support folks have been superlative in their help. Add to that the onramps and other training and there is just no match for MATLAB. Sure one can struggle with python and other ways of doing things, but if you want to get the work done, MATLAB is the best. You get what you pay for.

Sign in to comment.

Answers (0)

Categories

Find more on Introduction to Installation and Licensing in Help Center and File Exchange

Products


Release

R2023a

Community Treasure Hunt

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

Start Hunting!