Successful codepoint gathering

This commit is contained in:
John Whitington 2023-07-13 16:22:50 +01:00
parent 8d46e15a7e
commit bdc9d8e239
2 changed files with 20 additions and 9 deletions

View File

@ -104,9 +104,6 @@ let empty_res () =
let resstack = let resstack =
ref [empty_res ()] ref [empty_res ()]
let res () =
try hd !resstack with _ -> error "graphics stack empty"
let rescopy r = let rescopy r =
{r with {r with
images = Hashtbl.copy r.images; images = Hashtbl.copy r.images;
@ -114,6 +111,9 @@ let rescopy r =
extgstates = Hashtbl.copy r.extgstates; extgstates = Hashtbl.copy r.extgstates;
form_xobjects = Hashtbl.copy r.form_xobjects} form_xobjects = Hashtbl.copy r.form_xobjects}
let res () =
try hd !resstack with _ -> error "graphics stack empty"
let respush () = let respush () =
resstack := (rescopy (res ()))::!resstack resstack := (rescopy (res ()))::!resstack
@ -341,6 +341,12 @@ let rec contains_specials_drawop = function
and contains_specials l = and contains_specials l =
List.exists contains_specials_drawop l List.exists contains_specials_drawop l
let save_whole_stack () =
map (fun r -> rescopy r) !resstack
let restore_whole_stack r =
resstack := r
let draw_single ~fast ~underneath ~filename ~bates ~batespad fast range pdf drawops = let draw_single ~fast ~underneath ~filename ~bates ~batespad fast range pdf drawops =
(res ()).num <- max (res ()).num (minimum_resource_number pdf range); (res ()).num <- max (res ()).num (minimum_resource_number pdf range);
let endpage = Pdfpage.endpage pdf in let endpage = Pdfpage.endpage pdf in
@ -350,7 +356,9 @@ let draw_single ~fast ~underneath ~filename ~bates ~batespad fast range pdf draw
then None then None
else else
begin begin
let r = save_whole_stack () in
ignore (ops_of_drawops true pdf endpage filename bates batespad 0 (hd pages) drawops); ignore (ops_of_drawops true pdf endpage filename bates batespad 0 (hd pages) drawops);
restore_whole_stack r;
Some (ops_of_drawops false pdf endpage filename bates batespad 0 (hd pages) drawops) Some (ops_of_drawops false pdf endpage filename bates batespad 0 (hd pages) drawops)
end end
in in
@ -362,7 +370,9 @@ let draw_single ~fast ~underneath ~filename ~bates ~batespad fast range pdf draw
(match ops with (match ops with
| Some x -> x | Some x -> x
| None -> | None ->
let r = save_whole_stack () in
ignore (ops_of_drawops true pdf endpage filename bates batespad n p drawops); ignore (ops_of_drawops true pdf endpage filename bates batespad n p drawops);
restore_whole_stack r;
ops_of_drawops false pdf endpage filename bates batespad n p drawops) ops_of_drawops false pdf endpage filename bates batespad n p drawops)
else []) else [])
(ilist 1 endpage) (ilist 1 endpage)

View File

@ -496,13 +496,14 @@ let write_font filename data =
close_out fh close_out fh
let find_main encoding subset = let find_main encoding subset =
let encoding_table = Pdftext.table_of_encoding encoding in (take subset 5, [drop subset 5])
(*let encoding_table = Pdftext.table_of_encoding encoding in
let first, rest = let first, rest =
List.partition List.partition
(fun u -> try ignore (Hashtbl.find encoding_table u); true with Not_found -> false) (fun u -> try ignore (Hashtbl.find encoding_table u); true with Not_found -> false)
subset subset
in in
(first, splitinto 224 rest) (first, splitinto 224 rest)*)
let parse ~subset data encoding = let parse ~subset data encoding =
let mk_b byte_offset = bitbytes_of_input (let i = input_of_bytes data in i.seek_in byte_offset; i) in let mk_b byte_offset = bitbytes_of_input (let i = input_of_bytes data in i.seek_in byte_offset; i) in