Skip to documentation
SLOP

tiny.filigree.ClusterMap

Reference tiny.filigree ClusterMap

Defined in tiny.filigree.

API (11)

Actions

Public operations.

Fields and members

Public fields and members.

No direct callersNo direct callstiny.filigreeClusterMap
Static calls · unresolved targets: unknown · external targets: unknown.

Source

Source: lib/filigree/src/shape/model.zig:124

zig
pub const ClusterMap = struct {    run: GlyphRun,    pub fn byteOffsetToCluster(self: ClusterMap, byte_offset: usize) ?usize {        if (byte_offset > std.math.maxInt(u32)) return null;        const offset: u32 = @intCast(byte_offset);        for (self.run.clusters, 0..) |cluster, i| {            if (offset >= cluster.source.start and offset < cluster.source.end) return i;        }        return null;    }    pub fn clusterSourceRange(self: ClusterMap, cluster_index: usize) ?SourceRange {        if (cluster_index >= self.run.clusters.len) return null;        return self.run.clusters[cluster_index].source;    }    pub fn clusterGlyphSpan(self: ClusterMap, cluster_index: usize) ?GlyphSpan {        if (cluster_index >= self.run.clusters.len) return null;        return self.run.clusters[cluster_index].glyphs;    }    pub fn glyphToCluster(self: ClusterMap, glyph_index: usize) ?usize {        if (glyph_index >= self.run.glyphs.len) return null;        return self.run.glyphs[glyph_index].cluster_index;    }    pub fn clusterCaretStopCount(self: ClusterMap, cluster_index: usize) ?usize {        if (cluster_index >= self.run.clusters.len) return null;        return 2 + (self.clusterLigatureCaretCount(cluster_index) orelse return null);    }    pub fn clusterCaretStop(self: ClusterMap, cluster_index: usize, caret_index: usize) ?u32 {        if (cluster_index >= self.run.clusters.len) return null;        const stop_count = self.clusterCaretStopCount(cluster_index) orelse return null;        if (caret_index >= stop_count) return null;        const source = self.run.clusters[cluster_index].source;        if (caret_index == 0) return source.start;        if (caret_index + 1 == stop_count) return source.end;        const source_len = source.end - source.start;        const interior_count = stop_count - 2;        if (source_len == 0 or interior_count == 0) return null;        const relative = (@as(u64, caret_index) * @as(u64, source_len)) / @as(u64, interior_count + 1);        return source.start + @as(u32, @intCast(relative));    }    pub fn clusterLigatureCaretCount(self: ClusterMap, cluster_index: usize) ?usize {        if (cluster_index >= self.run.clusters.len) return null;        const glyph = self.clusterSingleLigatureGlyph(cluster_index) orelse return 0;        return glyph.ligature_caret_count;    }    pub fn clusterLigatureCaret(self: ClusterMap, cluster_index: usize, caret_index: usize) ?LigatureCaret {        if (cluster_index >= self.run.clusters.len) return null;        const glyph = self.clusterSingleLigatureGlyph(cluster_index) orelse return null;        if (caret_index >= glyph.ligature_caret_count) return null;        return self.run.ligature_carets[@as(usize, @intCast(glyph.ligature_caret_start)) + caret_index];    }    pub fn selectableAsUnitOnly(self: ClusterMap, cluster_index: usize) ?bool {        if (cluster_index >= self.run.clusters.len) return null;        const cluster = self.run.clusters[cluster_index];        return cluster.codepoint_count > 1 or cluster.glyphs.end - cluster.glyphs.start > 1;    }    pub fn breakRequiresReshaping(self: ClusterMap, cluster_index: usize) ?bool {        if (cluster_index >= self.run.clusters.len) return null;        return self.run.clusters[cluster_index].flags.unsafe_to_break;    }    fn clusterSingleLigatureGlyph(self: ClusterMap, cluster_index: usize) ?ShapedGlyph {        const cluster = self.run.clusters[cluster_index];        if (cluster.glyphs.end <= cluster.glyphs.start) return null;        if (cluster.glyphs.end - cluster.glyphs.start != 1) return null;        const glyph_index: usize = @intCast(cluster.glyphs.start);        if (glyph_index >= self.run.glyphs.len) return null;        const glyph = self.run.glyphs[glyph_index];        if (glyph.glyph_class != .ligature or glyph.ligature_caret_count == 0) return null;        const caret_start: usize = @intCast(glyph.ligature_caret_start);        const caret_count: usize = glyph.ligature_caret_count;        if (caret_start > self.run.ligature_carets.len) return null;        if (caret_count > self.run.ligature_carets.len - caret_start) return null;        return glyph;    }};

Source: lib/filigree/src/root.zig:65

zig
pub const ClusterMap = shape.ClusterMap;
Called byCallsNo direct callersClusterMapclusterCaretStopCountClusterMapclusterCaretStop
Static calls · unresolved targets: 0 · external targets: 0.
Called byCallsClusterMapclusterCaretStopClusterMapclusterLigatureCaretCountClusterMapclusterCaretStopCount
Static calls · unresolved targets: 0 · external targets: 0.
Called byCallsNo direct callersprivate sourcelib.filigree.src.shape.model.ClusterMapclusterSingleLigatureGlyphClusterMapclusterLigatureCaret
Static calls · unresolved targets: 0 · external targets: 0.
Called byCallsClusterMapclusterCaretStopCountprivate sourcelib.filigree.src.shape.model.ClusterMapclusterSingleLigatureGlyphClusterMapclusterLigatureCaretCount
Static calls · unresolved targets: 0 · external targets: 0.

Also reachable as

shape.ClusterMap.

Audit

Definitions11
Public names22
Members1
Version26.7.0
Revisiondaab053ee433