Font
require(["esri/symbols/Font"], function(Font) { /* code goes here */ });
esri/symbols/Font
The font used to display 2D text symbols and 3D text symbols. This class allows the developer to set the font's family, decoration, size, style, and weight properties. Take note of the Known Limits for each property to understand how they differ depending on the: layer type, rendering mechanism, and if you working with a MapView or SceneView.
- See also:
var textSymbol = {
type: "text", // autocasts as new TextSymbol()
color: "white",
haloColor: "black",
haloSize: "1px",
text: "You are here",
xoffset: 3,
yoffset: 3,
font: { // autocasts as new Font()
size: 12,
family: "sans-serif",
weight: "bold"
}
};
Constructors
- new Font(properties)
- Parameter:properties Objectoptional
See the properties for a list of all the properties that may be passed into the constructor.
Property Overview
Name | Type | Summary | Class | |
---|---|---|---|---|
String | The name of the class. more details | more details | Accessor | |
String | The text decoration. more details | more details | Font | |
String | The font family of the text. more details | more details | Font | |
Number | The font size in points. more details | more details | Font | |
String | The text style. more details | more details | Font | |
String | The text weight. more details | more details | Font |
Property Details
- Since: ArcGIS API for JavaScript 4.7
The name of the class. The declared class name is formatted as
esri.folder.className
.
- decorationString
The text decoration.
Possible Values: underline | line-through | none
Known Limitations
This property is currently not supported in 3D SceneViews.
- Default Value:none
- familyString
The font family of the text. The possible values are dependent upon the: layer type, rendering mechanism, and if you working with a MapView or SceneView. See the Labeling guide page for detailed explanation.
- Default Value:sans-serif
- See also:
The font size in points. This value may be autocast with a string expressing size in points or pixels (e.g.
12px
).- Default Value:9
- See also:
Examples:// size in points symbol.size = 14;
// size in pixels symbol.size = "20px";
// size in points symbol.size = "14pt";
- styleString
The text style. Specifies whether a font should be styled: normal, italic, or oblique.
Possible Values: normal | italic | oblique
Known Limitations
oblique
is not supported in 2D FeatureLayer and CSVLayer labels.- Default Value:normal
- See also:
- weightString
The text weight. Specifies the level of boldness.
Possible Values: normal | bold | bolder | lighter
Known Limitations
bolder
andlighter
are not supported in 2D FeatureLayer and CSVLayer labels.- Default Value:normal
- See also:
Method Overview
Name | Return Type | Summary | Class | |
---|---|---|---|---|
Font | Creates a deep clone of the font object. more details | more details | Font | |
* | Creates a new instance of this class and initializes it with values from a JSON object generated from a product in the ArcGIS platform. more details | more details | Font | |
Object | Converts an instance of this class to its ArcGIS portal JSON representation. more details | more details | Font |
Method Details
- clone(){Font}
Creates a deep clone of the font object.
Returns:Type Description Font A deep clone of the object that invoked this method.
- fromJSON(json){*}static
Creates a new instance of this class and initializes it with values from a JSON object generated from a product in the ArcGIS platform. The object passed into the input
json
parameter often comes from a response to a query operation in the REST API or a toJSON() method from another ArcGIS product. See the Using fromJSON() topic in the Guide for details and examples of when and how to use this function.Parameter:json ObjectA JSON representation of the instance in the ArcGIS format. See the ArcGIS REST API documentation for examples of the structure of various input JSON objects.
Returns:Type Description * Returns a new instance of this class.
- toJSON(){Object}
Converts an instance of this class to its ArcGIS portal JSON representation. See the Using fromJSON() topic in the Guide for more information.
Returns:Type Description Object The ArcGIS portal JSON representation of an instance of this class.