aboutsummaryrefslogtreecommitdiffstats
path: root/gl4java/utils/glf/GLF.java
blob: 60e7c92b261cadc623cb8c666769604bacadbde4 (plain)
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
/**
 * @(#) GLF.java
 */

package gl4java.utils.glf;

import java.net.*;
import java.io.*;

import gl4java.*;
import gl4java.utils.*;

/**
 * The default implementation class for GLF native function mapping
 *
 * @version 	2.00, 21. April 1999
 * @author      Sven Goethel
 */
public class GLF
	extends GLFFuncJNI
{
	public GLF() 
        { 
		super();
		glfInit();
	}

	protected void finalize()
		throws Throwable
	{
		glfClose();
		super.finalize();
	}

	public final int glfLoadFont ( String fontname )
	{
		return glfLoadFont(null, fontname);
	}

	public final int glfLoadFont ( URL baseURL, String fontURI )
	{
		int fontd = 0;
		long filed = Tool.copyResource2TempFile(this, baseURL, fontURI);
		if(filed!=0)
		{
			fontd = glfLoadFontNative(filed);
			Tool.tmpfileClose(filed);
			return fontd;
		}
		return GLF.GLF_ERROR;
	}

	public final int glfLoadBFont ( String fontname )
	{
		return glfLoadBFont(null, fontname);
	}

	public final int glfLoadBFont ( URL baseURL, String fontURI )
	{
		int fontd = 0;
		long filed = Tool.copyResource2TempFile(this, baseURL, fontURI);
		if(filed!=0)
		{
			fontd = glfLoadBFontNative(filed);
			Tool.tmpfileClose(filed);
			return fontd;
		}

		return GLF.GLF_ERROR;
	}

	public static void main( String args[] ) 
	{
		String fontURI = null;

		if(args.length==0)
		{
			System.out.println("java gl4java.utils.glf.GLF <font-URI> [<baseURL>]");
			System.out.println("... using default font times_new1.glf, now !");
			fontURI="times_new1.glf";
		} else fontURI = args[0];

		URL baseURL = null;

		if(args.length>1)
		{
			try {
				baseURL = new URL(args[1]);
			} catch (Exception ex) {
				System.out.println(ex);
			}
		}

		if(GLContext.doLoadNativeLibraries(null, null, null)==false)
		         System.out.println("could not load def. native libs.");

		GLF glf = new GLF();

		glf.glfLoadFont(baseURL, fontURI);
	}
}