diff --git a/CHANGES.md b/CHANGES.md index 577cd2b3be..433534c025 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -13,6 +13,7 @@ ### :bug: Bugs fixed - Fix problem with booleans selection [Taiga #11627](https://tree.taiga.io/project/penpot/issue/11627) +- Fix missing font when copy&paste a chunk of text [Taiga #11522](https://tree.taiga.io/project/penpot/issue/11522) ## 2.9.0 (Unreleased) diff --git a/frontend/src/app/main/fonts.cljs b/frontend/src/app/main/fonts.cljs index d72b3880cc..7d42607905 100644 --- a/frontend/src/app/main/fonts.cljs +++ b/frontend/src/app/main/fonts.cljs @@ -39,8 +39,8 @@ {:id "300italic" :name "300 (italic)" :weight "300" :style "italic" :suffix "lightitalic" :ttf-url "sourcesanspro-lightitalic.ttf"} {:id "regular" :name "regular" :weight "400" :style "normal" :ttf-url "sourcesanspro-regular.ttf"} {:id "italic" :name "italic" :weight "400" :style "italic" :ttf-url "sourcesanspro-italic.ttf"} - {:id "bold" :name "bold" :weight "bold" :style "normal" :ttf-url "sourcesanspro-bold.ttf"} - {:id "bolditalic" :name "bold (italic)" :weight "bold" :style "italic" :ttf-url "sourcesanspro-bolditalic.ttf"} + {:id "bold" :name "bold" :weight "700" :style "normal" :ttf-url "sourcesanspro-bold.ttf"} + {:id "bolditalic" :name "bold (italic)" :weight "700" :style "italic" :ttf-url "sourcesanspro-bolditalic.ttf"} {:id "black" :name "black" :weight "900" :style "normal" :ttf-url "sourcesanspro-black.ttf"} {:id "blackitalic" :name "black (italic)" :weight "900" :style "italic" :ttf-url "sourcesanspro-blackitalic.ttf"}]}]) diff --git a/frontend/src/app/render_wasm/api/fonts.cljs b/frontend/src/app/render_wasm/api/fonts.cljs index deed99ccf4..0872039b73 100644 --- a/frontend/src/app/render_wasm/api/fonts.cljs +++ b/frontend/src/app/render_wasm/api/fonts.cljs @@ -169,7 +169,31 @@ (defn serialize-font-weight [font-weight] - (js/Number font-weight)) + (if (number? font-weight) + font-weight + (let [font-weight-str (str font-weight)] + (cond + (re-matches #"\d+" font-weight-str) + (js/Number font-weight-str) + + (str/includes? font-weight-str "bold") + 700 + (str/includes? font-weight-str "black") + 900 + (str/includes? font-weight-str "extrabold") + 800 + (str/includes? font-weight-str "extralight") + 200 + (str/includes? font-weight-str "light") + 300 + (str/includes? font-weight-str "medium") + 500 + (str/includes? font-weight-str "semibold") + 600 + (str/includes? font-weight-str "thin") + 100 + :else + 400)))) (defn store-font [shape-id font] @@ -182,6 +206,7 @@ weight (serialize-font-weight raw-weight) style (serialize-font-style (cond (str/includes? font-variant-id "italic") "italic" + (str/includes? raw-weight "italic") "italic" :else "normal")) asset-id (font-id->asset-id font-id font-variant-id) font-data {:wasm-id wasm-id @@ -189,6 +214,7 @@ :font-variant-id font-variant-id :style style :weight weight}] + (store-font-id shape-id font-data asset-id emoji? fallback?))) (defn store-fonts diff --git a/frontend/text-editor/src/editor/TextEditor.js b/frontend/text-editor/src/editor/TextEditor.js index 277ba0eced..0d37fb9eea 100644 --- a/frontend/text-editor/src/editor/TextEditor.js +++ b/frontend/text-editor/src/editor/TextEditor.js @@ -520,7 +520,6 @@ export function createRootFromHTML(html, style) { const fragment = mapContentFragmentFromHTML(html, style); const root = createRoot([], style); root.replaceChildren(fragment); - console.log("ROOT", root); return root; } diff --git a/frontend/text-editor/src/editor/content/dom/Element.js b/frontend/text-editor/src/editor/content/dom/Element.js index a270e076f8..e188270758 100644 --- a/frontend/text-editor/src/editor/content/dom/Element.js +++ b/frontend/text-editor/src/editor/content/dom/Element.js @@ -34,7 +34,6 @@ export function createRandomId() { * @returns {HTMLElement} */ export function createElement(tag, options) { - console.log("createElement", options); const element = document.createElement(tag); if (options?.attributes) { Object.entries(options.attributes).forEach(([name, value]) =>