nx_pdf_text.nx
buildroot/runtime/nx_pdf_text.nx
about
nx_pdf_text.nx -- SOVEREIGN PDF -> text with PER-FONT /ToUnicode CMap association.
OSS pipeline (poppler/pdfminer/Docling = reference + benchmark, never deps):
objects -> FlateDecode -> per-font CMap (each /Font resource entry resolved to its font object,
its encoding [Identity-H = 2-byte] and its /ToUnicode map) -> track the current font via `/Fn Tf`
in the content stream -> decode each (...) operand with THAT font's width+map -> UTF-8.
This reads MIXED simple+CID/typeset documents (the real IEEE-standard shape), not just pure docs.
Composes nx_zlib_wrap (rule 15 DRY). license_tier: ORIGINAL
LIMITS: generation-0 objects only; resources found by scanning /Font dicts (no inherited-Resources
tree walk); no object streams (ObjStm)/xref-streams/encryption; bfrange array-dst not handled; no
glyph-position layout. Proven by gates: simple Type1/TrueType, pure Identity-H, and MIXED simple+CID.
dependencies 2 imports · 2 importers
imports: nx_syscalls.nxnx_zlib_wrap.nx
imported by: nx_lib_pdf.nxnx_safe_archive_ingest.nx
call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown
structs
| none |
consts
| 13 | const PT_MAGIC_65536: i64 = 65536 |
| 14 | const PT_MAGIC_8192: i64 = 8192 |
| 15 | const PT_MAGIC_50331648: i64 = 50331648 |
| 17 | const PT_MAX_OUT: i64 = 16777216 |
| 18 | const PT_MAX_STREAM: i64 = 8388608 |
| 19 | const PT_MAP_N: i64 = 65536 |
| 20 | const PT_MAXFONTS: i64 = 64 |
| 21 | const PT_NAMESLOT: i64 = 24 |
functions
| 23 | func pt_find(hay: *u8, n: i64, start: i64, needle: *u8, nlen: i64) -> i64 |
| 35 | func pt_hexv(ch: i64) -> i64 |
| 41 | func pt_read_hex(c: *u8, clen: i64, ip: *i64) -> i64 |
| 52 | func pt_is_ws(ch: i64) -> i64 { if ch == 0x20 { return 1 } if ch == 0x0a { return 1 } if ch == 0x0d { return 1 } if ch == 0x09 { return 1 } if ch == 0x0c { return 1 } if ch == 0x00 { return 1 } return 0 } |
| 53 | func pt_is_delim(ch: i64) -> i64 |
| 59 | func pt_skipws(c: *u8, clen: i64, i: i64) -> i64 |
| 64 | func pt_read_uint(c: *u8, clen: i64, i_p: *i64) -> i64 |
| 71 | func pt_itoa(num: i64, buf: *u8) -> i64 |
| 80 | func pt_find_obj(buf: *u8, n: i64, num: i64) -> i64 |
| 95 | func pt_emit_utf8(out: *u8, op_p: *i64, cap: i64, cp: i64) -> i64 called by 1: pt_emit_cp |
| 104 | func pt_emit_cp(out: *u8, op_p: *i64, cap: i64, cp: i64) -> i64 |
| 118 | func pt_parse_cmap_block(c: *u8, clen: i64, map: *i64) -> i64 |
| 166 | func pt_read_raw(c: *u8, clen: i64, i_start: i64, tmp: *u8, cap: i64, rlen_p: *i64) -> i64 called by 1: pt_extract_pf |
| 210 | func pt_emit_run(tmp: *u8, rlen: i64, out: *u8, cap: i64, op_p: *i64, is2: i64, map: *i64) -> i64 |
| 243 | func pt_extract_pf(c: *u8, clen: i64, out: *u8, cap: i64, op_p: *i64, |
| 301 | func pt_name_eq(name: *u8, nlen: i64, lit: *u8) -> i64 called by 1: pt_glyph_uni |
| 313 | func pt_glyph_uni(name: *u8, nlen: i64) -> i64 |
| 384 | func pt_parse_differences(buf: *u8, end: i64, start: i64, map: *i64) -> i64 |
| 414 | func pt_resolve_font(buf: *u8, n: i64, objnum: i64, is2_p: *i64, map_p: *i64) -> i64 called by 1: pt_build_fonts calls 8: pt_find_objpt_findsys_mmappt_skipwspt_read_uintnx_zlib_inflate+2 |
| 484 | func pt_build_fonts(buf: *u8, n: i64, fname: *u8, fnlen: *i64, fis2: *i64, fmap: *i64) -> i64 |
| 527 | func pt_expand_objstm(buf: *u8, n: i64, exp: *u8, cap: i64) -> i64 called by 1: nx_pdf_extract_text calls 6: sys_mmappt_findpt_skipwspt_read_uintnx_zlib_inflatept_itoa |
| 590 | func nx_pdf_extract_text(buf: *u8, n: i64, out: *u8, cap: i64) -> i64 |
| 648 | func main(argc: i64, argv: *i64) -> i64 |