mirror of
				https://github.com/johnwhitington/cpdf-source.git
				synced 2025-06-05 22:09:39 +02:00 
			
		
		
		
	Move Standard 14 substitute loading into Cpdfembed
This commit is contained in:
		| @@ -24,21 +24,6 @@ let initial_file_size = ref 0 | |||||||
|  |  | ||||||
| let empty = Pdf.empty () | let empty = Pdf.empty () | ||||||
|  |  | ||||||
| let fontnames = |  | ||||||
|   [(Pdftext.TimesRoman, ["NimbusRoman-Regular.ttf"]); |  | ||||||
|    (Pdftext.TimesBold, ["NimbusRoman-Bold.ttf"]); |  | ||||||
|    (Pdftext.TimesItalic, ["NimbusRoman-Italic.ttf"]); |  | ||||||
|    (Pdftext.TimesBoldItalic, ["NimbusRoman-BoldItalic.ttf"]); |  | ||||||
|    (Pdftext.Helvetica, ["NimbusSans-Regular.ttf"]); |  | ||||||
|    (Pdftext.HelveticaBold, ["NimbusSans-Bold.ttf"]); |  | ||||||
|    (Pdftext.HelveticaOblique, ["NimbusSans-Italic.ttf"]); |  | ||||||
|    (Pdftext.HelveticaBoldOblique, ["NimbusSans-BoldItalic.ttf"]); |  | ||||||
|    (Pdftext.Courier, ["NimbusMonoPS-Regular.ttf"]); |  | ||||||
|    (Pdftext.CourierBold, ["NimbusMonoPS-Bold.ttf"]); |  | ||||||
|    (Pdftext.CourierOblique, ["NimbusMonoPS-Italic.ttf"]); |  | ||||||
|    (Pdftext.CourierBoldOblique, ["NimbusMonoPS-BoldItalic.ttf"]); |  | ||||||
|    (Pdftext.Symbol, ["StandardSymbolsPS.ttf"]); |  | ||||||
|    (Pdftext.ZapfDingbats, ["D050000L.ttf"])] |  | ||||||
|  |  | ||||||
| (* Wrap up the file reading functions to exit with code 1 when an encryption | (* Wrap up the file reading functions to exit with code 1 when an encryption | ||||||
| problem occurs. This happens when object streams are in an encrypted document | problem occurs. This happens when object streams are in an encrypted document | ||||||
| @@ -1707,11 +1692,7 @@ let embed_font_inner font = | |||||||
|       begin match args.embedstd14 with |       begin match args.embedstd14 with | ||||||
|       | Some dirname ->  |       | Some dirname ->  | ||||||
|           begin try |           begin try | ||||||
|           let fontfile, fontname = |             let fontfile, fontname = Cpdfembed.load_substitute dirname f in | ||||||
|           let filename = hd (List.assoc f fontnames) in |  | ||||||
|             Pdfio.bytes_of_string (contents_of_file (Filename.concat dirname filename)), |  | ||||||
|             Filename.remove_extension filename |  | ||||||
|           in |  | ||||||
|               Cpdfembed.EmbedInfo {fontfile; fontname; encoding = args.fontencoding} |               Cpdfembed.EmbedInfo {fontfile; fontname; encoding = args.fontencoding} | ||||||
|           with |           with | ||||||
|             e -> error (Printf.sprintf "Can't load font for embedding: %s\n" (Printexc.to_string e)) |             e -> error (Printf.sprintf "Can't load font for embedding: %s\n" (Printexc.to_string e)) | ||||||
|   | |||||||
							
								
								
									
										21
									
								
								cpdfembed.ml
									
									
									
									
									
								
							
							
						
						
									
										21
									
								
								cpdfembed.ml
									
									
									
									
									
								
							| @@ -106,3 +106,24 @@ let rec collate_runs cfn a = function | |||||||
| let collate_runs = function | let collate_runs = function | ||||||
|   | [] -> [] |   | [] -> [] | ||||||
|   | (_, fontnum, _)::_ as l -> collate_runs fontnum [] l |   | (_, fontnum, _)::_ as l -> collate_runs fontnum [] l | ||||||
|  |  | ||||||
|  | let fontnames = | ||||||
|  |   [(Pdftext.TimesRoman, ["NimbusRoman-Regular.ttf"]); | ||||||
|  |    (Pdftext.TimesBold, ["NimbusRoman-Bold.ttf"]); | ||||||
|  |    (Pdftext.TimesItalic, ["NimbusRoman-Italic.ttf"]); | ||||||
|  |    (Pdftext.TimesBoldItalic, ["NimbusRoman-BoldItalic.ttf"]); | ||||||
|  |    (Pdftext.Helvetica, ["NimbusSans-Regular.ttf"]); | ||||||
|  |    (Pdftext.HelveticaBold, ["NimbusSans-Bold.ttf"]); | ||||||
|  |    (Pdftext.HelveticaOblique, ["NimbusSans-Italic.ttf"]); | ||||||
|  |    (Pdftext.HelveticaBoldOblique, ["NimbusSans-BoldItalic.ttf"]); | ||||||
|  |    (Pdftext.Courier, ["NimbusMonoPS-Regular.ttf"]); | ||||||
|  |    (Pdftext.CourierBold, ["NimbusMonoPS-Bold.ttf"]); | ||||||
|  |    (Pdftext.CourierOblique, ["NimbusMonoPS-Italic.ttf"]); | ||||||
|  |    (Pdftext.CourierBoldOblique, ["NimbusMonoPS-BoldItalic.ttf"]); | ||||||
|  |    (Pdftext.Symbol, ["StandardSymbolsPS.ttf"]); | ||||||
|  |    (Pdftext.ZapfDingbats, ["D050000L.ttf"])] | ||||||
|  |  | ||||||
|  | let load_substitute dirname f = | ||||||
|  |   let filename = hd (List.assoc f fontnames) in | ||||||
|  |     (Pdfio.bytes_of_string (contents_of_file (Filename.concat dirname filename)), | ||||||
|  |      Filename.remove_extension filename) | ||||||
|   | |||||||
| @@ -24,3 +24,6 @@ val embed_truetype : | |||||||
|  |  | ||||||
| (** Collate outputs of [get_char] with like font *) | (** Collate outputs of [get_char] with like font *) | ||||||
| val collate_runs : ('a * 'b * 'c) list -> ('a * 'b * 'c) list list | val collate_runs : ('a * 'b * 'c) list -> ('a * 'b * 'c) list list | ||||||
|  |  | ||||||
|  | (** Load substitute Standard 14 font *) | ||||||
|  | val load_substitute : string -> Pdftext.standard_font -> Pdfio.bytes * string | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user