]> git.ipfire.org Git - thirdparty/google/fonts.git/commitdiff
tags: sort tag axes GF way 9436/head
authorMarc Foley <m.foley.88@gmail.com>
Mon, 12 May 2025 12:09:17 +0000 (13:09 +0100)
committerMarc Foley <m.foley.88@gmail.com>
Mon, 12 May 2025 12:09:17 +0000 (13:09 +0100)
.ci/tags.html

index b128a196ce67ecab07746f5d7527163fe98af413..6dc5e7c7a463b49b632808793caeb8be1695c06b 100644 (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);
           }