Change Constant Block Font

10 visualizaciones (últimos 30 días)
Dana Schwanke
Dana Schwanke el 19 de Ag. de 2022
Respondida: Dana Schwanke el 23 de Ag. de 2022
Is there a way to change the font of a constant block in Simulink? Changing the font using the normal methods only changes the block name's font, not the content itself. It makes my otherwise perfectly-spaced constant structure definition quite hideous. I'm trying to get an equal-spaced font left-justified like I'd have it in a basic text editor.

Respuestas (2)

Shivani Dixit
Shivani Dixit el 22 de Ag. de 2022
Hello Dana,
I understand that you want to know how to change the content of the text and not only the font in Simulink Constant block.
You can try the following steps method:
  • Given some constant block, create a mask for it (CTRL-M or right click and select Mask -> Create Mask).
  • In the "Icon & Ports" tab of the mask edit menu, enter the desired text as an input to the "disp" function into the "Icon drawing commands". For example, if you want your block to say "My block", enter "disp('My block')".
  • Now you should be able to change the block format like other blocks through the right click context menu (Format -> Font Style for Selection).
I hope the above information helps in resolving the query. If you have further queries, feel free to reply back to this answer.
  3 comentarios
Shivani Dixit
Shivani Dixit el 23 de Ag. de 2022
Hello,
Thank you for providing clarity on the issue, as per my understanding you only want to change the font of the content of constant block in Simulink and not the content itself.
It seems that in the formatting options available, there is no direct way of left-justifying the equally spaced text. Some blocks in Simulink by design have fixed formatting. You can refer the following documentation for the same:
(Some blocks have fixed fonts and styles).
You can use masking as mentioned before even for formatting using the procedure I mentioned above. Since you are using complex structure with special characters as it is visible from the image, I suggest you the following workaround:
  1. Write the structure in the text-editor where left justified formatting is available.
  2. Using snipping tool/other tool , you can snip the part of your code/structure and save it in a folder.
  3. Click on the Simulink Constant Block and go to “Add image to block” in the Format toolstrip.
  4. Click on Browse and open the snippet of your code/structure and click Ok.
This will add your structure in image format to the block. The following example justifies the above workaround :
This will be helpful for you in case you are not changing content of the block very frequently and setting it for display purpose.
Dana Schwanke
Dana Schwanke el 23 de Ag. de 2022
While I may remember to update the image when I update the constant, that would be similar to me expecting the next programmer after me to remember to update the comments after changing the function: I can't rely on that, but I can at least rely on being able to read the code itself. The image-on-a-mask approach would be an invitation to mass confusion down the line for everyone.
This seems like a very basic feature that Mathworks should look to implement in the future; I would expect that if changing the Font of most other blocks is possible, the font of the Constant blocks matching the actual selected font should be quite simple.

Iniciar sesión para comentar.


Dana Schwanke
Dana Schwanke el 23 de Ag. de 2022
Short answer from Mathworks themselves: No.
Long answer: https://www.mathworks.com/matlabcentral/answers/1782170-change-constant-block-font#comment_2328350

Categorías

Más información sobre Interactive Model Editing en Help Center y File Exchange.

Productos


Versión

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by