Add configurable label font size; bump to 0.76
- New "Label size (mm)" field controlling the numeric-label font size, defaulting to a clean 9 mm (was the inherited Inkscape value 8.89194) - Pin k8s deployment to image tag 0.76
This commit is contained in:
+1
-1
@@ -15,7 +15,7 @@ spec:
|
||||
spec:
|
||||
containers:
|
||||
- name: m1730-generator
|
||||
image: git.baumann.gr/adebaumann/m1730-generator:0.72
|
||||
image: git.baumann.gr/adebaumann/m1730-generator:0.76
|
||||
imagePullPolicy: Always
|
||||
ports:
|
||||
- containerPort: 5000
|
||||
|
||||
+6
-5
@@ -8,7 +8,7 @@ from fontTools.pens.svgPathPen import SVGPathPen
|
||||
|
||||
app = Flask(__name__)
|
||||
|
||||
VERSION = "0.75"
|
||||
VERSION = "0.76"
|
||||
|
||||
_LOGO_PATH = pathlib.Path(__file__).parent / 'static' / 'logo.png'
|
||||
_LOGO_B64 = base64.b64encode(_LOGO_PATH.read_bytes()).decode()
|
||||
@@ -93,7 +93,7 @@ def _text_to_paths(text, x, y, font_size, anchor='start', fill='#1a1a1a', wrap_t
|
||||
|
||||
|
||||
def generate_svg(unit, min_val, max_val, range_label, big_ticks, small_ticks, label_count,
|
||||
use_paths=True, log_scale=False, custom_labels=None):
|
||||
use_paths=True, log_scale=False, custom_labels=None, label_size=9):
|
||||
if log_scale:
|
||||
if min_val <= 0 or max_val <= 0:
|
||||
raise ValueError("Logarithmic scale requires min and max values greater than 0.")
|
||||
@@ -197,10 +197,10 @@ def generate_svg(unit, min_val, max_val, range_label, big_ticks, small_ticks, la
|
||||
x = big_xs[idx]
|
||||
label = custom_labels[k] if custom_labels else _fmt(big_vals[idx])
|
||||
if use_paths:
|
||||
parts.append(' ' + _text_to_paths(label, x, 101.49598, 8.89194, anchor='middle'))
|
||||
parts.append(' ' + _text_to_paths(label, x, 101.49598, label_size, anchor='middle'))
|
||||
else:
|
||||
parts.append(
|
||||
f' <text style="font-size:8.89194px;font-family:\'ГОСТ тип А\',monospace;fill:#1a1a1a"'
|
||||
f' <text style="font-size:{label_size:.5f}px;font-family:\'ГОСТ тип А\',monospace;fill:#1a1a1a"'
|
||||
f' text-anchor="middle" x="{x:.5f}" y="101.49598">{escape(label)}</text>'
|
||||
)
|
||||
|
||||
@@ -226,10 +226,11 @@ def generate():
|
||||
log_scale = request.form.get('scale_type', 'linear') == 'log'
|
||||
|
||||
custom_labels = [s.strip() for s in request.form.get('labels', '').split(',') if s.strip()] or None
|
||||
label_size = max(0.5, min(25.0, float(request.form.get('label_size', 9))))
|
||||
|
||||
try:
|
||||
svg = generate_svg(unit, min_val, max_val, range_label, big_ticks, small_ticks,
|
||||
label_count, use_paths, log_scale, custom_labels)
|
||||
label_count, use_paths, log_scale, custom_labels, label_size)
|
||||
except ValueError as err:
|
||||
return Response(str(err), status=400, mimetype='text/plain')
|
||||
return Response(svg, mimetype='image/svg+xml')
|
||||
|
||||
@@ -350,12 +350,16 @@
|
||||
<span style="font-family:var(--f-mono);font-size:0.65rem;color:var(--muted)">(Labels minus one) should divide evenly into Major intervals for best appearance</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row" style="margin-top:1.25rem">
|
||||
<div class="row row-2" style="margin-top:1.25rem">
|
||||
<div class="field">
|
||||
<label>Custom labels (optional)</label>
|
||||
<input name="labels" type="text" placeholder="e.g. Lo, 25, Mid, 75, Hi — leave blank to use calculated values">
|
||||
<span style="font-family:var(--f-mono);font-size:0.65rem;color:var(--muted)">Comma-separated. When set, overrides the calculated numbers and its count sets the number of labels.</span>
|
||||
</div>
|
||||
<div class="field">
|
||||
<label>Label size (mm)</label>
|
||||
<input name="label_size" type="number" step="any" min="0.5" max="25" value="9" required>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user