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.
 
 
 
 
 
 

60 regels
1.5 KiB

  1. # -*- coding: utf-8 -*-
  2. #
  3. # libcaca Colour ASCII-Art library
  4. # Python language bindings
  5. # Copyright (c) 2010 Alex Foulon <alxf@lavabit.com>
  6. # All Rights Reserved
  7. #
  8. # This library is free software. It comes without any warranty, to
  9. # the extent permitted by applicable law. You can redistribute it
  10. # and/or modify it under the terms of the Do What The Fuck You Want
  11. # To Public License, Version 2, as published by Sam Hocevar. See
  12. # http://sam.zoy.org/wtfpl/COPYING for more details.
  13. #
  14. """ Libcaca Python bindings """
  15. import ctypes
  16. from caca import _lib
  17. class _Font(object):
  18. """ Model for Font object.
  19. """
  20. def __init__(self):
  21. self._font = 0
  22. def from_param(self):
  23. """ Required by ctypes module to call object as parameter of
  24. a C function.
  25. """
  26. return self._font
  27. def __del__(self):
  28. if self._font > 0:
  29. self._free()
  30. def __str__(self):
  31. return "<CacaFont>"
  32. def _free(self):
  33. """ Free a libcaca font.
  34. """
  35. _lib.caca_free_font.argtypes = [_Font]
  36. _lib.caca_free_font.restype = ctypes.c_int
  37. return _lib.caca_free_font(self)
  38. class Font(_Font):
  39. """ Font object, methods are libcaca functions with caca_font_t as first
  40. argument.
  41. """
  42. def __init__(self, font, size=0):
  43. """ Font constructor
  44. font -- the memory area containing the font or its name
  45. size -- the size of the memory area, or 0 if the font name is given
  46. """
  47. pass