Index: trunk/src/draw.c =================================================================== --- trunk/src/draw.c (revision 10737) +++ trunk/src/draw.c (revision 10738) @@ -702,7 +702,7 @@ } } -static void label_setup(pcb_text_t *text, pcb_coord_t x, pcb_coord_t y, double scale, pcb_bool vert, const char *lab) +void pcb_term_label_setup(pcb_text_t *text, pcb_coord_t x, pcb_coord_t y, double scale, pcb_bool vert, pcb_bool centered, const char *lab) { pcb_bool flip_x = conf_core.editor.view.flip_x; pcb_bool flip_y = conf_core.editor.view.flip_y; @@ -716,6 +716,20 @@ text->fid = 0; text->Scale = scale; text->Direction = (vert ? 1 : 0) + (flip_x ? 2 : 0); + + pcb_text_bbox(NULL, text); + + if (centered) { + pcb_coord_t dx, dy; + dx = (text->BoundingBox.X2 - text->BoundingBox.X1) / 2; + dy = (text->BoundingBox.Y2 - text->BoundingBox.Y1) / 2; + text->X -= dx; + text->Y -= dy; + text->BoundingBox.X1 -= dx; + text->BoundingBox.X2 -= dx; + text->BoundingBox.Y1 -= dy; + text->BoundingBox.Y2 -= dy; + } } void pcb_term_label_draw(pcb_coord_t x, pcb_coord_t y, double scale, pcb_bool vert, pcb_bool centered, const char *lab) @@ -722,22 +736,8 @@ { pcb_text_t text; - label_setup(&text, x, y, scale, vert, lab); + pcb_term_label_setup(&text, x, y, scale, vert, centered, lab); - if (centered) { - pcb_coord_t dx, dy; - pcb_text_bbox(NULL, &text); - dx = (text.BoundingBox.X2 - text.BoundingBox.X1) / 2; - dy = (text.BoundingBox.Y2 - text.BoundingBox.Y1) / 2; - text.X -= dx; - text.Y -= dy; - text.BoundingBox.X1 -= dx; - text.BoundingBox.X2 -= dx; - text.BoundingBox.Y1 -= dy; - text.BoundingBox.Y2 -= dy; - pcb_text_bbox(NULL, &text); - } - if (pcb_gui->gui) pcb_draw_doing_pinout++; pcb_text_draw(&text, 0); Index: trunk/src/draw.h =================================================================== --- trunk/src/draw.h (revision 10737) +++ trunk/src/draw.h (revision 10738) @@ -113,6 +113,11 @@ /* Draw (render) a terminal label */ void pcb_term_label_draw(pcb_coord_t x, pcb_coord_t y, double scale, pcb_bool vert, pcb_bool centered, const char *lab); +/* Similar to pcb_term_label_draw(), but doesn't draw only sets up text with + its bounding box */ +void pcb_term_label_setup(pcb_text_t *text, pcb_coord_t x, pcb_coord_t y, double scale, pcb_bool vert, pcb_bool centered, const char *lab); + + /* Schedule an object to be called again at the end for drawing its labels on top of everything. */ void pcb_draw_delay_label_add(pcb_any_obj_t *obj);