1 /** 2 * libcaca Java bindings for libcaca 3 * Copyright (c) 2009 Adrien Grand <jpountz@dinauz.org> 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 { Caca.load()17 Caca.load(); 18 } 19 loadFont(String fontName)20 private static native long loadFont(String fontName); loadFont(byte[] fontBytes)21 private static native long loadFont(byte[] fontBytes); 22 Font(String fontName)23 public Font(String fontName) { 24 ptr = loadFont(fontName); 25 } 26 Font(byte[] fontBytes)27 public Font(byte[] fontBytes) { 28 ptr = loadFont(fontBytes); 29 } 30 getFontNames()31 public static native String[] getFontNames(); 32 getFontWidth(long fontPtr)33 private static native int getFontWidth(long fontPtr); 34 getWidth()35 public int getWidth() { 36 return getFontWidth(ptr); 37 } 38 getFontHeight(long fontPtr)39 private static native int getFontHeight(long fontPtr); 40 getHeight()41 public int getHeight() { 42 return getFontHeight(ptr); 43 } 44 getFontBlocks(long fontPtr)45 private static native int[][] getFontBlocks(long fontPtr); 46 getBlocks()47 public int[][] getBlocks() { 48 return getFontBlocks(ptr); 49 } 50 freeFont(long fontPtr)51 private static native void freeFont(long fontPtr); 52 53 @Override finalize()54 public void finalize() throws Throwable { 55 freeFont(ptr); 56 super.finalize(); 57 } 58 59 } 60