From fb1021954c2eaba0638d2b726c68881cf3b6aa51 Mon Sep 17 00:00:00 2001 From: Matias Benedetto Date: Mon, 29 Jan 2024 18:15:04 -0300 Subject: [PATCH 1/2] move fontFace to a definition so it can be linked from other schemas --- schemas/json/theme.json | 202 +++++++++++++++++++--------------------- 1 file changed, 98 insertions(+), 104 deletions(-) diff --git a/schemas/json/theme.json b/schemas/json/theme.json index 38eac461b6b7b6..64e32b4da9df88 100644 --- a/schemas/json/theme.json +++ b/schemas/json/theme.json @@ -619,7 +619,30 @@ "description": "Font family presets for the font family selector.\nGenerates a single custom property (`--wp--preset--font-family--{slug}`) per preset value.", "type": "array", "items": { - "$ref": "#/definitions/fontFamily" + "type": "object", + "description": "Font family preset", + "properties": { + "name": { + "description": "Name of the font family preset, translatable.", + "type": "string" + }, + "slug": { + "description": "Kebab-case unique identifier for the font family preset.", + "type": "string" + }, + "fontFamily": { + "description": "CSS font-family value.", + "type": "string" + }, + "fontFace": { + "description": "Array of font-face declarations.", + "type": "array", + "items": { + "$ref": "#/definitions/fontFace" + } + } + }, + "additionalProperties": false } } }, @@ -627,119 +650,90 @@ } } }, - "fontFamily": { + "fontFace": { "type": "object", - "description": "Font family preset", "properties": { - "name": { - "description": "Name of the font family preset, translatable.", + "fontFamily": { + "description": "CSS font-family value.", + "type": "string", + "default": "" + }, + "fontStyle": { + "description": "CSS font-style value.", + "type": "string", + "default": "normal" + }, + "fontWeight": { + "description": "List of available font weights, separated by a space.", + "default": "400", + "oneOf": [ + { + "type": "string" + }, + { + "type": "integer" + } + ] + }, + "fontDisplay": { + "description": "CSS font-display value.", + "type": "string", + "default": "fallback", + "enum": [ "auto", "block", "fallback", "swap", "optional" ] + }, + "src": { + "description": "Paths or URLs to the font files.", + "oneOf": [ + { + "type": "string" + }, + { + "type": "array", + "items": { + "type": "string" + } + } + ], + "default": [] + }, + "fontStretch": { + "description": "CSS font-stretch value.", "type": "string" }, - "slug": { - "description": "Kebab-case unique identifier for the font family preset.", + "ascentOverride": { + "description": "CSS ascent-override value.", "type": "string" }, - "fontFamily": { - "description": "CSS font-family value.", + "descentOverride": { + "description": "CSS descent-override value.", "type": "string" }, - "fontFace": { - "description": "Array of font-face declarations.", - "type": "array", - "items": { - "type": "object", - "properties": { - "fontFamily": { - "description": "CSS font-family value.", - "type": "string", - "default": "" - }, - "fontStyle": { - "description": "CSS font-style value.", - "type": "string", - "default": "normal" - }, - "fontWeight": { - "description": "List of available font weights, separated by a space.", - "default": "400", - "oneOf": [ - { - "type": "string" - }, - { - "type": "integer" - } - ] - }, - "fontDisplay": { - "description": "CSS font-display value.", - "type": "string", - "default": "fallback", - "enum": [ - "auto", - "block", - "fallback", - "swap", - "optional" - ] - }, - "src": { - "description": "Paths or URLs to the font files.", - "oneOf": [ - { - "type": "string" - }, - { - "type": "array", - "items": { - "type": "string" - } - } - ], - "default": [] - }, - "fontStretch": { - "description": "CSS font-stretch value.", - "type": "string" - }, - "ascentOverride": { - "description": "CSS ascent-override value.", - "type": "string" - }, - "descentOverride": { - "description": "CSS descent-override value.", - "type": "string" - }, - "fontVariant": { - "description": "CSS font-variant value.", - "type": "string" - }, - "fontFeatureSettings": { - "description": "CSS font-feature-settings value.", - "type": "string" - }, - "fontVariationSettings": { - "description": "CSS font-variation-settings value.", - "type": "string" - }, - "lineGapOverride": { - "description": "CSS line-gap-override value.", - "type": "string" - }, - "sizeAdjust": { - "description": "CSS size-adjust value.", - "type": "string" - }, - "unicodeRange": { - "description": "CSS unicode-range value.", - "type": "string" - } - }, - "required": [ "fontFamily", "src" ], - "additionalProperties": false - } + "fontVariant": { + "description": "CSS font-variant value.", + "type": "string" + }, + "fontFeatureSettings": { + "description": "CSS font-feature-settings value.", + "type": "string" + }, + "fontVariationSettings": { + "description": "CSS font-variation-settings value.", + "type": "string" + }, + "lineGapOverride": { + "description": "CSS line-gap-override value.", + "type": "string" + }, + "sizeAdjust": { + "description": "CSS size-adjust value.", + "type": "string" + }, + "unicodeRange": { + "description": "CSS unicode-range value.", + "type": "string" } }, + "required": [ "fontFamily", "src" ], "additionalProperties": false }, "settingsPropertiesCustom": { From c637a411be0b6a73d5f73260cc4b83e6e27cb65e Mon Sep 17 00:00:00 2001 From: Matias Benedetto Date: Mon, 29 Jan 2024 18:15:27 -0300 Subject: [PATCH 2/2] update font-collection schema --- schemas/json/font-collection.json | 60 ++++++++++++++++++++++++++++--- 1 file changed, 55 insertions(+), 5 deletions(-) diff --git a/schemas/json/font-collection.json b/schemas/json/font-collection.json index 4973c71312b605..922569b47d9408 100644 --- a/schemas/json/font-collection.json +++ b/schemas/json/font-collection.json @@ -7,6 +7,18 @@ "description": "JSON schema URI for font-collection.json.", "type": "string" }, + "slug": { + "type": "string", + "description": "Slug of the font collection. Must be unique and URL friendly." + }, + "name": { + "type": "string", + "description": "Name of the font collection." + }, + "description": { + "type": "string", + "description": "Description of the font collection." + }, "font_families": { "type": "array", "description": "Array of font families ready to be installed", @@ -14,10 +26,44 @@ "type": "object", "properties": { "font_family_settings": { - "description": "Font family settings as in theme.json", - "allOf": [ - { "$ref": "./theme.json#/definitions/fontFamily" } - ] + "description": "Font family settings similar to theme.json but without fontFace key.", + "type": "object", + "properties": { + "name": { + "description": "Name of the font family preset, translatable.", + "type": "string" + }, + "slug": { + "description": "Kebab-case unique identifier for the font family preset.", + "type": "string" + }, + "fontFamily": { + "description": "CSS font-family value.", + "type": "string" + } + }, + "additionalProperties": false + }, + "font_faces": { + "description": "Array of font-face declarations.", + "type": "array", + "items": { + "type": "object", + "properties": { + "preview": { + "type": "string", + "description": "URL to a preview image of the font face" + }, + "font_face_settings": { + "description": "Font face settings as in theme.json", + "allOf": [ + { + "$ref": "./theme.json#/definitions/fontFace" + } + ] + } + } + } }, "categories": { "type": "array", @@ -25,6 +71,10 @@ "items": { "type": "string" } + }, + "preview": { + "type": "string", + "description": "URL to a preview image of the font family" } }, "required": [ "font_family_settings" ], @@ -50,5 +100,5 @@ } }, "additionalProperties": false, - "required": [ "$schema", "font_families" ] + "required": [ "$schema", "slug", "name", "font_families" ] }