source: tol/tolbaseBLT/lib/mimetex/mimetex.tcl @ 56ade3b

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

fixes #1932, se ha creado la rama trunk/tolbaseBLT copia de trunk/tolbase

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

  • Property mode set to 100644
File size: 1.4 KB
Line 
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
12    Linux,8        linux32/mimetex
13    Windows\ NT,4  win32/mimetex.exe
14    Windows\ NT,8  win32/mimetex.exe
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
56package provide mimetex 1.0
Note: See TracBrowser for help on using the repository browser.