Recognizes if input is ogg or not.
[xiph/unicode.git] / planarity / gameboard_draw_text.c
blobff0b75aac465bc41fdd9d1426dda0d095b43b325
1 /*
3 * gPlanarity:
4 * The geeky little puzzle game with a big noodly crunch!
5 *
6 * gPlanarity copyright (C) 2005 Monty <monty@xiph.org>
7 * Original Flash game by John Tantalo <john.tantalo@case.edu>
8 * Original game concept by Mary Radcliffe
10 * gPlanarity is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2, or (at your option)
13 * any later version.
15 * gPlanarity is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with Postfish; see the file COPYING. If not, write to the
22 * Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
27 #include <math.h>
28 #include <string.h>
29 #include <gtk/gtk.h>
30 #include <gdk/gdk.h>
32 #include "graph.h"
33 #include "gameboard.h"
35 GdkRectangle render_text_centered(cairo_t *c, char *s, int x, int y){
36 cairo_text_extents_t ex;
37 GdkRectangle r;
39 cairo_text_extents (c, s, &ex);
41 r.x=x-(ex.width/2);
42 r.y=y+(ex.y_bearing/2);
43 r.width=ex.width;
44 r.height=ex.height;
46 cairo_move_to (c, r.x-ex.x_bearing, r.y-ex.y_bearing);
47 cairo_show_text (c, s);
49 return r;
52 GdkRectangle render_border_centered(cairo_t *c, char *s, int x, int y){
53 cairo_text_extents_t ex;
54 GdkRectangle r;
56 cairo_text_extents (c, s, &ex);
58 r.x=x-(ex.width/2)-2;
59 r.y=y+(ex.y_bearing/2)-2;
60 r.width=ex.width+5;
61 r.height=ex.height+5;
63 cairo_save(c);
64 cairo_move_to (c, r.x-ex.x_bearing+2, r.y-ex.y_bearing+2 );
65 cairo_set_line_width(c,3);
66 cairo_set_source_rgba(c,1,1,1,.9);
67 cairo_text_path (c, s);
68 cairo_stroke(c);
69 cairo_restore(c);
71 return r;
74 GdkRectangle render_bordertext_centered(cairo_t *c, char *s, int x, int y){
75 GdkRectangle r = render_border_centered(c,s,x,y);
76 render_text_centered(c,s,x,y);
77 return r;