From 8df93c2707b25649ea48894cf8bb97aa8e8ddc98 Mon Sep 17 00:00:00 2001 From: "alonso.torres" Date: Tue, 10 May 2022 11:50:10 +0200 Subject: [PATCH] :bug: Fix problem when exporting single text --- frontend/src/app/main/render.cljs | 2 +- .../src/app/main/ui/shapes/text/fontfaces.cljs | 15 +++++++++------ .../src/app/main/ui/workspace/shapes/frame.cljs | 2 +- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/frontend/src/app/main/render.cljs b/frontend/src/app/main/render.cljs index 8e3e77da5..ec193c6af 100644 --- a/frontend/src/app/main/render.cljs +++ b/frontend/src/app/main/render.cljs @@ -402,7 +402,7 @@ :style {:-webkit-print-color-adjust :exact} :fill "none"} - (let [fonts (ff/frame->fonts object objects)] + (let [fonts (ff/shape->fonts object objects)] [:& ff/fontfaces-style {:fonts fonts}]) (case (:type object) diff --git a/frontend/src/app/main/ui/shapes/text/fontfaces.cljs b/frontend/src/app/main/ui/shapes/text/fontfaces.cljs index f2a903948..d08ebbb87 100644 --- a/frontend/src/app/main/ui/shapes/text/fontfaces.cljs +++ b/frontend/src/app/main/ui/shapes/text/fontfaces.cljs @@ -73,12 +73,15 @@ (when (d/not-empty? style) [:style style]))) -(defn frame->fonts - [frame objects] - (->> (cph/get-children objects (:id frame)) - (filter cph/text-shape?) - (map (comp fonts/get-content-fonts :content)) - (reduce set/union #{}))) +(defn shape->fonts + [shape objects] + (let [initial (cond-> #{} + (cph/text-shape? shape) + (into (fonts/get-content-fonts (:content shape))))] + (->> (cph/get-children objects (:id shape)) + (filter cph/text-shape?) + (map (comp fonts/get-content-fonts :content)) + (reduce set/union initial)))) (defn shapes->fonts [shapes] diff --git a/frontend/src/app/main/ui/workspace/shapes/frame.cljs b/frontend/src/app/main/ui/workspace/shapes/frame.cljs index 4102bea86..254d6a87e 100644 --- a/frontend/src/app/main/ui/workspace/shapes/frame.cljs +++ b/frontend/src/app/main/ui/workspace/shapes/frame.cljs @@ -61,7 +61,7 @@ thumbnail? (unchecked-get props "thumbnail?") objects (unchecked-get props "objects") - fonts (mf/use-memo (mf/deps shape objects) #(ff/frame->fonts shape objects)) + fonts (mf/use-memo (mf/deps shape objects) #(ff/shape->fonts shape objects)) fonts (-> fonts (hooks/use-equal-memo)) force-render (mf/use-state false)