Mercurial > MadButterfly
comparison src/shape_text.c @ 104:98c83441d7d6
-
author | Thinker K.F. Li <thinker@branda.to> |
---|---|
date | Thu, 11 Sep 2008 09:14:58 +0800 |
parents | dd813dcc232c |
children | b90abd31a281 |
comparison
equal
deleted
inserted
replaced
103:19f09c343dcc | 104:98c83441d7d6 |
---|---|
4 #include <math.h> | 4 #include <math.h> |
5 #include <cairo.h> | 5 #include <cairo.h> |
6 #include "mb_types.h" | 6 #include "mb_types.h" |
7 #include "shapes.h" | 7 #include "shapes.h" |
8 | 8 |
9 #define ASSERT(x) | |
9 #define OK 0 | 10 #define OK 0 |
10 #define ERR -1 | 11 #define ERR -1 |
11 | 12 |
12 typedef struct _sh_text { | 13 typedef struct _sh_text { |
13 shape_t shape; | 14 shape_t shape; |
117 | 118 |
118 x = text->x; | 119 x = text->x; |
119 y = text->y; | 120 y = text->y; |
120 coord_trans_pos(shape->coord, &x, &y); | 121 coord_trans_pos(shape->coord, &x, &y); |
121 r = get_extents(text, &extents); | 122 r = get_extents(text, &extents); |
122 if(r != OK) | 123 ASSERT(r == OK); |
123 /*! \todo announce error. change return type? */ | |
124 return; | |
125 | 124 |
126 text->d_x = x; | 125 text->d_x = x; |
127 text->d_y = y; | 126 text->d_y = y; |
128 shw = shape->stroke_width / 2; | 127 shw = shape->stroke_width / 2; |
129 /* FIXME: It is unreasonable that a font exceed it's bbox. | 128 /* FIXME: It is unreasonable that a font exceed it's bbox. |
132 poses[0][0] = x + extents.x_bearing - 5 - shw; | 131 poses[0][0] = x + extents.x_bearing - 5 - shw; |
133 poses[0][1] = y + extents.y_bearing - 5 - shw; | 132 poses[0][1] = y + extents.y_bearing - 5 - shw; |
134 poses[1][0] = poses[0][0] + extents.width + 10 + shape->stroke_width; | 133 poses[1][0] = poses[0][0] + extents.width + 10 + shape->stroke_width; |
135 poses[1][1] = poses[0][1] + extents.height + 10 + shape->stroke_width; | 134 poses[1][1] = poses[0][1] + extents.height + 10 + shape->stroke_width; |
136 geo_from_positions(shape->geo, 2, poses); | 135 geo_from_positions(shape->geo, 2, poses); |
136 /*! \todo Support ratation for shape_text. */ | |
137 } | 137 } |
138 | 138 |
139 | 139 |
140 static void draw_text(sh_text_t *text, cairo_t *cr) { | 140 static void draw_text(sh_text_t *text, cairo_t *cr) { |
141 cairo_set_scaled_font(cr, text->scaled_font); | 141 cairo_set_scaled_font(cr, text->scaled_font); |