Skip to content

Commit 9705206

Browse files
chore
1 parent ab7e0f4 commit 9705206

File tree

14 files changed

+128
-96
lines changed

14 files changed

+128
-96
lines changed

crates/grida-canvas-fonts/examples/ttf_parser_chained_sequence_features.rs

Lines changed: 2 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -102,9 +102,7 @@ fn main() {
102102
#[derive(Debug, Clone)]
103103
struct ChainedFeature {
104104
pub tag: String,
105-
pub name: String,
106105
pub glyphs: Vec<String>,
107-
pub source_table: String,
108106
}
109107

110108
fn build_glyph_map(face: &ttf_parser::Face) -> std::collections::HashMap<u16, char> {
@@ -150,7 +148,7 @@ fn extract_features_via_chained_sequences(
150148
}
151149

152150
fn extract_gsub_features_simplified(
153-
face: &ttf_parser::Face,
151+
_face: &ttf_parser::Face,
154152
gsub_table: ttf_parser::opentype_layout::LayoutTable,
155153
glyph_map: &std::collections::HashMap<u16, char>,
156154
) -> Vec<ChainedFeature> {
@@ -160,7 +158,6 @@ fn extract_gsub_features_simplified(
160158
for i in 0..gsub_table.features.len() {
161159
if let Some(feature) = gsub_table.features.get(i as u16) {
162160
let tag = feature.tag.to_string();
163-
let name = get_feature_name_from_font(face, &tag);
164161

165162
// Extract glyphs from all lookups in this feature
166163
let mut all_glyphs = std::collections::HashSet::new();
@@ -224,9 +221,7 @@ fn extract_gsub_features_simplified(
224221

225222
features.push(ChainedFeature {
226223
tag,
227-
name,
228224
glyphs: glyph_chars,
229-
source_table: "GSUB".to_string(),
230225
});
231226
}
232227
}
@@ -235,7 +230,7 @@ fn extract_gsub_features_simplified(
235230
}
236231

237232
fn extract_gpos_features_simplified(
238-
face: &ttf_parser::Face,
233+
_face: &ttf_parser::Face,
239234
gpos_table: ttf_parser::opentype_layout::LayoutTable,
240235
glyph_map: &std::collections::HashMap<u16, char>,
241236
) -> Vec<ChainedFeature> {
@@ -245,7 +240,6 @@ fn extract_gpos_features_simplified(
245240
for i in 0..gpos_table.features.len() {
246241
if let Some(feature) = gpos_table.features.get(i as u16) {
247242
let tag = feature.tag.to_string();
248-
let name = get_feature_name_from_font(face, &tag);
249243

250244
// Extract glyphs from all lookups in this feature
251245
let mut all_glyphs = std::collections::HashSet::new();
@@ -301,9 +295,7 @@ fn extract_gpos_features_simplified(
301295

302296
features.push(ChainedFeature {
303297
tag,
304-
name,
305298
glyphs: glyph_chars,
306-
source_table: "GPOS".to_string(),
307299
});
308300
}
309301
}
@@ -337,31 +329,3 @@ fn extract_coverage_glyphs(coverage: &ttf_parser::opentype_layout::Coverage) ->
337329

338330
glyphs
339331
}
340-
341-
fn get_feature_name_from_font(_face: &ttf_parser::Face, tag: &str) -> String {
342-
// Simplified feature name mapping
343-
match tag {
344-
"kern" => "Kerning".to_string(),
345-
"liga" => "Ligatures".to_string(),
346-
"ss01" => "Stylistic Set 1".to_string(),
347-
"cv01" => "Character Variant 1".to_string(),
348-
"locl" => "Localized Forms".to_string(),
349-
"zero" => "Slashed Zero".to_string(),
350-
"sinf" => "Scientific Inferiors".to_string(),
351-
"aalt" => "Access All Alternates".to_string(),
352-
"numr" => "Numerators".to_string(),
353-
"ordn" => "Ordinals".to_string(),
354-
"case" => "Case-Sensitive Forms".to_string(),
355-
"pnum" => "Proportional Numbers".to_string(),
356-
"ccmp" => "Glyph Composition/Decomposition".to_string(),
357-
"dlig" => "Discretionary Ligatures".to_string(),
358-
"sups" => "Superscript".to_string(),
359-
"tnum" => "Tabular Numbers".to_string(),
360-
"subs" => "Subscript".to_string(),
361-
"salt" => "Stylistic Alternates".to_string(),
362-
"dnom" => "Denominators".to_string(),
363-
"frac" => "Fractions".to_string(),
364-
"calt" => "Contextual Alternates".to_string(),
365-
_ => format!("Feature {}", tag),
366-
}
367-
}

crates/grida-canvas/examples/bench_cache_picture.rs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -216,9 +216,6 @@ fn main() {
216216
let surface = unsafe { &mut *surface_ptr };
217217
let size = window.inner_size();
218218
let scene = CachedScene::new(size.width as f32, size.height as f32);
219-
let mut camera_x = 0.0;
220-
let mut camera_y = 0.0;
221-
let mut zoom = 1.0;
222219
let start_time = Instant::now();
223220
let mut frame_count = 0;
224221
let mut last_fps_time = Instant::now();
@@ -246,12 +243,12 @@ fn main() {
246243
let now = Instant::now();
247244
let elapsed = now.duration_since(start_time).as_secs_f32();
248245
let angle = elapsed * 2.0;
249-
camera_x = angle.cos() * 100.0;
250-
camera_y = angle.sin() * 100.0;
246+
let camera_x = angle.cos() * 100.0;
247+
let camera_y = angle.sin() * 100.0;
251248

252249
// Add zoom animation
253250
let zoom_angle = elapsed * 1.0; // Slower zoom cycle
254-
zoom = 1.0 + zoom_angle.sin() * 0.5; // Oscillate between 0.5 and 1.5
251+
let zoom = 1.0 + zoom_angle.sin() * 0.5; // Oscillate between 0.5 and 1.5
255252

256253
// Clear and render
257254
let canvas = surface.canvas();

crates/grida-canvas/examples/golden_type_line_height.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,6 @@ fn main() {
253253
let x = start_x + (i as f32) * (col_width + col_spacing);
254254
draw_text_block(canvas, x, y_pos, col_width, label, line_height.clone());
255255
}
256-
y_pos += row_height + section_spacing;
257256

258257
// Save the result
259258
let image = surface.image_snapshot();

crates/grida-canvas/examples/grida_fills.rs

Lines changed: 32 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,10 @@ async fn demo_fills() -> Scene {
3838
Paint::from(CGColor(0, 0, 255, 255)),
3939
]);
4040
multi_solid_rect.stroke_width = 3.0;
41-
graph.append_child(Node::Rectangle(multi_solid_rect), Parent::NodeId(root_id.clone()));
41+
graph.append_child(
42+
Node::Rectangle(multi_solid_rect),
43+
Parent::NodeId(root_id.clone()),
44+
);
4245

4346
// 2. Rectangle with solid + linear gradient fills
4447
let mut solid_gradient_rect = nf.create_rectangle_node();
@@ -69,7 +72,10 @@ async fn demo_fills() -> Scene {
6972
}),
7073
]);
7174
solid_gradient_rect.stroke_width = 3.0;
72-
graph.append_child(Node::Rectangle(solid_gradient_rect), Parent::NodeId(root_id.clone()));
75+
graph.append_child(
76+
Node::Rectangle(solid_gradient_rect),
77+
Parent::NodeId(root_id.clone()),
78+
);
7379

7480
// 3. Rectangle with solid + radial gradient fills
7581
let mut solid_radial_rect = nf.create_rectangle_node();
@@ -104,7 +110,10 @@ async fn demo_fills() -> Scene {
104110
}),
105111
]);
106112
solid_radial_rect.stroke_width = 3.0;
107-
graph.append_child(Node::Rectangle(solid_radial_rect), Parent::NodeId(root_id.clone()));
113+
graph.append_child(
114+
Node::Rectangle(solid_radial_rect),
115+
Parent::NodeId(root_id.clone()),
116+
);
108117

109118
// 4. Rectangle with linear + radial gradient fills
110119
let mut gradient_gradient_rect = nf.create_rectangle_node();
@@ -152,7 +161,10 @@ async fn demo_fills() -> Scene {
152161
}),
153162
]);
154163
gradient_gradient_rect.stroke_width = 3.0;
155-
graph.append_child(Node::Rectangle(gradient_gradient_rect), Parent::NodeId(root_id.clone()));
164+
graph.append_child(
165+
Node::Rectangle(gradient_gradient_rect),
166+
Parent::NodeId(root_id.clone()),
167+
);
156168

