Skip To ContentArcGIS for DevelopersSign In Dashboard
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:
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: "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.
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

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.

List of currently supported fonts:

FontStyleWeightCode Snippet
Abril Fatface Regularnormalnormalfont: { family: 'Abril Fatface', style: 'normal', weight: 'normal' }
Alegreya Boldnormalboldfont: { family: 'Alegreya', style: 'normal', weight: 'bold' }
Alegreya Bold Italicitalicboldfont: { family: 'Alegreya', style: 'italic', weight: 'bold' }
Alegreya Italicitalicnormalfont: { family: 'Alegreya', style: 'italic', weight: 'normal' }
Alegreya Regularnormalnormalfont: { family: 'Alegreya', style: 'normal', weight: 'normal' }
Alegreya Sans Italicitalicnormalfont: { family: 'Alegreya Sans', style: 'italic', weight: 'normal' }
Alegreya SC Boldnormalboldfont: { family: 'Alegreya SC', style: 'normal', weight: 'bold' }
Alegreya SC Italicitalicnormalfont: { family: 'Alegreya SC', style: 'italic', weight: 'normal' }
Alegreya SC Regularnormalnormalfont: { family: 'Alegreya SC', style: 'normal', weight: 'normal' }
Amarante Regularnormalnormalfont: { family: 'Amarante', style: 'normal', weight: 'normal' }
Amatic SC Boldnormalboldfont: { family: 'Amatic SC', style: 'normal', weight: 'bold' }
Arial Boldnormalboldfont: { family: 'Arial', style: 'normal', weight: 'bold' }
Arial Bold Italicitalicboldfont: { family: 'Arial', style: 'italic', weight: 'bold' }
Arial Italicitalicnormalfont: { family: 'Arial', style: 'italic', weight: 'normal' }
Arial Regularnormalnormalfont: { family: 'Arial', style: 'normal', weight: 'normal' }
Arial Unicode MS Boldnormalboldfont: { family: 'Arial Unicode MS', style: 'normal', weight: 'bold' }
Arial Unicode MS Regularnormalnormalfont: { family: 'Arial Unicode MS', style: 'normal', weight: 'normal' }
Atomic Age Regularnormalnormalfont: { family: 'Atomic Age', style: 'normal', weight: 'normal' }
Audiowide Regularnormalnormalfont: { family: 'Audiowide', style: 'normal', weight: 'normal' }
Avenir Next LT Pro Boldnormalboldfont: { family: 'Avenir Next LT Pro', style: 'normal', weight: 'bold' }
Avenir Next LT Pro Bold Italicitalicboldfont: { family: 'Avenir Next LT Pro', style: 'italic', weight: 'bold' }
Avenir Next LT Pro Demi Italicitalicnormalfont: { family: 'Avenir Next LT Pro Demi', style: 'italic', weight: 'normal' }
Avenir Next LT Pro Italicitalicnormalfont: { family: 'Avenir Next LT Pro', style: 'italic', weight: 'normal' }
Avenir Next LT Pro Light Italicitalicnormalfont: { family: 'Avenir Next LT Pro Light', style: 'italic', weight: 'normal' }
Avenir Next LT Pro Regularnormalnormalfont: { family: 'Avenir Next LT Pro', style: 'normal', weight: 'normal' }
Avenir Next LT Pro Light Italicitalicnormalfont: { family: 'Avenir Next LT Pro Light', style: 'italic', weight: 'normal' }
Avenir Next LT Pro Light Regularnormalnormalfont: { family: 'Avenir Next LT Pro Light', style: 'normal', weight: 'normal' }
Avenir Next LT Pro Medium Boldnormalboldfont: { family: 'Avenir Next LT Pro Medium', style: 'normal', weight: 'bold' }
Avenir Next LT Pro Medium Bold Italicitalicboldfont: { family: 'Avenir Next LT Pro Medium', style: 'italic', weight: 'bold' }
Avenir Next LT Pro Regular Boldnormalboldfont: { family: 'Avenir Next LT Pro Regular', style: 'normal', weight: 'bold' }
Avenir Next LT Pro Regular Bold Italicitalicboldfont: { family: 'Avenir Next LT Pro Regular', style: 'italic', weight: 'bold' }
Avenir Next LT Pro Regular Italicitalicnormalfont: { family: 'Avenir Next LT Pro Regular', style: 'italic', weight: 'normal' }
Avenir Next LT Pro Regular Regularnormalnormalfont: { family: 'Avenir Next LT Pro Regular', style: 'normal', weight: 'normal' }
Belleza Regularnormalnormalfont: { family: 'Belleza', style: 'normal', weight: 'normal' }
Black Ops One Regularnormalnormalfont: { family: 'Black Ops One', style: 'normal', weight: 'normal' }
Cabin Sketch Boldnormalboldfont: { family: 'Cabin Sketch', style: 'normal', weight: 'bold' }
Cabin Sketch Regularnormalnormalfont: { family: 'Cabin Sketch', style: 'normal', weight: 'normal' }
Coming Soon Regularnormalnormalfont: { family: 'Coming Soon', style: 'normal', weight: 'normal' }
Esri Icon Fontnormalnormalfont: { family: 'CalciteWebCoreIcons', style: 'normal', weight: 'normal' }
Homemade Apple Regularnormalnormalfont: { family: 'Homemade Apple', style: 'normal', weight: 'normal' }
IM FELL DW Pica PRO Italicitalicnormalfont: { family: 'IM FELL DW Pica PRO', style: 'italic', weight: 'normal' }
IM FELL DW Pica PRO Regularnormalnormalfont: { family: 'IM FELL DW Pica PRO', style: 'normal', weight: 'normal' }
Josefin Sans Regularnormalnormalfont: { family: 'Josefin Sans', style: 'normal', weight: 'normal' }
Josefin Sans Semibold Italicitalicnormalfont: { family: 'Josefin Sans Semibold', style: 'italic', weight: 'normal' }
Josefin Slab Boldnormalboldfont: { family: 'Josefin Slab', style: 'normal', weight: 'bold' }
Josefin Slab Bold Italicitalicboldfont: { family: 'Josefin Slab', style: 'italic', weight: 'bold' }
Josefin Slab Italicitalicnormalfont: { family: 'Josefin Slab', style: 'italic', weight: 'normal' }
Josefin Slab Light Italicitalicnormalfont: { family: 'Josefin Slab Light', style: 'italic', weight: 'normal' }
Josefin Slab Regularnormalnormalfont: { family: 'Josefin Slab', style: 'normal', weight: 'normal' }
Josefin Slab Semibold Italicitalicnormalfont: { family: 'Josefin Slab Semibold', style: 'italic', weight: 'normal' }
Josefin Slab Thin Italicitalicnormalfont: { family: 'Josefin Slab Thin', style: 'italic', weight: 'normal' }
Just Another Hand Regularnormalnormalfont: { family: 'Just Another Hand', style: 'normal', weight: 'normal' }
Kranky Regularnormalnormalfont: { family: 'Kranky', style: 'normal', weight: 'normal' }
Life Savers Boldnormalboldfont: { family: 'Life Savers', style: 'normal', weight: 'bold' }
Loved By The King Regularnormalnormalfont: { family: 'Loved By The King', style: 'normal', weight: 'normal' }
Merriweather Boldnormalboldfont: { family: 'Merriweather', style: 'normal', weight: 'bold' }
Merriweather Bold Italicitalicboldfont: { family: 'Merriweather', style: 'italic', weight: 'bold' }
Merriweather Italicitalicnormalfont: { family: 'Merriweather', style: 'italic', weight: 'normal' }
Merriweather Regularnormalnormalfont: { family: 'Merriweather', style: 'normal', weight: 'normal' }
Montserrat Boldnormalboldfont: { family: 'Montserrat', style: 'normal', weight: 'bold' }
Montserrat Italicitalicnormalfont: { family: 'Montserrat', style: 'italic', weight: 'normal' }
Montserrat Medium Italicitalicnormalfont: { family: 'Montserrat Medium', style: 'italic', weight: 'normal' }
Montserrat Regularnormalnormalfont: { family: 'Montserrat', style: 'normal', weight: 'normal' }
Montserrat Semibold Italicitalicnormalfont: { family: 'Montserrat Semibold', style: 'italic', weight: 'normal' }
Noto Sans Boldnormalboldfont: { family: 'Noto Sans', style: 'normal', weight: 'bold' }
Noto Sans Bold Italicitalicboldfont: { family: 'Noto Sans', style: 'italic', weight: 'bold' }
Noto Sans Italicitalicnormalfont: { family: 'Noto Sans', style: 'italic', weight: 'normal' }
Noto Sans Regularnormalnormalfont: { family: 'Noto Sans', style: 'normal', weight: 'normal' }
Noto Serif Boldnormalboldfont: { family: 'Noto Serif', style: 'normal', weight: 'bold' }
Noto Serif Bold Italicitalicboldfont: { family: 'Noto Serif', style: 'italic', weight: 'bold' }
Noto Serif Italicitalicnormalfont: { family: 'Noto Serif', style: 'italic', weight: 'normal' }
Noto Serif Regularnormalnormalfont: { family: 'Noto Serif', style: 'normal', weight: 'normal' }
Old Standard TT Boldnormalboldfont: { family: 'Old Standard TT', style: 'normal', weight: 'bold' }
Old Standard TT Italicitalicnormalfont: { family: 'Old Standard TT', style: 'italic', weight: 'normal' }
Old Standard TT Regularnormalnormalfont: { family: 'Old Standard TT', style: 'normal', weight: 'normal' }
Orbitron Boldnormalboldfont: { family: 'Orbitron', style: 'normal', weight: 'bold' }
Orbitron Regularnormalnormalfont: { family: 'Orbitron', style: 'normal', weight: 'normal' }
Oregano Italicitalicnormalfont: { family: 'Oregano', style: 'italic', weight: 'normal' }
Oregano Regularnormalnormalfont: { family: 'Oregano', style: 'normal', weight: 'normal' }
Oswald Boldnormalboldfont: { family: 'Oswald', style: 'normal', weight: 'bold' }
Oswald Regularnormalnormalfont: { family: 'Oswald', style: 'normal', weight: 'normal' }
Pacifico Regularnormalnormalfont: { family: 'Pacifico', style: 'normal', weight: 'normal' }
Palatino Linotype Regularnormalnormalfont: { family: 'Palatino Linotype', style: 'normal', weight: 'normal' }
Playfair Display Black Regularnormalnormalfont: { family: 'Playfair Display Black', style: 'normal', weight: 'normal' }
Playfair Display Boldnormalboldfont: { family: 'Playfair Display', style: 'normal', weight: 'bold' }
Playfair Display Bold Italicitalicboldfont: { family: 'Playfair Display', style: 'italic', weight: 'bold' }
Playfair Display Italicitalicnormalfont: { family: 'Playfair Display', style: 'italic', weight: 'normal' }
Playfair Display Regularnormalnormalfont: { family: 'Playfair Display', style: 'normal', weight: 'normal' }
Playfair Display SC Boldnormalboldfont: { family: 'Playfair Display SC', style: 'normal', weight: 'bold' }
Playfair Display SC Regularnormalnormalfont: { family: 'Playfair Display SC', style: 'normal', weight: 'normal' }
Redressed Regularnormalnormalfont: { family: 'Redressed', style: 'normal', weight: 'normal' }
Risque Regularnormalnormalfont: { family: 'Risque', style: 'normal', weight: 'normal' }
Roboto Condensed Italicitalicnormalfont: { family: 'Roboto Condensed', style: 'italic', weight: 'normal' }
Roboto Condensed Light Italicitalicnormalfont: { family: 'Roboto Condensed Light', style: 'italic', weight: 'normal' }
Rye Regularnormalnormalfont: { family: 'Rye', style: 'normal', weight: 'normal' }
Special Elite Regularnormalnormalfont: { family: 'Special Elite', style: 'normal', weight: 'normal' }
Syncopate Boldnormalboldfont: { family: 'Syncopate', style: 'normal', weight: 'bold' }
Syncopate Regularnormalnormalfont: { family: 'Syncopate', style: 'normal', weight: 'normal' }
Tangerine Regularnormalnormalfont: { family: 'Tangerine', style: 'normal', weight: 'normal' }
Ubuntu Boldnormalboldfont: { family: 'Ubuntu', style: 'normal', weight: 'bold' }
Ubuntu Bold Italicitalicboldfont: { family: 'Ubuntu', style: 'italic', weight: 'bold' }
Ubuntu Condensed Regularnormalnormalfont: { family: 'Ubuntu Condensed', style: 'normal', weight: 'normal' }
Ubuntu Italicitalicnormalfont: { family: 'Ubuntu', style: 'italic', weight: 'normal' }
Ubuntu Light Boldnormalboldfont: { family: 'Ubuntu Light', style: 'normal', weight: 'bold' }
Ubuntu Light Bold Italicitalicboldfont: { family: 'Ubuntu Light', style: 'italic', weight: 'bold' }
Ubuntu Light Italicitalicnormalfont: { family: 'Ubuntu Light', style: 'italic', weight: 'normal' }
Ubuntu Light Regularnormalnormalfont: { family: 'Ubuntu Light', style: 'normal', weight: 'normal' }
Ubuntu Medium Italicitalicnormalfont: { family: 'Ubuntu Medium', style: 'italic', weight: 'normal' }
Ubuntu Mono Boldnormalboldfont: { family: 'Ubuntu Mono', style: 'normal', weight: 'bold' }
Ubuntu Mono Bold Italicitalicboldfont: { family: 'Ubuntu Mono', style: 'italic', weight: 'bold' }
Ubuntu Mono Italicitalicnormalfont: { family: 'Ubuntu Mono', style: 'italic', weight: 'normal' }
Ubuntu Mono Regularnormalnormalfont: { family: 'Ubuntu Mono', style: 'normal', weight: 'normal' }
Ubuntu Regularnormalnormalfont: { family: 'Ubuntu', style: 'normal', weight: 'normal' }
UnifrakturCook Boldnormalboldfont: { family: 'UnifrakturCook', style: 'normal', weight: 'bold' }
Vast Shadow Regularnormalnormalfont: { family: 'Vast Shadow', style: 'normal', weight: 'normal' }
Walter Turncoat Regularnormalnormalfont: { family: 'Walter Turncoat', style: 'normal', weight: 'normal' }
Default Value:sans-serif
See also:
Example:
var 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

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

Returns:
TypeDescription
ObjectThe ArcGIS portal JSON representation of an instance of this class.

API Reference search results

NameTypeModule
Loading...