1
0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-05-25 21:56:13 +02:00

🐛 Fix problem with text displacement in Safari

This commit is contained in:
alonso.torres 2022-03-24 16:56:30 +01:00
parent 6e36f66dde
commit 5aa68c7052
3 changed files with 25 additions and 3 deletions
frontend/src
app/main/ui
shapes/text
workspace/shapes
debug.cljs

View file

@ -51,8 +51,8 @@
[:> :g group-props [:> :g group-props
(for [[index data] (d/enumerate position-data)] (for [[index data] (d/enumerate position-data)]
(let [props (-> #js {:x (mth/round (:x data)) (let [props (-> #js {:x (mth/round (:x data))
:y (mth/round (:y data)) :y (mth/round (- (:y data) (:height data)))
:dominantBaseline "ideographic" :alignmentBaseline "text-before-edge"
:style (-> #js {:fontFamily (:font-family data) :style (-> #js {:fontFamily (:font-family data)
:fontSize (:font-size data) :fontSize (:font-size data)
:fontWeight (:font-weight data) :fontWeight (:font-weight data)

View file

@ -27,6 +27,7 @@
[app.util.timers :as timers] [app.util.timers :as timers]
[app.util.webapi :as wapi] [app.util.webapi :as wapi]
[beicon.core :as rx] [beicon.core :as rx]
[debug :refer [debug?]]
[okulary.core :as l] [okulary.core :as l]
[rumext.alpha :as mf])) [rumext.alpha :as mf]))
@ -224,4 +225,22 @@
(when show-svg-text? (when show-svg-text?
[:g.text-svg {:pointer-events "none"} [:g.text-svg {:pointer-events "none"}
[:& svg/text-shape {:shape shape}]])]])) [:& svg/text-shape {:shape shape}]])
(when (debug? :text-outline)
(for [data (:position-data shape)]
(let [{:keys [x y width height]} data]
[:*
;; Text fragment bounding box
[:rect {:x x
: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

@ -46,6 +46,9 @@
;; When active we can check in the browser the export values ;; When active we can check in the browser the export values
:show-export-metadata :show-export-metadata
;; Show text fragments outlines
:text-outline
}) })
;; These events are excluded when we activate the :events flag ;; These events are excluded when we activate the :events flag