157169
// 5. Ellipse with multiple radial gradients (concentric circles effect)
158170
let mut multi_radial_ellipse = nf.create_ellipse_node();
@@ -213,7 +225,10 @@ async fn demo_fills() -> Scene {
213225
}),
214226
]);
215227
multi_radial_ellipse.stroke_width = 3.0;
216-
graph.append_child(Node::Ellipse(multi_radial_ellipse), Parent::NodeId(root_id.clone()));
228+
graph.append_child(
229+
Node::Ellipse(multi_radial_ellipse),
230+
Parent::NodeId(root_id.clone()),
231+
);
217232

218233
// 6. Polygon with solid + linear gradient + radial gradient
219234
let pentagon_points = (0..5)
@@ -268,7 +283,10 @@ async fn demo_fills() -> Scene {
268283
}),
269284
]);
270285
complex_fill_polygon.stroke_width = 4.0;
271-
graph.append_child(Node::Polygon(complex_fill_polygon), Parent::NodeId(root_id.clone()));
286+
graph.append_child(
287+
Node::Polygon(complex_fill_polygon),
288+
Parent::NodeId(root_id.clone()),
289+
);
272290

273291
// 7. Regular polygon with multiple linear gradients at different angles
274292
let mut multi_linear_polygon = nf.create_regular_polygon_node();
@@ -331,7 +349,10 @@ async fn demo_fills() -> Scene {
331349
}),
332350
]);
333351
multi_linear_polygon.stroke_width = 3.0;
334-
graph.append_child(Node::RegularPolygon(multi_linear_polygon), Parent::NodeId(root_id.clone()));
352+
graph.append_child(
353+
Node::RegularPolygon(multi_linear_polygon),
354+
Parent::NodeId(root_id.clone()),
355+
);
335356

