mirror of
https://github.com/penpot/penpot.git
synced 2025-12-11 22:14:05 +01:00
🐛 Fix not picking up font style / variant in new renderer
This commit is contained in:
@@ -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)
|
||||
|
||||
|
||||
@@ -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"}]}])
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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]) =>
|
||||
|
||||
Reference in New Issue
Block a user