source: tol/tolbase/lib/mimetex/mimetex.tcl @ c416362

1941-docker-image-to-testdevel
Last change on this file since c416362 was c416362, checked in by Jorge Pérez <josp.jorge@…>, 11 years ago

closes #1902, el ejecutable de 32 bit vale para 64 bit

Por otra parte initWM necesita del paquete Img para crear imagenes de tipo png

git-svn-id: ​https://www.tol-project.org/svn/tolp/trunk@7107 be4846ae-f051-483a-831f-b64e7d08527f

  • Property mode set to 100644
File size: 1.4 KB
RevLine 
[a680983]1package require base64
2
3namespace eval mimetex {
4  variable cache
5  variable bin ""
6  variable defaultBin
7
8  array set cache {}
9
10  array set defaultBin {
11    Linux,4        linux32/mimetex
[c416362]12    Linux,8        linux32/mimetex
[a680983]13    Windows\ NT,4  win32/mimetex.exe
[c416362]14    Windows\ NT,8  win32/mimetex.exe
[a680983]15  }
16
17  proc SetBinPath { path } {
18    variable bin $path
19  }
20
21  proc RenderImage { latex { name "" } } {
22    variable cache
23    variable bin
24
25    puts "RenderImage $latex"
26    if { [ info exists cache($latex) ] } {
27      return $cache($latex)
28    }
29    if { [ file executable $bin ] } {
30      set p [open [list |$bin -d $latex] r]
31      fconfigure $p -translation binary -encoding binary
32      set rawData [base64::encode [read $p]]
33      close $p
34      if { $name eq "" } {
35        set cache($latex) [ image create photo -data $rawData ]
36      } else {
37        set cache($latex) [ image create photo $name -data $rawData ]
38      }
39      return $cache($latex)
40    } else {
41      error "could not execute mimetex, $bin is not executable"
42    }
43  }
44
45 
46  set os $::tcl_platform(os)
47  set wordSize $::tcl_platform(wordSize)
48  if { [ info exists defaultBin($os,$wordSize) ] } {
49    set _cwd [ file normalize [ file dir [ info script ] ] ]
50    SetBinPath [ file join $_cwd $defaultBin($os,$wordSize) ]
51  } else {
52    puts "There is no default mimetex.cgi for os = $os and wordSize = $wordSize. You should set it up with SetBinPath"
53  }
54}
55
[c416362]56package provide mimetex 1.0
Note: See TracBrowser for help on using the repository browser.