summaryrefslogtreecommitdiff
path: root/test/unicodeText.py
blob: 5ad50c7b76aba60dda90e31cdfe1bd8940434777 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Test unicode text

Functions/methods which accept unicode text:
  Context.select_font_face()
  Context.show_text()
  Context.text_extents()
  Context.text_path()
  ToyFontFace()
  ScaledFont.text_extents()
"""

import cairo

width, height = 300,300
surface = cairo.ImageSurface(cairo.FORMAT_ARGB32, width, height)
ctx = cairo.Context(surface)

ctx.scale(width, height)
ctx.set_line_width(0.04)

ctx.select_font_face("Sans",
                     cairo.FONT_SLANT_NORMAL,
                     cairo.FONT_WEIGHT_NORMAL)
ctx.set_font_size(0.20)
ctx.move_to(0.05, 0.5)
ctx.show_text("ēxāmple.")

surface.write_to_png("test-out.png")