mirror of
https://github.com/penpot/penpot.git
synced 2025-05-28 21:46:12 +02:00
Merge pull request #6445 from penpot/elenatorro-11044-fix-parsing-text-spaces
🐛 Fix parsing text spaces
This commit is contained in:
commit
15e9d92094
3 changed files with 9 additions and 10 deletions
|
@ -1194,6 +1194,4 @@
|
||||||
origin
|
origin
|
||||||
(:transform shape (gmt/matrix))
|
(:transform shape (gmt/matrix))
|
||||||
(:transform-inverse shape (gmt/matrix)))}}]
|
(:transform-inverse shape (gmt/matrix)))}}]
|
||||||
|
|
||||||
(.log js/console (clj->js modifiers))
|
|
||||||
(rx/of (dwm/set-wasm-modifiers modifiers))))))
|
(rx/of (dwm/set-wasm-modifiers modifiers))))))
|
||||||
|
|
|
@ -10,8 +10,7 @@
|
||||||
[app.render-wasm.helpers :as h]
|
[app.render-wasm.helpers :as h]
|
||||||
[app.render-wasm.mem :as mem]
|
[app.render-wasm.mem :as mem]
|
||||||
[app.render-wasm.serializers :as sr]
|
[app.render-wasm.serializers :as sr]
|
||||||
[app.render-wasm.wasm :as wasm]
|
[app.render-wasm.wasm :as wasm]))
|
||||||
[clojure.string :as str]))
|
|
||||||
|
|
||||||
(defn utf8->buffer [text]
|
(defn utf8->buffer [text]
|
||||||
(let [encoder (js/TextEncoder.)]
|
(let [encoder (js/TextEncoder.)]
|
||||||
|
@ -21,8 +20,7 @@
|
||||||
;; buffer has the following format:
|
;; buffer has the following format:
|
||||||
;; [<num-leaves> <paragraph_attributes> <leaves_attributes> <text>]
|
;; [<num-leaves> <paragraph_attributes> <leaves_attributes> <text>]
|
||||||
[leaves paragraph text]
|
[leaves paragraph text]
|
||||||
(let [leaves (filter #(not (str/blank? (:text %))) leaves)
|
(let [num-leaves (count leaves)
|
||||||
num-leaves (count leaves)
|
|
||||||
paragraph-attr-size 48
|
paragraph-attr-size 48
|
||||||
leaf-attr-size 52
|
leaf-attr-size 52
|
||||||
metadata-size (+ 1 paragraph-attr-size (* num-leaves leaf-attr-size))
|
metadata-size (+ 1 paragraph-attr-size (* num-leaves leaf-attr-size))
|
||||||
|
|
|
@ -125,10 +125,10 @@ impl TextContent {
|
||||||
let text: String = leaf.apply_text_transform(paragraph.text_transform);
|
let text: String = leaf.apply_text_transform(paragraph.text_transform);
|
||||||
builder.push_style(&stroke_style);
|
builder.push_style(&stroke_style);
|
||||||
builder.add_text(&text);
|
builder.add_text(&text);
|
||||||
let p = builder.build();
|
builder.pop();
|
||||||
stroke_paragraphs.push(p);
|
|
||||||
}
|
}
|
||||||
builder.reset();
|
let p = builder.build();
|
||||||
|
stroke_paragraphs.push(p);
|
||||||
}
|
}
|
||||||
paragraph_group.push(stroke_paragraphs);
|
paragraph_group.push(stroke_paragraphs);
|
||||||
}
|
}
|
||||||
|
@ -451,8 +451,11 @@ impl RawTextData {
|
||||||
}
|
}
|
||||||
|
|
||||||
let text_utf8 = buffer[offset..text_end].to_vec();
|
let text_utf8 = buffer[offset..text_end].to_vec();
|
||||||
let text = String::from_utf8(text_utf8).expect("Invalid UTF-8 text");
|
if text_utf8.is_empty() {
|
||||||
|
return (String::new(), text_end);
|
||||||
|
}
|
||||||
|
|
||||||
|
let text = String::from_utf8_lossy(&text_utf8).to_string();
|
||||||
(text, text_end)
|
(text, text_end)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue