1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
|
' Call dviout with an optional dvi-file parameter
' and font search configuration parameters.
option explicit
On Error Resume Next
dim oWsh, oEnv, oFS, oArgs, oExec, sTmp, bFirst
Dim sTL, oTL, sGS, sCmd, oTmp, i, s
set oWsh = wscript.createobject( "wscript.Shell" )
Set oArgs = wscript.Arguments
Set oEnv = oWsh.Environment( "PROCESS" )
Set oFS = CreateObject("Scripting.FileSystemObject")
If wscript.version < 5.6 Then
MsgBox "Need VBScript 5.6 or later. Aborting...", vbOKOnly+vbCritical, "Error"
Wscript.Quit
Else
sTmp = ""
' ask kpathsea
Set oExec = oWsh.Exec("kpsewhich -var-value=SELFAUTOPARENT")
sTmp = oExec.StdOut.ReadLine
Err.clear()
If sTmp <> "" then
sTL = replace(sTmp, "/", "\")
End If
End If
If sTL = "" Then
MsgBox "TeX Live not found; aborting...", vbOKOnly+vbCritical, "Error"
wscript.quit
End If
If InStr(sTL, " ") <> 0 Then
Set oTL = oFS.GetFolder(sTL)
sTL = oTL.ShortPath
End If
' Ghostscript environment settings
sGS = sTL & "\tlpkg\tlgs"
oEnv("PATH") = sGS & "\bin;" & oEnv("PATH")
oEnv("GS_LIB") = sGS & "\fonts;" & sGS & "\lib;" & sGS & "\Resource"
sCmd = sTL & "\dviout\dviout.exe -TEXROOT="
'add font trees to command-Line
'first make sure %TEXMFVAR%\fonts exists
sTmp = ""
' ask kpathsea
Set oExec = oWsh.Exec("kpsewhich -var-value=TEXMFVAR")
sTmp = oExec.StdOut.ReadLine
If Not oFS.FolderExists(sTmp) Then
s = oFS.GetParentFolderName(sTmp)
If Not oFS.FolderExists(s) Then
Err.clear()
oFS.CreateFolder(s)
If Not oFS.FolderExists(s) Then
MsgBox "No place to put bitmaps; aborting...", _
vbOKOnly+vbCritical, "Error"
wscript.quit
End If
End If
oFS.CreateFolder(sTmp)
If Not oFS.FolderExists(sTmp) Then
MsgBox "No place to put bitmaps; aborting...", _
vbOKOnly+vbCritical, "Error"
wscript.quit
End If
End If
If Not oFS.FolderExists(sTmp & "\fonts") Then
Err.clear()
oFS.CreateFolder(sTmp & "\fonts")
If Not oFS.FolderExists(sTmp & "\fonts") Then
MsgBox "No place to put bitmaps; aborting...", _
vbOKOnly+vbCritical, "Error"
wscript.quit
End If
End If
Set oExec = oWsh.Exec("kpsewhich -show-path=tfm")
sTmp = oExec.StdOut.ReadLine
bFirst = True
For Each s in Split(sTmp, ";", -1, 1)
s = Trim(s)
If s<>"." Then
If InStr(s, "!!")=1 Then
s = Mid(s, 3)
End If
i = InStr(s, "/fonts/tfm")
If i<>0 then
s = Mid(s, 1, i+5)
Else
s=""
End If
s = Trim(s)
If s<>"" then
s = replace(s, "/", "\")
If oFS.FolderExists(s) Then
If InStr(s," ")<>0 Then
Set oTmp = oFS.GetFolder(s)
s = oTmp.ShortPath
End If
If Not bFirst Then
sCmd=sCmd & ";"
Else
bfirst=False
End If
sCmd = sCmd & s
End If
End If
End If
Next
sCmd = sCmd & " -TEXPK=""^r\pk\\^s.^dpk;^r\tfm\\^s^tfm;" & _
"^r\vf\\^s.vf;^r\ovf\\^s.ovf;^r\tfm\\^s.tfm"""
' assume argument either short or already quoted
If (oArgs.length > 0) Then
For i = 0 To (oArgs.length - 1) Step 1
sCmd = sCmd & " " & oArgs(i)
Next
End If
' 2nd arg 1: normal window
oWsh.run sCmd, 1
'wscript.echo sCmd
|