admin管理员组

文章数量:1594753

一、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的命名规范为

  1. family 均变为小写字母,空格改为横杠 “-”
  2. weight :normal对应regular,bold 对应 bold
  3. style :一般没有
  4. 以上转换好之后,按 [family]-[weight]-[style] 顺序用横杠 "-"拼接。
familyweightESRI命名规范
sans-serifnormalarial-unicode-ms-regular
sans-serifboldarial-unicode-ms-bold
serifnormalnoto-serif-regular
serifboldnoto-serif-bold
Playfair Displaynormalplayfair-display-regular
Playfair Displayboldplayfair-display-bold
Microsoft YaHeinormalmicrosoft-yahei-regular
Microsoft YaHeiboldmicrosoft-yahei-bold
SimSunnormalsimsun-regular
SimSunboldsimsun-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 ,或不显示文字

本文标签: 字体简介APIArcGISfont