h = msgbox('Hello world (20 pt font)', 'Example');
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.
Adam Danz (2020). msgboxFontSize (https://www.mathworks.com/matlabcentral/fileexchange/68460-msgboxfontsize), MATLAB Central File Exchange. Retrieved .
Thanks, Jiro. I added the conditional the suppresses the set() outputs. Applying properties to the buttons is a somewhat larger task since the button placement will have to be carefully manipulated so that larger buttons do not overlap with the main text or other buttons. That will take a bit more time than I have right now. In the meantime, I've included a 2nd output that lists handles to all buttons so the user can change the color, fontsize, fontname, etc manually. In the help section, I've also included two lines of code that shows how to get the handle to the icon and change its size.
One code suggestion and one feature request.
Around line 91, you have
I suggest you wrap that line with the following
This will prevent the set function from displaying output when there are no unmatched name-value pairs.
As for feature request, it would be great if you could also scale the font of the buttons (Okay, cancel, etc.). Also, this could be challenging, but if you could scale the icons used in errordlg, warndlg, etc.
Anyway, thanks for the tool!
Now compatible with older releases (tested in r2014a, r2016a, r2017b, r2019a).
Properties now applied to buttons though the buttons are not resized.
Just updated the description. No change to m file.
1) suppresses output from set() when inputs do not include property-value pairs.
Added the ability to specify all name-value text properties.
Simplified one line by replacing set() with dot notation.