mirror of
https://github.com/penpot/penpot.git
synced 2025-12-12 06:24:17 +01:00
🐛 Fix problems with text editor size
This commit is contained in:
@@ -321,7 +321,7 @@
|
|||||||
"bottom" (- y (- height (:height selrect)))
|
"bottom" (- y (- height (:height selrect)))
|
||||||
"center" (- y (/ (- height (:height selrect)) 2))
|
"center" (- y (/ (- height (:height selrect)) 2))
|
||||||
y)]
|
y)]
|
||||||
[(assoc selrect :y y :width (:width selrect) :height (:height selrect)) transform])
|
[(assoc selrect :y y :width (:width selrect) :height (max height (:height selrect))) transform])
|
||||||
|
|
||||||
(let [bounds (gst/shape->rect shape)
|
(let [bounds (gst/shape->rect shape)
|
||||||
x (mth/min (dm/get-prop bounds :x)
|
x (mth/min (dm/get-prop bounds :x)
|
||||||
|
|||||||
@@ -26,6 +26,8 @@
|
|||||||
(l/derived :fonts st/state))
|
(l/derived :fonts st/state))
|
||||||
|
|
||||||
(def ^:private default-font-size 14)
|
(def ^:private default-font-size 14)
|
||||||
|
(def ^:private default-line-height 1.2)
|
||||||
|
(def ^:private default-letter-spacing 0.0)
|
||||||
|
|
||||||
(defn- google-font-id->uuid
|
(defn- google-font-id->uuid
|
||||||
[font-id]
|
[font-id]
|
||||||
@@ -221,6 +223,26 @@
|
|||||||
:else
|
:else
|
||||||
400))))
|
400))))
|
||||||
|
|
||||||
|
(defn serialize-line-height
|
||||||
|
([line-height]
|
||||||
|
(serialize-line-height line-height default-line-height))
|
||||||
|
([line-height default-value]
|
||||||
|
(cond
|
||||||
|
(number? line-height)
|
||||||
|
line-height
|
||||||
|
|
||||||
|
(string? line-height)
|
||||||
|
(or (d/parse-double line-height) default-value))))
|
||||||
|
|
||||||
|
(defn serialize-letter-spacing
|
||||||
|
[letter-spacing]
|
||||||
|
(cond
|
||||||
|
(number? letter-spacing)
|
||||||
|
letter-spacing
|
||||||
|
|
||||||
|
(string? letter-spacing)
|
||||||
|
(or (d/parse-double letter-spacing) default-letter-spacing)))
|
||||||
|
|
||||||
(defn store-font
|
(defn store-font
|
||||||
[shape-id font]
|
[shape-id font]
|
||||||
(let [font-id (get font :font-id)
|
(let [font-id (get font :font-id)
|
||||||
|
|||||||
@@ -55,10 +55,8 @@
|
|||||||
text-direction (sr/translate-text-direction (get paragraph :text-direction))
|
text-direction (sr/translate-text-direction (get paragraph :text-direction))
|
||||||
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 (f/serialize-line-height (get paragraph :line-height))
|
||||||
line-height (if (not (number? line-height)) 1.2 line-height)
|
letter-spacing (f/serialize-letter-spacing (get paragraph :letter-spacing))]
|
||||||
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)
|
||||||
@@ -75,17 +73,14 @@
|
|||||||
[offset dview spans paragraph]
|
[offset dview spans paragraph]
|
||||||
(let [paragraph-font-size (get paragraph :font-size)
|
(let [paragraph-font-size (get paragraph :font-size)
|
||||||
paragraph-font-weight (-> paragraph :font-weight f/serialize-font-weight)
|
paragraph-font-weight (-> paragraph :font-weight f/serialize-font-weight)
|
||||||
paragraph-line-height (get paragraph :line-height 1.2)]
|
paragraph-line-height (f/serialize-line-height (get paragraph :line-height))]
|
||||||
(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)
|
font-size (f/serialize-font-size font-size)
|
||||||
|
|
||||||
line-height (get span :line-height paragraph-line-height)
|
line-height (f/serialize-line-height (get span :line-height) paragraph-line-height)
|
||||||
line-height (if (not (number? line-height)) 1.2 line-height)
|
letter-spacing (f/serialize-letter-spacing (get paragraph :letter-spacing))
|
||||||
|
|
||||||
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)
|
||||||
|
|||||||
Reference in New Issue
Block a user