🐛 Fix problem editing rotated texts

This commit is contained in:
alonso.torres 2022-09-01 12:44:33 +02:00
parent d6317297d7
commit 04d6e76c6c
4 changed files with 43 additions and 25 deletions

View file

@ -4,8 +4,9 @@
### :bug: Bugs fixed ### :bug: Bugs fixed
- Fix error when moving nested frames outside [Taiga #4017] https://tree.taiga.io/project/penpot/issue/4017 - Fix error when moving nested frames outside [Taiga #4017](https://tree.taiga.io/project/penpot/issue/4017)
- Fix problem when hovering over nested frames [Taiga #4018] https://tree.taiga.io/project/penpot/issue/4018 - Fix problem when hovering over nested frames [Taiga #4018](https://tree.taiga.io/project/penpot/issue/4018)
- Fix problem editing rotated texts [Taiga #4026](https://tree.taiga.io/project/penpot/issue/4026)
## 1.15.2-beta ## 1.15.2-beta

View file

@ -17,16 +17,22 @@
:width width :width width
:height height}) :height height})
(defn position-data-points (defn position-data-selrect
[{:keys [position-data] :as shape}] [shape]
(let [points (->> position-data (let [points (->> shape
(mapcat (comp gpr/rect->points position-data->rect))) :position-data
transform (gtr/transform-matrix shape)] (mapcat (comp gpr/rect->points position-data->rect)))]
(gco/transform-points points transform))) (-> points (gpr/points->selrect))))
(defn position-data-bounding-box (defn position-data-bounding-box
[shape] [shape]
(gpr/points->selrect (position-data-points shape))) (let [points (->> shape
:position-data
(mapcat (comp gpr/rect->points position-data->rect)))
transform (gtr/transform-matrix shape)]
(-> points
(gco/transform-points transform)
(gpr/points->selrect ))))
(defn overlaps-position-data? (defn overlaps-position-data?
"Checks if the given position data is inside the shape" "Checks if the given position data is inside the shape"

View file

@ -8,6 +8,8 @@
(:require (:require
[app.common.data :as d] [app.common.data :as d]
[app.common.data.macros :as dm] [app.common.data.macros :as dm]
[app.common.geom.shapes :as gsh]
[app.common.geom.shapes.text :as gsht]
[app.common.math :as mth] [app.common.math :as mth]
[app.main.data.workspace.texts :as dwt] [app.main.data.workspace.texts :as dwt]
[app.main.refs :as refs] [app.main.refs :as refs]
@ -37,19 +39,28 @@
[:& text/text-shape {:shape shape}]] [:& text/text-shape {:shape shape}]]
(when (and (debug? :text-outline) (d/not-empty? (:position-data shape))) (when (and (debug? :text-outline) (d/not-empty? (:position-data shape)))
(for [[index data] (d/enumerate (:position-data shape))] [:g {:transform (gsh/transform-str shape {:no-flip true})}
(let [{:keys [x y width height]} data] (let [bounding-box (gsht/position-data-selrect shape)]
[:g {:key (dm/str index)} [:rect {
;; Text fragment bounding box :x (:x bounding-box)
[:rect {:x x :y (:y bounding-box)
:y (- y height) :width (:width bounding-box)
:width width :height (:height bounding-box)
:height height :style { :fill "none" :stroke "orange"}}])
:style {:fill "none" :stroke "red"}}]
;; Text baselineazo (for [[index data] (d/enumerate (:position-data shape))]
[:line {:x1 (mth/round x) (let [{:keys [x y width height]} data]
:y1 (mth/round (- (:y data) (:height data))) [:g {:key (dm/str index)}
:x2 (mth/round (+ x width)) ;; Text fragment bounding box
:y2 (mth/round (- (:y data) (:height data))) [:rect {:x x
:style {:stroke "blue"}}]])))])) :y (- y height)
:width width
:height height
:style {:fill "none" :stroke "red"}}]
;; Text baselineazo
[:line {:x1 (mth/round x)
:y1 (mth/round (- (:y data) (:height data)))
:x2 (mth/round (+ x width))
:y2 (mth/round (- (:y data) (:height data)))
:style {:stroke "blue"}}]]))])]))

View file

@ -272,7 +272,7 @@
(some? text-modifier) (some? text-modifier)
(dwt/apply-text-modifier text-modifier)) (dwt/apply-text-modifier text-modifier))
bounding-box (gsht/position-data-bounding-box shape) bounding-box (gsht/position-data-selrect shape)
x (min (:x bounding-box) (:x shape)) x (min (:x bounding-box) (:x shape))
y (min (:y bounding-box) (:y shape)) y (min (:y bounding-box) (:y shape))