Commit
font.*
rcParams so they take effect only on to-b…
…e-created text objects
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -808,18 +808,19 @@ def set_family(self, family): | |
'fantasy', or 'monospace', or a real font name. | ||
""" | ||
if family is None: | ||
self._family = None | ||
else: | ||
if is_string_like(family): | ||
family = [family] | ||
self._family = family | ||
family = rcParams['font.family'] | ||
if is_string_like(family): | ||
family = [family] | ||
self._family = family | ||
set_name = set_family | ||
|
||
def set_style(self, style): | ||
""" | ||
Set the font style. Values are: 'normal', 'italic' or | ||
'oblique'. | ||
""" | ||
if style is None: | ||
style = rcParams['font.style'] | ||
if style not in ('normal', 'italic', 'oblique', None): | ||
raise ValueError("style must be normal, italic or oblique") | ||
self._slant = style | ||
|
@@ -829,6 +830,8 @@ def set_variant(self, variant): | |
""" | ||
Set the font variant. Values are: 'normal' or 'small-caps'. | ||
""" | ||
if variant is None: | ||
variant = rcParams['font.variant'] | ||
if variant not in ('normal', 'small-caps', None): | ||
raise ValueError("variant must be normal or small-caps") | ||
self._variant = variant | ||
|
@@ -840,14 +843,15 @@ def set_weight(self, weight): | |
'regular', 'book', 'medium', 'roman', 'semibold', 'demibold', | ||
'demi', 'bold', 'heavy', 'extra bold', 'black' | ||
""" | ||
if weight is not None: | ||
try: | ||
weight = int(weight) | ||
if weight < 0 or weight > 1000: | ||
raise ValueError() | ||
except ValueError: | ||
if weight not in weight_dict: | ||
raise ValueError("weight is invalid") | ||
if weight is None: | ||
weight = rcParams['font.weight'] | ||
try: | ||
weight = int(weight) | ||
if weight < 0 or weight > 1000: | ||
raise ValueError() | ||
except ValueError: | ||
if weight not in weight_dict: | ||
raise ValueError("weight is invalid") | ||
self._weight = weight | ||
|
||
def set_stretch(self, stretch): | ||
|
@@ -857,14 +861,15 @@ def set_stretch(self, stretch): | |
'semi-expanded', 'expanded', 'extra-expanded' or | ||
'ultra-expanded', or a numeric value in the range 0-1000. | ||
""" | ||
if stretch is not None: | ||
try: | ||
stretch = int(stretch) | ||
if stretch < 0 or stretch > 1000: | ||
raise ValueError() | ||
except ValueError: | ||
if stretch not in stretch_dict: | ||
raise ValueError("stretch is invalid") | ||
if stretch is None: | ||
stretch = rcParams['font.weight'] | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
mdboom
Author
Member
|
||
try: | ||
stretch = int(stretch) | ||
if stretch < 0 or stretch > 1000: | ||
raise ValueError() | ||
except ValueError: | ||
if stretch not in stretch_dict: | ||
raise ValueError("stretch is invalid") | ||
self._stretch = stretch | ||
|
||
def set_size(self, size): | ||
|
@@ -873,12 +878,13 @@ def set_size(self, size): | |
'x-small', 'small', 'medium', 'large', 'x-large', 'xx-large' | ||
or an absolute font size, e.g., 12. | ||
""" | ||
if size is not None: | ||
try: | ||
size = float(size) | ||
except ValueError: | ||
if size is not None and size not in font_scalings: | ||
raise ValueError("size is invalid") | ||
if size is None: | ||
size = rcParams['font.size'] | ||
try: | ||
size = float(size) | ||
except ValueError: | ||
if size is not None and size not in font_scalings: | ||
raise ValueError("size is invalid") | ||
self._size = size | ||
|
||
def set_file(self, file): | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -262,7 +262,7 @@ def validate_colorlist(s): | |
|
||
def validate_stringlist(s): | ||
'return a list' | ||
if type(s) is str: | ||
if type(s) in (str, unicode): | ||
return [v.strip() for v in s.split(',')] | ||
else: | ||
assert type(s) in [list, tuple] | ||
|
@@ -513,7 +513,7 @@ def __call__(self, s): | |
|
||
|
||
## font props | ||
'font.family': ['sans-serif', str], # used by text object | ||
'font.family': ['sans-serif', validate_stringlist], # used by text object | ||
This comment has been minimized.
Sorry, something went wrong.
leejjoon
Contributor
|
||
'font.style': ['normal', str], | ||
'font.variant': ['normal', str], | ||
'font.stretch': ['normal', str], | ||
|
Was this supposed to be
'font.stretch'
? Relates to #2006