wp_print_font_faces

説明

void wp_print_font_faces( [ $fonts = array() ] )
フォントフェイス・スタイルを表示する。

パラメータ

  • $fonts
    フォントファミリーとそのバリエーションを含んだ連想配列を含む配列を指定(省略時はarray())。
    キー内容
    font-familyfont-familyプロパティ値(フォントファミリー名)
    srcフォントファイルのURLかその配列
    font-stylefont-styleプロパティ値(省略時は'normal')
    font-weightfont-weightプロパティ値(省略時は'400')
    font-displayfont-displayプロパティ値(省略時は'fallback')
    ascent-overrideascent-overrideプロパティ値
    descent-overridedescent-overrideプロパティ値
    font-stretchfont-stretchプロパティ値
    font-variantfont-variantプロパティ値
    font-feature-settingsfont-feature-settingsプロパティ値
    font-variation-settingsfont-variation-settingsプロパティ値
    line-gap-overrideline-gap-overrideプロパティ値
    size-adjustsize-adjustプロパティ値
    unicode-rangeunicode-rangeプロパティ値

返り値

返り値はありません。

注意

本関数は標準で'wp_head'アクションとして優先度50で登録されており、通常は呼び出すことはない。

パラメータ$fontsが省略された場合は、現在のテーマのtheme.jsonで指定されているフォントフェイス内容が適用される。

新テーマ「Twenty Twenty-Four」では以下の内容が出力されている。

<style id='wp-fonts-local'>
@font-face{font-family:Inter;font-style:normal;font-weight:300 900;font-display:fallback;src:url('http://localhost/wp-content/themes/twentytwentyfour/assets/fonts/inter/Inter-VariableFont_slnt,wght.woff2') format('woff2');font-stretch:normal;}
@font-face{font-family:Cardo;font-style:normal;font-weight:400;font-display:fallback;src:url('http://localhost/wp-content/themes/twentytwentyfour/assets/fonts/cardo/cardo_normal_400.woff2') format('woff2');}
@font-face{font-family:Cardo;font-style:italic;font-weight:400;font-display:fallback;src:url('http://localhost/wp-content/themes/twentytwentyfour/assets/fonts/cardo/cardo_italic_400.woff2') format('woff2');}
@font-face{font-family:Cardo;font-style:normal;font-weight:700;font-display:fallback;src:url('http://localhost/wp-content/themes/twentytwentyfour/assets/fonts/cardo/cardo_normal_700.woff2') format('woff2');}
</style>

使用例

  • 任意のフォントフェイス・スタイルを表示する
    wp_print_font_faces( [
    	"Inter" => [
    		0 => [
    			"src"          => [ get_theme_file_uri( "assets/fonts/inter/Inter-VariableFont_slnt,wght.woff2" ) ],
    			"font-family"  => "Inter",
    			"font-stretch" => "normal",
    			"font-style"   => "normal",
    			"font-weight"  => "300 900",
    		]
    	]
    ] );
    

フィルター

直接実行するフィルターはありません。

アクション

直接実行するアクションはありません。

ソースファイル

/wp-includes/fonts.php

最終更新 : 2023年11月09日 13:29


お勧め

meta_compare_key使ってみた(2019年3月19日 更新)

ブロックエディターの登場により、標準のカスタムフィールドを使う機会はかなり減った気がする。そんな中、5.1.0で追加されたのが、カスタムフィールド名(メタキー)に含まれる文字列を指定する'meta_compare_key'キーだ。

WP_List_Tableクラスの「一括操作」フォームを使ってみた(2018年5月27日 更新)

今回は「WP_List_Tableクラスを使ってみた」の続き。投稿一覧やプラグインページなどにある「一括操作」(Bulkアクション)フォーム対応に関するメモである。

テーマから投稿画像のサイズを指定する(2012年3月15日 更新)

投稿記事に挿入する画像サイズは、サムネイル(150×150)、中サイズ(300×300)、大サイズ(1024×1024)がデフォルトだが、テーマによっては別のサイズを指定したい場合はある。基本的には、「設定」-「メディア」の「メディア設定」ページで指定できるが、テーマ内のfunctions.phpで設定しておくとちょっと便利かもしれない。

ログインページを変える(2014年9月12日 更新)

WordPressの標準的な不正ログイン対策としては、ログインIDは'admin'を避けるパスワードはユニークで長くする、場合によってはアクセスできるIPアドレスを制限する、といった具合だろう。これらの他に何かできないものだろうかと、ちょっと考えてみた。

新規投稿時の本文プレースホルダーテキストを変える(2021年9月9日 更新)

ブロックエディターに影響を与えるフィルターは多数存在する。今回紹介するフィルターはその1つで、新規投稿時の本文ブロックのプレースホルダーテキストを変更するものだ。