How do I change the font of a block name and/or signal line name in Simulink?

14 views (last 30 days)
I would like to change the font of all my blocks and all my signal line names in my Simulink model. Is this possible and if so how can I do this programatically (i.e. from the command line)? Furthermore, is there a way to change the default font for blocks, signal lines and/or annotations when creating a new model?

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 28 Nov 2012
There are several ways to change the font of a block name and signal line name. Please go over the following methods and choose the one that best fits your needs while using 'tsModel.mdl' as an example model:
BLOCK NAME
Block-by-block:
Right-click on the desired blocks and navigate to 'Format' -> 'Font...' to change the font.
Command Line:
myModel = 'tsModel';
open_system(myModel)
sl_handle = get_param(myModel,'handle');
blocks = [find_system(sl_handle, 'LookUnderMasks', 'on'); ...
find_system(sl_handle, 'FindAll', 'on', 'Type', 'annotation')];
for i = 2:length(blocks)
set_param(blocks(i),'FontSize','14')
end
% For a full list of what block parameters can be changed
get_param(blocks(2),'ObjectParameters')
SIGNAL LINE NAME
Line-by-line:
Starting in Simulink 8.0 (R2012b) one can right-click on the desired signal line and navigate to 'Format' -> 'Font Style...' to change the font.
Command Line:
myModel = 'tsModel';
open_system(myModel);
lines = get_param(myModel,'Lines');
for i = 1:length(lines)
set_param(lines(i).Handle,'FontSize','14')
end
% For a full list of what line parameters can be changed
get_param(lines(1).Handle,'ObjectParameters')
FONT DEFAULT FOR NEW MODELS
In a model, please navigate to 'File' -> 'Preferences...' -> 'Simulink Preferences' -> 'Font Defaults for New Models.' Here one can set the default font that new models will inherit.

More Answers (0)

Categories

Find more on Programmatic Model Editing in Help Center and File Exchange

Products

Community Treasure Hunt

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

Start Hunting!