CSP: font-src

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since August 2016.

HTTP の Content-Security-Policy (CSP) における font-src ディレクティブは、 @font-face によってロードされるフォントの有効なソースを指定します。

CSP バージョン 1
ディレクティブ種別 Fetch directive
default-src による代替 あり。このディレクティブがない場合、ユーザーエージェントは default-src ディレクティブを探します。

構文

font-src ポリシーには、1 つ以上のソースが許可されています。

http
Content-Security-Policy: font-src <source>;
Content-Security-Policy: font-src <source> <source>;

ソース

<source> は、 CSP ソース値にあるいずれかの値を取ることができます。

なお、この同じ値のセットはすべてのフェッチディレクティブ(と 他の多くのディレクティブ)で使用できます。

違反している場合

この CSP ヘッダーがある場合、

http
Content-Security-Policy: font-src https://example.com/

以下のフォントリソースの読み込みはブロックされ、読み込まれません。

html
<style>
  @font-face {
    font-family: "MyFont";
    src: url("https://not-example.com/font");
  }
  body {
    font-family: "MyFont";
  }
</style>

仕様書

Specification
Content Security Policy Level 3
# directive-font-src

ブラウザーの互換性

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
font-src

Legend

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

Full support
Full support

関連情報