diff --git a/frontend/src/app/main/data/workspace/texts.cljs b/frontend/src/app/main/data/workspace/texts.cljs index eb6a3bf496..04e52d322b 100644 --- a/frontend/src/app/main/data/workspace/texts.cljs +++ b/frontend/src/app/main/data/workspace/texts.cljs @@ -58,13 +58,13 @@ ([{:keys [id points selrect] :as shape} content] (wasm.api/use-shape id) (wasm.api/set-shape-text id content) - (let [dimension (wasm.api/text-dimensions) - resize-v - (gpt/point - (/ (:width dimension) (-> selrect :width)) - (/ (:height dimension) (-> selrect :height))) + (let [dimension (wasm.api/get-text-dimensions) + resize-v (gpt/point + (/ (:width dimension) (-> selrect :width)) + (/ (:height dimension) (-> selrect :height))) + + origin (first points)] - origin (first points)] {id {:modifiers (ctm/resize-modifiers diff --git a/frontend/src/app/main/ui/workspace/shapes/text/text_edition_outline.cljs b/frontend/src/app/main/ui/workspace/shapes/text/text_edition_outline.cljs index 6974114acb..6214bf64b4 100644 --- a/frontend/src/app/main/ui/workspace/shapes/text/text_edition_outline.cljs +++ b/frontend/src/app/main/ui/workspace/shapes/text/text_edition_outline.cljs @@ -19,7 +19,7 @@ (if (features/active-feature? @st/state "render-wasm/v1") (let [transform (gsh/transform-str shape) {:keys [id x y grow-type]} shape - {:keys [width height]} (if (= :fixed grow-type) shape (wasm.api/text-dimensions id))] + {:keys [width height]} (if (= :fixed grow-type) shape (wasm.api/get-text-dimensions id))] [:rect.main.viewport-selrect {:x x :y y diff --git a/frontend/src/app/main/ui/workspace/shapes/text/v2_editor.cljs b/frontend/src/app/main/ui/workspace/shapes/text/v2_editor.cljs index ca9c94db4c..af15827efc 100644 --- a/frontend/src/app/main/ui/workspace/shapes/text/v2_editor.cljs +++ b/frontend/src/app/main/ui/workspace/shapes/text/v2_editor.cljs @@ -310,7 +310,7 @@ [x y width height] (if (features/active-feature? @st/state "render-wasm/v1") - (let [{:keys [max-width height]} (wasm.api/text-dimensions shape-id) + (let [{:keys [max-width height]} (wasm.api/get-text-dimensions shape-id) {:keys [x y]} (:selrect shape)] [x y max-width height]) diff --git a/frontend/src/app/main/ui/workspace/viewport_wasm.cljs b/frontend/src/app/main/ui/workspace/viewport_wasm.cljs index 58ed2be049..3ebfd80860 100644 --- a/frontend/src/app/main/ui/workspace/viewport_wasm.cljs +++ b/frontend/src/app/main/ui/workspace/viewport_wasm.cljs @@ -309,7 +309,7 @@ (ted/export-content))] (wasm.api/use-shape edition) (wasm.api/set-shape-text-content edition content) - (let [dimension (wasm.api/text-dimensions)] + (let [dimension (wasm.api/get-text-dimensions)] (st/emit! (dwt/resize-text-editor edition dimension)) (wasm.api/clear-drawing-cache) (wasm.api/request-render "content")))))) diff --git a/frontend/src/app/render_wasm/api.cljs b/frontend/src/app/render_wasm/api.cljs index 699a0afb4f..afa8a8221a 100644 --- a/frontend/src/app/render_wasm/api.cljs +++ b/frontend/src/app/render_wasm/api.cljs @@ -645,6 +645,7 @@ fonts (fonts/get-content-fonts content) emoji? (atom false) languages (atom #{})] + (loop [index 0] (when (< index (count paragraphs)) (let [paragraph (nth paragraphs index) @@ -673,16 +674,17 @@ [grow-type] (h/call wasm/internal-module "_set_shape_grow_type" (sr/translate-grow-type grow-type))) -(defn text-dimensions +(defn get-text-dimensions ([id] (use-shape id) - (text-dimensions)) + (get-text-dimensions)) ([] - (let [offset (h/call wasm/internal-module "_get_text_dimensions") - heapf32 (mem/get-heap-f32) - width (aget heapf32 (mem/->offset-32 offset)) - height (aget heapf32 (mem/->offset-32 (+ offset 4))) - max-width (aget heapf32 (mem/->offset-32 (+ offset 8)))] + (let [offset (-> (h/call wasm/internal-module "_get_text_dimensions") + (mem/->offset-32)) + heapf32 (mem/get-heap-f32) + width (aget heapf32 (+ offset 0)) + height (aget heapf32 (+ offset 1)) + max-width (aget heapf32 (+ offset 2))] (mem/free) {:width width :height height :max-width max-width}))) @@ -776,7 +778,6 @@ (perf/end-measure "set-object") pending))) - (defn process-pending [pending] (let [event (js/CustomEvent. "wasm:set-objects-finished")