336357
// 8. Container with multiple fills (demonstrating container fill capability)
337358
let mut multi_fill_container = nf.create_container_node();
@@ -366,7 +387,10 @@ async fn demo_fills() -> Scene {
366387
}),
367388
]);
368389
multi_fill_container.stroke_width = 3.0;
369-
graph.append_child(Node::Container(multi_fill_container), Parent::NodeId(root_id.clone()));
390+
graph.append_child(
391+
Node::Container(multi_fill_container),
392+
Parent::NodeId(root_id.clone()),
393+
);
370394

371395
Scene {
372396
name: "Fills Demo".to_string(),

crates/grida-canvas/examples/grida_shapes.rs

Lines changed: 28 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,10 @@ async fn demo_shapes() -> Scene {
4242
200 - (i * 20) as u8,
4343
255,
4444
))); // Fading gray
45-
graph.append_child(Node::Rectangle(rect), Parent::NodeId(root_container_id.clone()));
45+
graph.append_child(
46+
Node::Rectangle(rect),
47+
Parent::NodeId(root_container_id.clone()),
48+
);
4649
}
4750

4851
// Ellipse Row - demonstrating width/height ratio variations
@@ -60,7 +63,10 @@ async fn demo_shapes() -> Scene {
6063
200 - (i * 20) as u8,
6164
255,
6265
))]); // Fading gray
63-
graph.append_child(Node::Ellipse(ellipse), Parent::NodeId(root_container_id.clone()));
66+
graph.append_child(
67+
Node::Ellipse(ellipse),
68+
Parent::NodeId(root_container_id.clone()),
69+
);
6470
}
6571

6672
// Polygon Row - demonstrating point count variations
@@ -88,7 +94,10 @@ async fn demo_shapes() -> Scene {
8894
200 - (i * 20) as u8,
8995
255,
9096
))]); // Fading gray
91-
graph.append_child(Node::Polygon(polygon), Parent::NodeId(root_container_id.clone()));
97+
graph.append_child(
98+
Node::Polygon(polygon),
99+
Parent::NodeId(root_container_id.clone()),
100+
);
92101
}
93102

94103
// Regular Polygon Row - demonstrating point count variations
@@ -108,7 +117,10 @@ async fn demo_shapes() -> Scene {
108117
255,
109118
))]); // Fading gray
110119
regular_polygon.corner_radius = 8.0;
111-
graph.append_child(Node::RegularPolygon(regular_polygon), Parent::NodeId(root_container_id.clone()));
120+
graph.append_child(
121+
Node::RegularPolygon(regular_polygon),
122+
Parent::NodeId(root_container_id.clone()),
123+
);
112124
}
113125

