🐛 Fix problem when exporting single text

This commit is contained in:
alonso.torres 2022-05-10 11:50:10 +02:00
parent 82d744b94a
commit 8df93c2707
3 changed files with 11 additions and 8 deletions

View file

@ -402,7 +402,7 @@
:style {:-webkit-print-color-adjust :exact} :style {:-webkit-print-color-adjust :exact}
:fill "none"} :fill "none"}
(let [fonts (ff/frame->fonts object objects)] (let [fonts (ff/shape->fonts object objects)]
[:& ff/fontfaces-style {:fonts fonts}]) [:& ff/fontfaces-style {:fonts fonts}])
(case (:type object) (case (:type object)

View file

@ -73,12 +73,15 @@
(when (d/not-empty? style) (when (d/not-empty? style)
[:style style]))) [:style style])))
(defn frame->fonts (defn shape->fonts
[frame objects] [shape objects]
(->> (cph/get-children objects (:id frame)) (let [initial (cond-> #{}
(cph/text-shape? shape)
(into (fonts/get-content-fonts (:content shape))))]
(->> (cph/get-children objects (:id shape))
(filter cph/text-shape?) (filter cph/text-shape?)
(map (comp fonts/get-content-fonts :content)) (map (comp fonts/get-content-fonts :content))
(reduce set/union #{}))) (reduce set/union initial))))
(defn shapes->fonts (defn shapes->fonts
[shapes] [shapes]

View file

@ -61,7 +61,7 @@
thumbnail? (unchecked-get props "thumbnail?") thumbnail? (unchecked-get props "thumbnail?")
objects (unchecked-get props "objects") 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)) fonts (-> fonts (hooks/use-equal-memo))
force-render (mf/use-state false) force-render (mf/use-state false)