features.clj 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. (ns fira-code.features
  2. (:require
  3. [clojure.java.io :as io]
  4. [clojure.string :as str]
  5. [fira-code.glyphs :as glyphs]
  6. [fira-code.files :as files]))
  7. (defn append-calt [font]
  8. (let [features (->> (files/find "features/calt" #"features/calt/[^/]+\.fea")
  9. (map slurp)
  10. (map str/trim)
  11. (str/join "\n\n"))]
  12. (println " appending to feature calt" (glyphs/lines features) "lines")
  13. (glyphs/update-code font :features "calt"
  14. #(str % "\n\n" features))))
  15. (defn fill-feature [font file]
  16. (let [[_ name] (re-matches #"([^.]+)\.fea" (.getName file))
  17. code (slurp file)
  18. [_ notes code'] (re-matches #"(?s)#([^\n]+)\n(.*)" code)
  19. feature (if notes
  20. {:code (str/trim code')
  21. :name name
  22. :notes (str/trim notes)}
  23. {:code (str/trim code)
  24. :name name})]
  25. (glyphs/set-feature font name feature)))
  26. (defn fill-features [font]
  27. (reduce fill-feature font (files/find "features" #"features/[^/]+\.fea")))
  28. (defn fill-all [font]
  29. (-> font
  30. (append-calt)
  31. (fill-features)))