From 366516fa6473fd1eed4410b74172d16846eecef8 Mon Sep 17 00:00:00 2001 From: Werner Lemberg Date: Thu, 2 Oct 2014 15:40:32 +0200 Subject: [PATCH] Use `Control_Type' to handle different segment directions. We need `x_shift' and `y_shift' later on... --- lib/tacontrol.bison | 12 ++++++------ lib/tacontrol.c | 31 +++++++++++++++++++------------ lib/tacontrol.h | 4 +++- 3 files changed, 28 insertions(+), 19 deletions(-) diff --git a/lib/tacontrol.bison b/lib/tacontrol.bison index 4c37d61..a9ef049 100644 --- a/lib/tacontrol.bison +++ b/lib/tacontrol.bison @@ -172,11 +172,11 @@ entry: } | font_idx glyph_idx left_dir_set EOE { - $entry = TA_control_new(Control_Point_Dir, + $entry = TA_control_new(Control_Segment_Left, $font_idx, $glyph_idx, $left_dir_set, - TA_DIR_LEFT, + 0, 0, NULL); if (!$entry) @@ -187,11 +187,11 @@ entry: } | font_idx glyph_idx right_dir_set EOE { - $entry = TA_control_new(Control_Point_Dir, + $entry = TA_control_new(Control_Segment_Right, $font_idx, $glyph_idx, $right_dir_set, - TA_DIR_RIGHT, + 0, 0, NULL); if (!$entry) @@ -202,11 +202,11 @@ entry: } | font_idx glyph_idx none_dir_set EOE { - $entry = TA_control_new(Control_Point_Dir, + $entry = TA_control_new(Control_Segment_None, $font_idx, $glyph_idx, $none_dir_set, - TA_DIR_NONE, + 0, 0, NULL); if (!$entry) diff --git a/lib/tacontrol.c b/lib/tacontrol.c index ac51fb3..e1c0552 100644 --- a/lib/tacontrol.c +++ b/lib/tacontrol.c @@ -56,9 +56,10 @@ TA_control_new(Control_Type type, + (y_shift > 0 ? 0.5 : -0.5)); break; - case Control_Point_Dir: - /* values -1, 1, and 4 mean `left', `right', and `none', respectively */ - control->x_shift = x_shift; + case Control_Segment_Left: + case Control_Segment_Right: + case Control_Segment_None: + control->x_shift = 0; control->y_shift = 0; break; } @@ -184,22 +185,24 @@ control_show_line(FONT* font, ppems_buf); break; - case Control_Point_Dir: + case Control_Segment_Left: + case Control_Segment_Right: + case Control_Segment_None: /* display glyph index if we don't have a glyph name */ if (*glyph_name_buf) s = sdscatprintf(s, "%ld %s %c %s", control->font_idx, glyph_name_buf, - control->x_shift == TA_DIR_LEFT ? 'l' - : control->x_shift == TA_DIR_RIGHT ? 'r' + control->type == Control_Segment_Left ? 'l' + : control->type == Control_Segment_Right ? 'r' : 'n', points_buf); else s = sdscatprintf(s, "%ld %ld %c %s", control->font_idx, control->glyph_idx, - control->x_shift == TA_DIR_LEFT ? 'l' - : control->x_shift == TA_DIR_RIGHT ? 'r' + control->type == Control_Segment_Left ? 'l' + : control->type == Control_Segment_Right ? 'r' : 'n', points_buf); break; @@ -504,7 +507,9 @@ TA_control_build_tree(FONT* font) ppems_iter.range = control->ppems; ppem = number_set_get_first(&ppems_iter); - if (type == Control_Point_Dir) + if (type == Control_Segment_Left + || type == Control_Segment_Right + || type == Control_Segment_None) goto Points_Loop; while (ppems_iter.range) @@ -659,7 +664,9 @@ TA_control_point_dir_collect(FONT* font, break; /* check type */ - if (ctrl->type != Control_Point_Dir) + if (!(ctrl->type == Control_Segment_Left + || ctrl->type == Control_Segment_Right + || ctrl->type == Control_Segment_None)) break; /* too large values of font and glyph indices in `ctrl' */ @@ -670,8 +677,8 @@ TA_control_point_dir_collect(FONT* font, /* we store point index and direction together */ point_idx = (ctrl->point_idx << 2) - + (ctrl->x_shift == TA_DIR_LEFT ? 0 - : ctrl->x_shift == TA_DIR_RIGHT ? 1 + + (ctrl->type == Control_Segment_Left ? 0 + : ctrl->type == Control_Segment_Right ? 1 : 2); /* don't care about checking valid point indices */ diff --git a/lib/tacontrol.h b/lib/tacontrol.h index cdf19b4..06dc92e 100644 --- a/lib/tacontrol.h +++ b/lib/tacontrol.h @@ -59,7 +59,9 @@ typedef enum Control_Type_ { Control_Delta_before_IUP, Control_Delta_after_IUP, - Control_Point_Dir + Control_Segment_Left, + Control_Segment_Right, + Control_Segment_None } Control_Type; -- 2.11.4.GIT