tiny.filigree.breakLinesInto
Defined in tiny.filigree.
Source
Source: lib/filigree/src/shape/line.zig:29
zig
pub fn breakLinesInto( allocator: Allocator, glyphs: []const ShapedGlyph, text: Source, wrap_width: f64, workspace: *LineBreakWorkspace,) ![]const u32 { workspace.clear(); errdefer workspace.clear(); if (glyphs.len == 0 or wrap_width <= 0) { try workspace._line_ends.append(allocator, @intCast(glyphs.len)); return workspace._line_ends.items; } try collectLineBreaksInto( allocator, text, firstGlyphSourceOffset(glyphs), &workspace._opportunities, ); var line_width: f64 = 0; var line_start: u32 = 0; var last_text_break: u32 = 0; var last_cluster_break: u32 = 0; for (glyphs, 0..) |glyph, i| { const advance: f64 = @as(f64, @floatFromInt(glyph.x_advance)) / 64.0; line_width += advance; if (i + 1 < glyphs.len) { const next = glyphs[i + 1]; const cluster_boundary = next.cluster != glyph.cluster or next.cluster_index != glyph.cluster_index; if (cluster_boundary and !next.flags.unsafe_to_break) { const break_index: u32 = @intCast(i + 1); last_cluster_break = break_index; const text_break = lineBreakActionAt(workspace._opportunities.items, next.source_start); if (text_break == .mandatory) { try workspace._line_ends.append(allocator, break_index); line_width = 0; line_start = break_index; last_text_break = 0; last_cluster_break = 0; continue; } if (text_break == .opportunity) { last_text_break = break_index; } } } if (line_width > wrap_width) { const selected_break = if (last_text_break > line_start) last_text_break else last_cluster_break; if (selected_break <= line_start) continue; try workspace._line_ends.append(allocator, selected_break); line_start = selected_break; line_width = 0; var j: u32 = selected_break; while (j <= @as(u32, @intCast(i))) : (j += 1) { line_width += @as(f64, @floatFromInt(glyphs[j].x_advance)) / 64.0; } last_text_break = 0; last_cluster_break = 0; } } try workspace._line_ends.append(allocator, @intCast(glyphs.len)); return workspace._line_ends.items;}Source: lib/filigree/src/root.zig:96
zig
pub const breakLinesInto = shape.breakLinesInto;Also reachable as
Complete caller list
9 direct callers.
lib.filigree.src.shape.line.test_breakLinesInto_independent_workspaces_preserve_overlapping_results[function] — test source atlib/filigree/src/shape/line.zig:231in nearest public ownerlib.filigree.src.shape.linelib.filigree.src.shape.line.test_breakLinesInto_keeps_no_break_space_with_adjacent_text[function] — test source atlib/filigree/src/shape/line.zig:199in nearest public ownerlib.filigree.src.shape.linelib.filigree.src.shape.line.test_breakLinesInto_preserves_line_storage_after_output_growth_fails[function] — test source atlib/filigree/src/shape/line.zig:330in nearest public ownerlib.filigree.src.shape.linelib.filigree.src.shape.line.test_breakLinesInto_preserves_warmed_storage_after_opportunity_growth_fails[function] — test source atlib/filigree/src/shape/line.zig:290in nearest public ownerlib.filigree.src.shape.linelib.filigree.src.shape.line.test_breakLinesInto_refuses_break_before_closing_punctuation_after_space[function] — test source atlib/filigree/src/shape/line.zig:183in nearest public ownerlib.filigree.src.shape.linelib.filigree.src.shape.line.test_breakLinesInto_single_line[function] — test source atlib/filigree/src/shape/line.zig:153in nearest public ownerlib.filigree.src.shape.linelib.filigree.src.shape.line.test_breakLinesInto_skips_unsafe_cluster_boundaries[function] — test source atlib/filigree/src/shape/line.zig:216in nearest public ownerlib.filigree.src.shape.linelib.filigree.src.shape.line.test_breakLinesInto_warmed_workspace_needs_no_backing_allocation[function] — test source atlib/filigree/src/shape/line.zig:266in nearest public ownerlib.filigree.src.shape.linelib.filigree.src.shape.line.test_breakLinesInto_wraps_at_Unicode_space_opportunities[function] — test source atlib/filigree/src/shape/line.zig:166in nearest public ownerlib.filigree.src.shape.line
Audit
| Definitions | 1 |
|---|---|
| Public names | 2 |
| Members | 0 |
| Version | 26.7.0 |
| Revision | daab053ee433 |