mirror of
				https://github.com/johnwhitington/cpdf-source.git
				synced 2025-06-05 22:09:39 +02:00 
			
		
		
		
	debugging draw/font
This commit is contained in:
		| @@ -2096,6 +2096,7 @@ let setfont f = | |||||||
|   begin match args.op with Some Draw -> addop (Cpdfdraw.FontPack (f, embed_font (), null_hash ())) | _ -> () end |   begin match args.op with Some Draw -> addop (Cpdfdraw.FontPack (f, embed_font (), null_hash ())) | _ -> () end | ||||||
|  |  | ||||||
| let loadttf n = | let loadttf n = | ||||||
|  |   Printf.printf "loadttf: %s\n" n; | ||||||
|   let name, filename = |   let name, filename = | ||||||
|     match String.split_on_char '=' n with |     match String.split_on_char '=' n with | ||||||
|     | [name; filename] -> name, filename |     | [name; filename] -> name, filename | ||||||
| @@ -2129,6 +2130,10 @@ let setstderrtostdout () = | |||||||
| let settextwidth s = | let settextwidth s = | ||||||
|   args.op <- Some (TextWidth s) |   args.op <- Some (TextWidth s) | ||||||
|  |  | ||||||
|  | let setdraw () = | ||||||
|  |   args.op <- Some Draw; | ||||||
|  |   addop (Cpdfdraw.FontPack (args.fontname, embed_font (), null_hash ())) | ||||||
|  |  | ||||||
| (* Parse a control file, make an argv, and then make Arg parse it. *) | (* Parse a control file, make an argv, and then make Arg parse it. *) | ||||||
| let rec make_control_argv_and_parse filename = | let rec make_control_argv_and_parse filename = | ||||||
|   control_args := !control_args @ parse_control_file filename |   control_args := !control_args @ parse_control_file filename | ||||||
| @@ -2930,7 +2935,7 @@ and specs = | |||||||
|    ("-text-width", |    ("-text-width", | ||||||
|      Arg.String settextwidth, |      Arg.String settextwidth, | ||||||
|      " Find width of a line of text"); |      " Find width of a line of text"); | ||||||
|    ("-draw", Arg.Unit (setop Draw), " Begin drawing"); |    ("-draw", Arg.Unit setdraw, " Begin drawing"); | ||||||
|    ("-rect", Arg.String addrect, " Draw rectangle"); |    ("-rect", Arg.String addrect, " Draw rectangle"); | ||||||
|    ("-to", Arg.String addto, " Move to"); |    ("-to", Arg.String addto, " Move to"); | ||||||
|    ("-line", Arg.String addline, " Add line to"); |    ("-line", Arg.String addline, " Add line to"); | ||||||
| @@ -4463,8 +4468,7 @@ let go () = | |||||||
|   | Some Draw -> |   | Some Draw -> | ||||||
|       let pdf = get_single_pdf args.op false in |       let pdf = get_single_pdf args.op false in | ||||||
|       let range = parse_pagespec_allow_empty pdf (get_pagespec ()) in |       let range = parse_pagespec_allow_empty pdf (get_pagespec ()) in | ||||||
|       (* Whatever the font is going in to -draw, add its fontpack. *) |  | ||||||
|       addop (Cpdfdraw.FontPack (args.fontname, embed_font (), null_hash ())); |  | ||||||
|       let ops = match !drawops with [("_MAIN", ops)] -> rev ops | _ -> error "not enough -end-xobj or -et" in |       let ops = match !drawops with [("_MAIN", ops)] -> rev ops | _ -> error "not enough -end-xobj or -et" in | ||||||
|         write_pdf |         write_pdf | ||||||
|           false |           false | ||||||
|   | |||||||
| @@ -1,6 +1,8 @@ | |||||||
| open Pdfutil | open Pdfutil | ||||||
| open Cpdferror | open Cpdferror | ||||||
|  |  | ||||||
|  | (* FIXME Use hashtbl.replace everywhere? *) | ||||||
|  |  | ||||||
| type colspec = | type colspec = | ||||||
|    NoCol |    NoCol | ||||||
|  | RGB of float * float * float |  | RGB of float * float * float | ||||||
| @@ -195,10 +197,7 @@ let update_resources pdf old_resources = | |||||||
|  |  | ||||||
| let rec ops_of_drawop dryrun pdf endpage filename bates batespad num page = function | let rec ops_of_drawop dryrun pdf endpage filename bates batespad num page = function | ||||||
|   | Qq ops -> |   | Qq ops -> | ||||||
|       respush (); (* FIXME Is this right or not vis-a-vis fonts? *) |       [Pdfops.Op_q] @ ops_of_drawops dryrun pdf endpage filename bates batespad num page ops @ [Pdfops.Op_Q] | ||||||
|       let r = [Pdfops.Op_q] @ ops_of_drawops dryrun pdf endpage filename bates batespad num page ops @ [Pdfops.Op_Q] in |  | ||||||
|       respop (); |  | ||||||
|       r |  | ||||||
|   | Matrix m -> [Pdfops.Op_cm m]  |   | Matrix m -> [Pdfops.Op_cm m]  | ||||||
|   | Rect (x, y, w, h) -> [Pdfops.Op_re (x, y, w, h)] |   | Rect (x, y, w, h) -> [Pdfops.Op_re (x, y, w, h)] | ||||||
|   | Bezier (a, b, c, d, e, f) -> [Pdfops.Op_c (a, b, c, d, e, f)] |   | Bezier (a, b, c, d, e, f) -> [Pdfops.Op_c (a, b, c, d, e, f)] | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user