-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathmakesvg.js
62 lines (54 loc) · 1.59 KB
/
makesvg.js
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
var command=environment["sun.java.command"];
var match=command.match(/ (.+)\/makesvg/);
var dir;
if (match) {
dir = match[1];
} else {
dir = ".";
}
print ("loading libraries from `"+dir+"/kage-engine' ...");
load(dir+"/kage-engine/2d.js");
load(dir+"/kage-engine/buhin.js");
load(dir+"/kage-engine/curve.js");
load(dir+"/kage-engine/kage.js");
load(dir+"/kage-engine/kagecd.js");
load(dir+"/kage-engine/kagedf.js");
load(dir+"/kage-engine/polygon.js");
load(dir+"/kage-engine/polygons.js");
if(arguments.length != 1){
print("ERROR: input the target name");
quit();
}
target = arguments[0];
dirname = "./"+target+".work";
dir = new java.io.File(dirname);
if(!dir.exists()){
dir.mkdir();
}
fis = new java.io.FileInputStream("./" + target + ".source");
isr = new java.io.InputStreamReader(fis);
br = new java.io.BufferedReader(isr);
while((line = br.readLine()) != null){
tab = line.indexOf("\t");
code = line.substring(0, tab);
data = line.substring(tab + 1, line.length());
if(data.length() > 0){
var kage = new Kage();
//kage.kUseCurve = true;
kage.kUseCurve = false;
var polygons = new Polygons();
kage.kBuhin.push("temp", data + "");
kage.makeGlyph(polygons, "temp");
fos = new java.io.FileOutputStream(dirname + "/" + code + ".svg");
osw = new java.io.OutputStreamWriter(fos);
bw = new java.io.BufferedWriter(osw);
bw.write(polygons.generateSVG(false));
//bw.write(polygons.generateSVGFont(false));
bw.close();
osw.close();
fos.close();
}
}
br.close();
isr.close();
fis.close();