comparison src/shape_text.c @ 346:b391722bf20e

sh_image_t::img_data is managed by paint_image_t. - sh_image_t should not try to free it. - call sh_text_P_generate_layout() in sh_text_transform() - remove calling from other functions.
author Thinker K.F. Li <thinker@branda.to>
date Sun, 08 Mar 2009 14:44:41 +0800
parents b0571f10c1b8
children 27774b93521e
comparison
equal deleted inserted replaced
345:d04085404583 346:b391722bf20e
63 63
64 text->shape.free = sh_text_free; 64 text->shape.free = sh_text_free;
65 text->layout = NULL; 65 text->layout = NULL;
66 text->attrs = attrs; 66 text->attrs = attrs;
67 text->align = TEXTALIGN_START; 67 text->align = TEXTALIGN_START;
68 sh_text_P_generate_layout(text, rdman->cr); 68
69
70 rdman_shape_man(rdman, (shape_t *)text); 69 rdman_shape_man(rdman, (shape_t *)text);
71 70
72 return (shape_t *)text; 71 return (shape_t *)text;
73 } 72 }
74 73
205 return OK; 204 return OK;
206 } 205 }
207 206
208 void sh_text_transform(shape_t *shape) { 207 void sh_text_transform(shape_t *shape) {
209 sh_text_t *text; 208 sh_text_t *text;
209 coord_t *coord;
210 canvas_t *canvas;
210 co_aix x, y; 211 co_aix x, y;
211 co_aix shw; 212 co_aix shw;
212 PangoRectangle extents; 213 PangoRectangle extents;
213 co_aix poses[2][2]; 214 co_aix poses[2][2];
214 int r; 215 int r;
215 216
216 text = (sh_text_t *)shape; 217 text = (sh_text_t *)shape;
217 218
218 text->d_font_size = coord_trans_size(shape->coord, text->font_size); 219 text->d_font_size = coord_trans_size(shape->coord, text->font_size);
220
221 coord = sh_get_coord(shape);
222 canvas = _coord_get_canvas(coord);
223 sh_text_P_generate_layout(text, (cairo_t *)canvas);
219 224
220 x = text->x; 225 x = text->x;
221 y = text->y; 226 y = text->y;
222 coord_trans_pos(shape->coord, &x, &y); 227 coord_trans_pos(shape->coord, &x, &y);
223 r = get_extents(text, &extents); 228 r = get_extents(text, &extents);
257 pango_layout_set_attributes(text->layout, text->attrs); 262 pango_layout_set_attributes(text->layout, text->attrs);
258 pango_cairo_update_layout(cr,text->layout); 263 pango_cairo_update_layout(cr,text->layout);
259 printf("text=%s\n",text->data); 264 printf("text=%s\n",text->data);
260 } 265 }
261 static void draw_text(sh_text_t *text, cairo_t *cr) { 266 static void draw_text(sh_text_t *text, cairo_t *cr) {
262 sh_text_P_generate_layout(text, cr);
263 cairo_move_to(cr, text->d_x, text->d_y); 267 cairo_move_to(cr, text->d_x, text->d_y);
264 pango_cairo_layout_path(cr,text->layout); 268 pango_cairo_layout_path(cr,text->layout);
265 } 269 }
266 270
267 271