MATLAB Creating Graphical User Interfaces

(Barry) #1
Fonts and Colors for Cross-Platform Compatibility

Fonts and Colors for Cross-Platform Compatibility


In this section...
“Default System Font” on page 10- 85
“Standard Background Color” on page 10- 86

Default System Font


By default, user interface controls (uicontrols) use the default font for the platform on
which they are running. For example, when displaying your UI on PCs, user interface
controls use MS San Serif. When your UI runs on a different platform, they use that
computer's default font. This provides a consistent look with respect to your UI and other
applications on the same platform.

If you have set the FontName property to a named font and want to return to the default
value, you can set the property to the string, 'default'. This ensures that MATLAB
software uses the system default at run-time.

pbh1.FontName = 'default';

Specify a Fixed-Width Font

If you want to use a fixed-width font for a user interface control, set its FontName
property to the string, 'fixedwidth'. This special identifier ensures that your UI uses
the standard fixed-width font for the target platform.

You can find the name of the fixed-width font that is used on a given platform by
querying the root FixedWidthFontName property.

get(groot,'FixedWidthFontName')

Use a Specific Font Name

You can specify an actual font name (such as Times or Courier) for the FontName
property. However, doing so may cause your UI to appear differently than you intended
when run on a different computer. If the target computer does not have the specified
font, it substitutes another font that may not look good in your UI or may not be the
standard font used on that system. Also, different versions of the same named font may
have different size requirements for a given set of characters.
Free download pdf