Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

Font.java 1.3 KiB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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://sam.zoy.org/wtfpl/COPYING for more details.
  10. */
  11. package org.zoy.caca;
  12. public class Font extends NativeObject {
  13. static {
  14. Caca.load();
  15. }
  16. private static native long loadFont(String fontName);
  17. private static native long loadFont(byte[] fontBytes);
  18. public Font(String fontName) {
  19. ptr = loadFont(fontName);
  20. }
  21. public Font(byte[] fontBytes) {
  22. ptr = loadFont(fontBytes);
  23. }
  24. public static native String[] getFontNames();
  25. private static native int getFontWidth(long fontPtr);
  26. public int getWidth() {
  27. return getFontWidth(ptr);
  28. }
  29. private static native int getFontHeight(long fontPtr);
  30. public int getHeight() {
  31. return getFontHeight(ptr);
  32. }
  33. private static native int[][] getFontBlocks(long fontPtr);
  34. public int[][] getBlocks() {
  35. return getFontBlocks(ptr);
  36. }
  37. private static native void freeFont(long fontPtr);
  38. @Override
  39. public void finalize() throws Throwable {
  40. freeFont(ptr);
  41. super.finalize();
  42. }
  43. }