0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-03-30 00:21:19 -05:00

Initial work on fontSize rendering on text shapes.

This commit is contained in:
Andrey Antukh 2016-02-27 21:12:40 +02:00
parent 016b43e1a5
commit abed5dd35d

View file

@ -132,6 +132,13 @@
:style {:stroke "#333" :fill "transparent" :style {:stroke "#333" :fill "transparent"
:stroke-opacity "0.4"}}) :stroke-opacity "0.4"}})
(def ^:const +style-attrs+
[:font-size])
(defn- build-style
[{:keys [font-size]}]
(merge {} (when font-size {:fontSize (str font-size "px")})))
(defmethod uusc/render-shape :builtin/text (defmethod uusc/render-shape :builtin/text
[{:keys [id x1 y1 x2 y2 content drawing? editing?] :as shape}] [{:keys [id x1 y1 x2 y2 content drawing? editing?] :as shape}]
(let [key (str id) (let [key (str id)
@ -139,12 +146,14 @@
size (ush/size shape) size (ush/size shape)
props {:x x1 :y y1 props {:x x1 :y y1
:transform (str rfm)} :transform (str rfm)}
attrs (merge props size)] attrs (merge props size)
style (build-style shape)]
(html (html
[:g [:g
(if (or drawing? editing?) (if (or drawing? editing?)
[:g [:g
[:rect (merge attrs +select-rect-attrs+)]]) [:rect (merge attrs +select-rect-attrs+)]])
[:foreignObject attrs [:foreignObject attrs
[:p {:ref "container"} content]]]))) [:p {:ref "container" :style style} content]]])))