0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-01-24 07:29:08 -05:00

Merge pull request #3574 from penpot/azazeln28-fix-text-shapes-rendered-with-bad-proportions

🐛 Fix text shapes rendered with bad proportions
This commit is contained in:
Alejandro 2023-08-31 12:10:36 +02:00 committed by GitHub
commit c53b6117c0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 24 additions and 18 deletions

View file

@ -6,6 +6,7 @@
- List view is discarded on tab change on Workspace Assets Sidebar tab [Github #3547](https://github.com/penpot/penpot/issues/3547)
- Fix message popup remains open when exiting workspace with browser back button [Taiga #5747](https://tree.taiga.io/project/penpot/issue/5747)
- When editing text if font is changed, the proportions of the rendered shape are wrong [Taiga #5786](https://tree.taiga.io/project/penpot/issue/5786)
## 1.19.2

View file

@ -26,6 +26,7 @@
[app.util.object :as obj]
[app.util.text-editor :as ted]
[app.util.text-svg-position :as tsp]
[app.util.timers :as ts]
[promesa.core :as p]
[rumext.v2 :as mf]))
@ -79,25 +80,29 @@
(defn- update-text-modifier
[{:keys [grow-type id] :as shape} node]
(->> (tsp/calc-position-data id)
(p/fmap (fn [position-data]
(let [props {:position-data position-data}]
(if (contains? #{:auto-height :auto-width} grow-type)
(let [{:keys [width height]} (-> (dom/query node ".paragraph-set") (dom/get-client-size))
width (mth/ceil width)
height (mth/ceil height)]
(if (and (not (mth/almost-zero? width)) (not (mth/almost-zero? height)))
(cond-> props
(= grow-type :auto-width)
(assoc :width width)
(p/let [position-data (tsp/calc-position-data id)
props {:position-data position-data}
props
(if (contains? #{:auto-height :auto-width} grow-type)
(let [{:keys [width height]} (-> (dom/query node ".paragraph-set") (dom/get-client-size))
width (mth/ceil width)
height (mth/ceil height)]
(if (and (not (mth/almost-zero? width)) (not (mth/almost-zero? height)))
(cond-> props
(= grow-type :auto-width)
(assoc :width width)
(or (= grow-type :auto-height) (= grow-type :auto-width))
(assoc :height height))
props))
props)]
(st/emit! (dwt/update-text-modifier id props))))
(or (= grow-type :auto-height) (= grow-type :auto-width))
(assoc :height height))
props))
props))))
(p/fmap (fn [props]
;; We need to wait for the text modifier to be updated before
;; we can update the position data. Otherwise the position data
;; will be wrong.
;; TODO: This is a hack. We need to find a better way to do this.
(st/emit! (dwt/update-text-modifier id props))
(ts/schedule 30 #(update-text-shape shape node))))))
(mf/defc text-container
{::mf/wrap-props false