Skip to documentation
SLOP

tiny.filigree.breakLinesInto

Reference tiny.filigree breakLinesInto

Defined in tiny.filigree.

Called byCallstest sourcelib.filigree.src.shape.linetest: breakLinesInto independent work...test sourcelib.filigree.src.shape.linetest: breakLinesInto keeps no break s...test sourcelib.filigree.src.shape.linetest: breakLinesInto preserves line s...test sourcelib.filigree.src.shape.linetest: breakLinesInto preserves warmed...test sourcelib.filigree.src.shape.linetest: breakLinesInto refuses break be...+4 moreprivate sourcelib.filigree.src.shape.linecollectLineBreaksIntoprivate sourcelib.filigree.src.shape.linefirstGlyphSourceOffsetprivate sourcelib.filigree.src.shape.linelineBreakActionAttiny.filigreebreakLinesInto
Static calls · unresolved targets: 2 · external targets: 0.

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

shape.breakLinesInto.

Complete caller list

9 direct callers.

Audit

Definitions1
Public names2
Members0
Version26.7.0
Revisiondaab053ee433