Font

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 Limitations" for each property to understand how they differ depending on the layer type, and if you working with a MapView or SceneView.

See also:
Example:
let 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: "Josefin Slab",
    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.
Show inherited properties Hide inherited properties
Name Type Summary Class
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

declaredClass Stringreadonly inherited
Since: ArcGIS API for JavaScript 4.7

The name of the class. The declared class name is formatted as esri.folder.className.

decoration String

The text decoration.

Known Limitations

This property is currently not supported in 3D SceneViews.

Possible Values:"underline"|"line-through"|"none"

Default Value:none
family String

The font family of the text. The possible values are dependent upon the layer type, and if you working with a MapView or a SceneView. See the Labeling guide page for detailed explanation, or click the Read more below.

Font families for 3D SceneViews

The supported font families for 3D SceneViews are dependent upon the fonts installed on the user's computer and web browser. If an app uses a font that is not installed, the Font class implements a fallback mechanism that will use the default font family value, which is sans-serif.

Font families for 2D MapImageLayer

The supported font families for MapImageLayers in a MapView are dependent upon the fonts installed on the ArcGIS Server that published the layer. If an app uses a font that is not installed, the Font class implements a fallback mechanism that will use the default font family value, which is sans-serif.

Font families for 2D FeatureLayer, CSVLayer, StreamLayer, and TextSymbol

The supported font families are based on hosted fonts files in .pbf format. By default, the fonts available are mostly the same ones used by the Esri Vector Basemaps. These fonts are available via https://static.arcgis.com/fonts. The URL can be configured to point to your own font resources by setting the esriConfig.fontsUrl property. If an app uses a font that is not installed, the Font class implements a fallback mechanism that will use the default font family value, which is sans-serif. This uses the Arial Unicode MS font file.

A preview of the fonts listed in the following table are available in the Labeling overview page.

List of currently supported fonts:

