| | 372 | |
| | 373 | def _renderTitle(self, cx): |
| | 374 | if self.options.title: |
| | 375 | # get previous font information |
| | 376 | oldFace = cx.get_font_face() |
| | 377 | oldMatrix = cx.get_font_matrix() |
| | 378 | |
| | 379 | cx.select_font_face(self.options.titleFont, |
| | 380 | cairo.FONT_SLANT_NORMAL, |
| | 381 | cairo.FONT_WEIGHT_BOLD) |
| | 382 | cx.set_font_size(self.options.titleFontSize) |
| | 383 | |
| | 384 | title = unicode(self.options.title) |
| | 385 | extents = cx.text_extents(title) |
| | 386 | titleWidth = extents[2] |
| | 387 | |
| | 388 | x = self.area.x + self.area.w / 2.0 - titleWidth / 2.0 |
| | 389 | y = cx.font_extents()[0] # font ascent |
| | 390 | |
| | 391 | cx.move_to(x, y) |
| | 392 | cx.show_text(title) |
| | 393 | |
| | 394 | # restore font state |
| | 395 | cx.set_font_face(oldFace) |
| | 396 | cx.set_font_matrix(oldMatrix) |