source: libcaca/trunk/python/caca/font.py @ 4398

Last change on this file since 4398 was 4398, checked in by Sam Hocevar, 12 years ago

New improved ctypes-based Python bindings, by Alex Foulon <alxf@lavabit.com>.

  • Property svn:keywords set to Id
File size: 1.5 KB
Line 
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
15""" Libcaca Python bindings """
16
17import ctypes
18
19from caca import _lib
20
21class _Font(object):
22    """ Model for Font object.
23    """
24    def __init__(self):
25        self._font = 0
26
27    def from_param(self):
28        """ Required by ctypes module to call object as parameter of
29            a C function.
30        """
31        return self._font
32
33    def __del__(self):
34        if self._font > 0:
35            self._free()
36
37    def __str__(self):
38        return "<CacaFont>"
39
40    def _free(self):
41        """ Free a libcaca font.
42        """
43        _lib.caca_free_font.argtypes = [_Font]
44        _lib.caca_free_font.restype = ctypes.c_int
45
46        return _lib.caca_free_font(self)
47
48class Font(_Font):
49    """ Font object, methods are libcaca functions with caca_font_t as first
50        argument.
51    """
52    def __init__(self, font, size=0):
53        """ Font constructor
54
55            font    -- the memory area containing the font or its name
56            size    -- the size of the memory area, or 0 if the font name is given
57        """
58        pass
59
Note: See TracBrowser for help on using the repository browser.