Index: bxl.h =================================================================== --- bxl.h (revision 30609) +++ bxl.h (revision 30610) @@ -16,10 +16,11 @@ } pcb_bxl_just_t; typedef struct { - pcb_coord_t width, height, char_width; + double width, height, char_width; } pcb_bxl_test_style_t; typedef struct pcb_bxl_ctx_s { + pcb_board_t *pcb; pcb_subc_t *subc; char in_target_fp; /* 1 if we are parsing the target footprint; else skip */ @@ -32,8 +33,10 @@ pcb_coord_t origin_x, origin_y, endp_x, endp_y, width, radius; pcb_poly_t *poly; double arc_start, arc_delta; + double rot; pcb_bxl_just_t hjust, vjust; pcb_bxl_test_style_t *text_style; + char *text_str; unsigned flipped:1; unsigned invis:1; unsigned plated:1; @@ -55,11 +58,14 @@ void pcb_bxl_reset(pcb_bxl_ctx_t *ctx); void pcb_bxl_set_layer(pcb_bxl_ctx_t *ctx, const char *layer_name); void pcb_bxl_set_justify(pcb_bxl_ctx_t *ctx, const char *str); +void pcb_bxl_set_text_str(pcb_bxl_ctx_t *ctx, char *str); +void pcb_bxl_set_text_style(pcb_bxl_ctx_t *ctx, const char *name); void pcb_bxl_add_property(pcb_bxl_ctx_t *ctx, pcb_any_obj_t *obj, const char *keyval); void pcb_bxl_add_line(pcb_bxl_ctx_t *ctx); void pcb_bxl_add_arc(pcb_bxl_ctx_t *ctx); +void pcb_bxl_add_text(pcb_bxl_ctx_t *ctx); void pcb_bxl_poly_begin(pcb_bxl_ctx_t *ctx); void pcb_bxl_poly_end(pcb_bxl_ctx_t *ctx); Index: bxl_gram.c =================================================================== --- bxl_gram.c (revision 30609) +++ bxl_gram.c (revision 30610) @@ -24,9 +24,9 @@ 40, 40, 40, 40, 42, 32, 41, 41, 43, 43, 43, 43, 43, 45, 33, 44, 44, 46, 46, 46, 46, 34, 47, 47, 48, 48, 48, 48, 50, 36, - 49, 49, 51, 51, 51, 51, 51, 51, 37, 52, - 52, 53, 53, 53, 53, 53, 53, 38, 35, 54, - 54, 55, 55, 55, 11, + 49, 49, 51, 51, 51, 51, 51, 51, 53, 37, + 52, 52, 54, 54, 54, 54, 54, 54, 38, 35, + 55, 55, 56, 56, 56, 11, }; static const pcb_bxl_int_t pcb_bxl_len[] = { 2, 2, 0, 3, 1, 1, 1, 1, 1, 1, 1, @@ -39,9 +39,9 @@ 2, 2, 2, 1, 0, 3, 0, 4, 2, 3, 1, 1, 1, 0, 3, 0, 4, 4, 1, 1, 1, 2, 0, 4, 3, 1, 1, 1, 0, 3, - 0, 4, 2, 2, 2, 1, 1, 1, 2, 0, - 4, 2, 2, 2, 1, 1, 1, 2, 2, 0, - 4, 2, 2, 1, 6, + 0, 4, 2, 2, 2, 1, 1, 1, 0, 3, + 0, 4, 2, 2, 2, 1, 1, 1, 2, 2, + 0, 4, 2, 2, 1, 6, }; static const pcb_bxl_int_t pcb_bxl_defred[] = { 0, 0, 0, 0, 13, 11, 0, 0, 0, 0, 1, @@ -49,118 +49,118 @@ 0, 0, 0, 46, 0, 3, 0, 24, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 33, 8, 9, 34, 35, 36, 0, 0, 0, 0, - 0, 0, 0, 0, 50, 0, 14, 15, 16, 27, - 28, 29, 0, 32, 0, 0, 0, 0, 0, 47, - 0, 125, 26, 0, 0, 0, 0, 0, 49, 0, + 0, 0, 0, 0, 50, 0, 14, 15, 27, 28, + 29, 0, 32, 0, 0, 0, 0, 0, 47, 0, + 126, 26, 0, 0, 16, 0, 0, 0, 49, 0, 0, 0, 0, 0, 0, 0, 0, 0, 75, 84, - 0, 99, 0, 0, 0, 0, 0, 57, 58, 59, + 0, 99, 109, 0, 0, 0, 0, 57, 58, 59, 60, 61, 62, 63, 64, 0, 0, 0, 0, 30, - 38, 0, 65, 0, 0, 0, 92, 0, 0, 109, - 0, 118, 119, 54, 0, 51, 52, 53, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 74, 0, 0, - 76, 0, 85, 0, 0, 0, 0, 0, 96, 97, - 98, 0, 0, 100, 0, 0, 0, 115, 116, 117, - 0, 0, 0, 124, 0, 56, 0, 0, 0, 44, - 45, 0, 39, 68, 69, 70, 71, 0, 72, 73, - 0, 0, 0, 81, 82, 83, 0, 0, 89, 90, - 91, 0, 18, 21, 0, 17, 19, 0, 0, 0, - 0, 106, 107, 108, 0, 114, 112, 113, 0, 122, - 123, 0, 22, 42, 43, 0, 0, 67, 79, 0, - 0, 0, 0, 95, 94, 103, 104, 105, 0, 111, - 121, 41, 20, 80, 78, 0, 87, 102, 88, + 38, 0, 65, 0, 0, 0, 92, 0, 0, 0, + 119, 120, 54, 0, 51, 52, 53, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 74, 0, 0, 76, + 0, 85, 0, 0, 0, 0, 0, 96, 97, 98, + 0, 0, 100, 0, 110, 0, 0, 125, 0, 56, + 0, 0, 0, 44, 45, 0, 39, 68, 69, 70, + 71, 0, 72, 73, 0, 0, 0, 81, 82, 83, + 0, 0, 89, 90, 91, 0, 18, 21, 0, 17, + 19, 0, 0, 0, 0, 106, 107, 108, 0, 0, + 0, 0, 116, 117, 118, 0, 123, 124, 0, 22, + 42, 43, 0, 0, 67, 79, 0, 0, 0, 0, + 95, 94, 103, 104, 105, 0, 115, 113, 114, 0, + 122, 41, 20, 80, 78, 0, 87, 102, 112, 88, }; static const pcb_bxl_int_t pcb_bxl_dgoto[] = { 2, - 59, 60, 44, 3, 10, 11, 4, 12, 13, 14, - 15, 149, 138, 151, 171, 28, 21, 40, 23, 86, - 33, 87, 130, 172, 53, 35, 54, 55, 96, 97, - 98, 99, 100, 101, 102, 103, 104, 105, 113, 139, - 141, 114, 187, 143, 115, 192, 117, 152, 154, 118, - 205, 120, 161, 122, 165, + 75, 76, 44, 3, 10, 11, 4, 12, 13, 14, + 15, 148, 137, 150, 165, 28, 21, 40, 23, 86, + 33, 87, 129, 166, 53, 35, 54, 55, 96, 97, + 98, 99, 100, 101, 102, 103, 104, 105, 113, 138, + 140, 114, 181, 142, 115, 186, 117, 151, 153, 118, + 199, 155, 119, 206, 121, 159, }; -static const pcb_bxl_int_t pcb_bxl_sindex[] = { 6, - 6, 0, -255, 0, 0, -225, -224, -216, -245, 0, - 6, 0, 0, 0, 0, 0, 11, 6, -274, -255, - 12, -213, 6, 0, -252, 0, -180, 0, -179, -241, - -241, -241, 34, -188, -141, -178, -229, -229, -229, 47, - 0, 0, 0, 0, 0, 0, 11, 39, 43, 69, - 70, 71, -166, 6, 0, -201, 0, 0, 0, 0, - 0, 0, 12, 0, -142, -139, -229, -229, -229, 0, - -141, 0, 0, 6, 6, 73, 76, 78, 0, -144, - -191, -229, -229, -229, -133, -140, -144, 100, 0, 0, - 104, 0, 109, 110, 110, -128, 6, 0, 0, 0, - 0, 0, 0, 0, 0, 113, 114, 115, 111, 0, - 0, -154, 0, 117, 118, -221, 0, 119, -249, 0, - -183, 0, 0, 0, -191, 0, 0, 0, -129, 6, - -98, -99, -96, -95, -229, -92, -229, 0, 121, -240, - 0, -250, 0, -93, -88, -90, -86, -241, 0, 0, - 0, 127, -210, 0, -229, -87, -241, 0, 0, 0, - 131, -85, -84, 0, 133, 0, -229, -229, -81, 0, - 0, 137, 0, 0, 0, 0, 0, 135, 0, 0, - 100, -80, 138, 0, 0, 0, 142, -229, 0, 0, - 0, 144, 0, 0, -74, 0, 0, 104, -229, -229, - -229, 0, 0, 0, 146, 0, 0, 0, 109, 0, - 0, 110, 0, 0, 0, 111, -229, 0, 0, -229, - 117, 145, 118, 0, 0, 0, 0, 0, 119, 0, - 0, 0, 0, 0, 0, -229, 0, 0, 0, +static const pcb_bxl_int_t pcb_bxl_sindex[] = { 13, + 13, 0, -259, 0, 0, -250, -221, -218, -197, 0, + 13, 0, 0, 0, 0, 0, 27, 13, -244, -259, + 34, -245, 13, 0, -239, 0, -169, 0, -180, -229, + -229, -229, 59, -168, -196, -154, -203, -203, -203, 63, + 0, 0, 0, 0, 0, 0, 27, 47, 48, 67, + 72, 73, -163, 13, 0, -198, 0, 0, 0, 0, + 0, 34, 0, -139, -137, -203, -203, -203, 0, -196, + 0, 0, 13, 13, 0, 78, 81, 83, 0, -142, + -170, -203, -203, -203, -130, -136, -142, 94, 0, 0, + 98, 0, 0, 107, 107, -133, 13, 0, 0, 0, + 0, 0, 0, 0, 0, 108, 109, 110, 113, 0, + 0, -146, 0, 114, 116, -233, 0, 117, 118, -272, + 0, 0, 0, -170, 0, 0, 0, -184, 13, -99, + -100, -97, -96, -203, -93, -203, 0, 120, -243, 0, + -201, 0, -94, -90, -92, -86, -229, 0, 0, 0, + 121, -192, 0, -252, 0, -88, -84, 0, 136, 0, + -203, -203, -80, 0, 0, 138, 0, 0, 0, 0, + 0, 137, 0, 0, 94, -78, 139, 0, 0, 0, + 143, -203, 0, 0, 0, 144, 0, 0, -74, 0, + 0, 98, -203, -203, -203, 0, 0, 0, 146, -203, + -72, -229, 0, 0, 0, 148, 0, 0, 107, 0, + 0, 0, 113, -203, 0, 0, -203, 114, 147, 116, + 0, 0, 0, 0, 0, 117, 0, 0, 0, 118, + 0, 0, 0, 0, 0, -203, 0, 0, 0, 0, }; static const pcb_bxl_int_t pcb_bxl_rindex[] = { 9, - 1, 0, 188, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 180, 0, 0, 188, - 181, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, -83, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 180, 0, 0, 0, + 1, 0, 180, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 182, 0, 0, 180, + 183, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, -89, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 182, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 181, 0, 0, 0, 0, 0, 0, 0, - -83, 0, 0, 0, 0, 0, 0, 0, 0, -76, - -82, 0, 0, 0, 0, 0, -76, 183, 0, 0, - 184, 0, 185, 187, 187, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 191, 0, - 0, 0, 0, 192, 193, 0, 0, 194, 0, 0, - 0, 0, 0, 0, -82, 0, 0, 0, 0, 0, + 0, 183, 0, 0, 0, 0, 0, 0, 0, -89, + 0, 0, 0, 0, 0, 0, 0, 0, 0, -73, + -87, 0, 0, 0, 0, 0, -73, 186, 0, 0, + 187, 0, 0, 188, 188, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 189, 0, + 0, 0, 0, 190, 191, 0, 0, 192, 193, 0, + 0, 0, 0, -87, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 186, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 183, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 184, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 185, 0, - 0, 187, 0, 0, 0, 191, 0, 0, 0, 0, - 192, 0, 193, 0, 0, 0, 0, 0, 194, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 187, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 188, 0, + 0, 0, 189, 0, 0, 0, 0, 190, 0, 191, + 0, 0, 0, 0, 0, 192, 0, 0, 0, 193, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }; static const pcb_bxl_int_t pcb_bxl_gindex[] = { 0, - -130, -36, -27, 0, 178, 0, -1, 0, 0, 0, - 0, 86, -53, -47, -127, 143, 0, 0, 160, 122, - 0, 0, -8, 0, 139, 0, 0, 0, 87, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 30, 0, - -7, 0, 0, -10, 0, 0, 17, 0, -13, 0, - 0, 8, 0, -89, 0, + -25, -62, -29, 0, 184, 0, 6, 0, 0, 0, + 0, 51, -71, -91, -98, 145, 0, 0, 159, 122, + 0, 0, -5, 0, 140, 0, 0, 0, 87, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 37, 0, + -4, 0, 0, -7, 0, 0, 23, 0, -10, 0, + 0, -13, 0, 0, -95, 0, }; #define pcb_bxl_TABLESIZE 321 -static const pcb_bxl_int_t pcb_bxl_table[] = { 5, - 10, 61, 62, 45, 46, 123, 180, 6, 12, 20, - 19, 7, 186, 144, 191, 1, 24, 57, 58, 42, - 43, 34, 8, 167, 206, 204, 145, 145, 57, 58, - 76, 77, 78, 167, 16, 17, 145, 214, 25, 135, - 135, 144, 155, 18, 188, 106, 107, 108, 147, 135, - 22, 27, 71, 156, 148, 145, 9, 29, 30, 31, - 157, 36, 150, 167, 182, 159, 145, 164, 135, 227, - 228, 160, 80, 81, 47, 146, 147, 56, 41, 135, - 48, 170, 148, 37, 38, 39, 184, 63, 189, 199, - 200, 201, 185, 88, 190, 125, 65, 32, 178, 202, - 66, 89, 90, 183, 91, 203, 135, 92, 67, 68, - 69, 93, 70, 72, 94, 74, 82, 95, 75, 83, - 197, 84, 231, 162, 163, 85, 109, 110, 173, 208, - 213, 131, 132, 133, 134, 135, 136, 137, 49, 112, - 50, 51, 52, 116, 167, 168, 169, 145, 119, 121, - 129, 222, 124, 126, 127, 128, 140, 142, 153, 174, - 175, 181, 226, 176, 177, 179, 193, 198, 194, 195, - 196, 209, 207, 212, 210, 211, 215, 216, 217, 219, - 233, 220, 221, 234, 223, 224, 229, 2, 236, 31, - 25, 37, 66, 93, 110, 48, 120, 26, 55, 239, - 40, 77, 86, 101, 158, 73, 64, 232, 111, 79, - 218, 166, 237, 235, 225, 238, 230, 0, 0, 0, +static const pcb_bxl_int_t pcb_bxl_table[] = { 122, + 10, 45, 46, 6, 77, 78, 5, 7, 12, 16, + 143, 59, 60, 61, 57, 58, 20, 134, 8, 106, + 107, 108, 1, 24, 144, 29, 30, 31, 34, 143, + 161, 42, 43, 144, 156, 157, 164, 134, 17, 200, + 180, 18, 185, 144, 149, 146, 134, 179, 158, 184, + 201, 147, 9, 198, 57, 58, 134, 202, 19, 70, + 197, 176, 205, 145, 146, 32, 22, 178, 25, 183, + 147, 172, 161, 27, 36, 144, 177, 41, 80, 81, + 196, 161, 204, 49, 144, 50, 51, 52, 134, 161, + 162, 163, 144, 182, 37, 38, 39, 134, 210, 47, + 48, 56, 124, 62, 64, 65, 66, 193, 194, 195, + 174, 67, 68, 231, 88, 69, 71, 191, 73, 219, + 74, 82, 89, 90, 83, 91, 84, 85, 92, 109, + 223, 110, 93, 112, 167, 94, 211, 116, 95, 130, + 131, 132, 133, 134, 135, 136, 120, 123, 125, 126, + 127, 233, 128, 139, 234, 141, 152, 154, 168, 169, + 175, 192, 170, 171, 173, 187, 188, 189, 224, 225, + 190, 207, 229, 240, 227, 208, 209, 212, 213, 2, + 214, 216, 217, 218, 220, 221, 226, 228, 230, 48, + 236, 31, 25, 55, 37, 66, 93, 121, 40, 77, + 86, 101, 111, 26, 203, 63, 72, 232, 111, 79, + 160, 215, 237, 235, 222, 238, 239, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, @@ -173,29 +173,29 @@ 0, 0, 10, 0, 0, 0, 0, 0, 0, 0, 12, }; -static const pcb_bxl_int_t pcb_bxl_check[] = { 1, - 0, 38, 39, 31, 32, 95, 137, 263, 0, 11, - 256, 267, 140, 263, 142, 10, 18, 258, 259, 261, - 262, 23, 278, 274, 155, 153, 277, 277, 258, 259, - 67, 68, 69, 274, 260, 260, 277, 168, 313, 290, - 290, 263, 292, 260, 295, 82, 83, 84, 298, 290, - 40, 40, 54, 303, 304, 277, 312, 271, 272, 273, - 310, 314, 116, 274, 305, 119, 277, 121, 290, 200, - 201, 119, 74, 75, 41, 297, 298, 256, 258, 290, - 269, 129, 304, 264, 265, 266, 140, 41, 142, 300, - 301, 302, 140, 285, 142, 97, 58, 311, 135, 153, - 58, 293, 294, 140, 296, 153, 290, 299, 40, 40, - 40, 303, 279, 315, 306, 258, 44, 309, 258, 44, - 148, 44, 212, 307, 308, 270, 260, 268, 130, 157, - 167, 286, 287, 288, 289, 290, 291, 292, 280, 40, - 282, 283, 284, 40, 274, 275, 276, 277, 40, 40, - 40, 188, 281, 41, 41, 41, 40, 40, 40, 258, - 260, 41, 199, 260, 260, 258, 260, 41, 257, 260, - 257, 41, 260, 41, 260, 260, 258, 41, 44, 260, - 217, 44, 41, 220, 41, 260, 41, 0, 44, 10, - 10, 268, 10, 10, 10, 279, 10, 20, 281, 236, - 10, 10, 10, 10, 119, 63, 47, 216, 87, 71, - 181, 125, 223, 221, 198, 229, 209, -1, -1, -1, +static const pcb_bxl_int_t pcb_bxl_check[] = { 95, + 0, 31, 32, 263, 67, 68, 1, 267, 0, 260, + 263, 37, 38, 39, 258, 259, 11, 290, 278, 82, + 83, 84, 10, 18, 277, 271, 272, 273, 23, 263, + 274, 261, 262, 277, 307, 308, 128, 290, 260, 292, + 139, 260, 141, 277, 116, 298, 290, 139, 120, 141, + 303, 304, 312, 152, 258, 259, 290, 310, 256, 54, + 152, 305, 154, 297, 298, 311, 40, 139, 313, 141, + 304, 134, 274, 40, 314, 277, 139, 258, 73, 74, + 152, 274, 154, 280, 277, 282, 283, 284, 290, 274, + 275, 276, 277, 295, 264, 265, 266, 290, 161, 41, + 269, 256, 97, 41, 58, 58, 40, 300, 301, 302, + 136, 40, 40, 209, 285, 279, 315, 147, 258, 182, + 258, 44, 293, 294, 44, 296, 44, 270, 299, 260, + 193, 268, 303, 40, 129, 306, 162, 40, 309, 286, + 287, 288, 289, 290, 291, 292, 40, 281, 41, 41, + 41, 214, 40, 40, 217, 40, 40, 40, 258, 260, + 41, 41, 260, 260, 258, 260, 257, 260, 194, 195, + 257, 260, 202, 236, 200, 260, 41, 258, 41, 0, + 44, 260, 44, 41, 41, 260, 41, 260, 41, 279, + 44, 10, 10, 281, 268, 10, 10, 10, 10, 10, + 10, 10, 10, 20, 154, 47, 62, 213, 87, 70, + 124, 175, 220, 218, 192, 226, 230, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, @@ -210,7 +210,7 @@ }; #define pcb_bxl_FINAL 2 #define pcb_bxl_MAXTOKEN 315 -#define pcb_bxl_UNDFTOKEN 373 +#define pcb_bxl_UNDFTOKEN 374 #define pcb_bxl_TRANSLATE(a) ((a) > pcb_bxl_MAXTOKEN ? pcb_bxl_UNDFTOKEN : (a)) #if pcb_bxl_DEBUG static const char *const pcb_bxl_name[] = { @@ -233,7 +233,7 @@ "T_PROPERTY","T_WIZARD","T_VARNAME","T_VARDATA","T_TEMPLATEDATA","T_ISFLIPPED", "T_NOPASTE","T_SYMBOL","T_ENDSYMBOL","T_COMPONENT","T_ENDCOMPONENT",0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,"illegal-symbol", +0,0,0,0,0,0,0,0,0,0,0,0,"illegal-symbol", }; static const char *const pcb_bxl_rule[] = { "$accept : full_file", @@ -263,9 +263,9 @@ "text_style : T_TEXTSTYLE T_QSTR $$1 text_style_attrs", "text_style_attrs :", "text_style_attrs : '(' text_style_attr ')' text_style_attrs", -"text_style_attr : T_FONTWIDTH coord", -"text_style_attr : T_FONTCHARWIDTH coord", -"text_style_attr : T_FONTHEIGHT coord", +"text_style_attr : T_FONTWIDTH real", +"text_style_attr : T_FONTCHARWIDTH real", +"text_style_attr : T_FONTHEIGHT real", "pad_stack : T_PADSTACK T_QSTR pstk_attrs nl T_SHAPES ':' T_INTEGER nl pad_shapes T_ENDPADSTACK", "pstk_attrs :", "pstk_attrs : '(' pstk_attr ')' pstk_attrs", @@ -345,7 +345,8 @@ "arc_attr : common_origin", "arc_attr : common_layer", "arc_attr : common_width", -"text : T_TEXT text_attrs", +"$$6 :", +"text : T_TEXT $$6 text_attrs", "text_attrs :", "text_attrs : '(' text_attr ')' text_attrs", "text_attr : T_TEXT T_QSTR", @@ -594,6 +595,10 @@ #line 125 "../../src_plugins/io_bxl/bxl_gram.y" { pcb_bxl_set_justify(ctx, yyctx->stack.l_mark[0].un.s); free(yyctx->stack.l_mark[0].un.s); } break; +case 18: +#line 126 "../../src_plugins/io_bxl/bxl_gram.y" + { pcb_bxl_set_text_style(ctx, yyctx->stack.l_mark[0].un.s); free(yyctx->stack.l_mark[0].un.s); } +break; case 19: #line 127 "../../src_plugins/io_bxl/bxl_gram.y" { ctx->state.invis = yyctx->stack.l_mark[0].un.i; } @@ -620,15 +625,15 @@ break; case 27: #line 155 "../../src_plugins/io_bxl/bxl_gram.y" - { ctx->state.text_style->width = yyctx->stack.l_mark[0].un.c; } + { ctx->state.text_style->width = yyctx->stack.l_mark[0].un.d; } break; case 28: #line 156 "../../src_plugins/io_bxl/bxl_gram.y" - { ctx->state.text_style->char_width = yyctx->stack.l_mark[0].un.c; } + { ctx->state.text_style->char_width = yyctx->stack.l_mark[0].un.d; } break; case 29: #line 157 "../../src_plugins/io_bxl/bxl_gram.y" - { ctx->state.text_style->height = yyctx->stack.l_mark[0].un.c; } + { ctx->state.text_style->height = yyctx->stack.l_mark[0].un.d; } break; case 34: #line 177 "../../src_plugins/io_bxl/bxl_gram.y" @@ -698,11 +703,27 @@ #line 335 "../../src_plugins/io_bxl/bxl_gram.y" { ctx->state.arc_delta = yyctx->stack.l_mark[0].un.d; } break; +case 109: +#line 343 "../../src_plugins/io_bxl/bxl_gram.y" + { pcb_bxl_reset(ctx); } +break; +case 110: +#line 344 "../../src_plugins/io_bxl/bxl_gram.y" + { pcb_bxl_add_text(ctx); pcb_bxl_reset(ctx); } +break; case 113: #line 353 "../../src_plugins/io_bxl/bxl_gram.y" + { pcb_bxl_set_text_str(ctx, yyctx->stack.l_mark[0].un.s); /* $2 is taken over */ } +break; +case 114: +#line 354 "../../src_plugins/io_bxl/bxl_gram.y" { ctx->state.flipped = yyctx->stack.l_mark[0].un.i; } break; -#line 718 "../../src_plugins/io_bxl/bxl_gram.c" +case 115: +#line 355 "../../src_plugins/io_bxl/bxl_gram.y" + { ctx->state.rot = yyctx->stack.l_mark[0].un.d; } +break; +#line 739 "../../src_plugins/io_bxl/bxl_gram.c" } yyctx->stack.s_mark -= yyctx->yym; yyctx->state = *yyctx->stack.s_mark; Index: bxl_gram.y =================================================================== --- bxl_gram.y (revision 30609) +++ bxl_gram.y (revision 30610) @@ -123,7 +123,7 @@ common_attr_text: T_JUSTIFY T_ID { pcb_bxl_set_justify(ctx, $2); free($2); } - | T_TEXTSTYLE T_QSTR + | T_TEXTSTYLE T_QSTR { pcb_bxl_set_text_style(ctx, $2); free($2); } | T_ISVISIBLE boolean { ctx->state.invis = $2; } ; @@ -152,9 +152,9 @@ ; text_style_attr: - T_FONTWIDTH coord { ctx->state.text_style->width = $2; } - | T_FONTCHARWIDTH coord { ctx->state.text_style->char_width = $2; } - | T_FONTHEIGHT coord { ctx->state.text_style->height = $2; } + T_FONTWIDTH real { ctx->state.text_style->width = $2; } + | T_FONTCHARWIDTH real { ctx->state.text_style->char_width = $2; } + | T_FONTHEIGHT real { ctx->state.text_style->height = $2; } ; @@ -340,7 +340,8 @@ /*** Text ***/ text: - T_TEXT text_attrs + T_TEXT { pcb_bxl_reset(ctx); } + text_attrs { pcb_bxl_add_text(ctx); pcb_bxl_reset(ctx); } ; text_attrs: @@ -349,9 +350,9 @@ ; text_attr: - T_TEXT T_QSTR + T_TEXT T_QSTR { pcb_bxl_set_text_str(ctx, $2); /* $2 is taken over */ } | T_ISFLIPPED boolean { ctx->state.flipped = $2; } - | T_ROTATE real + | T_ROTATE real { ctx->state.rot = $2; } | common_attr_text | common_origin | common_layer Index: read.c =================================================================== --- read.c (revision 30609) +++ read.c (revision 30610) @@ -35,12 +35,15 @@ #include #include #include +#include "board.h" + #include "read.h" #include "bxl_decode.h" #include "bxl_lex.h" #include "bxl_gram.h" -#define SKIP if (!ctx->in_target_fp) return +#define SKIP if (!ctx->in_target_fp) return +#define SKIP_FREE(ptr) if (!ctx->in_target_fp) { free(ptr); return; } static const pcb_dflgmap_t bxl_layer_names[] = { /* name layer type purpose comb flags */ @@ -208,6 +211,39 @@ width, 0, pcb_flag_make(PCB_FLAG_CLEARLINE), 0); } +void pcb_bxl_add_text(pcb_bxl_ctx_t *ctx) +{ + int scale; + pcb_coord_t thickness; + SKIP; + + if (ctx->state.text_style != NULL) { +TODO("need to figure how text is scaled and justified in bxl"); + scale = ctx->state.text_style->height; + thickness = PCB_MIL_TO_COORD(ctx->state.text_style->width); + } + else { + scale = 100; + thickness = 0; + } + + + pcb_text_new(ctx->state.layer, pcb_font(ctx->pcb, 0, 1), + ctx->state.origin_x, ctx->state.origin_y, + ctx->state.rot, scale, thickness, ctx->state.text_str, + pcb_flag_make(PCB_FLAG_CLEARLINE)); + free(ctx->state.text_str); + ctx->state.text_str = NULL; +} + +void pcb_bxl_set_text_str(pcb_bxl_ctx_t *ctx, char *str) +{ + SKIP_FREE(str); + free(ctx->state.text_str); + ctx->state.text_str = str; +} + + void pcb_bxl_poly_begin(pcb_bxl_ctx_t *ctx) { SKIP; @@ -325,7 +361,14 @@ ctx->state.text_style = NULL; } +void pcb_bxl_set_text_style(pcb_bxl_ctx_t *ctx, const char *name) +{ + ctx->state.text_style = htsp_get(&ctx->text_name2style, name); + if (ctx->state.text_style == NULL) + pcb_message(PCB_MSG_WARNING, "bxl footprint error: text style '%s' not defined (using default style)\n", name); +} + #define WARN_CNT(_count_, args) \ do { \ long cnt = (bctx->warn._count_); \ @@ -333,14 +376,15 @@ } while(0) -static void pcb_bxl_init(pcb_bxl_ctx_t *bctx, const char *fpname) +static void pcb_bxl_init(pcb_bxl_ctx_t *bctx, pcb_board_t *pcb, const char *fpname) { memset(bctx, 0, sizeof(pcb_bxl_ctx_t)); + bctx->pcb = pcb; bctx->subc = pcb_subc_new(); TODO("This reads the first footprint only:"); bctx->in_target_fp = 1; htsp_init(&bctx->layer_name2ly, strhash, strkeyeq); - htsp_init(&bctx->text_name2style, strhash, strkeyeq); + htsp_init(&bctx->text_name2style, strhash_case, strkeyeq_case); } static void pcb_bxl_uninit(pcb_bxl_ctx_t *bctx) @@ -371,7 +415,7 @@ int io_bxl_parse_footprint(pcb_plug_io_t *ctx, pcb_data_t *data, const char *filename) { - pcb_hidlib_t *hl = NULL; + pcb_hidlib_t *hl = &PCB->hidlib; FILE *f; int chr, tok, yres, ret = 0; hdecode_t hctx; @@ -383,7 +427,7 @@ if (f == NULL) return -1; - pcb_bxl_init(&bctx, NULL); + pcb_bxl_init(&bctx, (pcb_board_t *)hl, NULL); pcb_bxl_decode_init(&hctx); pcb_bxl_lex_init(&lctx, pcb_bxl_rules);