{"id":10836,"date":"2019-07-08T01:00:29","date_gmt":"2019-07-08T05:00:29","guid":{"rendered":"https:\/\/blogs.mathworks.com\/pick\/?p=10836"},"modified":"2019-07-07T22:42:04","modified_gmt":"2019-07-08T02:42:04","slug":"changing-font-size-of-built-in-dialog-boxes","status":"publish","type":"post","link":"https:\/\/blogs.mathworks.com\/pick\/2019\/07\/08\/changing-font-size-of-built-in-dialog-boxes\/","title":{"rendered":"Changing font size of built-in dialog boxes"},"content":{"rendered":"\r\n<div class=\"content\"><p><a href=\"http:\/\/www.mathworks.com\/matlabcentral\/profile\/authors\/869871\">Jiro<\/a>&#8216;s Pick this week is <a href=\"https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/68460\"><tt>msgboxFontSize<\/tt><\/a> by <a href=\"https:\/\/www.mathworks.com\/matlabcentral\/profile\/authors\/3753776\">Adam Danz<\/a>.<\/p><p>This utility reminded me of a very recent project, which would have benefited greatly. I was building an app that made use of <a href=\"https:\/\/www.mathworks.com\/help\/matlab\/ref\/warndlg.html\"><tt>warndlg<\/tt><\/a> and <a href=\"https:\/\/www.mathworks.com\/help\/matlab\/ref\/errordlg.html\"><tt>errordlg<\/tt><\/a>. I needed to show the app as part of a presentation, and that required me to make the fonts bigger. The app itself, I had control over. But there were no parameters I could tweak in <tt>warndlg<\/tt> and <tt>errordlg<\/tt> to make their fonts bigger. I ended up modifying the built-in functions themselves to allow me to specify the font size.<\/p><p>Adam&#8217;s utility would have saved me a lot of trouble. His function takes an existing dialog box created by <tt>msgbox<\/tt>, <tt>warndlg<\/tt>, <tt>errordlg<\/tt> and changes the font size and other properties by searching for the text objects.<\/p><p>For example, take this standard warning dialog.<\/p><pre class=\"codeinput\">h = warndlg(<span class=\"string\">'This is the normal error dialog'<\/span>,<span class=\"string\">'Error'<\/span>);\r\n<\/pre><img decoding=\"async\" vspace=\"5\" hspace=\"5\" src=\"https:\/\/blogs.mathworks.com\/images\/pick\/jiro\/potw_msgboxFontSize\/potw_msgboxFontSize_01.png\" alt=\"\"> <p>Let&#8217;s change the font size to 30, and while we&#8217;re at it, we&#8217;ll also change the text.<\/p><pre class=\"codeinput\">msgboxFontSize(h,30,<span class=\"string\">'String'<\/span>,<span class=\"string\">'Notice how the font is bigger now!'<\/span>);\r\n<\/pre><img decoding=\"async\" vspace=\"5\" hspace=\"5\" src=\"https:\/\/blogs.mathworks.com\/images\/pick\/jiro\/potw_msgboxFontSize\/potw_msgboxFontSize_02.png\" alt=\"\"> <p>Notice that the dialog width is adjusted based on the font size.<\/p><p>I have a couple of enhancement requests for Adam.<\/p><div><ul><li>It would be great if we could also change the font size of the buttons (&#8220;OK&#8221; button in the above example).<\/li><li>It would be even greater if the icon size (the exclamation mark icon in the above example) increased proportionally as well.<\/li><\/ul><\/div><p><b>Comments<\/b><\/p><p>Give it a try and let us know what you think <a href=\"http:\/\/blogs.mathworks.com\/pick\/?p=10836#respond\">here<\/a> or leave a <a href=\"https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/68460#comment\">comment<\/a> for Adam.<\/p><script language=\"JavaScript\"> <!-- \r\n    function grabCode_9813b18667ad449cbea73d25e2d0f2e8() {\r\n        \/\/ Remember the title so we can use it in the new page\r\n        title = document.title;\r\n\r\n        \/\/ Break up these strings so that their presence\r\n        \/\/ in the Javascript doesn't mess up the search for\r\n        \/\/ the MATLAB code.\r\n        t1='9813b18667ad449cbea73d25e2d0f2e8 ' + '##### ' + 'SOURCE BEGIN' + ' #####';\r\n        t2='##### ' + 'SOURCE END' + ' #####' + ' 9813b18667ad449cbea73d25e2d0f2e8';\r\n    \r\n        b=document.getElementsByTagName('body')[0];\r\n        i1=b.innerHTML.indexOf(t1)+t1.length;\r\n        i2=b.innerHTML.indexOf(t2);\r\n \r\n        code_string = b.innerHTML.substring(i1, i2);\r\n        code_string = code_string.replace(\/REPLACE_WITH_DASH_DASH\/g,'--');\r\n\r\n        \/\/ Use \/x3C\/g instead of the less-than character to avoid errors \r\n        \/\/ in the XML parser.\r\n        \/\/ Use '\\x26#60;' instead of '<' so that the XML parser\r\n        \/\/ doesn't go ahead and substitute the less-than character. \r\n        code_string = code_string.replace(\/\\x3C\/g, '\\x26#60;');\r\n\r\n        copyright = 'Copyright 2019 The MathWorks, Inc.';\r\n\r\n        w = window.open();\r\n        d = w.document;\r\n        d.write('<pre>\\n');\r\n        d.write(code_string);\r\n\r\n        \/\/ Add copyright line at the bottom if specified.\r\n        if (copyright.length > 0) {\r\n            d.writeln('');\r\n            d.writeln('%%');\r\n            if (copyright.length > 0) {\r\n                d.writeln('% _' + copyright + '_');\r\n            }\r\n        }\r\n\r\n        d.write('<\/pre>\\n');\r\n\r\n        d.title = title + ' (MATLAB code)';\r\n        d.close();\r\n    }   \r\n     --> <\/script><p style=\"text-align: right; font-size: xx-small; font-weight:lighter;   font-style: italic; color: gray\"><br><a href=\"javascript:grabCode_9813b18667ad449cbea73d25e2d0f2e8()\"><span style=\"font-size: x-small;        font-style: italic;\">Get \r\n      the MATLAB code <noscript>(requires JavaScript)<\/noscript><\/span><\/a><br><br>\r\n      Published with MATLAB&reg; R2019a<br><\/p><p class=\"footer\"><br>\r\n      Published with MATLAB&reg; R2019a<br><\/p><\/div><!--\r\n9813b18667ad449cbea73d25e2d0f2e8 ##### SOURCE BEGIN #####\r\n%%\r\n% <http:\/\/www.mathworks.com\/matlabcentral\/profile\/authors\/869871 Jiro>'s\r\n% Pick this week is\r\n% <https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/68460\r\n% |msgboxFontSize|> by\r\n% <https:\/\/www.mathworks.com\/matlabcentral\/profile\/authors\/3753776 Adam\r\n% Danz>.\r\n%\r\n% This utility reminded me of a very recent project, which would have\r\n% benefited greatly. I was building an app that made use of\r\n% <https:\/\/www.mathworks.com\/help\/matlab\/ref\/warndlg.html |warndlg|> and\r\n% <https:\/\/www.mathworks.com\/help\/matlab\/ref\/errordlg.html |errordlg|>. I\r\n% needed to show the app as part of a presentation, and that required me to\r\n% make the fonts bigger. The app itself, I had control over. But there were\r\n% no parameters I could tweak in |warndlg| and |errordlg| to make their\r\n% fonts bigger. I ended up modifying the built-in functions themselves to\r\n% allow me to specify the font size.\r\n%\r\n% Adam's utility would have saved me a lot of trouble. His function takes\r\n% an existing dialog box created by |msgbox|, |warndlg|, |errordlg| and\r\n% changes the font size and other properties by searching for the text\r\n% objects.\r\n%\r\n% For example, take this standard warning dialog.\r\n\r\nh = warndlg('This is the normal error dialog','Error');\r\n\r\n%%\r\n% Let's change the font size to 30, and while we're at it, we'll also\r\n% change the text.\r\n\r\nmsgboxFontSize(h,30,'String','Notice how the font is bigger now!');\r\n\r\n%%\r\n% Notice that the dialog width is adjusted based on the font size. \r\n%\r\n% I have a couple of enhancement requests for Adam.\r\n%\r\n% * It would be great if we could also change the font size of the buttons\r\n% (\"OK\" button in the above example).\r\n% * It would be even greater if the icon size (the exclamation mark icon in\r\n% the above example) increased proportionally as well.\r\n%\r\n% *Comments*\r\n%\r\n% Give it a try and let us know what you think\r\n% <http:\/\/blogs.mathworks.com\/pick\/?p=10836#respond here> or leave a\r\n% <https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/68460#comment\r\n% comment> for Adam.\r\n\r\n##### SOURCE END ##### 9813b18667ad449cbea73d25e2d0f2e8\r\n-->","protected":false},"excerpt":{"rendered":"<div class=\"overview-image\"><img decoding=\"async\"  class=\"img-responsive\" src=\"https:\/\/blogs.mathworks.com\/images\/pick\/jiro\/potw_msgboxFontSize\/potw_msgboxFontSize_01.png\" onError=\"this.style.display ='none';\" \/><\/div><p>\r\nJiro&#8216;s Pick this week is msgboxFontSize by Adam Danz.This utility reminded me of a very recent project, which would have benefited greatly. I was building an app that made use of warndlg and&#8230; <a class=\"read-more\" href=\"https:\/\/blogs.mathworks.com\/pick\/2019\/07\/08\/changing-font-size-of-built-in-dialog-boxes\/\">read more >><\/a><\/p>","protected":false},"author":35,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[16],"tags":[],"_links":{"self":[{"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/posts\/10836"}],"collection":[{"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/users\/35"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/comments?post=10836"}],"version-history":[{"count":2,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/posts\/10836\/revisions"}],"predecessor-version":[{"id":10840,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/posts\/10836\/revisions\/10840"}],"wp:attachment":[{"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/media?parent=10836"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/categories?post=10836"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/tags?post=10836"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}