diff --git a/sch2fig/lib.c b/sch2fig/lib.c index e614ae4..5d19c76 100644 --- a/sch2fig/lib.c +++ b/sch2fig/lib.c @@ -216,6 +216,13 @@ static void draw_pin(const struct comp *comp, const struct pin_obj *pin, }; text_rot(&name_txt, matrix_to_angle(m)); + switch (name_txt.rot) { + case 180: + text_flip_x(&name_txt); + break; + default: + break; + } if (comp->show_pin_name) text_fig(&name_txt, COLOR_PIN_NAME, LAYER_PIN_NAME); @@ -239,7 +246,7 @@ static void draw_pin(const struct comp *comp, const struct pin_obj *pin, .vert = text_min, }; - text_rot(&num_txt, matrix_to_angle(m)); + text_rot(&num_txt, matrix_to_angle(m) % 180); 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 7a8fb44..6d5719a 100644 --- a/sch2fig/misc.c +++ b/sch2fig/misc.c @@ -30,6 +30,8 @@ unsigned matrix_to_angle(int m[6]) return 0; if (eq(m, 0, -1, -1, 0)) return 90; + if (eq(m, -1, 0, 0, 1)) + return 180; if (eq(m, 0, 1, 1, 0)) return 270; fprintf(stderr, "unrecognized matrix %d %d %d %d\n", diff --git a/sch2fig/text.c b/sch2fig/text.c index eb2baee..597849d 100644 --- a/sch2fig/text.c +++ b/sch2fig/text.c @@ -62,12 +62,21 @@ enum text_align text_flip(enum text_align align) case text_mid: return text_mid; case text_max: - return text_max; + return text_min; default: abort(); } } + +void text_flip_x(struct text *txt) +{ + txt->rot = angle_add(txt->rot, 180); + txt->hor = text_flip(txt->hor); + // @@@ flip vert, too ? +} + + static int rx(int x, int y, int rot) { float a = rot / 180.0 * M_PI; diff --git a/sch2fig/text.h b/sch2fig/text.h index c5446b6..2d0fce5 100644 --- a/sch2fig/text.h +++ b/sch2fig/text.h @@ -37,6 +37,7 @@ void text_free(struct text *txt); void text_set(struct text *txt, const char *s); void text_rot(struct text *txt, int deg); +void text_flip_x(struct text *txt); enum text_align text_flip(enum text_align align); void text_fig(const struct text *txt, int color, unsigned layer);