Title: WP_REST_Font_Faces_Controller::get_item_schema
Published: April 3, 2024
Last modified: April 28, 2025

---

# WP_REST_Font_Faces_Controller::get_item_schema(): array

## In this article

 * [Return](https://developer.wordpress.org/reference/classes/wp_rest_font_faces_controller/get_item_schema/?output_format=md#return)
 * [Source](https://developer.wordpress.org/reference/classes/wp_rest_font_faces_controller/get_item_schema/?output_format=md#source)
 * [Related](https://developer.wordpress.org/reference/classes/wp_rest_font_faces_controller/get_item_schema/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/classes/wp_rest_font_faces_controller/get_item_schema/?output_format=md#changelog)

[ Back to top](https://developer.wordpress.org/reference/classes/wp_rest_font_faces_controller/get_item_schema/?output_format=md#wp--skip-link--target)

Retrieves the post’s schema, conforming to JSON Schema.

## 󠀁[Return](https://developer.wordpress.org/reference/classes/wp_rest_font_faces_controller/get_item_schema/?output_format=md#return)󠁿

 array Item schema data.

## 󠀁[Source](https://developer.wordpress.org/reference/classes/wp_rest_font_faces_controller/get_item_schema/?output_format=md#source)󠁿

    ```php
    public function get_item_schema() {
    	if ( $this->schema ) {
    		return $this->add_additional_fields_schema( $this->schema );
    	}

    	$schema = array(
    		'$schema'    => 'http://json-schema.org/draft-04/schema#',
    		'title'      => $this->post_type,
    		'type'       => 'object',
    		// Base properties for every Post.
    		'properties' => array(
    			'id'                 => array(
    				'description' => __( 'Unique identifier for the post.', 'default' ),
    				'type'        => 'integer',
    				'context'     => array( 'view', 'edit', 'embed' ),
    				'readonly'    => true,
    			),
    			'theme_json_version' => array(
    				'description' => __( 'Version of the theme.json schema used for the typography settings.' ),
    				'type'        => 'integer',
    				'default'     => static::LATEST_THEME_JSON_VERSION_SUPPORTED,
    				'minimum'     => 2,
    				'maximum'     => static::LATEST_THEME_JSON_VERSION_SUPPORTED,
    				'context'     => array( 'view', 'edit', 'embed' ),
    			),
    			'parent'             => array(
    				'description' => __( 'The ID for the parent font family of the font face.' ),
    				'type'        => 'integer',
    				'context'     => array( 'view', 'edit', 'embed' ),
    			),
    			// Font face settings come directly from theme.json schema
    			// See https://schemas.wp.org/trunk/theme.json
    			'font_face_settings' => array(
    				'description'          => __( 'font-face declaration in theme.json format.' ),
    				'type'                 => 'object',
    				'context'              => array( 'view', 'edit', 'embed' ),
    				'properties'           => array(
    					'fontFamily'            => array(
    						'description' => __( 'CSS font-family value.' ),
    						'type'        => 'string',
    						'default'     => '',
    						'arg_options' => array(
    							'sanitize_callback' => array( 'WP_Font_Utils', 'sanitize_font_family' ),
    						),
    					),
    					'fontStyle'             => array(
    						'description' => __( 'CSS font-style value.' ),
    						'type'        => 'string',
    						'default'     => 'normal',
    						'arg_options' => array(
    							'sanitize_callback' => 'sanitize_text_field',
    						),
    					),
    					'fontWeight'            => array(
    						'description' => __( 'List of available font weights, separated by a space.' ),
    						'default'     => '400',
    						// Changed from `oneOf` to avoid errors from loose type checking.
    						// e.g. a fontWeight of "400" validates as both a string and an integer due to is_numeric check.
    						'type'        => array( 'string', 'integer' ),
    						'arg_options' => array(
    							'sanitize_callback' => 'sanitize_text_field',
    						),
    					),
    					'fontDisplay'           => array(
    						'description' => __( 'CSS font-display value.' ),
    						'type'        => 'string',
    						'default'     => 'fallback',
    						'enum'        => array(
    							'auto',
    							'block',
    							'fallback',
    							'swap',
    							'optional',
    						),
    						'arg_options' => array(
    							'sanitize_callback' => 'sanitize_text_field',
    						),
    					),
    					'src'                   => array(
    						'description' => __( 'Paths or URLs to the font files.' ),
    						// Changed from `oneOf` to `anyOf` due to rest_sanitize_array converting a string into an array,
    						// and causing a "matches more than one of the expected formats" error.
    						'anyOf'       => array(
    							array(
    								'type' => 'string',
    							),
    							array(
    								'type'  => 'array',
    								'items' => array(
    									'type' => 'string',
    								),
    							),
    						),
    						'default'     => array(),
    						'arg_options' => array(
    							'sanitize_callback' => function ( $value ) {
    								return is_array( $value ) ? array_map( array( $this, 'sanitize_src' ), $value ) : $this->sanitize_src( $value );
    							},
    						),
    					),
    					'fontStretch'           => array(
    						'description' => __( 'CSS font-stretch value.' ),
    						'type'        => 'string',
    						'arg_options' => array(
    							'sanitize_callback' => 'sanitize_text_field',
    						),
    					),
    					'ascentOverride'        => array(
    						'description' => __( 'CSS ascent-override value.' ),
    						'type'        => 'string',
    						'arg_options' => array(
    							'sanitize_callback' => 'sanitize_text_field',
    						),
    					),
    					'descentOverride'       => array(
    						'description' => __( 'CSS descent-override value.' ),
    						'type'        => 'string',
    						'arg_options' => array(
    							'sanitize_callback' => 'sanitize_text_field',
    						),
    					),
    					'fontVariant'           => array(
    						'description' => __( 'CSS font-variant value.' ),
    						'type'        => 'string',
    						'arg_options' => array(
    							'sanitize_callback' => 'sanitize_text_field',
    						),
    					),
    					'fontFeatureSettings'   => array(
    						'description' => __( 'CSS font-feature-settings value.' ),
    						'type'        => 'string',
    						'arg_options' => array(
    							'sanitize_callback' => 'sanitize_text_field',
    						),
    					),
    					'fontVariationSettings' => array(
    						'description' => __( 'CSS font-variation-settings value.' ),
    						'type'        => 'string',
    						'arg_options' => array(
    							'sanitize_callback' => 'sanitize_text_field',
    						),
    					),
    					'lineGapOverride'       => array(
    						'description' => __( 'CSS line-gap-override value.' ),
    						'type'        => 'string',
    						'arg_options' => array(
    							'sanitize_callback' => 'sanitize_text_field',
    						),
    					),
    					'sizeAdjust'            => array(
    						'description' => __( 'CSS size-adjust value.' ),
    						'type'        => 'string',
    						'arg_options' => array(
    							'sanitize_callback' => 'sanitize_text_field',
    						),
    					),
    					'unicodeRange'          => array(
    						'description' => __( 'CSS unicode-range value.' ),
    						'type'        => 'string',
    						'arg_options' => array(
    							'sanitize_callback' => 'sanitize_text_field',
    						),
    					),
    					'preview'               => array(
    						'description' => __( 'URL to a preview image of the font face.' ),
    						'type'        => 'string',
    						'format'      => 'uri',
    						'default'     => '',
    						'arg_options' => array(
    							'sanitize_callback' => 'sanitize_url',
    						),
    					),
    				),
    				'required'             => array( 'fontFamily', 'src' ),
    				'additionalProperties' => false,
    			),
    		),
    	);

    	$this->schema = $schema;

    	return $this->add_additional_fields_schema( $this->schema );
    }
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-includes/rest-api/endpoints/class-wp-rest-font-faces-controller.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/6.9.4/src/wp-includes/rest-api/endpoints/class-wp-rest-font-faces-controller.php#L493)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/6.9.4/src/wp-includes/rest-api/endpoints/class-wp-rest-font-faces-controller.php#L493-L675)

## 󠀁[Related](https://developer.wordpress.org/reference/classes/wp_rest_font_faces_controller/get_item_schema/?output_format=md#related)󠁿

| Uses | Description | 
| [WP_REST_Font_Faces_Controller::sanitize_src()](https://developer.wordpress.org/reference/classes/wp_rest_font_faces_controller/sanitize_src/)`wp-includes/rest-api/endpoints/class-wp-rest-font-faces-controller.php` |

Sanitizes a single src value for a font face.

  | 
| [__()](https://developer.wordpress.org/reference/functions/__/)`wp-includes/l10n.php` |

Retrieves the translation of $text.

  |

| Used by | Description | 
| [WP_REST_Font_Faces_Controller::get_settings_from_post()](https://developer.wordpress.org/reference/classes/wp_rest_font_faces_controller/get_settings_from_post/)`wp-includes/rest-api/endpoints/class-wp-rest-font-faces-controller.php` |

Gets the font face’s settings from the post.

  | 
| [WP_REST_Font_Faces_Controller::get_create_params()](https://developer.wordpress.org/reference/classes/wp_rest_font_faces_controller/get_create_params/)`wp-includes/rest-api/endpoints/class-wp-rest-font-faces-controller.php` |

Get the params used when creating a new font face.

  | 
| [WP_REST_Font_Faces_Controller::validate_create_font_face_settings()](https://developer.wordpress.org/reference/classes/wp_rest_font_faces_controller/validate_create_font_face_settings/)`wp-includes/rest-api/endpoints/class-wp-rest-font-faces-controller.php` |

Validates settings when creating a font face.

  | 
| [WP_REST_Font_Faces_Controller::sanitize_font_face_settings()](https://developer.wordpress.org/reference/classes/wp_rest_font_faces_controller/sanitize_font_face_settings/)`wp-includes/rest-api/endpoints/class-wp-rest-font-faces-controller.php` |

Sanitizes the font face settings when creating a font face.

  |

## 󠀁[Changelog](https://developer.wordpress.org/reference/classes/wp_rest_font_faces_controller/get_item_schema/?output_format=md#changelog)󠁿

| Version | Description | 
| [6.5.0](https://developer.wordpress.org/reference/since/6.5.0/) | Introduced. |

## User Contributed Notes

You must [log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fclasses%2Fwp_rest_font_faces_controller%2Fget_item_schema%2F)
before being able to contribute a note or feedback.