code wiki / (root) / nx_pdf_text.nx

nx_pdf_text.nx

buildroot/runtime/nx_pdf_text.nx

33806 B660 linesdepth 7pulls 8 transitivereach 5 importersview sourcekind tooltopic pdf
docsdependenciesstructsconstsfunctions

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

nx_syscalls.nx nx_zlib_wrap.nx nx_pdf_text.nx nx_lib_pdf.nx nx_safe_archive_ingest.nx

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

main sys_write sys_mmap sys_read_file sys_openat_rd sys_lseek sys_mmap ↻ sys_read sys_close nx_pdf_extract_text sys_mmap ↻ pt_expand_objstm sys_mmap ↻ pt_find pt_skipws pt_is_ws pt_read_uint nx_zlib_inflate sys_mmap ↻ nx_deflate_inflate sys_mmap ↻ nx_bitstream_alloc sys_mmap ↻ _deflate_inflate_block nx_bitstream_read_lsb nx_bitstream_byte_align nx_bitstream_read_byte_ali _deflate_build_static_litl _deflate_build_static_dist _deflate_decode_huffman_bl sys_mmap ↻ _deflate_build_dynamic_tre _deflate_bytes_consumed adler32 pt_itoa sys_mmap ↻ pt_build_fonts sys_mmap ↻ pt_find ↻ pt_is_ws ↻

structs

none

consts

13const PT_MAGIC_65536: i64 = 65536
14const PT_MAGIC_8192: i64 = 8192
15const PT_MAGIC_50331648: i64 = 50331648
17const PT_MAX_OUT: i64 = 16777216
18const PT_MAX_STREAM: i64 = 8388608
19const PT_MAP_N: i64 = 65536
20const PT_MAXFONTS: i64 = 64
21const PT_NAMESLOT: i64 = 24

functions

23func pt_find(hay: *u8, n: i64, start: i64, needle: *u8, nlen: i64) -> i64
35func pt_hexv(ch: i64) -> i64
41func pt_read_hex(c: *u8, clen: i64, ip: *i64) -> i64
called by 1: pt_parse_cmap_block calls 1: pt_hexv
52func 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 }
53func pt_is_delim(ch: i64) -> i64
59func pt_skipws(c: *u8, clen: i64, i: i64) -> i64
64func pt_read_uint(c: *u8, clen: i64, i_p: *i64) -> i64
71func pt_itoa(num: i64, buf: *u8) -> i64
80func pt_find_obj(buf: *u8, n: i64, num: i64) -> i64
95func pt_emit_utf8(out: *u8, op_p: *i64, cap: i64, cp: i64) -> i64
called by 1: pt_emit_cp
104func pt_emit_cp(out: *u8, op_p: *i64, cap: i64, cp: i64) -> i64
called by 1: pt_emit_run calls 1: pt_emit_utf8
118func pt_parse_cmap_block(c: *u8, clen: i64, map: *i64) -> i64
166func pt_read_raw(c: *u8, clen: i64, i_start: i64, tmp: *u8, cap: i64, rlen_p: *i64) -> i64
called by 1: pt_extract_pf
210func pt_emit_run(tmp: *u8, rlen: i64, out: *u8, cap: i64, op_p: *i64, is2: i64, map: *i64) -> i64
called by 1: pt_extract_pf calls 1: pt_emit_cp
243func pt_extract_pf(c: *u8, clen: i64, out: *u8, cap: i64, op_p: *i64,
301func pt_name_eq(name: *u8, nlen: i64, lit: *u8) -> i64
called by 1: pt_glyph_uni
313func pt_glyph_uni(name: *u8, nlen: i64) -> i64
384func pt_parse_differences(buf: *u8, end: i64, start: i64, map: *i64) -> i64
414func pt_resolve_font(buf: *u8, n: i64, objnum: i64, is2_p: *i64, map_p: *i64) -> i64
484func pt_build_fonts(buf: *u8, n: i64, fname: *u8, fnlen: *i64, fis2: *i64, fmap: *i64) -> i64
527func pt_expand_objstm(buf: *u8, n: i64, exp: *u8, cap: i64) -> i64
590func nx_pdf_extract_text(buf: *u8, n: i64, out: *u8, cap: i64) -> i64
648func main(argc: i64, argv: *i64) -> i64