nx_cdmap_referee_lib.nx
buildroot/runtime/nx_cdmap_referee_lib.nx
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
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
| 17 | const CR_MAXN: i64 = 64 // marks or labels one cdmap figure can carry |
| 18 | const CR_NAME_W: i64 = 64 // bytes per label name slot (zero-terminated) |
| 19 | const CR_I64_BYTES: i64 = 8 |
| 20 | const CR_ABSENT: i64 = 0 - 1 |
| 21 | const CR_CH_GT: i64 = 62 |
| 22 | const CR_CH_MINUS: i64 = 45 |
| 23 | const CR_CH_0: i64 = 48 |
| 24 | const CR_CH_9: i64 = 57 |
| 25 | const CR_CH_SPACE: i64 = 32 |
| 26 | const CR_CH_COLON: i64 = 58 |
| 27 | const CR_LABEL_BASE: i64 = 12 // the emitter's CDP_LABEL_BASE: a label's text baseline sits this far below its box top |
| 28 | const CR_FRAME_W: i64 = 4 |
| 29 | const CR_F_X0: i64 = 0 |
| 30 | const CR_F_Y0: i64 = 1 |
| 31 | const CR_F_X1: i64 = 2 |
| 32 | const CR_F_Y1: i64 = 3 |
| 33 | const CR_BASE10: i64 = 10 |
| 34 | const CR_PERMIL: i64 = 1000 |
| 37 | const CR_NOTE_OPEN: *u8 = "<g class='cdnote'>" |
| 38 | const CR_G_CLOSE: *u8 = "</g>" |
functions
| 40 | func cr_slen(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } return n } |
| 41 | func cr_streq(a: *u8, b: *u8) -> i64 |
| 48 | func cr_find(h: *u8, from: i64, to: i64, needle: *u8) -> i64 called by 13: crg_viewboxrs_ent_atrs_skip_pastrs_viewboxrs_renderrs_svg_standalone+7 calls 1: cr_slen |
| 64 | func cr_int_at(h: *u8, i: i64, to: i64) -> i64 |
| 85 | func cr_attr(h: *u8, tag0: i64, tag1: i64, needle: *u8) -> i64 |
| 90 | func cr_tag_end(h: *u8, from: i64, to: i64) -> i64 |
| 95 | func cr_name_at(names: *u8, i: i64) -> *u8 { return (names as i64 + i * CR_NAME_W) as *u8 } |
| 97 | func cr_rfind(h: *u8, from: i64, to: i64, needle: *u8) -> i64 |
| 108 | func cr_in_note(h: *u8, s0: i64, t: i64) -> i64 |
| 116 | func cr_text_into(h: *u8, t1: i64, s1: i64, names: *u8, i: i64) -> i64 |
| 128 | func cr_scan_notes(h: *u8, n: i64, nlx: *i64, nly: *i64, nlfont: *i64, nlnote: *i64, names: *u8, out: *i64) -> i64 |
| 171 | func 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 |
| 241 | func cr_w_heuristic(names: *u8, i: i64, font: i64) -> i64 { return cl_text_w(cr_slen(cr_name_at(names, i)), font) } |
| 243 | func cr_w_metric(fh: *i64, s: *u8, ph: i64) -> i64 |
| 251 | func cr_boxes(n: i64, names: *u8, lfont: *i64, lbold: *i64, fhr: *i64, fhb: *i64, lw: *i64, lh: *i64) -> i64 |
| 265 | func cr_critic(n: i64, mx: *i64, my: *i64, mr: *i64, lx: *i64, ly: *i64, lw: *i64, lh: *i64, frame: *i64, out: *i64) -> i64 |
| 270 | func cr_json_int(j: *u8, n: i64, block: *u8, key: *u8) -> i64 |
| 295 | func cr_delta_permil(heur: i64, metric: i64) -> i64 called by 1: main |