Merge pull request #7799 from penpot/alotor-fix-text-data-problem

🐛 Fix problem with text data serialization
This commit is contained in:
Elena Torró 2025-11-21 12:30:35 +01:00 committed by GitHub
commit a1f11c89f2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 21 additions and 1 deletions

View File

@ -25,6 +25,8 @@
(def ^:private fonts
(l/derived :fonts st/state))
(def ^:private default-font-size 14)
(defn- google-font-id->uuid
[font-id]
(let [font (fonts/get-font-data font-id)]
@ -182,6 +184,15 @@
(catch :default _e
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
[font-weight]
(if (number? font-weight)

View File

@ -56,7 +56,9 @@
text-decoration (sr/translate-text-decoration (get paragraph :text-decoration))
text-transform (sr/translate-text-transform (get paragraph :text-transform))
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
(mem/write-u8 dview text-align)
@ -77,10 +79,17 @@
(reduce (fn [offset span]
(let [font-style (sr/translate-font-style (get span :font-style "normal"))
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 (if (not (number? line-height)) 1.2 line-height)
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 (f/serialize-font-weight font-weight)
font-id (f/normalize-font-id (get span :font-id "sourcesanspro"))
font-family (hash (get span :font-family "sourcesanspro"))