require(["esri/symbols/Font"], function(Font) { /* code goes here */ });
Description
(Added at v1.0)
Font used for text symbols added to the graphics layer.
Note that variant
is deprecated, and will not available in version 4.
Samples
Search for
samples that use this class.
Constructors
Constants
STYLE_ITALIC | Text is in italics. |
STYLE_NORMAL | Text style is normal. |
STYLE_OBLIQUE | Text is slanted. |
VARIANT_NORMAL | Text variant is normal. Deprecated |
VARIANT_SMALLCAPS | Text is in all small caps. Deprecated |
WEIGHT_BOLD | Text weight is bold. |
WEIGHT_BOLDER | Text weight is extra bold. |
WEIGHT_LIGHTER | Text weight is lighter than normal. |
WEIGHT_NORMAL | Text weight is normal. |
Properties
Methods
Constructor Details
Creates a new Font object. This constructor takes no parameters.
Sample:
require([
"esri/symbols/Font", ...
], function(Font, ... ) {
var font = new Font();
...
});
Creates a new Font object.
Parameters:
<Number | String > size |
Optional |
Font size. Values can be in "pt", "px", "em", and "%". For example: "12pt", "12px", ".8em", "80%". If no unit is specified with number, defaults to "px". |
<String > style |
Optional |
Font style. See Constants table for values. |
<String > variant |
Optional |
Font variant. See Constants table for values. |
<String > weight |
Optional |
Font weight. See Constants table for values. |
<String > family |
Optional |
Font family. |
Sample:
require([
"esri/symbols/Font", ...
], function(Font, ... ) {
var font = new Font("20pt", Font.STYLE_ITALIC,
Font.VARIANT_NORMAL, Font.WEIGHT_BOLD,"Courier");
...
});
Creates a new Font object using a JSON object.
Parameters:
<Object > json |
Required |
JSON object representing the font. |
Property Details
Text decoration. (Added at v3.8)
Known values: "underline" | "line-through" | "none"
Default value: "none"
Font family.
Default value: Serif
Font size.
Default value: 10
Text style. See the Constants table for valid values.
Default value: STYLE_NORMAL
Text variant (deprecated). See the Constants table for valid values.
Default value: VARIANT_NORMAL
Text weight. See the Constants table for valid values.
Default value: WEIGHT_NORMAL
Method Details
Updates the font with the given decoration. (Added at v3.8)
Parameters:
<String > decoration |
Required |
Text decoration. See decoration property for the list of supported decorations. |
Sets the font family. The font family property does not work in Internet Explorer 7; Arial is always used.
Parameters:
<String > family |
Required |
Font family. |
Sets the font size. If no unit is specified with number, defaults to pixels, "px."
Parameters:
<Number | String > size |
Required |
Font size. Values can be in "pt", "px", "em", and "%". For example: "12pt", "12px", ".8em", "80%". If no unit is specified with number, defaults to "px". |
Sample:
font.setSize("12pt");
Sets the font style.
Parameters:
<String > style |
Required |
Font style. See Constants table for values. |
Sets the font variant (deprecated).
Parameters:
<String > variant |
Required |
Font variant. See Constants table for values. |
Sets the font weight.
Parameters:
<String > weight |
Required |
Font weight. See Constants table for values. |
Sample:
require([
"esri/symbols/Font", ...
], function(Font, ... ) {
var font = new Font( ... );
font.setWeight(Font.WEIGHT_BOLD);
...
});