Documentation

This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

uisetfont

Open font selection dialog box

Syntax

uisetfont
uisetfont(h)
uisetfont(optsin)
uisetfont(___,title)
optsout = uisetfont(___)

Description

uisetfont opens a modal Font dialog box with default font name and font style values selected. If the user clicks OK, then the selected font properties are returned to the MATLAB® Command Window. If the user clicks Cancel, or the close button (X) in the dialog box title bar, then a value of 0 is returned to the Command Window.

example

uisetfont(h) specifies the object on which the Font dialog box will operate. The values displaying in the dialog box when it opens are the current settings for that object.

The value of h can be a text, axes, or uicontrol object.

uisetfont(optsin) initializes the Font dialog box selections with the values defined for the specified optsin structure.

uisetfont(___,title) specifies a custom title for the Font dialog box. This syntax can include any of the input arguments in the previous syntaxes.

example

optsout = uisetfont(___) returns the values selected in the dialog box to the optsout structure when the user clicks OK. If the user clicks Cancel or an error occurs, then optsout is set to 0. This syntax can specify no input arguments or any of the input arguments in the previous syntaxes.

Examples

collapse all

Create a plot containing a text annotation.

f = figure('Position',[200 200 392 294]);
x = 0:pi/20:2*pi;
y = sin(x);
plot(x,y);
t = text(pi,0,'\leftarrow sin(\pi)');

Open the Font dialog box, and select the Bold Italic style. (The font names displayed in the dialog box are system-dependent.)

optsout = uisetfont(t);

Click OK. The font style changes in the plot annotation.

Input Arguments

collapse all

Target object for font changes, specified as an axes, text, or uicontrol object.

Font values, specified as a structure of font properties.

The following table lists the structure fields, the default values, and the dialog box controls with which a user can change the values.

Structure Fields

Structure FieldDefault ValueDialog Box Control
FontNamesystem-dependentFont list.
FontWeight'normal'Style list.
FontAngle'normal'Style list.
FontUnits'points' Not provided because the value of FontUnits is always 'points' for the supported objects.
FontSizesystem-dependentSize list

A structure field value of 'normal' corresponds to Plain in the dialog box Style list.

The user can select a Size value from the list or type in an unlisted value. If the user types a floating-point number, MATLAB rounds it to the closest integer value before storing it.

Example: optsin.FontWeight = 'bold';

Dialog box title, specified as a character vector or a string scalar.

Example: 'Font Selection'

Output Arguments

collapse all

Font values, returned as a structure of font property values. The structure fields are:

  • FontName

  • FontWeight

  • FontAngle

  • FontUnits

  • FontSize

If the user typed a floating-point number for the dialog box field that corresponds to the FontSize value, then MATLAB rounds it to the closest integer value before returning it.

More About

collapse all

Modal Dialog Box

A modal dialog box prevents a user from interacting with other MATLAB windows before responding to the modal dialog box.

See Also

| |

Introduced before R2006a

Was this topic helpful?