chiark / gitweb /
Fix outline adjustment for Bedstead Bold
authorBen Harris <bjh21@bjh21.me.uk>
Sat, 16 Oct 2021 14:13:52 +0000 (15:13 +0100)
committerBen Harris <bjh21@bjh21.me.uk>
Sat, 16 Oct 2021 19:06:33 +0000 (20:06 +0100)
A couple of special cases handle the inside corners of glyphs like
"asterisk".  They're very ad-hoc, but also reasonably simple so I'll
forgive them.

bedstead.c

index 59dfd89b09ca78d3740f3ca19c0533418542fbe5..c2b89d400e3fa1ae5ca0669860c3b31197169934 100644 (file)
@@ -2747,9 +2747,10 @@ emit_path()
  * vertical strokes.  More precisely, we pretend that the weight
  * variation is achieved by moving the rising edges of the output
  * waveform of the SAA5050.  This is implemented by moving all left
- * edges left and right.  The code below only handles cases where we
- * don't run out of slack in horizontal lines, which limits weight to
- * the range (-0.5 * XPIX) < weight < (0.25 * XPIX).
+ * edges left and right.  The code below is not fully general: it can
+ * handle cases where the slack in horizontal lines doesn't run out,
+ * and one special case where it does.  This means it should work
+ * correctly for the range (2 * XQTR_S - 1) < weight < (2 * XQTR_S).
  */
 static void
 adjust_weight()
@@ -2767,8 +2768,26 @@ adjust_weight()
                PX = p->prev->v.x; PY = p->prev->v.y;
                NX = p->next->v.x; NY = p->next->v.y;
                /* Move left-edge points horizontally */
-               if (PY <= Y && Y <= NY)
+               if (PY <= Y && Y <= NY) {
                        moves[i].x -= W;
+                       /*
+                        * These two clauses deal in an ad-hoc way
+                        * with the special cases (all four seen on
+                        * the "asterisk" glyph) where the bevel of an
+                        * inside corner gets completely consumed by
+                        * boldening.
+                        */
+                       if (W > XQTR_S && PY == Y && PX == X - XQTR_S) {
+                               moves[i].y += W - XQTR_S;
+                               if (NX != X) moves[i].x += W - XQTR_S;
+                               killpoint(p->prev);
+                       }
+                       if (W > XQTR_S && NY == Y && NX == X - XQTR_S) {
+                               moves[i].y -= W - XQTR_S;
+                               if (PX != X) moves[i].x += W - XQTR_S;
+                               killpoint(p->next);
+                       }
+               }
                /* Move top inner corner points along NE/SW diagonal */
                if (PY < Y && Y > NY && PX > X && X > NX) {
                        moves[i].x -= W/2;