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

21 ビュー (過去 30 日間)
Aravind Kota
Aravind Kota 2018 年 7 月 30 日
コメント済み: Adam Danz 2020 年 8 月 8 日
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.
Adam Danz
Adam Danz 2020 年 8 月 8 日
This thread from the MathWorks Support Team may be helpful, especially workaround #2.
Also see Matlab's documentation on Auto Reflow.
Glad I could help (a little).

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeEnvironment and Settings についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by