mirror of
https://github.com/penpot/penpot.git
synced 2025-02-10 17:18:21 -05:00
🐛 Fix font uploading issue on windows.
This commit is contained in:
parent
a9cf4dad82
commit
3532263af4
2 changed files with 21 additions and 5 deletions
|
@ -6,6 +6,7 @@
|
||||||
|
|
||||||
(ns app.rpc.mutations.fonts
|
(ns app.rpc.mutations.fonts
|
||||||
(:require
|
(:require
|
||||||
|
[app.common.exceptions :as ex]
|
||||||
[app.common.spec :as us]
|
[app.common.spec :as us]
|
||||||
[app.common.uuid :as uuid]
|
[app.common.uuid :as uuid]
|
||||||
[app.config :as cf]
|
[app.config :as cf]
|
||||||
|
@ -49,6 +50,7 @@
|
||||||
(let [data (media/run cfg {:cmd :generate-fonts :input data :rlimit :font})
|
(let [data (media/run cfg {:cmd :generate-fonts :input data :rlimit :font})
|
||||||
storage (media/configure-assets-storage storage conn)
|
storage (media/configure-assets-storage storage conn)
|
||||||
|
|
||||||
|
|
||||||
otf (when-let [fdata (get data "font/otf")]
|
otf (when-let [fdata (get data "font/otf")]
|
||||||
(sto/put-object storage {:content (sto/content fdata)
|
(sto/put-object storage {:content (sto/content fdata)
|
||||||
:content-type "font/otf"}))
|
:content-type "font/otf"}))
|
||||||
|
@ -65,6 +67,13 @@
|
||||||
(sto/put-object storage {:content (sto/content fdata)
|
(sto/put-object storage {:content (sto/content fdata)
|
||||||
:content-type "font/woff2"}))]
|
:content-type "font/woff2"}))]
|
||||||
|
|
||||||
|
(when (and (nil? otf)
|
||||||
|
(nil? ttf)
|
||||||
|
(nil? woff1)
|
||||||
|
(nil? woff2))
|
||||||
|
(ex/raise :type :validation
|
||||||
|
:code :invalid-font-upload))
|
||||||
|
|
||||||
(db/insert! conn :team-font-variant
|
(db/insert! conn :team-font-variant
|
||||||
{:id (uuid/next)
|
{:id (uuid/next)
|
||||||
:team-id (:team-id params)
|
:team-id (:team-id params)
|
||||||
|
|
|
@ -111,10 +111,13 @@
|
||||||
(:data content)})
|
(:data content)})
|
||||||
(dissoc :content)))))))
|
(dissoc :content)))))))
|
||||||
|
|
||||||
(parse-mtype [mtype]
|
(parse-mtype [ba]
|
||||||
(case mtype
|
(let [u8 (js/Uint8Array. ba 0 4)
|
||||||
"application/vnd.oasis.opendocument.formula-template" "font/otf"
|
sg (areduce u8 i ret "" (str ret (if (zero? i) "" " ") (.toString (aget u8 i) 8)))]
|
||||||
mtype))
|
(case sg
|
||||||
|
"117 124 124 117" "font/otf"
|
||||||
|
"0 1 0 0" "font/ttf"
|
||||||
|
"167 117 106 106" "font/woff")))
|
||||||
|
|
||||||
(parse-font [{:keys [data] :as params}]
|
(parse-font [{:keys [data] :as params}]
|
||||||
(try
|
(try
|
||||||
|
@ -128,7 +131,11 @@
|
||||||
(rx/map (fn [data]
|
(rx/map (fn [data]
|
||||||
{:data data
|
{:data data
|
||||||
:name (.-name blob)
|
:name (.-name blob)
|
||||||
:type (parse-mtype (.-type blob))}))))]
|
:type (parse-mtype data)}))
|
||||||
|
(rx/mapcat (fn [{:keys [type] :as font}]
|
||||||
|
(if type
|
||||||
|
(rx/of font)
|
||||||
|
(rx/empty))))))]
|
||||||
|
|
||||||
(->> (rx/from blobs)
|
(->> (rx/from blobs)
|
||||||
(rx/mapcat read-blob)
|
(rx/mapcat read-blob)
|
||||||
|
|
Loading…
Add table
Reference in a new issue