diff --git a/sch2fig/lib.c b/sch2fig/lib.c index ecc7578..c6b1527 100644 --- a/sch2fig/lib.c +++ b/sch2fig/lib.c @@ -264,6 +264,13 @@ static void draw_pin(const struct comp *comp, const struct pin_obj *pin, }; text_rot(&name_txt, matrix_to_angle(m)); + if (matrix_is_mirrored(m)) { + if ((name_txt.rot % 180) == 0) + name_txt.hor = text_flip(name_txt.hor); + else + name_txt.vert = text_flip(name_txt.vert); + } + switch (name_txt.rot) { case 180: text_flip_x(&name_txt); @@ -295,6 +302,13 @@ static void draw_pin(const struct comp *comp, const struct pin_obj *pin, }; text_rot(&num_txt, matrix_to_angle(m) % 180); + if (matrix_is_mirrored(m)) { + if ((num_txt.rot % 180) == 0) + num_txt.hor = text_flip(num_txt.hor); + else + num_txt.vert = text_flip(num_txt.vert); + } + if (comp->show_pin_num) text_fig(&num_txt, COLOR_PIN_NUMBER, LAYER_PIN_NUMBER); diff --git a/sch2fig/misc.c b/sch2fig/misc.c index 6d5719a..a946edc 100644 --- a/sch2fig/misc.c +++ b/sch2fig/misc.c @@ -14,6 +14,7 @@ #include #include #include +#include #include "misc.h" @@ -34,12 +35,31 @@ unsigned matrix_to_angle(int m[6]) return 180; if (eq(m, 0, 1, 1, 0)) return 270; + if (eq(m, -1, 0, 0, -1)) + return 0; fprintf(stderr, "unrecognized matrix %d %d %d %d\n", m[1], m[2], m[4], m[5]); exit(1); } +bool matrix_is_mirrored(int m[6]) +{ + if (eq(m, 1, 0, 0, -1)) + return 0; + if (eq(m, 0, -1, -1, 0)) + return 0; + if (eq(m, -1, 0, 0, 1)) + return 0; + if (eq(m, 0, 1, 1, 0)) + return 0; + + if (eq(m, -1, 0, 0, -1)) + return 1; + assert(0); +} + + int angle_add(int a, int b) { a += b; diff --git a/sch2fig/misc.h b/sch2fig/misc.h index e17e7ec..342d88c 100644 --- a/sch2fig/misc.h +++ b/sch2fig/misc.h @@ -42,6 +42,7 @@ static inline int my(int x, int y, int m[6]) unsigned matrix_to_angle(int m[6]); +bool matrix_is_mirrored(int m[6]); int angle_add(int a, int b); #endif /* !MISC_H */ diff --git a/sch2fig/sch.c b/sch2fig/sch.c index fc3cf94..32cedc0 100644 --- a/sch2fig/sch.c +++ b/sch2fig/sch.c @@ -177,6 +177,13 @@ static void dump_field(const struct sch_field *field, int m[6]) break; } + if (matrix_is_mirrored(m)) { + if ((txt.rot % 180) == 0) + txt.hor = text_flip(txt.hor); + else + txt.vert = text_flip(txt.vert); + } + text_fig(&txt, COLOR_FIELD, LAYER_FIELD); }