mirror of
https://github.com/penpot/penpot.git
synced 2026-05-24 17:33:41 +00:00
🐛 Fix problem with text data serialization
This commit is contained in:
parent
4f24a8f5f1
commit
33d70f0e45
@ -25,6 +25,8 @@
|
|||||||
(def ^:private fonts
|
(def ^:private fonts
|
||||||
(l/derived :fonts st/state))
|
(l/derived :fonts st/state))
|
||||||
|
|
||||||
|
(def ^:private default-font-size 14)
|
||||||
|
|
||||||
(defn- google-font-id->uuid
|
(defn- google-font-id->uuid
|
||||||
[font-id]
|
[font-id]
|
||||||
(let [font (fonts/get-font-data font-id)]
|
(let [font (fonts/get-font-data font-id)]
|
||||||
@ -182,6 +184,15 @@
|
|||||||
(catch :default _e
|
(catch :default _e
|
||||||
uuid/zero)))
|
uuid/zero)))
|
||||||
|
|
||||||
|
(defn serialize-font-size
|
||||||
|
[font-size]
|
||||||
|
(cond
|
||||||
|
(number? font-size)
|
||||||
|
font-size
|
||||||
|
|
||||||
|
(string? font-size)
|
||||||
|
(or (d/parse-double font-size) default-font-size)))
|
||||||
|
|
||||||
(defn serialize-font-weight
|
(defn serialize-font-weight
|
||||||
[font-weight]
|
[font-weight]
|
||||||
(if (number? font-weight)
|
(if (number? font-weight)
|
||||||
|
|||||||
@ -56,7 +56,9 @@
|
|||||||
text-decoration (sr/translate-text-decoration (get paragraph :text-decoration))
|
text-decoration (sr/translate-text-decoration (get paragraph :text-decoration))
|
||||||
text-transform (sr/translate-text-transform (get paragraph :text-transform))
|
text-transform (sr/translate-text-transform (get paragraph :text-transform))
|
||||||
line-height (get paragraph :line-height 1.2)
|
line-height (get paragraph :line-height 1.2)
|
||||||
letter-spacing (get paragraph :letter-spacing)]
|
line-height (if (not (number? line-height)) 1.2 line-height)
|
||||||
|
letter-spacing (get paragraph :letter-spacing)
|
||||||
|
letter-spacing (if (not (number? letter-spacing)) 0.0 letter-spacing)]
|
||||||
|
|
||||||
(-> offset
|
(-> offset
|
||||||
(mem/write-u8 dview text-align)
|
(mem/write-u8 dview text-align)
|
||||||
@ -77,10 +79,17 @@
|
|||||||
(reduce (fn [offset span]
|
(reduce (fn [offset span]
|
||||||
(let [font-style (sr/translate-font-style (get span :font-style "normal"))
|
(let [font-style (sr/translate-font-style (get span :font-style "normal"))
|
||||||
font-size (get span :font-size paragraph-font-size)
|
font-size (get span :font-size paragraph-font-size)
|
||||||
|
font-size (f/serialize-font-size font-size)
|
||||||
|
|
||||||
line-height (get span :line-height paragraph-line-height)
|
line-height (get span :line-height paragraph-line-height)
|
||||||
|
line-height (if (not (number? line-height)) 1.2 line-height)
|
||||||
|
|
||||||
letter-spacing (get span :letter-spacing 0.0)
|
letter-spacing (get span :letter-spacing 0.0)
|
||||||
|
letter-spacing (if (not (number? letter-spacing)) 0.0 letter-spacing)
|
||||||
|
|
||||||
font-weight (get span :font-weight paragraph-font-weight)
|
font-weight (get span :font-weight paragraph-font-weight)
|
||||||
font-weight (f/serialize-font-weight font-weight)
|
font-weight (f/serialize-font-weight font-weight)
|
||||||
|
|
||||||
font-id (f/normalize-font-id (get span :font-id "sourcesanspro"))
|
font-id (f/normalize-font-id (get span :font-id "sourcesanspro"))
|
||||||
font-family (hash (get span :font-family "sourcesanspro"))
|
font-family (hash (get span :font-family "sourcesanspro"))
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user