mirror of
https://github.com/penpot/penpot.git
synced 2025-01-24 15:39:50 -05:00
🐛 Fix woff2 generation
This commit is contained in:
parent
38468d7584
commit
f67c4ddca0
3 changed files with 6 additions and 22 deletions
|
@ -229,17 +229,6 @@
|
||||||
(when (zero? (:exit res))
|
(when (zero? (:exit res))
|
||||||
foutput)))
|
foutput)))
|
||||||
|
|
||||||
(ttf-or-otf->woff2 [data]
|
|
||||||
;; NOTE: foutput is not used directly, it represents the
|
|
||||||
;; default output of the exection of the underlying
|
|
||||||
;; command.
|
|
||||||
(let [finput (tmp/tempfile :prefix "penpot.font." :suffix ".tmp")
|
|
||||||
foutput (fs/path (str (fs/base finput) ".woff2"))
|
|
||||||
_ (bs/write-to-file! data finput)
|
|
||||||
res (sh/sh "woff2_compress" (str finput))]
|
|
||||||
(when (zero? (:exit res))
|
|
||||||
foutput)))
|
|
||||||
|
|
||||||
(woff->sfnt [data]
|
(woff->sfnt [data]
|
||||||
(let [finput (tmp/tempfile :prefix "penpot" :suffix "")
|
(let [finput (tmp/tempfile :prefix "penpot" :suffix "")
|
||||||
_ (bs/write-to-file! data finput)
|
_ (bs/write-to-file! data finput)
|
||||||
|
@ -271,15 +260,13 @@
|
||||||
(let [data (get input "font/ttf")]
|
(let [data (get input "font/ttf")]
|
||||||
(-> input
|
(-> input
|
||||||
(update "font/otf" gen-if-nil #(ttf->otf data))
|
(update "font/otf" gen-if-nil #(ttf->otf data))
|
||||||
(update "font/woff" gen-if-nil #(ttf-or-otf->woff data))
|
(update "font/woff" gen-if-nil #(ttf-or-otf->woff data))))
|
||||||
(assoc "font/woff2" (ttf-or-otf->woff2 data))))
|
|
||||||
|
|
||||||
(contains? current "font/otf")
|
(contains? current "font/otf")
|
||||||
(let [data (get input "font/otf")]
|
(let [data (get input "font/otf")]
|
||||||
(-> input
|
(-> input
|
||||||
(update "font/woff" gen-if-nil #(ttf-or-otf->woff data))
|
(update "font/woff" gen-if-nil #(ttf-or-otf->woff data))
|
||||||
(assoc "font/ttf" (otf->ttf data))
|
(assoc "font/ttf" (otf->ttf data))))
|
||||||
(assoc "font/woff2" (ttf-or-otf->woff2 data))))
|
|
||||||
|
|
||||||
(contains? current "font/woff")
|
(contains? current "font/woff")
|
||||||
(let [data (get input "font/woff")
|
(let [data (get input "font/woff")
|
||||||
|
@ -291,8 +278,7 @@
|
||||||
(let [stype (get-sfnt-type sfnt)]
|
(let [stype (get-sfnt-type sfnt)]
|
||||||
(cond-> input
|
(cond-> input
|
||||||
true
|
true
|
||||||
(-> (assoc "font/woff" data)
|
(-> (assoc "font/woff" data))
|
||||||
(assoc "font/woff2" (ttf-or-otf->woff2 sfnt)))
|
|
||||||
|
|
||||||
(= stype :otf)
|
(= stype :otf)
|
||||||
(-> (assoc "font/otf" sfnt)
|
(-> (assoc "font/otf" sfnt)
|
||||||
|
|
|
@ -46,7 +46,6 @@
|
||||||
(t/is (uuid? (:ttf-file-id result)))
|
(t/is (uuid? (:ttf-file-id result)))
|
||||||
(t/is (uuid? (:otf-file-id result)))
|
(t/is (uuid? (:otf-file-id result)))
|
||||||
(t/is (uuid? (:woff1-file-id result)))
|
(t/is (uuid? (:woff1-file-id result)))
|
||||||
(t/is (uuid? (:woff2-file-id result)))
|
|
||||||
(t/are [k] (= (get params k)
|
(t/are [k] (= (get params k)
|
||||||
(get result k))
|
(get result k))
|
||||||
:team-id
|
:team-id
|
||||||
|
@ -82,7 +81,6 @@
|
||||||
(t/is (uuid? (:ttf-file-id result)))
|
(t/is (uuid? (:ttf-file-id result)))
|
||||||
(t/is (uuid? (:otf-file-id result)))
|
(t/is (uuid? (:otf-file-id result)))
|
||||||
(t/is (uuid? (:woff1-file-id result)))
|
(t/is (uuid? (:woff1-file-id result)))
|
||||||
(t/is (uuid? (:woff2-file-id result)))
|
|
||||||
(t/are [k] (= (get params k)
|
(t/are [k] (= (get params k)
|
||||||
(get result k))
|
(get result k))
|
||||||
:team-id
|
:team-id
|
||||||
|
|
|
@ -233,7 +233,7 @@
|
||||||
;; run the touched gc task
|
;; run the touched gc task
|
||||||
(let [task (:app.storage/gc-touched-task th/*system*)
|
(let [task (:app.storage/gc-touched-task th/*system*)
|
||||||
res (task {})]
|
res (task {})]
|
||||||
(t/is (= 6 (:freeze res)))
|
(t/is (= 5 (:freeze res)))
|
||||||
(t/is (= 0 (:delete res)))
|
(t/is (= 0 (:delete res)))
|
||||||
|
|
||||||
(let [result-1 (:result out1)
|
(let [result-1 (:result out1)
|
||||||
|
@ -248,7 +248,7 @@
|
||||||
;; Run the task again
|
;; Run the task again
|
||||||
(let [res (task {})]
|
(let [res (task {})]
|
||||||
(t/is (= 2 (:freeze res)))
|
(t/is (= 2 (:freeze res)))
|
||||||
(t/is (= 4 (:delete res))))
|
(t/is (= 3 (:delete res))))
|
||||||
|
|
||||||
;; now check that there are no touched objects
|
;; now check that there are no touched objects
|
||||||
(let [res (db/exec-one! th/*pool* ["select count(*) from storage_object where touched_at is not null"])]
|
(let [res (db/exec-one! th/*pool* ["select count(*) from storage_object where touched_at is not null"])]
|
||||||
|
@ -256,7 +256,7 @@
|
||||||
|
|
||||||
;; now check that all objects are marked to be deleted
|
;; now check that all objects are marked to be deleted
|
||||||
(let [res (db/exec-one! th/*pool* ["select count(*) from storage_object where deleted_at is not null"])]
|
(let [res (db/exec-one! th/*pool* ["select count(*) from storage_object where deleted_at is not null"])]
|
||||||
(t/is (= 4 (:count res))))))))
|
(t/is (= 3 (:count res))))))))
|
||||||
|
|
||||||
(t/deftest test-touched-gc-task-3
|
(t/deftest test-touched-gc-task-3
|
||||||
(let [storage (-> (:app.storage/storage th/*system*)
|
(let [storage (-> (:app.storage/storage th/*system*)
|
||||||
|
|
Loading…
Add table
Reference in a new issue