Skip to content

Commit 52a5129

Browse files
Introducing new method to get handle
also encapsulating handle field to private. It cant be accessed from outside of this class
1 parent ee0fdb8 commit 52a5129

File tree

1 file changed

+23
-2
lines changed
  • bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics

1 file changed

+23
-2
lines changed

bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/Font.java

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,8 @@ public final class Font extends Resource {
4646
* platforms and should never be accessed from application code.
4747
* </p>
4848
*
49-
* @noreference This field is not intended to be referenced by clients.
5049
*/
51-
public long handle;
50+
private long handle;
5251

5352
/**
5453
* The zoom in % of the standard resolution used for conversion of point height to pixel height
@@ -294,6 +293,28 @@ public String toString () {
294293
return "Font {" + handle + "}";
295294
}
296295

296+
/**
297+
* <b>IMPORTANT:</b> This method is not part of the public
298+
* API for Font. It is marked public only so that it
299+
* can be shared within the packages provided by SWT. It is not
300+
* available on all platforms, and should never be called from
301+
* application code.
302+
*
303+
* Creates a new handle for the requested font or return the existing one
304+
*
305+
* @param font the font to get the handle of
306+
*
307+
* @return handle of the font
308+
*
309+
* @noreference This method is not intended to be referenced by clients.
310+
*/
311+
public static long win32_getHandle (Font font) {
312+
if(font.handle == 0) {
313+
font.init(font.fontData);
314+
}
315+
return font.handle;
316+
}
317+
297318
/**
298319
* Invokes platform specific functionality to allocate a new font.
299320
* <p>

0 commit comments

Comments
 (0)