1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 package org.microemu.device.swt;
21
22 import java.net.URL;
23
24 import org.eclipse.swt.SWT;
25 import org.eclipse.swt.graphics.Font;
26
27 public class SwtTrueTypeFont implements SwtFont {
28
29 private URL url;
30
31 private String style;
32
33 private int size;
34
35 private boolean antialiasing;
36
37 private boolean initialized;
38
39 private Font font;
40
41 public SwtTrueTypeFont(URL url, String style, int size, boolean antialiasing) {
42 this.url = url;
43 this.style = style.toLowerCase();
44 this.size = size;
45 this.antialiasing = antialiasing;
46
47 this.initialized = false;
48 }
49
50 public void setAntialiasing(boolean antialiasing) {
51 if (this.antialiasing != antialiasing) {
52 this.antialiasing = antialiasing;
53 initialized = false;
54 }
55 }
56
57 public Font getFont() {
58 checkInitialized();
59
60 return font;
61 }
62
63 private synchronized void checkInitialized() {
64 if (!initialized) {
65 int swtStyle = 0;
66 if (style.indexOf("plain") != -1) {
67 swtStyle |= SWT.NORMAL;
68 }
69 if (style.indexOf("bold") != -1) {
70 swtStyle |= SWT.BOLD;
71 }
72 if (style.indexOf("italic") != -1) {
73 swtStyle |= SWT.ITALIC;
74 }
75 if (style.indexOf("underlined") != -1) {
76
77 }
78
79
80 initialized = true;
81 try {
82 throw new RuntimeException("not implemented");
83 } catch (RuntimeException ex) {
84 ex.printStackTrace();
85 throw ex;
86 }
87 }
88 }
89
90 public int charWidth(char ch) {
91 try {
92 throw new RuntimeException("not implemented");
93 } catch (RuntimeException ex) {
94 ex.printStackTrace();
95 throw ex;
96 }
97 }
98
99 public int charsWidth(char[] ch, int offset, int length) {
100 try {
101 throw new RuntimeException("not implemented");
102 } catch (RuntimeException ex) {
103 ex.printStackTrace();
104 throw ex;
105 }
106 }
107
108 public int getBaselinePosition() {
109 try {
110 throw new RuntimeException("not implemented");
111 } catch (RuntimeException ex) {
112 ex.printStackTrace();
113 throw ex;
114 }
115 }
116
117 public int getHeight() {
118 try {
119 throw new RuntimeException("not implemented");
120 } catch (RuntimeException ex) {
121 ex.printStackTrace();
122 throw ex;
123 }
124 }
125
126 public int stringWidth(String str) {
127 try {
128 throw new RuntimeException("not implemented");
129 } catch (RuntimeException ex) {
130 ex.printStackTrace();
131 throw ex;
132 }
133 }
134
135 }