mirror of
https://github.com/penpot/penpot.git
synced 2025-05-18 11:06:14 +02:00
🐛 Fix problem with font loading
This commit is contained in:
parent
c356ae6de8
commit
46be4ca6d1
1 changed files with 15 additions and 7 deletions
|
@ -7,6 +7,7 @@
|
||||||
(ns app.util.text-svg-position
|
(ns app.util.text-svg-position
|
||||||
(:require
|
(:require
|
||||||
[app.common.data :as d]
|
[app.common.data :as d]
|
||||||
|
[app.common.data.macros :as dm]
|
||||||
[app.common.geom.point :as gpt]
|
[app.common.geom.point :as gpt]
|
||||||
[app.common.transit :as transit]
|
[app.common.transit :as transit]
|
||||||
[app.main.fonts :as fonts]
|
[app.main.fonts :as fonts]
|
||||||
|
@ -43,13 +44,20 @@
|
||||||
[^js node]
|
[^js node]
|
||||||
|
|
||||||
(let [styles (js/getComputedStyle node)
|
(let [styles (js/getComputedStyle node)
|
||||||
font (.getPropertyValue styles "font")]
|
font (.getPropertyValue styles "font")
|
||||||
(if (dom/check-font? font)
|
font (if (or (not font) (empty? font))
|
||||||
(p/resolved font)
|
;; Firefox 95 won't return the font correctly.
|
||||||
(let [font-id (.getPropertyValue styles "--font-id")]
|
;; We can get the font shorthand with the font-size + font-family
|
||||||
|
(dm/str (.getPropertyValue styles "font-size")
|
||||||
|
" "
|
||||||
|
(.getPropertyValue styles "font-family"))
|
||||||
|
font)
|
||||||
|
|
||||||
|
font-id (.getPropertyValue styles "--font-id")]
|
||||||
|
|
||||||
(-> (fonts/ensure-loaded! font-id)
|
(-> (fonts/ensure-loaded! font-id)
|
||||||
(p/then #(when (not (dom/check-font? font))
|
(p/then #(when (not (dom/check-font? font))
|
||||||
(load-font font))))))))
|
(load-font font))))))
|
||||||
|
|
||||||
(defn calc-text-node-positions
|
(defn calc-text-node-positions
|
||||||
[base-node viewport zoom]
|
[base-node viewport zoom]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue