用于显示 2D 文本符号和 3D 文本符号的字体。此类允许开发人员设置字体的 family、decoration、size、style和 weight 属性。请注意每个属性的“已知限制”,以了解它们如何根据图层类型以及您是否使用 MapView 或 SceneView 而有所不同。
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"
}
};
构造函数
属性概览
Name | 类型 | 描述 | 类 | |
---|---|---|---|---|
String | 更多信息 类的名称。 | 更多信息 | Accessor | |
String | 更多信息 文本修饰符。 | 更多信息 | Font | |
String | 更多信息 文本的字体系列。 | 更多信息 | Font | |
Number | 更多信息 字体大小(以磅为单位)。 | 更多信息 | Font | |
String | 更多信息 文本样式。 | 更多信息 | Font | |
String | 更多信息 文本粗细。 | 更多信息 | Font |
属性详情
-
起始版本:GeoScene API for JavaScript 4.7
-
类的名称。声明的类名格式为
geoscene.folder.className
。
-
decoration String
-
文本修饰符。
可能的值:"underline"|"line-through"|"none"
- 默认值:none
-
family String
-
文本的字体系列。可能的值取决于图层类型,以及您使用的是 MapView 还是 SceneView。有关详细说明,请参阅标签指南页面,或单击下面的
Read more
。3D SceneViews 的字体系列
3D SceneViews 支持的字体系列取决于安装在用户计算机和 Web 浏览器上的字体。如果应用程序使用了未安装的字体,Font 类将实现一个回退机制,该机制将使用默认字体系列值,即
sans-serif
。有关如何在 Windows 或 Mac 上安装新字体的说明,请参阅这些参考资料。本地未安装的字体也可以通过在 css 文件中定义 @font-face 并从符号层中的
family
属性引用它来从 url 加载。2D MapImageLayer 的字体系列
MapView 中 MapImageLayers 支持的字体系列取决于安装在发布图层的 GeoScene Server 上的字体。如果应用程序使用了未安装的字体,Font 类将实现一个回退机制,该机制将使用默认字体系列值,即
sans-serif
。2D FeatureLayer、CSVLayer、StreamLayer 和 TextSymbol 的字体系列
支持的字体系列基于
.pbf
格式的托管字体文件。默认情况下,可用的字体大多与 GeoScene 矢量底图使用的字体相同。这些字体可通过https://static.geoscene.cn/fonts
获得。通过设置 geosceneConfig.fontsUrl 属性,可以将 URL 配置为指向您自己的字体资源。如果应用程序使用了未安装的字体,Font 类将实现一个回退机制,该机制将使用默认字体系列值,即sans-serif
。这使用Arial Unicode MS
字体文件。Labeling 概述页面中提供了下表中列出的字体的预览。
2D MapView 当前支持的字体列表:
Font Style Weight 代码片段 Abril Fatface 常规版 normal normal font: { family: 'Abril Fatface', style: 'normal', weight: 'normal' } Alegreya Bold normal bold font: { family: 'Alegreya', style: 'normal', weight: 'bold' } Alegreya Bold Italic italic bold font: { family: 'Alegreya', style: 'italic', weight: 'bold' } Alegreya Italic italic normal font: { family: 'Alegreya', style: 'italic', weight: 'normal' } Alegreya Regular normal normal font: { family: 'Alegreya', style: 'normal', weight: 'normal' } Alegreya SC Bold normal bold font: { family: 'Alegreya SC', style: 'normal', weight: 'bold' } Alegreya SC Italic italic normal font: { family: 'Alegreya SC', style: 'italic', weight: 'normal' } Alegreya SC Regular normal normal font: { family: 'Alegreya SC', style: 'normal', weight: 'normal' } Alegreya Sans Italic italic normal font: { family: 'Alegreya Sans', style: 'italic', weight: 'normal' } Amarante Regular normal normal font: { family: 'Amarante', style: 'normal', weight: 'normal' } Amatic SC Bold normal bold font: { family: 'Amatic SC', style: 'normal', weight: 'bold' } Arial Bold normal bold font: { family: 'Arial', style: 'normal', weight: 'bold' } Arial Bold Italic italic bold font: { family: 'Arial', style: 'italic', weight: 'bold' } Arial Italic italic normal font: { family: 'Arial', style: 'italic', weight: 'normal' } Arial Regular normal normal font: { family: 'Arial', style: 'normal', weight: 'normal' } Arial Unicode MS Bold normal bold font: { family: 'Arial Unicode MS', style: 'normal', weight: 'bold' } Arial Unicode MS Regular normal normal font: { family: 'Arial Unicode MS', style: 'normal', weight: 'normal' } Atomic Age Regular normal normal font: { family: 'Atomic Age', style: 'normal', weight: 'normal' } Audiowide Regular normal normal font: { family: 'Audiowide', style: 'normal', weight: 'normal' } Avenir Next LT Pro Bold normal bold font: { family: 'Avenir Next LT Pro', style: 'normal', weight: 'bold' } Avenir Next LT Pro Bold Italic italic bold font: { family: 'Avenir Next LT Pro', style: 'italic', weight: 'bold' } Avenir Next LT Pro Demi Italic italic normal font: { family: 'Avenir Next LT Pro Demi', style: 'italic', weight: 'normal' } Avenir Next LT Pro Italic italic normal font: { family: 'Avenir Next LT Pro', 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', style: 'italic', weight: 'normal' } Avenir Next LT Pro Medium Bold normal bold font: { family: 'Avenir Next LT Pro Medium', style: 'normal', weight: 'bold' } Avenir Next LT Pro Medium Bold Italic italic bold font: { family: 'Avenir Next LT Pro Medium', style: 'italic', weight: 'bold' } Avenir Next LT Pro Regular normal normal font: { family: 'Avenir Next LT Pro', style: 'normal', weight: 'normal' } Avenir Next LT Pro Regular Bold normal bold font: { family: 'Avenir Next LT Pro Regular', style: 'normal', weight: 'bold' } BellTopo Sans Bold normal bold font: { family: 'BellTopo Sans', style: 'normal', weight: 'bold' } BellTopo Sans Bold Italic italic bold font: { family: 'BellTopo Sans', style: 'italic', weight: 'bold' } BellTopo Sans Italic italic normal font: { family: 'BellTopo Sans', style: 'italic', weight: 'normal' } BellTopo Sans Regular normal normal font: { family: 'BellTopo Sans', style: 'normal', weight: 'normal' } Belleza Regular normal normal font: { family: 'Belleza', style: 'normal', weight: 'normal' } Black Ops One Regular normal normal font: { family: 'Black Ops One', style: 'normal', weight: 'normal' } Cabin Sketch Bold normal bold font: { family: 'Cabin Sketch', style: 'normal', weight: 'bold' } Cabin Sketch Regular normal normal font: { family: 'Cabin Sketch', style: 'normal', weight: 'normal' } Coming Soon Regular normal normal font: { family: 'Coming Soon', style: 'normal', weight: 'normal' } FGDC GeoAge Regular normal normal font: { family: 'FGDC GeoAge', style: 'normal', weight: 'normal' } Homemade Apple Regular normal normal font: { family: 'Homemade Apple', style: 'normal', weight: 'normal' } IM FELL DW Pica PRO Italic italic normal font: { family: 'IM FELL DW Pica PRO', style: 'italic', weight: 'normal' } IM FELL DW Pica PRO Regular normal normal font: { family: 'IM FELL DW Pica PRO', style: 'normal', weight: 'normal' } Josefin Sans Regular normal normal font: { family: 'Josefin Sans', style: 'normal', weight: 'normal' } Josefin Sans Semibold Italic italic bold font: { family: 'Josefin Sans Semibold', style: 'italic', weight: 'bold' } Josefin Slab Bold normal bold font: { family: 'Josefin Slab', style: 'normal', weight: 'bold' } Josefin Slab Bold Italic italic bold font: { family: 'Josefin Slab', style: 'italic', weight: 'bold' } Josefin Slab Italic italic normal font: { family: 'Josefin Slab', style: 'italic', weight: 'normal' } Josefin Slab Light Italic italic normal font: { family: 'Josefin Slab Light', style: 'italic', weight: 'normal' } Josefin Slab Regular normal normal font: { family: 'Josefin Slab', style: 'normal', weight: 'normal' } Josefin Slab Semibold Italic italic bold font: { family: 'Josefin Slab Semibold', style: 'italic', weight: 'bold' } Josefin Slab Thin Italic italic normal font: { family: 'Josefin Slab Thin', style: 'italic', weight: 'normal' } Just Another Hand Regular normal normal font: { family: 'Just Another Hand', style: 'normal', weight: 'normal' } Kranky Regular normal normal font: { family: 'Kranky', style: 'normal', weight: 'normal' } Life Savers Bold normal bold font: { family: 'Life Savers', style: 'normal', weight: 'bold' } Loved by the King Regular normal normal font: { family: 'Loved by the King', style: 'normal', weight: 'normal' } Merriweather Bold normal bold font: { family: 'Merriweather', style: 'normal', weight: 'bold' } Merriweather Bold Italic italic bold font: { family: 'Merriweather', style: 'italic', weight: 'bold' } Merriweather Italic italic normal font: { family: 'Merriweather', style: 'italic', weight: 'normal' } Merriweather Regular normal normal font: { family: 'Merriweather', style: 'normal', weight: 'normal' } Montserrat Bold normal bold font: { family: 'Montserrat', style: 'normal', weight: 'bold' } Montserrat Italic italic normal font: { family: 'Montserrat', style: 'italic', weight: 'normal' } Montserrat Medium Italic italic normal font: { family: 'Montserrat Medium', style: 'italic', weight: 'normal' } Montserrat Regular normal normal font: { family: 'Montserrat', style: 'normal', weight: 'normal' } Montserrat Semibold Italic italic bold font: { family: 'Montserrat Semibold', style: 'italic', weight: 'bold' } Noto Sans Bold normal bold font: { family: 'Noto Sans', style: 'normal', weight: 'bold' } Noto Sans Bold Italic italic bold font: { family: 'Noto Sans', style: 'italic', weight: 'bold' } Noto Sans Italic italic normal font: { family: 'Noto Sans', style: 'italic', weight: 'normal' } Noto Sans Regular normal normal font: { family: 'Noto Sans', style: 'normal', weight: 'normal' } Noto Serif Bold normal bold font: { family: 'Noto Serif', style: 'normal', weight: 'bold' } Noto Serif Bold Italic italic bold font: { family: 'Noto Serif', style: 'italic', weight: 'bold' } Noto Serif Italic italic normal font: { family: 'Noto Serif', style: 'italic', weight: 'normal' } Noto Serif Regular normal normal font: { family: 'Noto Serif', style: 'normal', weight: 'normal' } Old Standard TT Bold normal bold font: { family: 'Old Standard TT', style: 'normal', weight: 'bold' } Old Standard TT Italic italic normal font: { family: 'Old Standard TT', style: 'italic', weight: 'normal' } Old Standard TT Regular normal normal font: { family: 'Old Standard TT', style: 'normal', weight: 'normal' } Orbitron Bold normal bold font: { family: 'Orbitron', style: 'normal', weight: 'bold' } Orbitron Regular normal normal font: { family: 'Orbitron', style: 'normal', weight: 'normal' } Oregano Italic italic normal font: { family: 'Oregano', style: 'italic', weight: 'normal' } Oregano Regular normal normal font: { family: 'Oregano', style: 'normal', weight: 'normal' } Oswald Bold normal bold font: { family: 'Oswald', style: 'normal', weight: 'bold' } Oswald Regular normal normal font: { family: 'Oswald', style: 'normal', weight: 'normal' } Pacifico Regular normal normal font: { family: 'Pacifico', style: 'normal', weight: 'normal' } Palatino Linotype Regular normal normal font: { family: 'Palatino Linotype', style: 'normal', weight: 'normal' } Playfair Display Black normal normal font: { family: 'Playfair Display Black', style: 'normal', weight: 'normal' } Playfair Display Bold normal bold font: { family: 'Playfair Display', style: 'normal', weight: 'bold' } Playfair Display Bold Italic italic bold font: { family: 'Playfair Display', style: 'italic', weight: 'bold' } Playfair Display Italic italic normal font: { family: 'Playfair Display', style: 'italic', weight: 'normal' } Playfair Display Regular normal normal font: { family: 'Playfair Display', style: 'normal', weight: 'normal' } Playfair Display SC Bold normal bold font: { family: 'Playfair Display SC', style: 'normal', weight: 'bold' } Playfair Display SC Regular normal normal font: { family: 'Playfair Display SC', style: 'normal', weight: 'normal' } Redressed Regular normal normal font: { family: 'Redressed', style: 'normal', weight: 'normal' } Risque Regular normal normal font: { family: 'Risque', style: 'normal', weight: 'normal' } Roboto Condensed Italic italic normal font: { family: 'Roboto Condensed', style: 'italic', weight: 'normal' } Roboto Condensed Light Italic italic normal font: { family: 'Roboto Condensed Light', style: 'italic', weight: 'normal' } Rye Regular normal normal font: { family: 'Rye', style: 'normal', weight: 'normal' } Special Elite Regular normal normal font: { family: 'Special Elite', style: 'normal', weight: 'normal' } Syncopate Bold normal bold font: { family: 'Syncopate', style: 'normal', weight: 'bold' } Syncopate Regular normal normal font: { family: 'Syncopate', style: 'normal', weight: 'normal' } Tangerine Regular normal normal font: { family: 'Tangerine', style: 'normal', weight: 'normal' } Ubuntu Bold normal bold font: { family: 'Ubuntu', style: 'normal', weight: 'bold' } Ubuntu Bold Italic italic bold font: { family: 'Ubuntu', style: 'italic', weight: 'bold' } Ubuntu Condensed Regular normal normal font: { family: 'Ubuntu Condensed', style: 'normal', weight: 'normal' } Ubuntu Italic italic normal font: { family: 'Ubuntu', 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', style: 'normal', weight: 'bold' } Ubuntu Light Bold Italic italic bold font: { family: 'Ubuntu Light', style: 'italic', weight: 'bold' } Ubuntu Light Italic italic normal font: { family: 'Ubuntu Light', style: 'italic', weight: 'normal' } Ubuntu Medium Italic italic normal font: { family: 'Ubuntu Medium', style: 'italic', weight: 'normal' } Ubuntu Mono Bold normal bold font: { family: 'Ubuntu Mono', style: 'normal', weight: 'bold' } Ubuntu Mono Bold Italic italic bold font: { family: 'Ubuntu Mono', style: 'italic', weight: 'bold' } Ubuntu Mono Italic italic normal font: { family: 'Ubuntu Mono', style: 'italic', weight: 'normal' } Ubuntu Mono Regular normal normal font: { family: 'Ubuntu Mono', style: 'normal', weight: 'normal' } Ubuntu Regular normal normal font: { family: 'Ubuntu', style: 'normal', weight: 'normal' } UnifrakturCook Bold normal bold font: { family: 'UnifrakturCook', style: 'normal', weight: 'bold' } Vast Shadow Regular normal normal font: { family: 'Vast Shadow', style: 'normal', weight: 'normal' } Walter Turncoat Regular normal normal font: { family: 'Walter Turncoat', style: 'normal', weight: 'normal' } 示例: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" } };
-
字体大小(以磅为单位)。该值可以使用以点或像素(例如
12px
)表示大小的字符串进行自动转换。已知限制
在 3D SceneViews中,如果设置了 TextSymbol3DLayer.size 属性,它将覆盖此 size 属性。
- 默认值:9
- 另请参阅:
示例:// size in points symbol.size = 14;
// size in pixels symbol.size = "20px";
// size in points symbol.size = "14pt";
-
style String
-
文本样式。指定字体是否应设置样式:正常、斜体或倾斜。
已知限制
oblique
2D FeatureLayer、CSVLayer 和 StreamLayer 标签不支持。可能的值:"normal"|"italic"|"oblique"
- 默认值: normal
- 另请参阅:
-
weight String
-
文本粗细。指定粗体级别。
已知限制
bolder
2D FeatureLayer、CSVLayer 和 StreamLayer 标签不支持lighter
。可能的值:"normal"|"bold"|"bolder"|"lighter"
- 默认值: normal
- 另请参阅:
方法概览
名称 | 返回类型 | 描述 | 类 | |
---|---|---|---|---|
Font | 更多信息 创建 font 对象的深拷贝。 | 更多信息 | Font | |
* | 更多信息 创建此类的新实例并使用从 ArcGIS 产品生成的 JSON 对象的值对其进行初始化。 | 更多信息 | Font | |
Object | 更多信息 将此类的实例转换为其 GeoScene 门户 JSON 表示。 | 更多信息 | Font |
方法详情
-
fromJSON(json){*}static
-
创建此类的新实例并使用从 ArcGIS 产品生成的 JSON 对象的值对其进行初始化。传递到输入
json
参数的对象通常来自对 REST API 中的查询操作的响应或来自另一个 GeoScene 产品的 toJSON() 方法。有关何时以及如何使用此函数的详细信息和示例,请参阅指南中的使用 fromJSON() 主题。参数:json ObjectGeoScene 格式的实例的 JSON 表示。有关各种输入 JSON 对象的结构示例,请参阅 GeoScene REST API 文档。
返回:类型 说明 * 返回此类的新实例。
-
toJSON(){Object}
-
将此类的实例转换为其 GeoScene 门户 JSON 表示。有关更多信息,请参阅使用 fromJSON() 指南主题。
返回:类型 说明 Object 此类实例的GeoScene 门户 JSON 表示。