def test_text_clip(self): with self.draw_and_check(): self.gc.clip_to_rect(23, 77, 100, 23) font = Font(family=MODERN) font.size = 24 self.gc.set_font(font) self.gc.set_text_position(23, 67) self.gc.show_text("hello kiva")
def test_text(self): for family in [ DECORATIVE, DEFAULT, ITALIC, MODERN, ROMAN, SCRIPT, TELETYPE]: for weight in range(100, 1001, 100): for style in [NORMAL, ITALIC]: with self.subTest(family=family, weight=weight, style=style): self.gc = self.create_graphics_context() with self.draw_and_check(): font = Font(family=family) font.size = 24 font.weight = weight font.style = style self.gc.set_font(font) self.gc.set_text_position(23, 67) self.gc.show_text("hello kiva")
# This software is provided without warranty under the terms of the BSD # license included in LICENSE.txt and may be redistributed only under # the conditions described in the aforementioned license. The license # is also available online at http://www.enthought.com/licenses/BSD.txt # # Thanks for using Enthought open source! from time import perf_counter from kiva.agg import AffineMatrix, GraphicsContextArray from kiva.api import MODERN, Font gc = GraphicsContextArray((200, 200)) font = Font(family=MODERN) # print(font.size) font.size = 8 gc.set_font(font) t1 = perf_counter() # consecutive printing of text. with gc: gc.set_antialias(False) gc.set_fill_color((0, 1, 0)) gc.translate_ctm(50, 50) gc.rotate_ctm(3.1416 / 4) gc.show_text("hello") gc.translate_ctm(-50, -50) gc.set_text_matrix(AffineMatrix()) gc.set_fill_color((0, 1, 1))