You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

62 lines
1.3 KiB

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