From 3b1f549d19e7bd096d65f1798935caebbfbf17b5 Mon Sep 17 00:00:00 2001 From: Marc Foley Date: Mon, 12 May 2025 13:09:17 +0100 Subject: [PATCH] tags: sort tag axes GF way --- .ci/tags.html | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/.ci/tags.html b/.ci/tags.html index b128a196c..6dc5e7c7a 100644 --- a/.ci/tags.html +++ b/.ci/tags.html @@ -425,12 +425,25 @@ function axesCombos(axes) { let results = []; for (k in this.familyData) { const family = this.familyData[k]; - // to do bullshit aplhabetical sorting let path = `https://fonts.googleapis.com/css2?family=${family.family.replaceAll(" ", "+")}` + // GF api wants the axes in sorted alphabetical order. However, axes with + // caps are last + const sortedUpperCaseAxes = [] + const sortedLowerCaseAxes = [] + for (let a of family.axes) { + if (a.tag.toUpperCase() === a.tag) { + sortedUpperCaseAxes.push(a); + } else { + sortedLowerCaseAxes.push(a); + } + } + sortedLowerCaseAxes.sort((a, b) => a.tag.localeCompare(b.tag)); + sortedUpperCaseAxes.sort((a, b) => a.tag.localeCompare(b.tag)); + const sortedAxes = [...sortedLowerCaseAxes, ...sortedUpperCaseAxes] if (family.axes.length > 0) { - path += ":" + family.axes.map(a => {return a.tag}).join(",") + path += ":" + sortedAxes.map(a => {return a.tag}).join(",") path += "@"; - path += family.axes.map(a => {return `${Number(a.min)}..${Number(a.max)}`}).join(",") + path += sortedAxes.map(axis => {return `${Number(axis.min)}..${Number(axis.max)}`}).join(",") } results.push(path); } -- 2.47.2