mirror of
https://github.com/penpot/penpot.git
synced 2025-12-24 06:58:34 -05:00
Compare commits
1 Commits
develop
...
azazeln28-
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9929bc12ef |
@@ -641,8 +641,6 @@
|
||||
(f/add-noto-fonts langs))
|
||||
result (f/store-fonts shape-id updated-fonts)]
|
||||
|
||||
(h/call wasm/internal-module "_update_shape_text_layout")
|
||||
|
||||
result)))))
|
||||
|
||||
(defn set-shape-text
|
||||
@@ -760,6 +758,7 @@
|
||||
[pending]
|
||||
(let [event (js/CustomEvent. "wasm:set-objects-finished")
|
||||
pending (-> (d/index-by :key :callback pending) vals)]
|
||||
(prn "pending" pending)
|
||||
(if (not-empty? pending)
|
||||
(->> (rx/from pending)
|
||||
(rx/merge-map (fn [callback] (callback)))
|
||||
|
||||
@@ -84,6 +84,7 @@
|
||||
ptr (h/call wasm/internal-module "_alloc_bytes" size)
|
||||
heap (gobj/get ^js wasm/internal-module "HEAPU8")
|
||||
mem (js/Uint8Array. (.-buffer heap) ptr size)]
|
||||
|
||||
(.set mem (js/Uint8Array. font-array-buffer))
|
||||
(h/call wasm/internal-module "_store_font"
|
||||
(aget shape-id-buffer 0)
|
||||
@@ -131,6 +132,7 @@
|
||||
(when asset-id
|
||||
(let [uri (font-id->ttf-url (:font-id font-data) asset-id (:font-variant-id font-data))
|
||||
id-buffer (uuid/get-u32 (:wasm-id font-data))
|
||||
shape-id-buffer (uuid/get-u32 shape-id)
|
||||
font-data (assoc font-data :family-id-buffer id-buffer)
|
||||
font-stored? (not= 0 (h/call wasm/internal-module "_is_font_uploaded"
|
||||
(aget id-buffer 0)
|
||||
@@ -141,6 +143,11 @@
|
||||
(:style font-data)
|
||||
emoji?))]
|
||||
(when-not font-stored?
|
||||
(h/call wasm/internal-module "_mark_shape"
|
||||
(aget shape-id-buffer 0)
|
||||
(aget shape-id-buffer 1)
|
||||
(aget shape-id-buffer 2)
|
||||
(aget shape-id-buffer 3))
|
||||
(fetch-font shape-id font-data uri emoji? fallback?)))))
|
||||
|
||||
(defn serialize-font-style
|
||||
@@ -217,7 +224,6 @@
|
||||
[shape-id fonts]
|
||||
(keep (fn [font] (store-font shape-id font)) fonts))
|
||||
|
||||
|
||||
(defn add-emoji-font
|
||||
[fonts]
|
||||
(conj fonts {:font-id "gfont-noto-color-emoji"
|
||||
|
||||
@@ -52,6 +52,19 @@ impl FontStore {
|
||||
self.debug_font = debug_font;
|
||||
}
|
||||
|
||||
pub fn list_registered_fonts(&self) {
|
||||
println!("fontmgrs {}", self.font_collection.font_managers_count());
|
||||
if let Some(fallback_font_mgr) = self.font_collection.fallback_manager() {
|
||||
for font in fallback_font_mgr {
|
||||
println!("{:?}", font);
|
||||
}
|
||||
}
|
||||
println!("families {}", self.font_mgr.count_families());
|
||||
for font in self.font_mgr.family_names() {
|
||||
println!("{:?}", font);
|
||||
}
|
||||
}
|
||||
|
||||
pub fn font_provider(&self) -> &textlayout::TypefaceFontProvider {
|
||||
&self.font_provider
|
||||
}
|
||||
|
||||
@@ -5,8 +5,7 @@ mod shapes_pool;
|
||||
pub use shapes_pool::*;
|
||||
|
||||
use crate::render::RenderState;
|
||||
use crate::shapes::Shape;
|
||||
use crate::shapes::StructureEntry;
|
||||
use crate::shapes::{Shape, Type, StructureEntry};
|
||||
use crate::tiles;
|
||||
use crate::uuid::Uuid;
|
||||
|
||||
@@ -24,17 +23,19 @@ pub(crate) struct State {
|
||||
pub modifiers: HashMap<Uuid, skia::Matrix>,
|
||||
pub scale_content: HashMap<Uuid, f32>,
|
||||
pub structure: HashMap<Uuid, Vec<StructureEntry>>,
|
||||
pub marked_shapes: Vec<Uuid>,
|
||||
}
|
||||
|
||||
impl State {
|
||||
pub fn new(width: i32, height: i32) -> Self {
|
||||
State {
|
||||
Self {
|
||||
render_state: RenderState::new(width, height),
|
||||
current_id: None,
|
||||
shapes: ShapesPool::new(),
|
||||
modifiers: HashMap::new(),
|
||||
scale_content: HashMap::new(),
|
||||
structure: HashMap::new(),
|
||||
marked_shapes: Vec::new(),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -56,6 +57,7 @@ impl State {
|
||||
}
|
||||
|
||||
pub fn start_render_loop(&mut self, timestamp: i32) -> Result<(), String> {
|
||||
self.update_marked_shapes();
|
||||
self.render_state.start_render_loop(
|
||||
&self.shapes,
|
||||
&self.modifiers,
|
||||
@@ -220,4 +222,30 @@ impl State {
|
||||
|
||||
None
|
||||
}
|
||||
|
||||
pub fn mark_shape(&mut self, shape_id: Uuid) {
|
||||
println!("mark_shape {}", shape_id);
|
||||
self.marked_shapes.push(shape_id);
|
||||
}
|
||||
|
||||
pub fn has_marked_shapes(&self) -> bool {
|
||||
!self.marked_shapes.is_empty()
|
||||
}
|
||||
|
||||
pub fn update_marked_shapes(&mut self) -> bool {
|
||||
self.render_state.fonts.list_registered_fonts();
|
||||
if !self.has_marked_shapes() {
|
||||
println!("update_marked_shapes -> false");
|
||||
return false;
|
||||
}
|
||||
while let Some(shape_id) = self.marked_shapes.pop() {
|
||||
if let Some(shape) = self.shapes.get_mut(&shape_id) {
|
||||
if let Type::Text(text_content) = &mut shape.shape_type {
|
||||
text_content.update_layout(shape.selrect);
|
||||
}
|
||||
}
|
||||
}
|
||||
println!("update_marked_shapes -> true");
|
||||
true
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,8 @@ use macros::ToJs;
|
||||
|
||||
use crate::mem;
|
||||
use crate::shapes::{GrowType, RawTextData, Type};
|
||||
use crate::{with_current_shape_mut, STATE};
|
||||
use crate::{with_state_mut, with_current_shape_mut, STATE};
|
||||
use crate::utils::uuid_from_u32_quartet;
|
||||
|
||||
#[derive(Debug, PartialEq, Clone, Copy, ToJs)]
|
||||
#[repr(u8)]
|
||||
@@ -89,3 +90,30 @@ pub extern "C" fn update_shape_text_layout() {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn mark_shape(a: u32, b: u32, c: u32, d: u32) {
|
||||
with_state_mut!(state, {
|
||||
let shape_id = uuid_from_u32_quartet(a, b, c, d);
|
||||
state.mark_shape(shape_id);
|
||||
});
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn update_marked_shapes() {
|
||||
with_state_mut!(state, {
|
||||
state.update_marked_shapes();
|
||||
});
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn update_shape_text_layout_for(a: u32, b: u32, c: u32, d: u32) {
|
||||
with_state_mut!(state, {
|
||||
let shape_id = uuid_from_u32_quartet(a, b, c, d);
|
||||
if let Some(shape) = state.shapes.get_mut(&shape_id) {
|
||||
if let Type::Text(text_content) = &mut shape.shape_type {
|
||||
text_content.update_layout(shape.selrect);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user