* Added 5th parameter to texvc call (can be null and defaults to rgb '1.0 1.0 1.0').
authorJure Kajzer <freakolowsky@users.mediawiki.org>
Mon, 30 Nov 2009 18:42:16 +0000 (18:42 +0000)
committerJure Kajzer <freakolowsky@users.mediawiki.org>
Mon, 30 Nov 2009 18:42:16 +0000 (18:42 +0000)
  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

RELEASE-NOTES
includes/DefaultSettings.php
includes/Math.php
math/README
math/render.ml
math/texvc.ml

index f11febb..75113ca 100644 (file)
@@ -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 ===
 
index 5253829..b0dfd3b 100644 (file)
@@ -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
index 2e61494..ea9ff58 100644 (file)
@@ -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
index 069be75..d0e2164 100644 (file)
@@ -48,13 +48,13 @@ Just Works. It can be run manually for testing or for use in another app.
 
 === Command-line parameters ===
 
-    texvc <temp directory> <output directory> <TeX code> <encoding>
+    texvc <temp directory> <output directory> <TeX code> <encoding> <color>
 
 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 ===
 
index 67ecab8..f167355 100644 (file)
@@ -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)
index abddd3d..38a7e93 100644 (file)
@@ -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)