| 1 |
/** |
| 2 |
* libcaca Java bindings for libcaca |
| 3 |
* Copyright (c) 2009 Adrien Grand <[email protected]> |
| 4 |
* |
| 5 |
* This library is free software. It comes without any warranty, to |
| 6 |
* the extent permitted by applicable law. You can redistribute it |
| 7 |
* and/or modify it under the terms of the Do What the Fuck You Want |
| 8 |
* to Public License, Version 2, as published by Sam Hocevar. See |
| 9 |
* http://www.wtfpl.net/ for more details. |
| 10 |
*/ |
| 11 |
|
| 12 |
package org.zoy.caca; |
| 13 |
|
| 14 |
public class Font extends NativeObject { |
| 15 |
|
| 16 |
static { |
| 17 |
Caca.load(); |
| 18 |
} |
| 19 |
|
| 20 |
private static native long loadFont(String fontName); |
| 21 |
private static native long loadFont(byte[] fontBytes); |
| 22 |
|
| 23 |
public Font(String fontName) { |
| 24 |
ptr = loadFont(fontName); |
| 25 |
} |
| 26 |
|
| 27 |
public Font(byte[] fontBytes) { |
| 28 |
ptr = loadFont(fontBytes); |
| 29 |
} |
| 30 |
|
| 31 |
public static native String[] getFontNames(); |
| 32 |
|
| 33 |
private static native int getFontWidth(long fontPtr); |
| 34 |
|
| 35 |
public int getWidth() { |
| 36 |
return getFontWidth(ptr); |
| 37 |
} |
| 38 |
|
| 39 |
private static native int getFontHeight(long fontPtr); |
| 40 |
|
| 41 |
public int getHeight() { |
| 42 |
return getFontHeight(ptr); |
| 43 |
} |
| 44 |
|
| 45 |
private static native int[][] getFontBlocks(long fontPtr); |
| 46 |
|
| 47 |
public int[][] getBlocks() { |
| 48 |
return getFontBlocks(ptr); |
| 49 |
} |
| 50 |
|
| 51 |
private static native void freeFont(long fontPtr); |
| 52 |
|
| 53 |
@Override |
| 54 |
public void finalize() throws Throwable { |
| 55 |
freeFont(ptr); |
| 56 |
super.finalize(); |
| 57 |
} |
| 58 |
|
| 59 |
} |