files/en-us/web/api/fontdata/family/index.md
{{APIRef("Local Font Access API")}}{{SeeCompatTable}}
The family read-only property of the {{domxref("FontData")}} interface returns the family of the font face.
This is the name used when referring to the font family from code, for example, in the {{cssxref("font-family")}} property or in places within the {{cssxref("@font-face")}} at-rule such as the local() function.
Examples include:
A string.
The following snippet will query for all available fonts, and log metadata. This could be used, for example, to populate a font-picker control.
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);
}
}
{{Specifications}}
{{Compat}}