From abed5dd35d0b87f53eb1c16e3c933de63cb0f0f0 Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Sat, 27 Feb 2016 21:12:40 +0200 Subject: [PATCH] Initial work on fontSize rendering on text shapes. --- src/uxbox/ui/shapes/text.cljs | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/uxbox/ui/shapes/text.cljs b/src/uxbox/ui/shapes/text.cljs index cdffa65e7..66eb9eca2 100644 --- a/src/uxbox/ui/shapes/text.cljs +++ b/src/uxbox/ui/shapes/text.cljs @@ -132,6 +132,13 @@ :style {:stroke "#333" :fill "transparent" :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 [{:keys [id x1 y1 x2 y2 content drawing? editing?] :as shape}] (let [key (str id) @@ -139,12 +146,14 @@ size (ush/size shape) props {:x x1 :y y1 :transform (str rfm)} - attrs (merge props size)] + attrs (merge props size) + style (build-style shape)] + (html [:g (if (or drawing? editing?) [:g [:rect (merge attrs +select-rect-attrs+)]]) [:foreignObject attrs - [:p {:ref "container"} content]]]))) + [:p {:ref "container" :style style} content]]])))