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

21 次查看(过去 30 天)
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 个评论
Adam Danz
Adam Danz 2018-7-31
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 2018-8-1
I thin there should be a way to normalize the FontUnits in the program just like other Units in GUIDE properties.

请先登录,再进行评论。

回答(1 个)

Adam Danz
Adam Danz 2018-8-1
编辑:Adam Danz 2020-8-5
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 个评论
CAM
CAM 2020-8-7
编辑:CAM 2020-8-7
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.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Environment and Settings 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by