mirror of
https://github.com/penpot/penpot.git
synced 2026-04-25 11:18:36 +00:00
🐛 Fix problem when changing font and grow text
This commit is contained in:
parent
b5922d32ca
commit
e4f0a2d54d
@ -400,7 +400,11 @@
|
||||
shape-ids (cond (cfh/text-shape? shape) [id]
|
||||
(cfh/group-shape? shape) (cfh/get-children-ids objects id))]
|
||||
|
||||
(rx/of (dwsh/update-shapes shape-ids update-fn))))))
|
||||
(rx/concat
|
||||
(rx/of (dwsh/update-shapes shape-ids update-fn))
|
||||
(if (features/active-feature? state "render-wasm/v1")
|
||||
(dwwt/resize-wasm-text-debounce id)
|
||||
(rx/empty)))))))
|
||||
|
||||
(defn update-root-attrs
|
||||
[{:keys [id attrs]}]
|
||||
@ -786,11 +790,18 @@
|
||||
(rx/of (update-position-data id position-data))))
|
||||
(rx/empty))))))
|
||||
|
||||
(defn font-loaded-event?
|
||||
[font-id]
|
||||
(fn [event]
|
||||
(and
|
||||
(= :font-loaded (ptk/type event))
|
||||
(= (:font-id (deref event)) font-id))))
|
||||
|
||||
(defn update-attrs
|
||||
[id attrs]
|
||||
(ptk/reify ::update-attrs
|
||||
ptk/WatchEvent
|
||||
(watch [_ state _]
|
||||
(watch [_ state stream]
|
||||
(let [text-editor-instance (:workspace-editor state)]
|
||||
(if (and (features/active-feature? state "text-editor/v2")
|
||||
(some? text-editor-instance))
|
||||
@ -828,9 +839,13 @@
|
||||
(:shape-id result) (:content result)
|
||||
:update-name? true))))))))
|
||||
;; Resize (with delay for font-id changes)
|
||||
(cond->> (rx/of (dwwt/resize-wasm-text id))
|
||||
(contains? attrs :font-id)
|
||||
(rx/delay 200))))))))
|
||||
(if (contains? attrs :font-id)
|
||||
(->> stream
|
||||
(rx/filter (font-loaded-event? (:font-id attrs)))
|
||||
(rx/take 1)
|
||||
(rx/observe-on :async)
|
||||
(rx/map #(dwwt/resize-wasm-text id)))
|
||||
(rx/of (dwwt/resize-wasm-text id)))))))))
|
||||
|
||||
ptk/EffectEvent
|
||||
(effect [_ state _]
|
||||
|
||||
@ -21,7 +21,8 @@
|
||||
[cuerdas.core :as str]
|
||||
[goog.object :as gobj]
|
||||
[lambdaisland.uri :as u]
|
||||
[okulary.core :as l]))
|
||||
[okulary.core :as l]
|
||||
[potok.v2.core :as ptk]))
|
||||
|
||||
(def ^:private fonts
|
||||
(l/derived :fonts st/state))
|
||||
@ -127,6 +128,7 @@
|
||||
mem (js/Uint8Array. (.-buffer heap) ptr size)]
|
||||
|
||||
(.set mem (js/Uint8Array. font-array-buffer))
|
||||
(st/emit! (ptk/data-event :font-loaded {:font-id (:font-id font-data)}))
|
||||
(h/call wasm/internal-module "_store_font"
|
||||
(aget font-id-buffer 0)
|
||||
(aget font-id-buffer 1)
|
||||
@ -208,7 +210,8 @@
|
||||
id-buffer (uuid/get-u32 (:wasm-id font-data))
|
||||
font-data (assoc font-data :family-id-buffer id-buffer)
|
||||
font-stored? (font-stored? font-data emoji?)]
|
||||
(when-not font-stored?
|
||||
(if font-stored?
|
||||
(st/async-emit! (ptk/data-event :font-loaded {:font-id (:font-id font-data)}))
|
||||
(fetch-font font-data uri emoji? fallback?)))))
|
||||
|
||||
(defn serialize-font-style
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user