fontUtils.js 1.2 KB

12345
  1. /*
  2. All material copyright ESRI, All Rights Reserved, unless otherwise specified.
  3. See https://js.arcgis.com/4.25/esri/copyright.txt for details.
  4. */
  5. import e from"../config.js";const t=-26,r=-18,n="woff2",s=new Map;async function o(t){const r=i(t);let o=s.get(r);if(o)return o;const a=new FontFace(t.family,`url('${e.fontsUrl}/woff2/${r}.${n}') format('${n}')`),u=document.fonts;return u.has(a)&&"loading"===a.status?a.loaded:(o=a.load(),s.set(r,o),u.add(a),o)}function a(e){if(!e)return"arial-unicode-ms";const t=e.toLowerCase().split(" ").join("-");switch(t){case"serif":return"noto-serif";case"sans-serif":return"arial-unicode-ms";case"monospace":return"ubuntu-mono";case"fantasy":return"cabin-sketch";case"cursive":return"redressed";default:return t}}function i(e){const t=c(e)+f(e);return a(e.family)+(t.length>0?t:"-regular")}function u(e){switch(e){case"underline":return t;case"line-through":return r}return NaN}function c(e){if(!e.weight)return"";switch(e.weight.toLowerCase()){case"bold":case"bolder":return"-bold"}return""}function f(e){if(!e.style)return"";switch(e.style.toLowerCase()){case"italic":case"oblique":return"-italic"}return""}export{u as getFontDecorationTop,a as getFontFamily,i as getFullyQualifiedFontName,o as loadFont};