Example #1
0
    def test_unrotated_transposed_font_get_mask(self):
        # Arrange
        text = "mask this"
        font = self.get_font()
        orientation = None
        transposed_font = ImageFont.TransposedFont(font,
                                                   orientation=orientation)

        # Act
        mask = transposed_font.getmask(text)

        # Assert
        self.assertEqual(mask.size, (108, 13))
Example #2
0
    def test_rotated_transposed_font_get_mask(self):
        # Arrange
        text = "mask this"
        font = self.get_font()
        orientation = Image.ROTATE_90
        transposed_font = ImageFont.TransposedFont(font,
                                                   orientation=orientation)

        # Act
        mask = transposed_font.getmask(text)

        # Assert
        self.assertEqual(mask.size, (13, 108))
Example #3
0
    def test_unrotated_transposed_font(self):
        img_grey = Image.new("L", (100, 100))
        draw = ImageDraw.Draw(img_grey)
        word = "testing"
        font = self.get_font()

        orientation = None
        transposed_font = ImageFont.TransposedFont(font,
                                                   orientation=orientation)

        # Original font
        draw.font = font
        box_size_a = draw.textsize(word)

        # Rotated font
        draw.font = transposed_font
        box_size_b = draw.textsize(word)

        # Check boxes a and b are same size
        self.assertEqual(box_size_a, box_size_b)
Example #4
0
    def test_rotated_transposed_font(self):
        img_grey = Image.new("L", (100, 100))
        draw = ImageDraw.Draw(img_grey)
        word = "testing"
        font = self.get_font()

        orientation = Image.ROTATE_90
        transposed_font = ImageFont.TransposedFont(font,
                                                   orientation=orientation)

        # Original font
        draw.font = font
        box_size_a = draw.textsize(word)

        # Rotated font
        draw.font = transposed_font
        box_size_b = draw.textsize(word)

        # Check (w,h) of box a is (h,w) of box b
        self.assertEqual(box_size_a[0], box_size_b[1])
        self.assertEqual(box_size_a[1], box_size_b[0])