require(["esri/symbols/Font"], function(Font) { /* code goes here */ });
Class: esri/symbols/Font
Inheritance: Font Accessor
Since: ArcGIS API for JavaScript 4.0

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:
Example:
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 Object
optional

See the properties for a list of all the properties that may be passed into the constructor.

Property Overview

Any properties can be set, retrieved or listened to. See the Working with Properties topic.
NameTypeSummaryClass
String

The name of the class.

more details
more detailsAccessor
String

The text decoration.

more details
more detailsFont
String

The font family of the text.

more details
more detailsFont
Number

The font size in points.

more details
more detailsFont
String

The text style.

more details
more detailsFont
String

The text weight.

more details
more detailsFont

Property Details

declaredClassStringreadonly inherited
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:
Autocasts from Number|String

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 and lighter are not supported in 2D FeatureLayer and CSVLayer labels.

Default Value:normal
See also:

Method Overview

NameReturn TypeSummaryClass
Font

Creates a deep clone of the font object.

more details
more detailsFont
*

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 detailsFont
Object

Converts an instance of this class to its ArcGIS portal JSON representation.

more details
more detailsFont

Method Details

clone(){Font}

Creates a deep clone of the font object.

Returns:
TypeDescription
FontA 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 Object

A 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:
TypeDescription
*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:
TypeDescription
ObjectThe ArcGIS portal JSON representation of an instance of this class.

API Reference search results

NameTypeModule
Loading...