From: Jure Kajzer Date: Mon, 30 Nov 2009 18:42:16 +0000 (+0000) Subject: * Added 5th parameter to texvc call (can be null and defaults to rgb '1.0 1.0 1.0'). X-Git-Tag: 1.31.0-rc.0~38670 X-Git-Url: http://git.cyclocoop.org/%40spipnet%40?a=commitdiff_plain;h=251527d2c1f916268323d57d572f1599a026c54c;p=lhc%2Fweb%2Fwiklou.git * Added 5th parameter to texvc call (can be null and defaults to rgb '1.0 1.0 1.0'). This parameter controls texvc background color. Can be set to output transparent background * Added $wgTexvcBackgroundColor parameter to DefaultSettings with value 'rgb 1.0 1.0 1.0' * Changed Math.php to call texvc with new parameter --- diff --git a/RELEASE-NOTES b/RELEASE-NOTES index f11febbb0a..75113ca626 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -290,6 +290,7 @@ Hopefully we will remove this configuration var soon) * (bug 20717) Added checkboxes to hide users with bot and/or sysop group membership in SpecialActiveusers * Allow \pagecolor and \definecolor in texvc +* $wgTexvcBackgroundColor contains background color for texvc call === Bug fixes in 1.16 === diff --git a/includes/DefaultSettings.php b/includes/DefaultSettings.php index 5253829617..b0dfd3b375 100644 --- a/includes/DefaultSettings.php +++ b/includes/DefaultSettings.php @@ -1895,6 +1895,13 @@ $wgSpecialPageCacheUpdates = array( $wgUseTeX = false; /** Location of the texvc binary */ $wgTexvc = './math/texvc'; +/** + * Texvc background color + * use LaTeX color format as used in \special function + * for transparent background use value 'Transparent' for alpha transparency or + * 'transparent' for binary transparency. + */ +$wgTexvcBackgroundColor = 'rgb 1.0 1.0 1.0'; /** * Normally when generating math images, we double-check that the diff --git a/includes/Math.php b/includes/Math.php index 2e61494486..ea9ff58ac5 100644 --- a/includes/Math.php +++ b/includes/Math.php @@ -33,7 +33,7 @@ class MathRenderer { function render() { global $wgTmpDirectory, $wgInputEncoding; - global $wgTexvc, $wgMathCheckFiles; + global $wgTexvc, $wgMathCheckFiles, $wgTexvcBackgroundColor; $fname = 'MathRenderer::render'; if( $this->mode == MW_MATH_SOURCE ) { @@ -63,7 +63,8 @@ class MathRenderer { escapeshellarg( $wgTmpDirectory ).' '. escapeshellarg( $wgTmpDirectory ).' '. escapeshellarg( $this->tex ).' '. - escapeshellarg( $wgInputEncoding ); + escapeshellarg( $wgInputEncoding ).' '. + escapeshellarg( $wgTexvcBackgroundColor ); if ( wfIsWindows() ) { # Invoke it within cygwin sh, because texvc expects sh features in its default shell diff --git a/math/README b/math/README index 069be750a0..d0e2164884 100644 --- a/math/README +++ b/math/README @@ -48,13 +48,13 @@ Just Works. It can be run manually for testing or for use in another app. === Command-line parameters === - texvc + texvc Be sure to properly quote the TeX code! Example: - texvc /home/wiki/tmp /home/wiki/math "y=x+2" iso-8859-1 + texvc /home/wiki/tmp /home/wiki/math "y=x+2" iso-8859-1 "rgb 1.0 1.0 1.0" === Output format === diff --git a/math/render.ml b/math/render.ml index 67ecab8d0e..f16735554e 100644 --- a/math/render.ml +++ b/math/render.ml @@ -5,11 +5,11 @@ let cmd_convert tmpprefix finalpath = "convert -quality 100 -density 120 " ^ tmp (* 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 backcolor = "dvipng -bg \'" ^ backcolor ^ "\' -gamma 1.5 -D 120 -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 backcolor = let tmpprefix0 = (string_of_int (Unix.getpid ()))^"_"^md5 in let tmpprefix = (tmppath^"/"^tmpprefix0) in let unlink_all () = @@ -30,7 +30,7 @@ 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") backcolor) != 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) diff --git a/math/texvc.ml b/math/texvc.ml index abddd3d0d6..38a7e93b7e 100644 --- a/math/texvc.ml +++ b/math/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 backcolor = let outtex = Util.mapjoin Texutil.render_tex tree in let md5 = Digest.to_hex (Digest.string outtex) in begin @@ -19,11 +19,11 @@ 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 backcolor 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))) + try render Sys.argv.(1) Sys.argv.(2) (Parser.tex_expr lexer_token_safe (Lexing.from_string Sys.argv.(3))) (try Sys.argv.(5) with _ -> "rgb 1.0 1.0 1.0") with Parsing.Parse_error -> print_string "S" | LexerException _ -> print_string "E" | Texutil.Illegal_tex_function s -> print_string ("F" ^ s)