diff --git a/fonts/FreeMono.ttf b/fonts/FreeMono.ttf
new file mode 100644
index 0000000..96b830e
Binary files /dev/null and b/fonts/FreeMono.ttf differ
diff --git a/fonts/FreeMonoBold.ttf b/fonts/FreeMonoBold.ttf
new file mode 100644
index 0000000..4863d6b
Binary files /dev/null and b/fonts/FreeMonoBold.ttf differ
diff --git a/fonts/FreeMonoBoldOblique.ttf b/fonts/FreeMonoBoldOblique.ttf
new file mode 100644
index 0000000..e0bf213
Binary files /dev/null and b/fonts/FreeMonoBoldOblique.ttf differ
diff --git a/fonts/FreeMonoOblique.ttf b/fonts/FreeMonoOblique.ttf
new file mode 100644
index 0000000..b3c3ad2
Binary files /dev/null and b/fonts/FreeMonoOblique.ttf differ
diff --git a/fonts/FreeSans.ttf b/fonts/FreeSans.ttf
new file mode 100644
index 0000000..6de62eb
Binary files /dev/null and b/fonts/FreeSans.ttf differ
diff --git a/fonts/FreeSansBold.ttf b/fonts/FreeSansBold.ttf
new file mode 100644
index 0000000..e75685b
Binary files /dev/null and b/fonts/FreeSansBold.ttf differ
diff --git a/fonts/FreeSansBoldOblique.ttf b/fonts/FreeSansBoldOblique.ttf
new file mode 100644
index 0000000..ec3bc02
Binary files /dev/null and b/fonts/FreeSansBoldOblique.ttf differ
diff --git a/fonts/FreeSansOblique.ttf b/fonts/FreeSansOblique.ttf
new file mode 100644
index 0000000..733f882
Binary files /dev/null and b/fonts/FreeSansOblique.ttf differ
diff --git a/fonts/FreeSerif.ttf b/fonts/FreeSerif.ttf
new file mode 100644
index 0000000..e08b157
Binary files /dev/null and b/fonts/FreeSerif.ttf differ
diff --git a/fonts/FreeSerifBold.ttf b/fonts/FreeSerifBold.ttf
new file mode 100644
index 0000000..00c25d3
Binary files /dev/null and b/fonts/FreeSerifBold.ttf differ
diff --git a/fonts/FreeSerifBoldItalic.ttf b/fonts/FreeSerifBoldItalic.ttf
new file mode 100644
index 0000000..5f32a91
Binary files /dev/null and b/fonts/FreeSerifBoldItalic.ttf differ
diff --git a/fonts/FreeSerifItalic.ttf b/fonts/FreeSerifItalic.ttf
new file mode 100644
index 0000000..388c112
Binary files /dev/null and b/fonts/FreeSerifItalic.ttf differ
diff --git a/k8s/deployment.yaml b/k8s/deployment.yaml
index 90db510..c2a0b61 100644
--- a/k8s/deployment.yaml
+++ b/k8s/deployment.yaml
@@ -15,7 +15,7 @@ spec:
spec:
containers:
- name: e440-generator
- image: git.baumann.gr/adebaumann/e440-generator:1.01
+ image: git.baumann.gr/adebaumann/e440-generator:1.02
imagePullPolicy: Always
ports:
- containerPort: 5000
diff --git a/web/app.py b/web/app.py
index 1e80ab7..ae91ba8 100644
--- a/web/app.py
+++ b/web/app.py
@@ -101,6 +101,57 @@ _FRAC_AXIS = 0.32
_FRAC_GAP = 0.14
_FRAC_SIDE = 0.12
+_SYM_WIDTH = 0.75
+_SYM_HEIGHT = 0.50
+_SYM_LW = 0.08
+_SYM_RISE = 0.25
+
+
+def _symbol_svg(name: str, x: float, y: float, fs: float, fill: str) -> str:
+ w = fs * _SYM_WIDTH
+ h = fs * _SYM_HEIGHT
+ lw = fs * _SYM_LW
+ yc = y - _SYM_RISE * fs
+ stroke = f"fill:none;stroke:{fill};stroke-width:{lw:.5f};stroke-linecap:round"
+
+ if name == "ac":
+ d = (
+ f"M {x:.5f},{yc:.5f}"
+ f" C {x + w / 3:.5f},{yc - h / 2:.5f}"
+ f" {x + 2 * w / 3:.5f},{yc + h / 2:.5f}"
+ f" {x + w:.5f},{yc:.5f}"
+ )
+ return f''
+
+ elif name == "dc":
+ dash = w / 5
+ gap = w / 5
+ y1 = yc - h / 4
+ y2 = yc + h / 4
+ p1 = f''
+ p2 = f''
+ p3 = f''
+ p4 = f''
+ return p1 + "\n " + p2 + "\n " + p3 + "\n " + p4
+
+ else: # acdc
+ y_wave = yc - h / 4
+ y_dash = yc + h / 4
+ dash = w / 5
+ gap = w / 5
+ d = (
+ f"M {x:.5f},{y_wave:.5f}"
+ f" C {x + w / 3:.5f},{y_wave - h / 2:.5f}"
+ f" {x + 2 * w / 3:.5f},{y_wave + h / 2:.5f}"
+ f" {x + w:.5f},{y_wave:.5f}"
+ )
+ p1 = f''
+ p2 = f''
+ p3 = f''
+ p4 = f''
+ return p1 + "\n " + p2 + "\n " + p3 + "\n " + p4
+
+
_UNIT_BOX_X0, _UNIT_BOX_X1 = UNIT_X - 15.0, UNIT_X + 15.0
_UNIT_BOX_Y0, _UNIT_BOX_Y1 = UNIT_Y - 6.0, UNIT_Y + 6.0
_UNIT_MAX_FS = 9.46938021
@@ -182,6 +233,16 @@ def _parse_markup(s: str):
inner, j = _extract_braced(s, i)
nodes.append(_parse_braced(inner))
i = j
+ elif c == "[":
+ end = s.find("]", i + 1)
+ if end > i:
+ name = s[i + 1 : end].lower()
+ if name in ("ac", "dc", "acdc"):
+ nodes.append(("sym", name))
+ i = end + 1
+ continue
+ nodes.append(("lit", c))
+ i += 1
else:
nodes.append(("lit", c))
i += 1
@@ -205,6 +266,8 @@ def _measure(nodes, fs: float, fd: _FontData) -> float:
max(_measure(n[1], fs2, fd), _measure(n[2], fs2, fd))
+ 2 * _FRAC_SIDE * fs2
)
+ elif n[0] == "sym":
+ w += fs * _SYM_WIDTH
return w
@@ -238,6 +301,8 @@ def _vbounds(nodes, fs: float, fd: _FontData):
dt, db = _vbounds(n[2], fs2, fd)
a = min(nt + num_base, axis)
b = max(db + den_base, axis)
+ elif n[0] == "sym":
+ a, b = -_SYM_HEIGHT / 2 * fs, _SYM_HEIGHT / 2 * fs
else:
continue
lo, hi = min(lo, a), max(hi, b)
@@ -279,6 +344,9 @@ def _draw_nodes(nodes, x: float, y: float, fs: float, fill: str, fd: _FontData):
f' style="stroke:{fill};stroke-width:{fs * 0.055:.5f};stroke-linecap:butt" />'
)
cx += bar_w
+ elif n[0] == "sym":
+ parts.append(_symbol_svg(n[1], cx, y, fs, fill))
+ cx += fs * _SYM_WIDTH
return parts, cx - x