1
0
Fork 0
mirror of synced 2024-06-01 18:30:34 +12:00

Fixed glyphs file serializer to match Glyphs nuances

This commit is contained in:
Nikita Prokopov 2019-09-09 17:15:37 +03:00
parent 6a9cfb866f
commit d385788ff6
2 changed files with 14 additions and 9 deletions

View file

@ -1,7 +1,7 @@
{ {
.appVersion = "1131"; .appVersion = "1131";
DisplayStrings = ( DisplayStrings = (
"flask\012Flask\012fiber\012fj\012/f_l.liga lflask\012Tla\012/f_t.liga" "flask\012Flask\012fiber\012fji\012Tla"
); );
classes = ( classes = (
{ {
@ -97,7 +97,6 @@ value = 1;
{ {
name = fsType; name = fsType;
value = ( value = (
); );
}, },
{ {
@ -114923,7 +114922,6 @@ unitsPerEm = 1950;
userData = { userData = {
GSDimensionPlugin.Dimensions = { GSDimensionPlugin.Dimensions = {
"B67F0F2D-EC95-4CB8-966E-23AE86958A69" = { "B67F0F2D-EC95-4CB8-966E-23AE86958A69" = {
}; };
"BF448B58-7A35-489E-A1C9-12628F60690C" = { "BF448B58-7A35-489E-A1C9-12628F60690C" = {
HH = 141; HH = 141;
@ -114947,4 +114945,4 @@ oV = 98;
}; };
versionMajor = 1; versionMajor = 1;
versionMinor = 207; versionMinor = 207;
} }

View file

@ -109,7 +109,7 @@
(def escape-re #"[\n\"\\]") (def escape-re #"[\n\"\\]")
(defn serialize [form] (defn- serialize-impl [form]
(cond (cond
(string? form) (if (re-matches #"[a-zA-Z0-9._/]+" form) (string? form) (if (re-matches #"[a-zA-Z0-9._/]+" form)
form form
@ -118,14 +118,21 @@
(number? form) (str form) (number? form) (str form)
(instance? clojure.lang.MapEntry form) (instance? clojure.lang.MapEntry form)
(str (str
(serialize (key form)) (serialize-impl (key form))
" = " " = "
(if (= ".appVersion" (key form)) ;; https://github.com/googlefonts/glyphsLib/issues/209 (if (= ".appVersion" (key form)) ;; https://github.com/googlefonts/glyphsLib/issues/209
(str \" (val form) \") (str \" (val form) \")
(serialize (val form))) (serialize-impl (val form)))
";") ";")
(sequential? form) (str "(\n" (str/join ",\n" (map serialize form)) "\n)") (sequential? form) (if (empty? form)
(map? form) (str "{\n" (str/join "\n" (map serialize form)) "\n}"))) "(\n)"
(str "(\n" (str/join ",\n" (map serialize-impl form)) "\n)"))
(map? form) (if (empty? form)
"{\n}"
(str "{\n" (str/join "\n" (map serialize-impl form)) "\n}"))))
(defn serialize [font]
(str (serialize-impl font) "\n"))
; (-> (slurp "FiraCode.glyphs") parse serialize (->> (spit "FiraCode_saved.glyphs"))) ; (-> (slurp "FiraCode.glyphs") parse serialize (->> (spit "FiraCode_saved.glyphs")))