0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-02-11 01:28:30 -05:00

🐛 Fix custom fonts loading on dashboard thumbnails

This commit is contained in:
Andrey Antukh 2022-07-12 09:50:27 +02:00 committed by Alonso Torres
parent 05c8ad8bf9
commit 2b70331630
2 changed files with 40 additions and 31 deletions

View file

@ -40,6 +40,9 @@
- Support for import/export binary format [Taiga #2991](https://tree.taiga.io/project/penpot/us/2991)
### :bug: Bugs fixed
- Fix font rendering on grid thumbnails [Taiga #3473](https://tree.taiga.io/project/penpot/issue/3473)
### :arrow_up: Deps updates
### :heart: Community contributions by (Thank you!)

View file

@ -23,7 +23,7 @@
[okulary.core :as l]
[promesa.core :as p]))
(log/set-level! :warn)
(log/set-level! :info)
(def google-fonts
(preload-gfonts "fonts/gfonts.2022.07.11.json"))
@ -126,8 +126,7 @@
(defmethod load-font :builtin
[{:keys [id ::on-loaded] :as font}]
(log/debug :action "load-font" :font-id id :backend "builtin")
;; (js/console.log "[debug:fonts]: loading builtin font" id)
(log/debug :hint "load-font" :font-id id :backend "builtin")
(when (fn? on-loaded)
(on-loaded id)))
@ -142,7 +141,7 @@
(defmethod load-font :google
[{:keys [id ::on-loaded] :as font}]
(when (exists? js/window)
(log/debug :action "load-font" :font-id id :backend "google")
(log/info :hint "load-font" :font-id id :backend "google")
(let [url (generate-gfonts-url font)]
(load-font-css! url (partial on-loaded id))
nil)))
@ -185,7 +184,7 @@
(defmethod load-font :custom
[{:keys [id ::on-loaded] :as font}]
(when (exists? js/window)
(js/console.log "[debug:fonts]: loading custom font" id)
(log/info :hint "load-font" :font-id id :backend "custom")
(let [css (generate-custom-font-css font)]
(add-font-css! css)
(when (fn? on-loaded)
@ -200,8 +199,15 @@
(p/create (fn [resolve]
(ensure-loaded! id resolve))))
([id on-loaded]
(log/debug :action "try-ensure-loaded!" :font-id id)
(if-not (exists? js/window)
;; If we are in the worker environment, we just mark it as loaded
;; without really loading it.
(do
(swap! loaded conj id)
(p/resolved id))
(when-let [font (get @fontsdb id)]
(log/debug :action "ensure-loaded!" :font-id id :font font)
(cond
;; Font already loaded, we just continue
(contains? @loaded id)
@ -229,7 +235,7 @@
(load-font))))]
(swap! loading assoc id load-p)
load-p)))))
load-p))))))
(defn ready
[cb]