FontData:fullName 属性

Limited availability

This feature is not Baseline because it does not work in some of the most widely-used browsers.

实验性: 这是一项实验性技术
在将其用于生产之前,请仔细检查浏览器兼容性表格

FontData 接口的 fullName 只读属性返回字体的全名。这通常是一个用于识别字体的人类可读的名称,例如:“Optima Bold”。

示例包括:

  • Apple SD Gothic Neo UltraLight
  • Arial Black
  • Avenir Next Heavy
  • Katari Medium Italic
  • YuMincho +36p Kana Extrabold

一个字符串。

示例

以下代码片段将查询所有可用的字体并打印元数据。例如,这可以用于填充字体选择器控件。

js
async function logFontData() {
  try {
    const availableFonts = await window.queryLocalFonts();
    for (const fontData of availableFonts) {
      console.log(fontData.postscriptName);
      console.log(fontData.fullName);
      console.log(fontData.family);
      console.log(fontData.style);
    }
  } catch (err) {
    console.error(err.name, err.message);
  }
}

规范

Specification
Local Font Access API
# ref-for-dom-fontdata-fullname

浏览器兼容性

Report problems with this compatibility data on GitHub
desktopmobile
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
fullName
Experimental

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support
No support
No support
Experimental. Expect behavior to change in the future.

参见