File: subclassing.rst

package info (click to toggle)
defcon 0.10.3-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 3,096 kB
  • sloc: python: 12,305; makefile: 66
file content (24 lines) | stat: -rw-r--r-- 733 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
.. highlight:: python

.. _Subclassing:

===========
Subclassing
===========

The defcon objects are built to have basic functionality. Your application can, and should, have its own functionality that is not part of the standard defcon repertoire. The objects are built with this in mind -- they are built to be subclassed and extended. This is done easily::

  from defcon import Glyph

  class MyCustomGlyph(Glyph):

    def myCustomMethod(self):
      # do something to the glyph data

When it is time to load a font, you pass this custom class to the Font object::

  from defcon import Font

  font = Font(glyphClass=MyCustomGlyph)

When a glyph is loaded, the glyph class you provided will be used to create the glyph object.