Font Style Weight Code Snippet
Abril Fatface Regular normal normal font: { family: 'Abril Fatface Regular', style: 'normal', weight: 'normal' }
Alegreya Bold normal bold font: { family: 'Alegreya Bold', style: 'normal', weight: 'bold' }
Alegreya Bold Italic italic bold font: { family: 'Alegreya Bold Italic', style: 'italic', weight: 'bold' }
Alegreya Italic italic normal font: { family: 'Alegreya Italic', style: 'italic', weight: 'normal' }
Alegreya Regular normal normal font: { family: 'Alegreya Regular', style: 'normal', weight: 'normal' }
Alegreya SC Bold normal bold font: { family: 'Alegreya SC Bold', style: 'normal', weight: 'bold' }
Alegreya SC Italic italic normal font: { family: 'Alegreya SC Italic', style: 'italic', weight: 'normal' }
Alegreya SC Regular normal normal font: { family: 'Alegreya SC Regular', style: 'normal', weight: 'normal' }
Alegreya Sans Italic italic normal font: { family: 'Alegreya Sans Italic', style: 'italic', weight: 'normal' }
Amarante Regular normal normal font: { family: 'Amarante Regular', style: 'normal', weight: 'normal' }
Amatic SC Bold normal bold font: { family: 'Amatic SC Bold', style: 'normal', weight: 'bold' }
Arial Bold normal bold font: { family: 'Arial Bold', style: 'normal', weight: 'bold' }
Arial Bold Italic italic bold font: { family: 'Arial Bold Italic', style: 'italic', weight: 'bold' }
Arial Italic italic normal font: { family: 'Arial Italic', style: 'italic', weight: 'normal' }
Arial Regular normal normal font: { family: 'Arial Regular', style: 'normal', weight: 'normal' }
Arial Unicode MS Bold normal bold font: { family: 'Arial Unicode MS Bold', style: 'normal', weight: 'bold' }
Arial Unicode MS Regular normal normal font: { family: 'Arial Unicode MS Regular', style: 'normal', weight: 'normal' }
Atomic Age Regular normal normal font: { family: 'Atomic Age Regular', style: 'normal', weight: 'normal' }
Audiowide Regular normal normal font: { family: 'Audiowide Regular', style: 'normal', weight: 'normal' }
Avenir Next LT Pro Bold normal bold font: { family: 'Avenir Next LT Pro Bold', style: 'normal', weight: 'bold' }
Avenir Next LT Pro Bold Italic italic bold font: { family: 'Avenir Next LT Pro Bold Italic', style: 'italic', weight: 'bold' }
Avenir Next LT Pro Demi Italic italic normal font: { family: 'Avenir Next LT Pro Demi Italic', style: 'italic', weight: 'normal' }
Avenir Next LT Pro Italic italic normal font: { family: 'Avenir Next LT Pro Italic', style: 'italic', weight: 'normal' }
Avenir Next LT Pro Light normal normal font: { family: 'Avenir Next LT Pro Light', style: 'normal', weight: 'normal' }
Avenir Next LT Pro Light Italic italic normal font: { family: 'Avenir Next LT Pro Light Italic', style: 'italic', weight: 'normal' }
Avenir Next LT Pro Regular normal normal font: { family: 'Avenir Next LT Pro Regular', style: 'normal', weight: 'normal' }
AvenirNext LT Pro Light Italic italic normal font: { family: 'AvenirNext LT Pro Light Italic', style: 'italic', weight: 'normal' }
AvenirNext LT Pro Light Regular normal normal font: { family: 'AvenirNext LT Pro Light Regular', style: 'normal', weight: 'normal' }
AvenirNext LT Pro Medium Bold normal bold font: { family: 'AvenirNext LT Pro Medium Bold', style: 'normal', weight: 'bold' }
AvenirNext LT Pro Medium Bold Italic italic bold font: { family: 'AvenirNext LT Pro Medium Bold Italic', style: 'italic', weight: 'bold' }
AvenirNext LT Pro Regular Bold normal bold font: { family: 'AvenirNext LT Pro Regular Bold', style: 'normal', weight: 'bold' }
AvenirNext LT Pro Regular Bold Italic italic bold font: { family: 'AvenirNext LT Pro Regular Bold Italic', style: 'italic', weight: 'bold' }
AvenirNext LT Pro Regular Italic italic normal font: { family: 'AvenirNext LT Pro Regular Italic', style: 'italic', weight: 'normal' }
AvenirNext LT Pro Regular Regular normal normal font: { family: 'AvenirNext LT Pro Regular Regular', style: 'normal', weight: 'normal' }
Belleza Regular normal normal font: { family: 'Belleza Regular', style: 'normal', weight: 'normal' }
Black Ops One Regular normal normal font: { family: 'Black Ops One Regular', style: 'normal', weight: 'normal' }
Cabin Sketch Bold normal bold font: { family: 'Cabin Sketch Bold', style: 'normal', weight: 'bold' }
Cabin Sketch Regular normal normal font: { family: 'Cabin Sketch Regular', style: 'normal', weight: 'normal' }
Coming Soon Regular normal normal font: { family: 'Coming Soon Regular', style: 'normal', weight: 'normal' }
Homemade Apple Regular normal normal font: { family: 'Homemade Apple Regular', style: 'normal', weight: 'normal' }
IM FELL DW Pica PRO Italic italic normal font: { family: 'IM FELL DW Pica PRO Italic', style: 'italic', weight: 'normal' }
IM FELL DW Pica PRO Regular normal normal font: { family: 'IM FELL DW Pica PRO Regular', style: 'normal', weight: 'normal' }
Josefin Sans Regular normal normal font: { family: 'Josefin Sans Regular', style: 'normal', weight: 'normal' }
Josefin Slab Bold normal bold font: { family: 'Josefin Slab Bold', style: 'normal', weight: 'bold' }
Josefin Slab Bold Italic italic bold font: { family: 'Josefin Slab Bold Italic', style: 'italic', weight: 'bold' }
Josefin Slab Italic italic normal font: { family: 'Josefin Slab Italic', style: 'italic', weight: 'normal' }
Josefin Slab Light Italic italic normal font: { family: 'Josefin Slab Light Italic', style: 'italic', weight: 'normal' }
Josefin Slab Regular normal normal font: { family: 'Josefin Slab Regular', style: 'normal', weight: 'normal' }
Josefin Slab Thin Italic italic normal font: { family: 'Josefin Slab Thin Italic', style: 'italic', weight: 'normal' }
Just Another Hand Regular normal normal font: { family: 'Just Another Hand Regular', style: 'normal', weight: 'normal' }
Kranky Regular normal normal font: { family: 'Kranky Regular', style: 'normal', weight: 'normal' }
Life Savers Bold normal bold font: { family: 'Life Savers Bold', style: 'normal', weight: 'bold' }
Loved by the King Regular normal normal font: { family: 'Loved by the King Regular', style: 'normal', weight: 'normal' }
Merriweather Bold normal bold font: { family: 'Merriweather Bold', style: 'normal', weight: 'bold' }
Merriweather Bold Italic italic bold font: { family: 'Merriweather Bold Italic', style: 'italic', weight: 'bold' }
Merriweather Italic italic normal font: { family: 'Merriweather Italic', style: 'italic', weight: 'normal' }
Merriweather Regular normal normal font: { family: 'Merriweather Regular', style: 'normal', weight: 'normal' }
Montserrat Bold normal bold font: { family: 'Montserrat Bold', style: 'normal', weight: 'bold' }
Montserrat Italic italic normal font: { family: 'Montserrat Italic', style: 'italic', weight: 'normal' }
Montserrat Medium Italic italic normal font: { family: 'Montserrat Medium Italic', style: 'italic', weight: 'normal' }
Montserrat Regular normal normal font: { family: 'Montserrat Regular', style: 'normal', weight: 'normal' }
Noto Sans Bold normal bold font: { family: 'Noto Sans Bold', style: 'normal', weight: 'bold' }
Noto Sans Bold Italic italic bold font: { family: 'Noto Sans Bold Italic', style: 'italic', weight: 'bold' }
Noto Sans Italic italic normal font: { family: 'Noto Sans Italic', style: 'italic', weight: 'normal' }
Noto Sans Regular normal normal font: { family: 'Noto Sans Regular', style: 'normal', weight: 'normal' }
Noto Serif Bold normal bold font: { family: 'Noto Serif Bold', style: 'normal', weight: 'bold' }
Noto Serif Bold Italic italic bold font: { family: 'Noto Serif Bold Italic', style: 'italic', weight: 'bold' }
Noto Serif Italic italic normal font: { family: 'Noto Serif Italic', style: 'italic', weight: 'normal' }
Noto Serif Regular normal normal font: { family: 'Noto Serif Regular', style: 'normal', weight: 'normal' }
Old Standard TT Bold normal bold font: { family: 'Old Standard TT Bold', style: 'normal', weight: 'bold' }
Old Standard TT Italic italic normal font: { family: 'Old Standard TT Italic', style: 'italic', weight: 'normal' }
Old Standard TT Regular normal normal font: { family: 'Old Standard TT Regular', style: 'normal', weight: 'normal' }
Orbitron Bold normal bold font: { family: 'Orbitron Bold', style: 'normal', weight: 'bold' }
Orbitron Regular normal normal font: { family: 'Orbitron Regular', style: 'normal', weight: 'normal' }
Oregano Italic italic normal font: { family: 'Oregano Italic', style: 'italic', weight: 'normal' }
Oregano Regular normal normal font: { family: 'Oregano Regular', style: 'normal', weight: 'normal' }
Oswald Bold normal bold font: { family: 'Oswald Bold', style: 'normal', weight: 'bold' }
Oswald Regular normal normal font: { family: 'Oswald Regular', style: 'normal', weight: 'normal' }
Pacifico Regular normal normal font: { family: 'Pacifico Regular', style: 'normal', weight: 'normal' }
Palatino Linotype Regular normal normal font: { family: 'Palatino Linotype Regular', style: 'normal', weight: 'normal' }
Playfair Display Black normal normal font: { family: 'Playfair Display Black', style: 'normal', weight: 'normal' }
Playfair Display Black Regular normal normal font: { family: 'Playfair Display Black Regular', style: 'normal', weight: 'normal' }
Playfair Display Bold normal bold font: { family: 'Playfair Display Bold', style: 'normal', weight: 'bold' }
Playfair Display Bold Italic italic bold font: { family: 'Playfair Display Bold Italic', style: 'italic', weight: 'bold' }
Playfair Display Italic italic normal font: { family: 'Playfair Display Italic', style: 'italic', weight: 'normal' }
Playfair Display Regular normal normal font: { family: 'Playfair Display Regular', style: 'normal', weight: 'normal' }
Playfair Display SC Bold normal bold font: { family: 'Playfair Display SC Bold', style: 'normal', weight: 'bold' }
Playfair Display SC Regular normal normal font: { family: 'Playfair Display SC Regular', style: 'normal', weight: 'normal' }
Redressed Regular normal normal font: { family: 'Redressed Regular', style: 'normal', weight: 'normal' }
Risque Regular normal normal font: { family: 'Risque Regular', style: 'normal', weight: 'normal' }
Roboto Condensed Italic italic normal font: { family: 'Roboto Condensed Italic', style: 'italic', weight: 'normal' }
Roboto Condensed Light Italic italic normal font: { family: 'Roboto Condensed Light Italic', style: 'italic', weight: 'normal' }
Rye Regular normal normal font: { family: 'Rye Regular', style: 'normal', weight: 'normal' }
Special Elite Regular normal normal font: { family: 'Special Elite Regular', style: 'normal', weight: 'normal' }
Syncopate Bold normal bold font: { family: 'Syncopate Bold', style: 'normal', weight: 'bold' }
Syncopate Regular normal normal font: { family: 'Syncopate Regular', style: 'normal', weight: 'normal' }
Tangerine Regular normal normal font: { family: 'Tangerine Regular', style: 'normal', weight: 'normal' }
Ubuntu Bold normal bold font: { family: 'Ubuntu Bold', style: 'normal', weight: 'bold' }
Ubuntu Bold Italic italic bold font: { family: 'Ubuntu Bold Italic', style: 'italic', weight: 'bold' }
Ubuntu Condensed Regular normal normal font: { family: 'Ubuntu Condensed Regular', style: 'normal', weight: 'normal' }
Ubuntu Italic italic normal font: { family: 'Ubuntu Italic', style: 'italic', weight: 'normal' }
Ubuntu Light normal normal font: { family: 'Ubuntu Light', style: 'normal', weight: 'normal' }
Ubuntu Light Bold normal bold font: { family: 'Ubuntu Light Bold', style: 'normal', weight: 'bold' }
Ubuntu Light Bold Italic italic bold font: { family: 'Ubuntu Light Bold Italic', style: 'italic', weight: 'bold' }
Ubuntu Light Italic italic normal font: { family: 'Ubuntu Light Italic', style: 'italic', weight: 'normal' }
Ubuntu Light Regular normal normal font: { family: 'Ubuntu Light Regular', style: 'normal', weight: 'normal' }
Ubuntu Medium Italic italic normal font: { family: 'Ubuntu Medium Italic', style: 'italic', weight: 'normal' }
Ubuntu Mono Bold normal bold font: { family: 'Ubuntu Mono Bold', style: 'normal', weight: 'bold' }
Ubuntu Mono Bold Italic italic bold font: { family: 'Ubuntu Mono Bold Italic', style: 'italic', weight: 'bold' }
Ubuntu Mono Italic italic normal font: { family: 'Ubuntu Mono Italic', style: 'italic', weight: 'normal' }
Ubuntu Mono Regular normal normal font: { family: 'Ubuntu Mono Regular', style: 'normal', weight: 'normal' }
Ubuntu Regular normal normal font: { family: 'Ubuntu Regular', style: 'normal', weight: 'normal' }
UnifrakturCook Bold normal bold font: { family: 'UnifrakturCook Bold', style: 'normal', weight: 'bold' }
Vast Shadow Regular normal normal font: { family: 'Vast Shadow Regular', style: 'normal', weight: 'normal' }
Walter Turncoat Regular normal normal font: { family: 'Walter Turncoat Regular', style: 'normal', weight: 'normal' }
Default Value:sans-serif
See also:
Example:
let textSymbol = {
  type: "text",  // autocasts as new TextSymbol()
  text: "Science of Where",
  font: {  // autocasts as new Font()
    family: "Merriweather",
    size: 12,
    style: "italic",
    weight: "bold"
  }
};
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).

Known Limitations

In 3D SceneViews, if the TextSymbol3DLayer.size property is set, it will override this size property.

Default Value:9
See also:
Examples:
// size in points
symbol.size = 14;
// size in pixels
symbol.size = "20px";
// size in points
symbol.size = "14pt";
style String

The text style. Specifies whether a font should be styled: normal, italic, or oblique.

Known Limitations

oblique is not supported in 2D FeatureLayer, CSVLayer, and StreamLayer labels.

Possible Values:"normal"|"italic"|"oblique"

Default Value:normal
See also:
weight String

The text weight. Specifies the level of boldness.

Known Limitations

bolder and lighter are not supported in 2D FeatureLayer, CSVLayer, and StreamLayer labels.

Possible Values:"normal"|"bold"|"bolder"|"lighter"

Default Value:normal
See also:

Method Overview

Name Return Type Summary Class
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 an ArcGIS product.

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:
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 an ArcGIS product. 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:
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() guide topic for more information.

Returns:
Type Description
Object The ArcGIS portal JSON representation of an instance of this class.