Index: trunk/src/obj_text.c =================================================================== --- trunk/src/obj_text.c (revision 31194) +++ trunk/src/obj_text.c (revision 31195) @@ -310,6 +310,26 @@ *scy = (text->scale_y > 0) ? text->scale_y : sc; } +int pcb_text_old_scale(pcb_text_t *text, int *scale_out) +{ + double scx, scy; + + if ((text->scale_x <= 0) && (text->scale_y <= 0)) { /* old model */ + *scale_out = text->Scale; + return 0; + } + + pcb_text_get_scale_xy(text, &scx, &scy); + if (fabs(scx - scy) < 0.01) { /* new model but scx == scy */ + *scale_out = rnd_round(scx * 100); + return 0; + } + + *scale_out = rnd_round((scx + scy) / 2.0 * 100); + return -1; +} + + /* creates the bounding box of a text object */ void pcb_text_bbox(pcb_font_t *FontPtr, pcb_text_t *Text) { Index: trunk/src/obj_text.h =================================================================== --- trunk/src/obj_text.h (revision 31194) +++ trunk/src/obj_text.h (revision 31195) @@ -54,6 +54,11 @@ #define PCB_SCALE_TEXT(COORD,TEXTSCALE) ((rnd_coord_t)rnd_round((COORD) * ((double)(TEXTSCALE) / 100.0))) #define PCB_UNPCB_SCALE_TEXT(COORD,TEXTSCALE) ((rnd_coord_t)rnd_round((COORD) * (100.0 / (double)(TEXTSCALE)))) +/* Determine what the Scale value would have been in the old, Scale only + setup and store it in scale_out. Useful for compatibility saves. Returns + 0 on succes, -1 on error (with a best effort estimation left in scale_out) */ +int pcb_text_old_scale(pcb_text_t *text, int *scale_out); + pcb_text_t *pcb_text_alloc(pcb_layer_t * layer); pcb_text_t *pcb_text_alloc_id(pcb_layer_t *layer, long int id); void pcb_text_free(pcb_text_t * data);