mirror of
https://github.com/tonsky/FiraCode.git
synced 2024-08-17 00:40:32 +03:00
31 lines
935 B
Clojure
31 lines
935 B
Clojure
|
(ns fira-code.spacers
|
||
|
(:require
|
||
|
[clojure.string :as str]
|
||
|
[fira-code.glyphs :as glyphs]
|
||
|
[fira-code.time :as time]
|
||
|
[flatland.ordered.map :refer [ordered-map]]))
|
||
|
|
||
|
|
||
|
(defn spacer [name]
|
||
|
(ordered-map
|
||
|
:color 3,
|
||
|
:glyphname name,
|
||
|
:lastChange (time/now-str),
|
||
|
:layers
|
||
|
[(ordered-map :layerId (:Light glyphs/weights), :width 1200)
|
||
|
(ordered-map :layerId (:Bold glyphs/weights), :width 1200)]))
|
||
|
|
||
|
|
||
|
(defn add-spacers [font ligas]
|
||
|
(let [needed (->> (into #{} cat ligas)
|
||
|
(map #(str % ".spacer")))
|
||
|
existing (->> (:glyphs font)
|
||
|
(map :glyphname)
|
||
|
(filter #(str/ends-with? % ".spacer")))
|
||
|
new (->> (remove (set existing) needed)
|
||
|
(sort-by str/lower-case))]
|
||
|
(if-not (empty? new)
|
||
|
(do
|
||
|
(println " added glyphs: " (str/join " " new))
|
||
|
(update font :glyphs #(into % (map spacer new))))
|
||
|
font)))
|