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
* (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 ===
$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
function render() {
global $wgTmpDirectory, $wgInputEncoding;
- global $wgTexvc, $wgMathCheckFiles;
+ global $wgTexvc, $wgMathCheckFiles, $wgTexvcBackgroundColor;
$fname = 'MathRenderer::render';
if( $this->mode == MW_MATH_SOURCE ) {
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
=== 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 ===
(* 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 () =
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)
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
| 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)