mirror of
https://github.com/tonsky/FiraCode.git
synced 2024-08-17 00:40:32 +03:00
migrated gen_calt to parse_glyphs
This commit is contained in:
parent
24daff0fca
commit
76d08bbb6c
1
.gitignore
vendored
1
.gitignore
vendored
@ -4,3 +4,4 @@ FiraCode_mess.glyphs
|
|||||||
target
|
target
|
||||||
clojure/*.edn
|
clojure/*.edn
|
||||||
FiraCode\ (Autosaved).glyphs
|
FiraCode\ (Autosaved).glyphs
|
||||||
|
.cpcache
|
@ -1,34 +1,7 @@
|
|||||||
#^:shebang '[
|
(ns gen-calt
|
||||||
exec java -cp "$HOME/.m2/repository/org/clojure/clojure/1.8.0/clojure-1.8.0.jar" clojure.main "$0" "$@"]
|
(:require
|
||||||
|
[clojure.string :as str]
|
||||||
|
[parse-glyphs :as parse]))
|
||||||
(require '[clojure.string :as str])
|
|
||||||
|
|
||||||
(def file "FiraCode.glyphs")
|
|
||||||
|
|
||||||
(println "Looking for ligatures in" file "...\n")
|
|
||||||
|
|
||||||
;; [ ["dash" "greater" "greater"] ... ]
|
|
||||||
(def ligas (->> (slurp file)
|
|
||||||
(re-seq #"glyphname = ([a-z_]+)\.liga;")
|
|
||||||
(map second)
|
|
||||||
set
|
|
||||||
(mapv #(vec (str/split % #"_")))))
|
|
||||||
|
|
||||||
|
|
||||||
; (def ligas
|
|
||||||
; [ ["hyphen" "greater"]
|
|
||||||
; ["greater" "equal"]
|
|
||||||
; ["equal" "greater"]
|
|
||||||
; ["hyphen" "hyphen" "greater"]
|
|
||||||
; ["equal" "equal" "greater"]
|
|
||||||
; ["greater" "hyphen"]])
|
|
||||||
|
|
||||||
; (def ligas
|
|
||||||
; [ ["slash" "asterisk"]
|
|
||||||
; ["slash" "asterisk" "asterisk"]
|
|
||||||
; ["asterisk" "asterisk"]
|
|
||||||
; ["asterisk" "asterisk" "asterisk"]])
|
|
||||||
|
|
||||||
(def ignores
|
(def ignores
|
||||||
{ ["slash" "asterisk"]
|
{ ["slash" "asterisk"]
|
||||||
@ -50,7 +23,6 @@
|
|||||||
(str
|
(str
|
||||||
" ignore sub slash asterisk' asterisk asterisk;\n"
|
" ignore sub slash asterisk' asterisk asterisk;\n"
|
||||||
" ignore sub asterisk' asterisk asterisk slash;\n")
|
" ignore sub asterisk' asterisk asterisk slash;\n")
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|
||||||
(defn liga->rule
|
(defn liga->rule
|
||||||
@ -93,15 +65,26 @@
|
|||||||
" } 1_2_3_4;")
|
" } 1_2_3_4;")
|
||||||
#"\d" {"1" a "2" b "3" c "4" d}))))
|
#"\d" {"1" a "2" b "3" c "4" d}))))
|
||||||
|
|
||||||
|
(defn -main [& args]
|
||||||
|
(let [file (or (first args) "FiraCode.glyphs")
|
||||||
|
_ (println "Looking for ligatures in" file "...\n")
|
||||||
|
font (parse/parse (slurp file))
|
||||||
|
ligas (for [g (:glyphs font)
|
||||||
|
:let [name (:glyphname g)]
|
||||||
|
:when (str/ends-with? name ".liga")
|
||||||
|
:let [[_ liga] (re-matches #"([a-z_]+)\.liga" name)]]
|
||||||
|
(str/split liga #"_"))] ;; [ ["dash" "greater" "greater"] ... ]
|
||||||
|
|
||||||
(println "### start of generated calt\n")
|
(println "### start of generated calt\n")
|
||||||
(println (->> ligas (sort-by count) (reverse) (map liga->rule) (str/join "\n\n")))
|
(println (->> ligas (sort-by count) (reverse) (map liga->rule) (str/join "\n\n")))
|
||||||
(println "\n### end of generated calt\n")
|
(println "\n### end of generated calt\n")
|
||||||
|
|
||||||
(println "Total ligatures count:" (count ligas))
|
(println "Total ligatures count:" (count ligas))
|
||||||
(println " " (->> ligas
|
(println " " (->> ligas
|
||||||
(group-by count)
|
(group-by count)
|
||||||
(sort-by first)
|
(sort-by first)
|
||||||
(map (fn [[k v]] (str (count v) (case k 2 " pairs", 3 " triples", 4 " quadruples"))))
|
(map (fn [[k v]] (str (count v) (case k 2 " pairs", 3 " triples", 4 " quadruples"))))
|
||||||
(str/join ", ")))
|
(str/join ", ")))
|
||||||
(println)
|
(println)))
|
||||||
|
|
||||||
|
;; (-main)
|
@ -103,8 +103,8 @@
|
|||||||
|
|
||||||
(defn layer [l]
|
(defn layer [l]
|
||||||
{ :id (case (:layerId l)
|
{ :id (case (:layerId l)
|
||||||
(:Regular weights) "Regular"
|
((:Regular weights)) "Regular"
|
||||||
(:Bold weights) "Bold"
|
((:Bold weights)) "Bold"
|
||||||
(:layerId l))
|
(:layerId l))
|
||||||
:width (:width l) })
|
:width (:width l) })
|
||||||
|
|
||||||
|
3
deps.edn
Normal file
3
deps.edn
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
{:paths ["clojure"]
|
||||||
|
:deps {org.clojure/clojure {:mvn/version "1.10.0-alpha8"}
|
||||||
|
fipp/fipp {:mvn/version "0.6.12"}}}
|
@ -1,7 +0,0 @@
|
|||||||
(defproject org.example/sample "1.0.0-SNAPSHOT"
|
|
||||||
:dependencies [
|
|
||||||
[org.clojure/clojure "1.10.0-alpha8"]
|
|
||||||
[fipp "0.6.12"]
|
|
||||||
]
|
|
||||||
:source-paths ["clojure"]
|
|
||||||
)
|
|
Loading…
Reference in New Issue
Block a user