File: text_extents.py

package info (click to toggle)
wxpython3.0 3.0.2.0%2Bdfsg-4
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 482,760 kB
  • ctags: 518,293
  • sloc: cpp: 2,127,226; python: 294,045; makefile: 51,942; ansic: 19,033; sh: 3,013; xml: 1,629; perl: 17
file content (27 lines) | stat: -rw-r--r-- 563 bytes parent folder | download | duplicates (16)
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
utf8 = "cairo"

snippet_normalize (cr, width, height)

cr.select_font_face ("Sans",
                     cairo.FONT_SLANT_NORMAL,
                     cairo.FONT_WEIGHT_NORMAL)

cr.set_font_size (0.4)
x_bearing, y_bearing, width, height, x_advance, y_advance = cr.text_extents (utf8)

x=0.1
y=0.6

cr.move_to (x,y)
cr.show_text (utf8)

#/* draw helping lines */
cr.set_source_rgba (1,0.2,0.2,0.6)
cr.arc (x, y, 0.05, 0, 2*M_PI)
cr.fill ()
cr.move_to (x,y)
cr.rel_line_to (0, -height)
cr.rel_line_to (width, 0)
cr.rel_line_to (x_bearing, -y_bearing)
cr.stroke ()