admin管理员组文章数量:1595564
一、TextSymbol 字体font简介
在ArcGIS API For JavaScript开发中,设置标注label 或Graphic时若使用TextSymbol,用font设置文字样式,如字体 family、大小 size、风格 style、粗细weight。
参考:https://developers.arcgis/javascript/latest/api-reference/esri-symbols-Font.html
font设置的参数会转为ESRI命名规范去请求pbf文件,如
font: {
family: "sans-serif",
size: 12,
weight: "normal"
}
- 1
- 2
- 3
- 4
- 5
会请求 https://static.arcgis/fonts/arial-unicode-ms-regular/0-255.pbf
二、使用本地部署的字体
若在线地址 (https://static.arcgis/fonts)速度较慢,或系统部署在内网无法访问公网 。可下载这些字体文件,在本地部署。
常用字体
文件夹按ESRI命名规则,arial-unicode-ms-regular、arial-unicode-ms-bold,microsoft-yahei-regular,microsoft-yahei-bold,simsun-regular
配置方法
将字体文件夹部署在tomcat或者IIS后,使用esriConfig.fontsUrl属性来设置字体来源。
三、更多字体下载
除特殊几个字体外,一般ESRI的命名规范为
- family 均变为小写字母,空格改为横杠 “-”
- weight :normal对应regular,bold 对应 bold
- style :一般没有
- 以上转换好之后,按 [family]-[weight]-[style] 顺序用横杠 "-"拼接。
family | weight | ESRI命名规范 |
---|---|---|
sans-serif | normal | arial-unicode-ms-regular |
sans-serif | bold | arial-unicode-ms-bold |
serif | normal | noto-serif-regular |
serif | bold | noto-serif-bold |
Playfair Display | normal | playfair-display-regular |
Playfair Display | bold | playfair-display-bold |
Microsoft YaHei | normal | microsoft-yahei-regular |
Microsoft YaHei | bold | microsoft-yahei-bold |
SimSun | normal | simsun-regular |
SimSun | bold | simsun-bold |
如果需要更多字体,可从ESRI官网下载 ,方法参考:https://blog.csdn/weixin_38169562/article/details/101633574
也可下载其他pbf字体,并按ESRI的命名规范修改文件夹名。
四、注意事项
以下是开发中font设置可能遇到的问题
- style 设为“italic”或者“oblique” 常常无效
- family设为"bolder"或者"lighter"常常无效
- 找不到对应字体,页面会默认使用 sans-serif,normal 即 arial-unicode-ms-regular ,或不显示文字
版权声明:本文标题:ArcGIS API For JavaScript Font字体简介,下载及本地部署 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://m.elefans.com/dongtai/1728200823a1149351.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论