[Sorry if this is posted twice, I tried to post via gmane but the message didn't show up after 16 hours]
Hi all,
texvc currently generates math images with a density of 120 dpi. This value is hard coded.
I'm attaching a patch which allows one to change that value by passing an additional density argument on the command line.
This patch is already being used on wikipedia when one uses the collection extension to generate a pdf.
Is it ok to apply this patch to current svn trunk? My coworker has commit rights, but it's not clear to us who is responsible for texvc and if it would be ok to apply it.
Regards, - Ralf
diff --git a/Makefile b/Makefile index 47c40f9..361a665 100644 --- a/Makefile +++ b/Makefile @@ -9,6 +9,7 @@ render.o render.cmi render.cmo render.cmx texvc_tex.cmx \ texvc_tex.o texvc_tex.cmi texvc_tex html.cmi html.cmo html.cmx \ html.o mathml.cmi mathml.cmo mathml.cmx mathml.o CGIPATH=-I /usr/lib/ocaml/cgi -I /usr/lib/ocaml/netstring -I /usr/lib/ocaml/pcre +PREFIX=/usr/local
all: texvc texvc_test texvc_tex texvc.bc: util.cmo parser.cmo html.cmo mathml.cmo texutil.cmo render.cmo lexer.cmo texvc.cmo @@ -37,6 +38,9 @@ texvc_cgi: util.cmo parser.cmo texutil.cmo render.cmo lexer.cmo texvc_cgi.cmo clean: rm -f $(OBJ)
+install:: all + install -m 755 -p -s texvc texvc_test texvc_tex $(PREFIX)/bin + html.cmo: render_info.cmi tex.cmi util.cmo html.cmi html.cmx: render_info.cmi tex.cmi util.cmx html.cmi html.cmi: tex.cmi diff --git a/render.ml b/render.ml index 67ecab8..945c2b0 100644 --- a/render.ml +++ b/render.ml @@ -1,15 +1,15 @@ let cmd_dvips tmpprefix = "dvips -q -R -E " ^ tmpprefix ^ ".dvi -f >" ^ tmpprefix ^ ".ps" let cmd_latex tmpprefix = "latex " ^ tmpprefix ^ ".tex >/dev/null" (* Putting -transparent white in converts arguments will sort-of give you transperancy *) -let cmd_convert tmpprefix finalpath = "convert -quality 100 -density 120 " ^ tmpprefix ^ ".ps " ^ finalpath ^ " >/dev/null 2>/dev/null" +let cmd_convert tmpprefix finalpath resolution_in_dpi = "convert -quality 100 -density " ^ (string_of_int resolution_in_dpi) ^ " " ^ tmpprefix ^ ".ps " ^ finalpath ^ " >/dev/null 2>/dev/null" (* Putting -bg Transparent in dvipng's arguments will give full-alpha transparency *) (* Note that IE have problems with such PNGs and need an additional javascript snippet *) (* Putting -bg transparent in dvipng's arguments will give binary transparency *) -let cmd_dvipng tmpprefix finalpath = "dvipng -gamma 1.5 -D 120 -T tight --strict " ^ tmpprefix ^ ".dvi -o " ^ finalpath ^ " >/dev/null 2>/dev/null" +let cmd_dvipng tmpprefix finalpath resolution_in_dpi = "dvipng -gamma 1.5 -D " ^ (string_of_int resolution_in_dpi) ^ " -T tight --strict " ^ tmpprefix ^ ".dvi -o " ^ finalpath ^ " >/dev/null 2>/dev/null"
exception ExternalCommandFailure of string
-let render tmppath finalpath outtex md5 = +let render tmppath finalpath outtex md5 resolution_in_dpi = let tmpprefix0 = (string_of_int (Unix.getpid ()))^"_"^md5 in let tmpprefix = (tmppath^"/"^tmpprefix0) in let unlink_all () = @@ -30,10 +30,10 @@ let render tmppath finalpath outtex md5 = close_out f; if Util.run_in_other_directory tmppath (cmd_latex tmpprefix0) != 0 then (unlink_all (); raise (ExternalCommandFailure "latex")) - else if (Sys.command (cmd_dvipng tmpprefix (finalpath^"/"^md5^".png")) != 0) + else if (Sys.command (cmd_dvipng tmpprefix (finalpath^"/"^md5^".png") resolution_in_dpi) != 0) then (if (Sys.command (cmd_dvips tmpprefix) != 0) then (unlink_all (); raise (ExternalCommandFailure "dvips")) - else if (Sys.command (cmd_convert tmpprefix (finalpath^"/"^md5^".png")) != 0) + else if (Sys.command (cmd_convert tmpprefix (finalpath^"/"^md5^".png") resolution_in_dpi) != 0) then (unlink_all (); raise (ExternalCommandFailure "convert")) else unlink_all ()) else unlink_all () diff --git a/texvc.ml b/texvc.ml index abddd3d..7fae97c 100644 --- a/texvc.ml +++ b/texvc.ml @@ -3,7 +3,7 @@ let lexer_token_safe lexbuf = try Lexer.token lexbuf with Failure s -> raise (LexerException s)
-let render tmppath finalpath tree = +let render tmppath finalpath tree resolution_in_dpi = let outtex = Util.mapjoin Texutil.render_tex tree in let md5 = Digest.to_hex (Digest.string outtex) in begin @@ -19,11 +19,12 @@ let render tmppath finalpath tree = | Some h,Html.LIBERAL,Some m -> "L" ^ md5 ^ h ^ "\000" ^ m | None,_,Some m -> "X" ^ md5 ^ m ); - Render.render tmppath finalpath outtex md5 + Render.render tmppath finalpath outtex md5 resolution_in_dpi end let _ = - Texutil.set_encoding (try Sys.argv.(4) with _ -> "UTF-8"); - try render Sys.argv.(1) Sys.argv.(2) (Parser.tex_expr lexer_token_safe (Lexing.from_string Sys.argv.(3))) + Texutil.set_encoding (try Sys.argv.(4) with _ -> "UTF-8"); + let resolution_in_dpi = (try int_of_string Sys.argv.(5) with _ -> 120) in + try render Sys.argv.(1) Sys.argv.(2) (Parser.tex_expr lexer_token_safe (Lexing.from_string Sys.argv.(3))) resolution_in_dpi with Parsing.Parse_error -> print_string "S" | LexerException _ -> print_string "E" | Texutil.Illegal_tex_function s -> print_string ("F" ^ s) @@ -32,3 +33,4 @@ let _ = | Failure _ -> print_string "-" | Render.ExternalCommandFailure s -> () | _ -> print_string "-" +