image thumbnail

msgboxFontSize

version 2.3 (3.32 KB) by Adam Danz
Change the fontsize and other text properties in a msgbox(), errordlg(), warndlg() etc.

239 Downloads

Updated 24 Jul 2019

View License

Editor's Note: This file was selected as MATLAB Central Pick of the Week

h = msgbox('Hello world (20 pt font)', 'Example');
msgboxFontSize(h, fontsize)
msgboxFontSize(h, fontsize, 'FontName', 'Consolas', 'Color', 'b')
msgboxFontSize(h, fontsize, 'ignorebuttons', true) % does not apply change to buttons.

The text properties in Matlab's msgbox(), errordlg(), warndlg(), etc cannot be directly
edited and the default 'fontsize' is quite small. This function gets around that problem
by searching for text within the msgbox handle, changes its fontsize, and then changes
the window size to fit the new fontsize. The position of the lower, left corner of
the msgbox will not change and the resize property is turned on. Additional name-value
text properties can be set except for 'units' (see examples).

Outputs include the handle to the text object and handles to all pushbuttons. The help section
shows how to get the handle to the icon in errordlg & warndlg as well.

List of text properties: https://www.mathworks.com/help/matlab/ref/matlab.graphics.primitive.text-properties.html

** Also see supersizeme() which contains an interactive GUI with a slider that allows you to scale the font size of all text within a figure or axes.
https://www.mathworks.com/matlabcentral/fileexchange/67644-supersizeme

Cite As

Adam Danz (2021). msgboxFontSize (https://www.mathworks.com/matlabcentral/fileexchange/68460-msgboxfontsize), MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R2014a
Compatible with R2014a and later releases
Platform Compatibility
Windows macOS Linux
Acknowledgements

Inspired: Spur-Gear-Designer

Community Treasure Hunt

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

Start Hunting!