Compare commits
2
Commits
fb5c88f90d
...
cecfcad8c7
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
cecfcad8c7 | ||
|
|
5e980adfd3 |
+19
-6
@@ -182,8 +182,13 @@ def _wrap(text, font, max_w, max_lines=2):
|
||||
if not cur or _text_width(cur + ch, font) <= max_w:
|
||||
cur += ch
|
||||
else:
|
||||
out.append(cur)
|
||||
cur = ch
|
||||
# 在空格处换行时把空格留在上一行尾部,下一行不要顶着缩进
|
||||
if ch.isspace():
|
||||
out.append(cur + ch)
|
||||
cur = ''
|
||||
else:
|
||||
out.append(cur)
|
||||
cur = ch
|
||||
if cur:
|
||||
out.append(cur)
|
||||
if len(out) > max_lines:
|
||||
@@ -318,8 +323,12 @@ def plan_label(cfg, title, fields, qr_data=''):
|
||||
else:
|
||||
warn.append('内容较长,已压缩行距排满整张标签')
|
||||
|
||||
# 最后一行只占一个字号的高度,不占整行行距,垂直居中才不会显得偏上
|
||||
block_h = (len(rows) - 1) * font * ratio + font
|
||||
# 行距:有二维码时把文字从上到下均匀铺开(现场反馈底部空太多),
|
||||
# 没二维码的标签仍垂直居中。
|
||||
step = font * ratio
|
||||
if qr and best is not None and len(rows) > 1:
|
||||
step = max(step, (avail_h - font) / float(len(rows) - 1))
|
||||
block_h = (len(rows) - 1) * step + font
|
||||
if qr:
|
||||
# 有二维码时文字贴顶:和右上角的码同一条水平线,读起来是“左右布局”。
|
||||
# 以前一律垂直居中,码在上、字块在中,看着像上下两段(现场反馈)。
|
||||
@@ -329,8 +338,12 @@ def plan_label(cfg, title, fields, qr_data=''):
|
||||
lines = []
|
||||
for t in rows:
|
||||
lines.append({'text': t, 'font': font, 'x': mx, 'y': int(y),
|
||||
'w': int(_text_width(t, font))})
|
||||
y += font * ratio
|
||||
'w': int(_text_width(t.rstrip(), font))})
|
||||
y += step
|
||||
# 二维码贴右下角:底边和最后一行底边对齐(现场参考图的版式)。
|
||||
# 放在最后算,是因为要先知道文字铺完最后一行落在哪。
|
||||
if qr and lines:
|
||||
qr['y'] = max(my, int(lines[-1]['y'] + font - qr['size']))
|
||||
|
||||
gap_mm = _num(cfg.get('gap_mm'), 2)
|
||||
if gap_mm < 0:
|
||||
|
||||
@@ -83,6 +83,14 @@ def fail_reasons(p, cfg, qr):
|
||||
out.append('二维码越右边界')
|
||||
if q['y'] + q['size'] > h - my + 1:
|
||||
out.append('二维码越下边界')
|
||||
if q['y'] < my - 1:
|
||||
out.append('二维码越上边界')
|
||||
# 二维码底边和最后一行底边对齐(参考图版式)
|
||||
if p['lines']:
|
||||
last_bottom = p['lines'][-1]['y'] + p['font']
|
||||
if abs((q['y'] + q['size']) - last_bottom) > 1:
|
||||
out.append('二维码底边未与末行对齐 码底=%d 末行=%d'
|
||||
% (q['y'] + q['size'], last_bottom))
|
||||
return out
|
||||
|
||||
|
||||
|
||||
@@ -29,9 +29,9 @@
|
||||
|
||||
【v1.0.69 标签改左右布局 + 点卡不再抖(2026-11-23)】
|
||||
|
||||
◆ 标签改成左右布局(文字在左、二维码在右)
|
||||
· 文字块改成贴顶排版,和右上角二维码在同一条水平线上;以前文字块
|
||||
垂直居中,看着像“上面一块码、中间一块字”两段。
|
||||
◆ 标签改成左右布局(文字在左、二维码在右下)
|
||||
· 文字从第一行到最后一行均匀铺满整张纸的高度,底部不再空一大块。
|
||||
· 二维码贴右下角,底边和最后一行(日期)底边对齐。
|
||||
· 没有二维码的标签(调试预览)仍按原来的垂直居中,版面不变。
|
||||
· 安装包出厂纸型改为 60×40mm(203dpi 下 480×320 点)。
|
||||
· 老机器升级不会覆盖 config.json,纸型仍是原来的设置;需要时走
|
||||
|
||||
Reference in New Issue
Block a user