ArcGIS API For JavaScript Font字体简介,下载及本地部署

    技术2022-07-11  133

    一、TextSymbol 字体font简介

    在ArcGIS API For JavaScript开发中,设置标注label 或Graphic时若使用TextSymbol,用font设置文字样式,如字体 family、大小 size、风格 style、粗细weight。

    参考:https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-Font.html font设置的参数会转为ESRI命名规范去请求pbf文件,如

    font: { family: "sans-serif", size: 12, weight: "normal" }

    会请求 https://static.arcgis.com/fonts/arial-unicode-ms-regular/0-255.pbf

    二、使用本地部署的字体

    若在线地址 (https://static.arcgis.com/fonts)速度较慢,或系统部署在内网无法访问公网 。可下载这些字体文件,在本地部署。

    常用字体下载 字体文件pbf 下载地址1:https://download.csdn.net/download/monaleila/12567449 下载地址2:https://download.csdn.net/download/monaleila/12570755 文件夹按ESRI命名规则,arial-unicode-ms-regular、arial-unicode-ms-bold,为 sans-serif 的normal字体 和 sans-serif 的bold字体。

    配置方法

    将字体文件夹部署在tomcat或者IIS后,使用esriConfig.fontsUrl属性来设置字体来源。

    三、更多字体下载

    除特殊几个字体外,一般ESRI的命名规范为

    family 均变为小写字母,空格改为横杠 “-”weight :normal对应regular,bold 对应 boldstyle :一般没有以上转换好之后,按 [family]-[weight]-[style] 顺序用横杠 "-"拼接。 familyweightESRI命名规范sans-serifnormalarial-unicode-ms-regularsans-serifboldarial-unicode-ms-boldserifnormalnoto-serif-regularserifboldnoto-serif-boldPlayfair Displaynormalplayfair-display-regularPlayfair Displayboldplayfair-display-boldMicrosoft YaHeinormalmicrosoft-yahei-regularMicrosoft YaHeiboldmicrosoft-yahei-boldSimSunnormalsimsun-regularSimSunboldsimsun-bold

    如果需要更多字体,可从ESRI官网下载 ,方法参考:https://blog.csdn.net/weixin_38169562/article/details/101633574

    或参考.Net的 https://editor.csdn.net/md?articleId=107086004

    也可下载其他pbf字体,并按ESRI的命名规范修改文件夹名。

    四、注意事项

    以下是开发中font设置可能遇到的问题

    style 设为“italic”或者“oblique” 常常无效family设为"bolder"或者"lighter"常常无效找不到对应字体,页面会默认使用 sans-serif,normal 即 arial-unicode-ms-regular ,或不显示文字
    Processed: 0.014, SQL: 9