How to use the defcon.objects.base.BaseObject function in defcon

To help you get started, we’ve selected a few defcon examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github sugarlabs / edit-fonts-activity / third_party / defcon / objects / layerSet.py View on Github external
import weakref
from ufoLib import UFOReader
from defcon.objects.base import BaseObject
from defcon.objects.layer import Layer


class LayerSet(BaseObject):
    """
    This object manages all layers in the font.

    **This object posts the following notifications:**

    +-------------------------------+
    |Name                           |
    +===============================+
    |LayerSet.Changed               |
    +-------------------------------+
    |LayerSet.LayersChanged         |
    +-------------------------------+
    |LayerSet.LayerChanged          |
    +-------------------------------+
    |LayerSet.DefaultLayerWillChange|
    +-------------------------------+
github sugarlabs / edit-fonts-activity / third_party / defcon / objects / glyph.py View on Github external
warn(
        "addRepresentationFactory is deprecated. Use the functions in defcon.__init__.",
        DeprecationWarning)
    Glyph.representationFactories[name] = dict(
        factory=factory,
        destructiveNotifications=["Glyph.Changed"])


def removeRepresentationFactory(name):
    warn(
        "removeRepresentationFactory is deprecated. Use the functions in defcon.__init__.",
        DeprecationWarning)
    del Glyph.representationFactories[name]


class Glyph(BaseObject):
    """
    This object represents a glyph and it contains contour, component, anchor
    and other assorted bits data about the glyph.

    **This object posts the following notifications:**

    ============================
    Name
    ============================
    Glyph.Changed
    Glyph.BeginUndo
    Glyph.EndUndo
    Glyph.BeginRedo
    Glyph.EndRedo
    Glyph.NameWillChange
    Glyph.NameChanged
github sugarlabs / edit-fonts-activity / third_party / defcon / objects / imageSet.py View on Github external
import os
import hashlib
import weakref
from ufoLib import UFOReader, UFOLibError
from defcon.objects.base import BaseObject
from ufoLib.filenames import userNameToFileName
from ufoLib.validators import pngSignature


class ImageSet(BaseObject):
    """
    This object manages all images in the font.

    **This object posts the following notifications:**

    ===========================
    Name
    ===========================
    ImageSet.Changed
    ImageSet.FileNamesChanged
    ImageSet.ImageChanged
    ImageSet.ImageWillBeAdded
    ImageSet.ImageAdded
    ImageSet.ImageWillBeDeleted
    ImageSet.ImageDeleted
    ===========================
github robotools / defcon / Lib / defcon / objects / layoutEngine.py View on Github external
except:
            import traceback
            print(traceback.format_exc(5))
        if "GDEF" in otf:
            gdef = otf["GDEF"]
        if "GSUB" in otf:
            gsub = otf["GSUB"]
        if "GPOS" in otf:
            gpos = otf["GPOS"]
    return gdef, gsub, gpos

# -----------
# Main Object
# -----------

class LayoutEngine(BaseObject):

    """
    This object provides a GDEF, GSUB and GPOS OpenType Layout Engine for
    the default layer of the given font. The engine uses the ``compositor``
    module so you must have that installed to use this object.

    **This object posts the following notifications:**

    - LayoutEngine.Changed

    This object monitors the font's feature text and character mapping. When
    those change, the compiled tables will be flagged for recompilation and
    the next time the engine is queried the tables will be recompiled. Any
    data that you have retrieved, such as the list of feature tags, may no
    longer be correct. Thus, the data will need to be retrieved again. To be
    notified when this is necessary, subscribe to the ``LayoutEngine.Changed``
github robotools / defcon / Lib / defcon / objects / features.py View on Github external
from __future__ import absolute_import
import weakref
from defcon.objects.base import BaseObject


class Features(BaseObject):

    """
    This object contais the test represening features in the font.

    **This object posts the following notifications:**

    - Features.Changed
    - Features.BeginUndo
    - Features.EndUndo
    - Features.BeginRedo
    - Features.EndRedo
    - Features.TextChanged

    """

    changeNotificationName = "Features.Changed"
github robotools / defcon / Lib / defcon / objects / component.py View on Github external
from __future__ import absolute_import
import weakref
from warnings import warn
from fontTools.misc.transform import Transform
from defcon.objects.base import BaseObject
from defcon.tools.identifiers import makeRandomIdentifier
from defcon.tools.representations import componentBoundsRepresentationFactory, componentPointBoundsRepresentationFactory

_defaultTransformation = (1, 0, 0, 1, 0, 0)


class Component(BaseObject):

    """
    This object represents a reference to another glyph.

    **This object posts the following notifications:**

    - Component.Changed
    - Component.BaseGlyphChanged
    - Component.BaseGlyphDataChanged
    - Component.TransformationChanged
    - Component.IdentifierChanged

    """

    changeNotificationName = "Component.Changed"
    representationFactories = {
github sugarlabs / edit-fonts-activity / defcon / objects / features.py View on Github external
import weakref
from defcon.objects.base import BaseObject


class Features(BaseObject):
    """
    This object contais the test represening features in the font.

    **This object posts the following notifications:**

    ================
    Name
    ================
    Features.Changed
    Features.BeginUndo
    Features.EndUndo
    Features.BeginRedo
    Features.EndRedo
    Features.TextChanged
    ================
    """
github sugarlabs / edit-fonts-activity / third_party / defcon / objects / info.py View on Github external
prop = property(getter, setter, doc)

    setattr(cls, setterName, setter)
    setattr(cls, getterName, getter)
    setattr(cls, name, prop)


def init_properties(cls):
    for name in cls._properties:
        init_property(cls, name, cls._properties[name])
    return cls


@init_properties
class Info(BaseObject):
    """
    This object represents info values.

    **This object posts the following notifications:**

    ===========================
    Name
    ===========================
    Info.Changed
    Info.BeginUndo
    Info.EndUndo
    Info.BeginRedo
    Info.EndRedo
    Info.ValueChanged
    Info.GuidelinesChanged
    Info.GuidelineWillBeDeleted
github sugarlabs / edit-fonts-activity / third_party / defcon / objects / component.py View on Github external
import weakref
from warnings import warn
from fontTools.misc.transform import Transform
from defcon.objects.base import BaseObject

_defaultTransformation = (1, 0, 0, 1, 0, 0)


class Component(BaseObject):
    """
    This object represents a reference to another glyph.

    **This object posts the following notifications:**

    ===============================
    Name
    ===============================
    Component.Changed
    Component.BaseGlyphChanged
    Component.BaseGlyphDataChanged
    Component.TransformationChanged
    Component.IdentifierChanged
    ===============================
    """
github robotools / defcon / Lib / defcon / objects / layer.py View on Github external
from __future__ import absolute_import
import weakref
from fontTools.ufoLib import UFOFileStructure
from fontTools.misc.arrayTools import unionRect
from defcon.objects.base import BaseObject
from defcon.objects.glyph import Glyph
from defcon.objects.lib import Lib
from defcon.objects.uniData import UnicodeData
from defcon.objects.color import Color
from functools import partial


class Layer(BaseObject):

    """
    This object represents a layer in a :class:`LayerSet`.

    **This object posts the following notifications:**

    - Layer.Changed
    - Layer.GlyphsChanged
    - Layer.GlyphChanged
    - Layer.GlyphWillBeAdded
    - Layer.GlyphAdded
    - Layer.GlyphWillBeDeleted
    - Layer.GlyphDeleted
    - Layer.GlyphNameChanged
    - Layer.GlyphUnicodesChanged
    - Layer.NameChanged