spacers.clj 935 B

12345678910111213141516171819202122232425262728293031
  1. (ns fira-code.spacers
  2. (:require
  3. [clojure.string :as str]
  4. [fira-code.glyphs :as glyphs]
  5. [fira-code.time :as time]
  6. [flatland.ordered.map :refer [ordered-map]]))
  7. (defn spacer [name]
  8. (ordered-map
  9. :color 3,
  10. :glyphname name,
  11. :lastChange (time/now-str),
  12. :layers
  13. [(ordered-map :layerId (:Light glyphs/weights), :width 1200)
  14. (ordered-map :layerId (:Bold glyphs/weights), :width 1200)]))
  15. (defn add-spacers [font ligas]
  16. (let [needed (->> (into #{} cat ligas)
  17. (map #(str % ".spacer")))
  18. existing (->> (:glyphs font)
  19. (map :glyphname)
  20. (filter #(str/ends-with? % ".spacer")))
  21. new (->> (remove (set existing) needed)
  22. (sort-by str/lower-case))]
  23. (if-not (empty? new)
  24. (do
  25. (println " added glyphs: " (str/join " " new))
  26. (update font :glyphs #(into % (map spacer new))))
  27. font)))