@@ -55,6 +55,16 @@ public final class Font extends Resource {
55
55
*/
56
56
int zoom ;
57
57
58
+ /**
59
+ * this field is used to mark destroyed images
60
+ */
61
+ private boolean isDestroyed ;
62
+
63
+ /**
64
+ * this field is used to store fontData provided during initialization
65
+ */
66
+ private FontData fontData ;
67
+
58
68
/**
59
69
* Font height in points. As the conversion to pixel height involves rounding the fontHeight must
60
70
* be cached.
@@ -100,15 +110,15 @@ private Font(Device device, long handle, int zoom) {
100
110
public Font (Device device , FontData fd ) {
101
111
super (device );
102
112
this .zoom = DPIUtil .getNativeDeviceZoom ();
103
- init (fd );
113
+ this . fontData = new FontData (fd . toString () );
104
114
this .fontHeight = fd .height ;
105
115
init ();
106
116
}
107
117
108
118
private Font (Device device , FontData fd , int zoom ) {
109
119
super (device );
110
120
this .zoom = zoom ;
111
- init (fd );
121
+ this . fontData = new FontData (fd . toString () );
112
122
this .fontHeight = fd .height ;
113
123
init ();
114
124
}
@@ -147,7 +157,7 @@ public Font(Device device, FontData[] fds) {
147
157
}
148
158
this .zoom = DPIUtil .getNativeDeviceZoom ();
149
159
FontData fd = fds [0 ];
150
- init ( fds [ 0 ] );
160
+ this . fontData = new FontData ( fd . toString () );
151
161
this .fontHeight = fd .height ;
152
162
init ();
153
163
}
@@ -180,7 +190,7 @@ public Font(Device device, String name, int height, int style) {
180
190
super (device );
181
191
if (name == null ) SWT .error (SWT .ERROR_NULL_ARGUMENT );
182
192
this .zoom = DPIUtil .getNativeDeviceZoom ();
183
- init ( new FontData (name , height , style ) );
193
+ this . fontData = new FontData (name , height , style );
184
194
this .fontHeight = height ;
185
195
init ();
186
196
}
@@ -189,14 +199,15 @@ public Font(Device device, String name, int height, int style) {
189
199
super (device );
190
200
if (name == null ) SWT .error (SWT .ERROR_NULL_ARGUMENT );
191
201
this .zoom = DPIUtil .getNativeDeviceZoom ();
192
- init ( new FontData (name , height , style ) );
202
+ this . fontData = new FontData (name , height , style );
193
203
this .fontHeight = height ;
194
204
init ();
195
205
}
196
206
@ Override
197
207
void destroy () {
198
208
OS .DeleteObject (handle );
199
209
handle = 0 ;
210
+ isDestroyed = true ;
200
211
}
201
212
202
213
/**
@@ -237,7 +248,7 @@ public FontData[] getFontData() {
237
248
238
249
private LOGFONT fetchLogFontData () {
239
250
LOGFONT logFont = new LOGFONT ();
240
- OS .GetObject (handle , LOGFONT .sizeof , logFont );
251
+ OS .GetObject (win32_getHandle ( this ) , LOGFONT .sizeof , logFont );
241
252
return logFont ;
242
253
}
243
254
@@ -278,7 +289,7 @@ void init (FontData fd) {
278
289
*/
279
290
@ Override
280
291
public boolean isDisposed () {
281
- return handle == 0 ;
292
+ return isDestroyed ;
282
293
}
283
294
284
295
/**
0 commit comments