mirror of
				https://github.com/johnwhitington/cpdf-source.git
				synced 2025-06-05 22:09:39 +02:00 
			
		
		
		
	more
This commit is contained in:
		
							
								
								
									
										9
									
								
								Makefile
									
									
									
									
									
								
							
							
						
						
									
										9
									
								
								Makefile
									
									
									
									
									
								
							| @@ -3,11 +3,10 @@ NONDOC = cpdfyojson cpdfxmlm cpdfutil | |||||||
|  |  | ||||||
| DOC = cpdfunicodedata cpdferror cpdfdebug cpdfjson cpdfstrftime cpdfcoord \ | DOC = cpdfunicodedata cpdferror cpdfdebug cpdfjson cpdfstrftime cpdfcoord \ | ||||||
|       cpdfattach cpdfpagespec cpdfposition cpdfpresent cpdfmetadata \ |       cpdfattach cpdfpagespec cpdfposition cpdfpresent cpdfmetadata \ | ||||||
|       cpdfbookmarks cpdfpage cpdfaddtext cpdfimage cpdffont cpdftype \ |       cpdfbookmarks cpdfpage cpdftruetype cpdfembed cpdfaddtext cpdfimage \ | ||||||
|       cpdfpad cpdfocg cpdfsqueeze cpdfdraft cpdfspot \ |       cpdffont cpdftype cpdfpad cpdfocg cpdfsqueeze cpdfdraft cpdfspot \ | ||||||
|       cpdfpagelabels cpdfcreate cpdfannot cpdfxobject cpdfimpose cpdftweak \ |       cpdfpagelabels cpdfcreate cpdfannot cpdfxobject cpdfimpose cpdftweak \ | ||||||
|       cpdftruetype cpdfembed cpdftexttopdf cpdftoc\ |       cpdftexttopdf cpdftoc cpdfcommand | ||||||
|       cpdfcommand |  | ||||||
|  |  | ||||||
| MODS = $(NONDOC) $(DOC) | MODS = $(NONDOC) $(DOC) | ||||||
|  |  | ||||||
| @@ -31,7 +30,7 @@ $(foreach x,$(MODS),$x.cmti) | |||||||
|  |  | ||||||
| ifneq ($(shell ocamlopt -version),) | ifneq ($(shell ocamlopt -version),) | ||||||
|   TARGETS += native-code native-code-library |   TARGETS += native-code native-code-library | ||||||
|   LIBINSTALL_FILES += cpdf.a cpdf.cmxa $(foreach x,$(PDFMODS),$x.cmx) |   LIBINSTALL_FILES += cpdf.a cpdf.cmxa $(foreach x,$(MODS),$x.cmx) | ||||||
| endif | endif | ||||||
|  |  | ||||||
| all : $(TARGETS) | all : $(TARGETS) | ||||||
|   | |||||||
| @@ -21,6 +21,12 @@ let charcodes_of_utf8 font s = | |||||||
|     in |     in | ||||||
|     implode (map char_of_int charcodes) |     implode (map char_of_int charcodes) | ||||||
|  |  | ||||||
|  | let unicode_codepoint_of_pdfcode encoding_table glyphlist_table p = | ||||||
|  |   try | ||||||
|  |     hd (Hashtbl.find glyphlist_table (Hashtbl.find encoding_table p)) | ||||||
|  |   with | ||||||
|  |     Not_found -> 0 | ||||||
|  |  | ||||||
| (* Get the width of some text in the given font *) | (* Get the width of some text in the given font *) | ||||||
| let width_of_text font text = | let width_of_text font text = | ||||||
|   match font with |   match font with | ||||||
| @@ -586,8 +592,19 @@ let | |||||||
|                      !pdf; |                      !pdf; | ||||||
|                    voffset := !voffset +. (linespacing *. fontsize)) |                    voffset := !voffset +. (linespacing *. fontsize)) | ||||||
|               lines; |               lines; | ||||||
|               let charcodes = map fst (list_of_hashtbl used) in |               begin match embedinfo with | ||||||
|               Printf.printf "%i charcodes used\n" (length charcodes); |               | None -> () | ||||||
|  |               | Some (_, fontfile, fontname, encoding) -> | ||||||
|  |                   let charcodes = map fst (list_of_hashtbl used) in | ||||||
|  |                   let encoding_table = Pdftext.table_of_encoding encoding in | ||||||
|  |                   let glyphlist_table = Pdfglyphlist.glyph_hashes () in | ||||||
|  |                   let codepoints = | ||||||
|  |                     map (fun c -> unicode_codepoint_of_pdfcode encoding_table glyphlist_table (int_of_char c)) charcodes | ||||||
|  |                   in | ||||||
|  |                   let objnum = match fontpdfobj with Pdf.Indirect i -> i | _ -> failwith "bad fontpdfobj" in | ||||||
|  |                   let font = Cpdfembed.embed_truetype !pdf ~fontfile ~fontname ~codepoints ~encoding in | ||||||
|  |                     ignore (Pdftext.write_font ~objnum !pdf font) | ||||||
|  |                   end; | ||||||
|               !pdf |               !pdf | ||||||
|  |  | ||||||
| let removetext range pdf = | let removetext range pdf = | ||||||
|   | |||||||
| @@ -3705,12 +3705,13 @@ let go () = | |||||||
|   | Some (AddText text) -> |   | Some (AddText text) -> | ||||||
|       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 | ||||||
|           let font = |           let font, embedinfo = | ||||||
|             match args.font with |             match args.font with | ||||||
|             | StandardFont f -> Some (Pdftext.StandardFont (f, args.fontencoding)) |             | StandardFont f -> Some (Pdftext.StandardFont (f, args.fontencoding)), None | ||||||
|             | OtherFont f -> None (* it's in fontname *) |             | OtherFont f -> None, None (* it's in fontname *) | ||||||
|             | FontToEmbed fontfile -> |             | FontToEmbed fontfile -> | ||||||
|                 Some (Cpdfembed.embed_truetype pdf ~fontfile ~fontname:args.fontname ~codepoints:[] ~encoding:args.fontencoding) |                 Some (Cpdfembed.embed_truetype pdf ~fontfile ~fontname:args.fontname ~codepoints:[] ~encoding:args.fontencoding), | ||||||
|  |                 Some (pdf, fontfile, args.fontname, args.fontencoding) | ||||||
|           in |           in | ||||||
|             warn_prerotate range pdf; |             warn_prerotate range pdf; | ||||||
|             let pdf = |             let pdf = | ||||||
| @@ -3722,7 +3723,7 @@ let go () = | |||||||
|             in |             in | ||||||
|               write_pdf false |               write_pdf false | ||||||
|                 (Cpdfaddtext.addtexts |                 (Cpdfaddtext.addtexts | ||||||
|                    args.linewidth args.outline args.fast args.fontname |                    ?embedinfo args.linewidth args.outline args.fast args.fontname | ||||||
|                    font args.embedfonts args.bates args.batespad args.color args.position |                    font args.embedfonts args.bates args.batespad args.color args.position | ||||||
|                    args.linespacing args.fontsize args.underneath text range |                    args.linespacing args.fontsize args.underneath text range | ||||||
|                    () args.relative_to_cropbox args.opacity |                    () args.relative_to_cropbox args.opacity | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user