Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion enable/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
===========

- :class:`~.IDroppedOnHandler`
- :func:`~.str_to_font`
- :func:`~.intersect_bounds`

Constants
Expand Down
19 changes: 11 additions & 8 deletions enable/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,16 @@


def str_to_font(object, name, value):
"Converts a (somewhat) free-form string into a valid Font object."
# FIXME: Make this less free-form and more well-defined.
""" Converts a (somewhat) free-form string into a valid Font object.
"""
import warnings

warnings.warn(
("str_to_font should not be imported from enable.api. Use the version "
"from kiva.fonttools instead."),
DeprecationWarning,
stacklevel=2,
)
try:
point_size = 10
family = SWISS
Expand Down Expand Up @@ -115,14 +123,9 @@ def str_to_font(object, name, value):
raise TraitError(object, name, "a font descriptor string", repr(value))


str_to_font.info = (
"a string describing a font (e.g. '12 pt bold italic "
+ "swiss family Arial' or 'default 12')"
)

# Pick a default font that should work on all platforms.
default_font_name = "modern 10"
default_font = str_to_font(None, None, default_font_name)
default_font = Font(family=MODERN, size=10)


def bounding_box(components):
Expand Down
5 changes: 3 additions & 2 deletions enable/examples/demo/enable/filled_container_demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,9 @@
from numpy import array
from traits.api import Any, Enum, Float, Instance, Tuple

from enable.api import Container, Component, Pointer, str_to_font
from enable.api import Container, Component, Pointer
from enable.example_support import DemoFrame, demo_main
from kiva.fonttools import str_to_font


class MyFilledContainer(Container):
Expand All @@ -35,7 +36,7 @@ class MyFilledContainer(Container):
def _draw_container_mainlayer(self, gc, view_bounds, mode="default"):
'Draws a filled container with the word "Container" in the center'
if not self._font:
self._font = str_to_font(None, None, "modern 10")
self._font = str_to_font("modern 10")

with gc:
gc.set_fill_color(self.bgcolor_)
Expand Down
5 changes: 3 additions & 2 deletions enable/examples/demo/enable/hidpi_component.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
from traits.api import Any, HasTraits, Instance, Str
from traitsui.api import HGroup, UItem, View

from enable.api import Component, ComponentEditor, str_to_font
from enable.api import Component, ComponentEditor
from kiva.fonttools import str_to_font


class MyComponent(Component):
Expand All @@ -27,7 +28,7 @@ class MyComponent(Component):

def draw(self, gc, **kwargs):
if not self._font:
self._font = str_to_font(None, None, "modern 48")
self._font = str_to_font("modern 48")

gc.clear((0.5, 0.5, 0.5))
mx = self.x + self.width / 2.0
Expand Down