1
0
mirror of synced 2025-12-19 17:48:10 -05:00

tags: sort tag axes GF way

This commit is contained in:
Marc Foley
2025-05-12 13:09:17 +01:00
parent bcc7728b61
commit 3b1f549d19

View File

@@ -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);
}