I would like to use a new, custom font within an app designed using app designer
16 views (last 30 days)
Show older comments
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
- 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.
- I pasted the .ttf file into the E:\Program Files\Matlab2023a\sys\java\jre\win64\jre\lib\fonts folder
- 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
Answers (0)
See Also
Categories
Find more on Introduction to Installation and Licensing 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!