How to resize the text in GUI when the app is used in different screen resolution?

37 views (last 30 days)
I have developed a GUI using GUIDE and packaged that into an app to be used by different user with different screen resolution. I found that GUI figure is being resized according to the resolution but the text is not being scaled and being cut off. How to resize the text in a GUI when the resolution changes when packaged into an app? Any answers are welcomed. Thanks in advance.
  5 Comments
Adam Danz
Adam Danz on 31 Jul 2018
As >1 person above has alluded, changing the FontUnits to normalized should fix the problem. 'FontUnits' is a text property that should be set from GUIDE or wherever you're creating the GUI.
Aravind Kota
Aravind Kota on 1 Aug 2018
I thin there should be a way to normalize the FontUnits in the program just like other Units in GUIDE properties.

Sign in to comment.

Answers (1)

Adam Danz
Adam Danz on 1 Aug 2018
Edited: Adam Danz on 5 Aug 2020
Option 1:
Open your GUI in GUIDE, right-click your edit box or text object to open the property inspector. Then change FontUnits to 'normalized'. You'll have to do this to all GUI components that have FontUnits property.
Option 2
Don't change the GUI in GUIDE. Instead, when you're opening your GUI have your code search for all objects with 'FontUnits' property and change the property to 'normalized'. To do this, open the GUI code and enter these 2 lines at the end of your "..._OpeningFcn()". If your GUI is named 'MyGUI',
function MyGUI_OpeningFcn()
...
txtHand = findall(handles.MyGUI, '-property', 'FontUnits');
set(txtHand, 'FontUnits', 'normalized')
end
The advantage of this method is that if you add more components to your GUI in the future, you won't need to remember to change their FontUnits. This is fast and changes all components automatically.
Demo
Here's option-2 applied to a fake demo-GUI in GUIDE.
  10 Comments
CAM
CAM on 7 Aug 2020
Edited: CAM on 7 Aug 2020
My colleagues have different monitor resolutions (ex: 1920x1080) than me (2560x1440), hence the font size issues. I agree with you that there appears to be no simple way around it, other than using smaller fonts overall in the design (as I describe in my comments of July 22). I agree this is a minor issue, and we will just have to account for it in future apps.
Thank you so much for all of your help and the follow up discussions.

Sign in to comment.

Categories

Find more on Migrate GUIDE Apps in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!