Skip to content

Commit a26147c

Browse files
committed
validation update
1 parent 6490345 commit a26147c

2 files changed

Lines changed: 12 additions & 7 deletions

File tree

plotdevice/gfx/atoms.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -326,13 +326,10 @@ class StyleMixin(Grob):
326326
"""Mixin class for text-styling support.
327327
Adds the stylesheet, fill, and font attributes to the class."""
328328
ctxAttrs = ('_font', '_stylesheet', '_fillcolor')
329-
opts = ('face','family','size','weight','width','variant','italic', # font selection
330-
'lig','sc','osf','tab','vpos','frac', 'ss', # aat features
331-
'leading', 'tracking', 'indent', 'align', 'hyphenate', # layout
332-
'fontname','fontsize','lineheight','font', # nodebox compat
333-
'style', # use named style as baseline
334-
'fill', # color override
335-
)
329+
layoutOpts = ('leading','spacing','margin','indent','align','hyphenate','lineheight')
330+
fontOpts = ('face','family','size','weight','width','variant','italic','tracking','fontname','fontsize','font')
331+
aatOpts = ('lig','sc','osf','tab','vpos','frac', 'ss')
332+
opts = fontOpts + layoutOpts + aatOpts + ('style', 'fill')
336333

337334
def __init__(self, **kwargs):
338335
super(StyleMixin, self).__init__(**kwargs)

plotdevice/gfx/typography.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,14 @@ def __exit__(self, type, value, tb):
228228
_ctx._layout, _ctx._font = self._rollback
229229
del self._rollback
230230

231+
@classmethod
232+
def validate(cls, kwargs):
233+
known = LineLayout._fields + ('lineheight',)
234+
remaining = [arg for arg in kwargs.keys() if arg not in known]
235+
if remaining:
236+
unknown = "Unknown %s argument%s: %s" % (cls.__name__, '' if len(remaining)==1 else 's', ", ".join(remaining))
237+
raise DeviceError(unknown)
238+
231239

232240
class Family(object):
233241
def __init__(self, famname):

0 commit comments

Comments
 (0)