code wiki / (root) / nx_cdmap_referee_lib.nx

nx_cdmap_referee_lib.nx

buildroot/runtime/nx_cdmap_referee_lib.nx

13959 B298 linesdepth 7pulls 11 transitivereach 40 importersview sourcekind librarytopic cdmap
docsdependenciesstructsconstsfunctions

about

nx_cdmap_referee_lib.nx -- THE SECOND RULER for the position map (datavis DV2a, 2026-09-15): re-derives the readability grade of an EMITTED cdmap figure from the published SVG alone, then re-measures every label with REAL TrueType advances (nx_ttf_fontlib over a real sans face -- Liberation Sans, SIL-OFL data under knowledge/fonts/) in place of the emitter's 560-permil-em estimate, and runs the same critic (nx_chartlay_lib cl_critic) over both. The emitter's self-grade (api.json readability_cut) is a CLAIM; this lib is the independent method class that can refute it: the heuristic critic must REPRODUCE the published grade from the SVG (else the page and its api.json disagree), and the metric critic says whether real glyph widths would have produced overlaps the estimate hid. It is NOT the browser-pixel referee (DV2, crg_judge): the viewer's font is unknown to us and Liberation Sans is a stand-in of the same class; a browser render judged on pixels stays the contracted rung above this one and is not claimed here. Scope stated: label boxes keep the emitter's 1.25-em height so the ONE variable under test is width; kerning is not applied (a sum of hmtx advances is the width the emitter would need to reserve); entity bytes in a label (a rare &) are measured as their literal characters. license_tier: ORIGINAL

dependencies 3 imports · 4 importers

nx_syscalls.nx nx_chartlay_lib.nx nx_ttf_fontlib.nx nx_cdmap_referee_lib.nx nx_cdmap_pixjudge_lib.nx nx_cdmap_raster_lib.nx nx_cdmap_referee.nx nx_cdmap_referee_gate.nx

imports: nx_syscalls.nxnx_chartlay_lib.nxnx_ttf_fontlib.nx

imported by: nx_cdmap_pixjudge_lib.nxnx_cdmap_raster_lib.nxnx_cdmap_referee.nxnx_cdmap_referee_gate.nx

structs

none

consts

17const CR_MAXN: i64 = 64 // marks or labels one cdmap figure can carry
18const CR_NAME_W: i64 = 64 // bytes per label name slot (zero-terminated)
19const CR_I64_BYTES: i64 = 8
20const CR_ABSENT: i64 = 0 - 1
21const CR_CH_GT: i64 = 62
22const CR_CH_MINUS: i64 = 45
23const CR_CH_0: i64 = 48
24const CR_CH_9: i64 = 57
25const CR_CH_SPACE: i64 = 32
26const CR_CH_COLON: i64 = 58
27const CR_LABEL_BASE: i64 = 12 // the emitter's CDP_LABEL_BASE: a label's text baseline sits this far below its box top
28const CR_FRAME_W: i64 = 4
29const CR_F_X0: i64 = 0
30const CR_F_Y0: i64 = 1
31const CR_F_X1: i64 = 2
32const CR_F_Y1: i64 = 3
33const CR_BASE10: i64 = 10
34const CR_PERMIL: i64 = 1000
37const CR_NOTE_OPEN: *u8 = "<g class='cdnote'>"
38const CR_G_CLOSE: *u8 = "</g>"

functions

40func cr_slen(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } return n }
41func cr_streq(a: *u8, b: *u8) -> i64
called by 2: rs_rendermain
48func cr_find(h: *u8, from: i64, to: i64, needle: *u8) -> i64
64func cr_int_at(h: *u8, i: i64, to: i64) -> i64
85func cr_attr(h: *u8, tag0: i64, tag1: i64, needle: *u8) -> i64
90func cr_tag_end(h: *u8, from: i64, to: i64) -> i64
95func cr_name_at(names: *u8, i: i64) -> *u8 { return (names as i64 + i * CR_NAME_W) as *u8 }
97func cr_rfind(h: *u8, from: i64, to: i64, needle: *u8) -> i64
called by 2: maincr_in_note calls 1: cr_find
108func cr_in_note(h: *u8, s0: i64, t: i64) -> i64
called by 1: cr_scan calls 1: cr_rfind
116func cr_text_into(h: *u8, t1: i64, s1: i64, names: *u8, i: i64) -> i64
called by 1: cr_scan_notes calls 1: cr_find
128func cr_scan_notes(h: *u8, n: i64, nlx: *i64, nly: *i64, nlfont: *i64, nlnote: *i64, names: *u8, out: *i64) -> i64
171func cr_scan(h: *u8, n: i64, mx: *i64, my: *i64, mr: *i64, lx: *i64, ly: *i64, lfont: *i64, lbold: *i64, names: *u8, frame: *i64, out: *i64) -> i64
241func cr_w_heuristic(names: *u8, i: i64, font: i64) -> i64 { return cl_text_w(cr_slen(cr_name_at(names, i)), font) }
called by 1: cr_boxes calls 3: cl_text_wcr_slencr_name_at
243func cr_w_metric(fh: *i64, s: *u8, ph: i64) -> i64
called by 3: mainmaincr_boxes calls 1: tf_char_adv
251func cr_boxes(n: i64, names: *u8, lfont: *i64, lbold: *i64, fhr: *i64, fhb: *i64, lw: *i64, lh: *i64) -> i64
265func cr_critic(n: i64, mx: *i64, my: *i64, mr: *i64, lx: *i64, ly: *i64, lw: *i64, lh: *i64, frame: *i64, out: *i64) -> i64
called by 3: g_box_grademaing_grade calls 1: cl_critic
270func cr_json_int(j: *u8, n: i64, block: *u8, key: *u8) -> i64
295func cr_delta_permil(heur: i64, metric: i64) -> i64
called by 1: main