Index: trunk/src_plugins/io_pads/delay_create.h =================================================================== --- trunk/src_plugins/io_pads/delay_create.h (revision 34662) +++ trunk/src_plugins/io_pads/delay_create.h (revision 34663) @@ -152,6 +152,7 @@ pcb_dlcr_draw_t *pcb_dlcr_line_new(pcb_dlcr_t *dlcr, rnd_coord_t x1, rnd_coord_t y1, rnd_coord_t x2, rnd_coord_t y2, rnd_coord_t width, rnd_coord_t clearance); pcb_dlcr_draw_t *pcb_dlcr_arc_new(pcb_dlcr_t *dlcr, rnd_coord_t cx, rnd_coord_t cy, rnd_coord_t r, double start_deg, double delta_deg, rnd_coord_t width, rnd_coord_t clearance); pcb_dlcr_draw_t *pcb_dlcr_text_new(pcb_dlcr_t *dlcr, rnd_coord_t x, rnd_coord_t y, double rot, int scale, rnd_coord_t thickness, const char *str, long flags); +pcb_dlcr_draw_t *pcb_dlcr_text_by_bbox_new(pcb_dlcr_t *dlcr, pcb_font_t *font, rnd_coord_t x, rnd_coord_t y, rnd_coord_t bbw, rnd_coord_t bbh, rnd_coord_t anchx, rnd_coord_t anchy, double scxy, pcb_text_mirror_t mirror, double rot, rnd_coord_t thickness, const char *str, long flags); pcb_dlcr_draw_t *pcb_dlcr_via_new(pcb_dlcr_t *dlcr, rnd_coord_t x, rnd_coord_t y, rnd_coord_t clearance, long proto_id, const char *proto_name, const char *term); pcb_dlcr_draw_t *pcb_dlcr_poly_new(pcb_dlcr_t *dlcr, int hole, long prealloc_len); pcb_dlcr_draw_t *pcb_dlcr_poly_lineto(pcb_dlcr_t *dlcr, pcb_dlcr_draw_t *poly, rnd_coord_t x, rnd_coord_t y); Index: trunk/src_plugins/io_pads/read_high.c =================================================================== --- trunk/src_plugins/io_pads/read_high.c (revision 34662) +++ trunk/src_plugins/io_pads/read_high.c (revision 34663) @@ -303,14 +303,16 @@ { pcb_dlcr_draw_t *text; char name[16], hjust[16], vjust[16], font[128], str[1024]; - rnd_coord_t x, y, thick, h; - double rot, scale; + rnd_coord_t x, y, thick, h, str_width; + double rot, anx = 0, any = 0; long level, flg = 0; int res, mirr = 0; rnd_bool is_label = !!(how & TEXT_IS_LABEL); rnd_bool in_subc = !!(how & TEXT_IN_LAST_SUBC); + rnd_coord_t anchx, anchy; + pcb_text_mirror_t tmir = 0; - *font = *str = '\0'; + *font = *str = *hjust = *vjust = '\0'; if (is_label) if ((res = pads_read_word(rctx, name, sizeof(name), 0)) <= 0) return res; @@ -327,10 +329,18 @@ if (*hjust == 'N') { mirr = 0; if ((res = pads_read_word(rctx, hjust, sizeof(hjust), 0)) <= 0) return res; + if (strcmp(hjust, "CENTER") == 0) anx = 0.5; + else if (strcmp(hjust, "LEFT") == 0) anx = 0.0; + else if (strcmp(hjust, "RIGHT") == 0) anx = 1.0; + else PADS_ERROR((RND_MSG_ERROR, "invalid text horizontal adjustment: %s\n", hjust)); } else if (*hjust == 'M') { mirr = 1; if ((res = pads_read_word(rctx, hjust, sizeof(hjust), 0)) <= 0) return res; + if (strcmp(hjust, "CENTER") == 0) any = 0.5; + else if (strcmp(hjust, "UP") == 0) any = 0.0; + else if (strcmp(hjust, "DOWN") == 0) any = 1.0; + else PADS_ERROR((RND_MSG_ERROR, "invalid text vertical adjustment: %s\n", vjust)); } if ((res = pads_read_word(rctx, vjust, sizeof(vjust), 0)) <= 0) return res; @@ -352,9 +362,6 @@ else rnd_trace("\n"); - TODO("Rewrite for bbox based"); - scale = (double)h/RND_MM_TO_COORD(1.0) * 66.7; - if (is_label) { if (strcmp(str, "Part Type") == 0) goto skip; @@ -367,7 +374,14 @@ } TODO("do not ignore text alignment; requires powerpcb to check"); - text = pcb_dlcr_text_new(&rctx->dlcr, x+xo, y+yo+h, rot, scale, 0, str, (is_label ? PCB_FLAG_FLOATER : 0) | flg); + str_width = rnd_round(h / 1.9 * strlen(str)); + anchx = rnd_round(str_width * anx); + anchy = rnd_round(h * any); + + text = pcb_dlcr_text_by_bbox_new(&rctx->dlcr, pcb_font(rctx->pcb, 0, 1), + x+xo, y+yo+h, str_width, h, anchx, anchy, 1, tmir, rot, thick, str, + (is_label ? PCB_FLAG_FLOATER : 0) | flg); + text->loc_line = rctx->line; if (in_subc) { text->in_last_subc = 1;