114126
// Path Row - demonstrating different path patterns
@@ -135,7 +147,10 @@ async fn demo_shapes() -> Scene {
135147
200 - (i * 20) as u8,
136148
255,
137149
))]); // Fading gray
138-
graph.append_child(Node::SVGPath(path), Parent::NodeId(root_container_id.clone()));
150+
graph.append_child(
151+
Node::SVGPath(path),
152+
Parent::NodeId(root_container_id.clone()),
153+
);
139154
}
140155

141156
// Star Polygon Row - demonstrating different point counts and inner radius variations
@@ -156,7 +171,10 @@ async fn demo_shapes() -> Scene {
156171
255,
157172
))]); // Fading gray
158173
star.corner_radius = 8.0;
159-
graph.append_child(Node::RegularStarPolygon(star), Parent::NodeId(root_container_id.clone()));
174+
graph.append_child(
175+
Node::RegularStarPolygon(star),
176+
Parent::NodeId(root_container_id.clone()),
177+
);
160178
}
161179

162180
// Arc Row - demonstrating different angle variations
@@ -178,7 +196,10 @@ async fn demo_shapes() -> Scene {
178196
255,
179197
))]); // Fading gray
180198
arc.corner_radius = Some(8.0);
181-
graph.append_child(Node::Ellipse(arc), Parent::NodeId(root_container_id.clone()));
199+
graph.append_child(
200+
Node::Ellipse(arc),
201+
Parent::NodeId(root_container_id.clone()),
202+
);
182203
}
183204

184205
Scene {

crates/grida-canvas/examples/grida_shapes_ellipse.rs

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,10 @@ async fn demo_ellipses() -> Scene {
3939
200 + (i * 5) as u8,
4040
255,
4141
))]); // Blue gradient
42-
graph.append_child(Node::Ellipse(ellipse), Parent::NodeId(root_container_id.clone()));
42+
graph.append_child(
43+
Node::Ellipse(ellipse),
44+
Parent::NodeId(root_container_id.clone()),
45+
);
4346
}
4447

4548
// Row 2: Ellipses with different inner radius (rings)
@@ -58,7 +61,10 @@ async fn demo_ellipses() -> Scene {
5861
50 + (i * 20) as u8,
5962
255,
6063
))]); // Orange gradient
61-
graph.append_child(Node::Ellipse(ring), Parent::NodeId(root_container_id.clone()));
64+
graph.append_child(
65+
Node::Ellipse(ring),
66+
Parent::NodeId(root_container_id.clone()),
67+
);
6268
}
6369

6470
// Row 3: Arcs with different angles
@@ -78,7 +84,10 @@ async fn demo_ellipses() -> Scene {
7884
100 + (i * 15) as u8,
7985
255,
8086
))]); // Green gradient
81-
graph.append_child(Node::Ellipse(arc), Parent::NodeId(root_container_id.clone()));
87+
graph.append_child(
88+
Node::Ellipse(arc),
89+
Parent::NodeId(root_container_id.clone()),
90+
);
8291
}
8392

8493
// Row 4: Arcs with inner radius (donut arcs)
@@ -99,7 +108,10 @@ async fn demo_ellipses() -> Scene {
99108
150 + (i * 12) as u8,
100109
255,
101110
))]); // Purple gradient
102-
graph.append_child(Node::Ellipse(donut_arc), Parent::NodeId(root_container_id.clone()));
111+
graph.append_child(
112+
Node::Ellipse(donut_arc),
113+
Parent::NodeId(root_container_id.clone()),
114+
);
103115
}
104116

105117
// Row 5: Ellipses with strokes
@@ -119,7 +131,10 @@ async fn demo_ellipses() -> Scene {
119131
255,
120132
))]); // Red gradient stroke
121133
stroke_ellipse.stroke_width = 3.0 + (i as f32 * 2.0); // 3 to 17 stroke weight
122-
graph.append_child(Node::Ellipse(stroke_ellipse), Parent::NodeId(root_container_id.clone()));
134+
graph.append_child(
135+
Node::Ellipse(stroke_ellipse),
136+
Parent::NodeId(root_container_id.clone()),
137+
);
123138
}
124139

125140
Scene {

0 commit comments

Comments
 (0)