File size: 931 Bytes
e1ced61
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
"""Text manifest — every rendered glyph linked to a semantic node (§9, P6).

The P6 gate "every text glyph is linked to semantic node" is enforced here: a
:class:`GlyphRecord` cannot be constructed without a ``node_id``, and
:func:`link_verdict` flags any record missing one. Kind-specific renderers build
records during their draw pass (a point label → the point id, a series label →
the series id, a tick label → a synthetic axis node, an angle measure → the
angle entity), and :func:`renderers.base.build_text_manifest` serializes them.
"""

from __future__ import annotations

from collections.abc import Sequence

from .base import GlyphRecord


def link_verdict(glyphs: Sequence[GlyphRecord]) -> tuple[bool, list[int]]:
    """``(all_linked, bad_indices)`` — every glyph must carry a node id."""
    bad = [i for i, g in enumerate(glyphs) if not g.node_id]
    return (not bad, bad)


__all__ = ["link_verdict"]