Files
novalon-website/deliverables/logo-redesign-2026-10-13/lockup.py
T
zhangxiang a57826f710 docs(brand): 品牌全案手册与落库证据入库(判据、门禁、负例都在场)
BRAND-MANUAL.md 收敛识别方案裁定与实测判据;TOKEN-MIGRATION.md 记 P1/P3/P4 迁移面与孪生缺陷;
TEST-PATCH.md 记 P7 的 1→0 实测。随包入库的是结论赖以成立的仪器与证据:check-assets、check-manual、
verify-assets-cross、check-wordmark-copies、check-docsync、check-probes(四段闸,每段带能失败的负例)、
check-baseline-shift.cjs(平移感知基线判据,四合成样本两绿两红自测通过;它取代被证伪的
「diff 包围盒不许越页眉带」)与 measured/baseline-shift-p1.json(第一批 104 张逐张分类,带 _src 出处戳)。

大体积工作件不入库:样机 HTML 与栅格截图 100+MB、字体母版 45MB 留在盘上,入库 690 个文本/矢量件。
2026-10-16 19:23:28 +08:00

339 lines
16 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
锁定重排(第四十三刀)—— 甲方确认方案一,指出英文太靠左
甲方实测依据(_caa.py 量国美顶部锁定):
书法 752px 宽 / 拉丁 751px 宽 ⇒ wRatio = 0.9987
左差 0px、右差 −1px ⇒ **两端对齐**,不是左对齐
拉丁字高 / 书法字高 = 23/43 = 0.535
我们的现状:号(NOVALON)只贴了左边,右端比名短 87 单位 ⇒ 挂不住。
还有一个几何 flush ≠ 光学 flush 的细节:
novalon.py 的 N 是一笔宽 T 的竖,**中心线落在 x=0 上**,
所以整条字标的墨是从局部 x = −T/2 = −7 开始的。
若按 x=0 对齐左线,名的墨左沿和号的墨左沿会差半个笔宽。
书法那边不用调 —— 我是按 bbox 中心定位的,墨左沿就是 x0。
⇒ 号要往右挪 7·k(k=缩放),两条左线才是真的对齐。
五档摆法全部量出 左差/右差/字高比,跟国美的 0 / −1 / 0.535 对账。
"""
import importlib.util
import json
import math
import os
import re
HERE = os.path.dirname(os.path.abspath(__file__))
def load(name, fn):
sp = importlib.util.spec_from_file_location(name, os.path.join(HERE, fn))
m = importlib.util.module_from_spec(sp)
sp.loader.exec_module(m)
return m
nv = load("nv", "novalon.py")
r2 = load("r2", "ring2.py")
CH = json.load(open(os.path.join(HERE, "_wm-chars.json"), encoding="utf-8"))["chars"]
RED, INK, WHITE = "#C41E3A", "#26221E", "#FFFFFF"
# 国美实测目标
CAA_W, CAA_H, CAA_L, CAA_R = 0.999, 0.535, 0.0, -1.0
NAME_H = 52.0 # 名字高(书法)
LX = 16.0 # 左线
CGAP = 0.10 # 字间缝 / 字高
OVER = nv.T / 2.0 # 号左端的墨外伸量(局部单位)= 7
def name_row(x, cy, h, col=INK):
"""睿新致遠 横排。返回 (片段, 墨左, 墨右, 墨高)。"""
g = h * CGAP
total = 4 * h + 3 * g
body = "".join(r2.char_svg(i, x + h / 2.0 + i * (h + g), cy, h, col)
for i in range(4))
return body, x, x + total, h
def wm_nat_widths(track=None):
"""各字母的推进宽(在【标准笔宽】下取)。P5=S4 的加粗只改 A 的墨,不改推进 ⇒
先把宽度定死再发射,两端对齐的数才不会被一次着色偷偷带走。"""
G = nv.G if track is None else track
old = nv.T
ws = []
for ch in "NOVALON":
_g, w = nv.GLYPH[ch](0.0, nv.H)
ws.append(w)
nv.T = old
return ws
def wm_at(x, ytop, cap, col=INK, track=None, geo=False, accent=None, per_letter=False):
"""把号放在绝对坐标 x 上。geo=False ⇒ x 是【墨左沿】(光学对齐);
geo=True ⇒ x 是【局部原点】,N 的竖笔中心线就在原点上,
于是墨从 x − 7k 就开始 —— 这就是几何对齐偷走的半个笔宽。
返回 (片段, 墨左, 墨右, 字高)。
⚠ 墨右必须算上末笔 N 右竖的外伸:两端各多 OVER·k。
上一版只扣了左半边,于是「右差 0.00」是假的 ——
浏览器实测墨右 243.9 vs 名右 239.6,实际外伸 +4.35。
accent=(字母, 颜色, 笔宽倍数) —— **P5=S4 的落地点**:号里的 A 用正朱砂并把笔宽乘 1.146。
默认 None ⇒ 走原来的单条 path,既有资产逐字节不变(这是回归对照,不是保守)。
给了 accent 才逐字母发射;推进宽一律按标准笔宽取(见 wm_nat_widths)⇒
着色与加粗只动墨,名/号两端对齐的五个数不必重引。"""
k = cap / nv.H
G = nv.G if track is None else track
ws = wm_nat_widths(track)
nat = sum(ws) + G * (len(ws) - 1) # 局部单位下的字身宽
T0 = nv.T
els = []
xx = 0.0
for i, ch in enumerate("NOVALON"):
c, mult = col, 1.0
if accent and ch == accent[0]:
c, mult = accent[1], accent[2]
nv.T = T0 * mult
g, _w = nv.GLYPH[ch](xx, nv.H)
nv.T = T0
els.append('<path fill="%s" fill-rule="nonzero" d="%s"/>' % (c, g.strip()))
xx += ws[i] + G
if not accent and not per_letter: # 只有两者都关才回退到单条合并 path
d = ""
xx = 0.0
for i, ch in enumerate("NOVALON"):
g, _w = nv.GLYPH[ch](xx, nv.H)
d += g + " "
xx += ws[i] + G
els = ['<path fill="%s" fill-rule="nonzero" d="%s"/>' % (col, d.strip())]
el = "".join(els) if (accent or per_letter) else els[0]
ox = x if geo else x + OVER * k
inkL = ox - OVER * k
inkR = ox + nat * k + OVER * k
frag = '<g transform="translate(%g,%g) scale(%g)">%s</g>' % (ox, ytop, k, el)
return frag, inkL, inkR, cap
def wm_nat(track=None):
"""局部单位下的字身宽 Σ字宽 + 6×字距。"""
G = nv.G if track is None else track
xx = 0.0
for ch in "NOVALON":
_, w = nv.GLYPH[ch](xx, nv.H)
xx += w + G
return xx - G
def ink_w(cap, track=None):
"""给定字高(与可选字距)时,号的【墨宽】—— 含两端各半个笔宽的外伸。"""
k = cap / nv.H
return wm_nat(track) * k + 2.0 * OVER * k
def solve_cap(width, track=None):
"""要让墨宽等于 width,字高该是多少(字距锁死)。"""
return width * nv.H / (wm_nat(track) + 2.0 * OVER)
def solve_track(cap, width):
"""要让墨宽等于 width,字距该是多少(字高锁死)。"""
k = cap / nv.H
need = width / k - 2.0 * OVER
return (need - wm_nat(nv.G)) / 6.0 + nv.G
def svg(w, h, inner, px):
return ('<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 %g %g" '
'style="width:%dpx;height:auto;display:block">%s</svg>'
% (w, h, px, inner))
def make(mode, px=520, cal_col=INK, wm_col=INK):
YTOP = 78.0
body, nl, nr, nh = name_row(LX, 44.0, NAME_H, cal_col)
cap_nat = solve_cap(nr - nl) # 字距锁死时,让墨宽等于名宽所需的字高
if mode == "now": # 现状:cap 19、且只按几何左线对齐
cap, x, track = 19.0, LX, None
body2, ml, mr, ch_ = wm_at(LX, YTOP, cap, wm_col, None, geo=True)
H0 = max(44.0 + NAME_H / 2.0, YTOP + ch_) + 14.0
info = dict(nl=nl, nr=nr, ml=ml, mr=mr, cap=ch_, H=H0,
left_diff=ml - nl, right_diff=mr - nr,
w_ratio=(mr - ml) / (nr - nl), h_ratio=ch_ / nh)
return svg(460.0, H0, body + body2, px), info
elif mode == "justify_natural": # 两端对齐·保认可字距(调字高)
cap, x, track = cap_nat, LX, None
elif mode == "justify_caa": # 两端对齐·守国美字高比(调字距)
cap = CAA_H * NAME_H
track = solve_track(cap, nr - nl) # 字高锁死时,让墨宽等于名宽所需的字距
x = LX
TRACK_LOG[mode] = track
elif mode == "center":
cap, x, track = cap_nat * 0.78, 0, None
elif mode == "right":
cap, x, track = cap_nat * 0.78, 0, None
else:
raise AssertionError("未知模式 %s" % mode)
W = 460.0
if mode == "center":
frag, ml, mr, ch_ = wm_at(0, YTOP, cap, wm_col, track)
shift = (nl + nr) / 2.0 - (ml + mr) / 2.0
frag, ml, mr, ch_ = wm_at(shift, YTOP, cap, wm_col, track)
elif mode == "right":
frag, ml, mr, ch_ = wm_at(0, YTOP, cap, wm_col, track)
frag, ml, mr, ch_ = wm_at(nr - (mr - ml), YTOP, cap, wm_col, track)
else:
frag, ml, mr, ch_ = wm_at(x, YTOP, cap, wm_col, track)
info_cap = ch_
inner = body + frag
# 画布高度必须由实际墨底算出来,不能写死。
# 上一版写死 104:名墨底 70、号从 78 往下长 cap,
# 守字高比那档底到 105.8、保字高比那档到 109.1 ⇒ 两档都被切了底边,
# 号越大切得越多 —— 甲方看到的「英文看不全」就是这个。
name_bot = 44.0 + NAME_H / 2.0
H = max(name_bot, YTOP + info_cap) + 14.0
assert YTOP + cap <= H, "号的墨底 %g 掉出画布 %g" % (YTOP + cap, H)
assert nr <= 460.0 - 8.0, "名的右端 %g 顶到画布边" % nr
assert mr <= 460.0 - 8.0, "号的墨右 %g 顶到画布边" % mr
info = dict(nl=nl, nr=nr, ml=ml, mr=mr, cap=ch_, H=H,
left_diff=ml - nl, right_diff=mr - nr,
w_ratio=(mr - ml) / (nr - nl), h_ratio=ch_ / nh)
return svg(W, H, inner, px), info
TRACK_LOG = {}
MODES = [
("now", "现状(你说的那一版)", "号 cap 19、只贴左线。右端空 87 单位,挂不住。"),
("justify_natural", "两端对齐·保字距",
"把号的字高提到与自然宽度等于名的宽度;字距 22 一个不动(已认可的构造几何不改)。"),
("justify_caa", "两端对齐·守国美字高比",
"反过来:字高锁在国美的 0.535 倍,靠加字距把宽度撑满。字距会明显变松。"),
("center", "居中", "号缩一点,摆在名的正中下方。传统但不动声色。"),
("right", "右对齐", "号贴名的右端。左端留空,读起来像落款而不是副标。"),
]
CSS = """
*{box-sizing:border-box}
body{margin:0;background:#F7F4EF;color:#4F4A42;
font:17px/1.9 "Songti SC","Noto Serif SC",Georgia,serif;-webkit-font-smoothing:antialiased}
.wrap{max-width:1180px;margin:0 auto;padding:46px 32px 100px}
code{font:13.5px/1.5 ui-monospace,Menlo,monospace;background:#EFEAE1;padding:1px 5px}
.ey{font:12px/1.4 "PingFang SC",Inter,sans-serif;letter-spacing:.18em;
text-transform:uppercase;color:#8A8377}
h1{font-size:48px;line-height:1.16;color:#26221E;margin:12px 0 16px;font-weight:600}
h1 em{font-style:normal;color:#C41E3A}
p{max-width:90ch;margin:10px 0}
.lede{font-size:19px;color:#26221E;max-width:82ch}
.j{border-left:2px solid #C41E3A;padding:3px 0 3px 18px;margin:14px 0;color:#26221E;max-width:94ch}
.panel{background:#fff;border:1px solid #EFEAE1;padding:24px 26px;margin:0 0 12px}
.panel.pick{border-color:#C41E3A;box-shadow:0 0 0 1px #C41E3A inset}
.dark{background:#141210}
.nm{font:650 15px/1.4 "PingFang SC",Inter,sans-serif;color:#26221E;margin-bottom:4px}
.mt{font:12px/1.6 "PingFang SC",Inter,sans-serif;color:#8A8377;
font-variant-numeric:tabular-nums;margin-top:8px}
.mt b{color:#26221E}
.mt .good{color:#0f7b3b;font-weight:700}
.mt .bad{color:#C41E3A;font-weight:700}
.nt{font-size:14px/1.75 "PingFang SC",Inter,sans-serif;color:#4F4A42;margin-top:6px;max-width:88ch}
table{border-collapse:collapse;width:100%;margin:14px 0;
font:13px/1.6 "PingFang SC",Inter,sans-serif}
th,td{padding:10px 12px;border-bottom:1px solid #C3BDB1;text-align:left}
th{font-size:11px;letter-spacing:.11em;text-transform:uppercase;color:#8A8377;font-weight:500}
td.n,th.n{text-align:right;font-variant-numeric:tabular-nums;white-space:nowrap}
footer{margin-top:52px;padding-top:16px;border-top:1px solid #C3BDB1;
font:12.5px/1.7 "PingFang SC",Inter,sans-serif;color:#8A8377}
"""
def build():
P = ['<!DOCTYPE html><html lang="zh-CN"><head><meta charset="utf-8">'
'<meta name="viewport" content="width=device-width,initial-scale=1">'
'<title>锁定重排</title><style>' + CSS + '</style></head><body><div class="wrap">']
P.append('<div class="ey">Cut 43 · 2026-10-14 · 方案一已确认 · 目标:两端对齐 左差0 右差−1 · repo 零改动</div>')
P.append('<h1>锁定重排:<em>从「左对齐」改成「两端对齐」</em></h1>')
P.append('<p class="lede">你指出的偏移是真的。量了国美那套顶部锁定:书法 752px、拉丁 751px、'
'左差 0、右差 −1 —— <b>它是两端对齐的,两条边都咬死</b>,不是左对齐。'
'我们之前只贴了左边,右端空 87 单位,所以号挂不住。</p>')
P.append('<div class="j"><b>顺带修一个几何 flush ≠ 光学 flush 的细节。</b>'
'构造几何的 N 是一笔宽 T 的竖,<b>中心线</b>落在局部 x=0 上,'
'所以整条号的墨其实从 x = −T/2 = −7 就开始。书法那边我是按 bbox 中心定位的,'
'墨左沿就是 x0。所以号要往右挪 7·k 才是真的对齐 —— 差半个笔宽,'
'单看看不出来,叠在一条辅助线上立刻穿帮。</div>')
infos = []
for mode, nm, why in MODES:
s_, info = make(mode)
infos.append((nm, mode, info))
ld, rd = info["left_diff"], info["right_diff"]
ok = abs(ld) <= 0.6 and abs(rd - CAA_R) <= 3.0
cls = "panel pick" if mode == "justify_natural" else "panel"
P.append('<div class="%s"><div class="nm">%s%s</div>%s'
'<div class="mt">名宽 <b>%.1f</b> · 号宽 <b>%.1f</b> · 宽比 <b>%.3f</b> '
'(国美 0.999)· 左差 <b class="%s">%+.2f</b> · 右差 <b class="%s">%+.2f</b> '
'(国美 0 / −1)· 字高比 <b>%.3f</b>(国美 0.535)· 号字高 <b>%.1f</b></div>'
'<div class="nt">%s</div></div>'
% (cls, nm, " ← 我的主张" if mode == "justify_natural" else "", s_,
info["nr"] - info["nl"], info["mr"] - info["ml"], info["w_ratio"],
"good" if abs(ld) <= 0.6 else "bad", ld,
"good" if abs(rd - CAA_R) <= 3.0 else "bad", rd,
info["h_ratio"], info["cap"], why))
P.append('<h2 style="font-size:26px;color:#26221E;margin:48px 0 8px">对账表</h2>')
P.append('<table><thead><tr><th>摆法</th><th class="n">宽比</th><th class="n">左差</th>'
'<th class="n">右差</th><th class="n">字高比</th><th class="n">号字高</th>'
'<th>两端对齐达标</th></tr></thead><tbody>')
for nm, mode, i in infos:
ok = abs(i["left_diff"]) <= 0.6 and abs(i["right_diff"] - CAA_R) <= 3.0
P.append('<tr><td><b>%s</b></td><td class="n">%.3f</td><td class="n">%+.2f</td>'
'<td class="n">%+.2f</td><td class="n">%.3f</td><td class="n">%.1f</td>'
'<td class="%s">%s</td></tr>'
% (nm, i["w_ratio"], i["left_diff"], i["right_diff"], i["h_ratio"],
i["cap"], "yes" if ok else "no", "达标" if ok else "未达标"))
P.append('<tr><td><b>国美实测</b></td><td class="n">0.999</td><td class="n">0.00</td>'
'<td class="n">−1.00</td><td class="n">0.535</td><td class="n">—</td>'
'<td>基准</td></tr>')
P.append('</tbody></table>')
P.append('<div class="j"><b>两条路的取舍只有一句。</b>'
'要同时满足「宽比 1.0」和「字高比 0.535」,就必须动字距 —— '
'因为 NOVALON 只有 7 个字母,自然字距下的宽高比是固定的。'
'国美能两个条件同时成立,是因为 "China Academy of Art" 有 20 个字符,'
'字距不用动就能凑到那个宽度。'
'所以我选<b>保字距、调字高</b>:构造几何的字距 22 是已经认可的东西,不该为对齐去改它;'
'代价是号比国美的比例略大一点(字高比 %.3f vs 0.535),'
'而"号略大"在中文品牌里本来就是常态。</div>'
% next(i["h_ratio"] for n2, m2, i in infos if m2 == "justify_natural"))
P.append('<footer>生成器 <code>lockup.py</code> · 书法四字取自 <code>public/logo.svg</code> '
'字标组真迹路径 · 号沿用 <code>novalon.py</code> 构造几何(笔宽 14%/字距 22 未改)· '
'左差/右差/宽比/字高比全部为解析量,与 <code>_caa.py</code> 对参照图的栅格实测同口径 · '
'repo 零改动</footer>')
P.append('</div></body></html>')
return "".join(P)
if __name__ == "__main__":
html = build()
with open(os.path.join(HERE, "lockup.html"), "w", encoding="utf-8") as f:
f.write(html)
os.makedirs(os.path.join(HERE, "assets-lockup"), exist_ok=True)
for mode, nm, why in MODES:
s_, i = make(mode)
inner = s_.split(">", 1)[1].rsplit("</svg>", 1)[0]
with open(os.path.join(HERE, "assets-lockup", mode + ".svg"), "w",
encoding="utf-8") as fh:
fh.write('<svg xmlns="http://www.w3.org/2000/svg" '
'viewBox="0 0 460 %g">%s</svg>' % (i["H"], inner))
tr = TRACK_LOG.get(mode)
print("%-18s 宽比 %.3f 左差 %+5.2f 右差 %+5.2f 字高比 %.3f 号字高 %5.1f%s"
% (mode, i["w_ratio"], i["left_diff"], i["right_diff"],
i["h_ratio"], i["cap"],
"" if tr is None else " 字距 %g(=认可的 %.2f 倍)" % (tr, tr / nv.G)))
print("lockup.html %s B" % format(len(html.encode("utf-8")), ","))