Files
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

280 lines
14 KiB
Python
Raw Permalink 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 -*-
"""
拱(第三十一刀)
甲方裁定:「英文字体不错,但是符号不好看」。
诊断:我从 NOVALON 里拆出来的那个没有横杠的 A,单独看是个 **caret(^)** ——
脱字符、上标号、向上的箭头。它在字里读作字母,是因为被七个字符的序列托着;
拆出来序列没了,它就只剩一个插入符。花旗那枚弧成立,是因为它本身不是字母,
只是碰了一下 t 的竖笔。
所以"拱"这个概念没错,**形画错了**:拱必须有梁。
两根腿 + 一道有厚度的顶跨 + 底下腾空 = 门洞、结构、可通行。
两笔相交的尖顶 = 插入符。
新方案全部由**半圆与等宽直段**构造 —— 与字标同一套零件、同一个笔宽(14%),
所以它天然是一家人,不需要另外找语汇。
"""
import importlib.util
import math
import os
HERE = os.path.dirname(os.path.abspath(__file__))
def load(name, path):
sp = importlib.util.spec_from_file_location(name, path)
m = importlib.util.module_from_spec(sp)
sp.loader.exec_module(m)
return m
nv = load("nv", os.path.join(HERE, "novalon.py"))
RED, WHITE, DEEP = nv.RED, nv.WHITE, nv.DEEP
PAPER, CARD, HEAD, BODY, MUTED, LINE = nv.PAPER, nv.CARD, nv.HEAD, nv.BODY, nv.MUTED, nv.LINE
H_LOGO, T_LOGO, G_LOGO = nv.H, nv.T, nv.G
S = 256.0
def _f(v):
return ("%g" % v)
def _path(*cmds):
"""把 (指令, 参数...) 拼成 d 字符串,并**校验参数个数**。
手写 %s 连错两次(16 对 18、18 对 20)—— 这类错该被机器拦住,不该靠数占位符。"""
need = {"M": 2, "L": 2, "H": 1, "V": 1, "Z": 0, "Q": 4, "C": 6, "T": 2, "S": 4}
out = []
for c in cmds:
op, args = c[0], c[1:]
if op == "A":
assert len(args) == 7, "A 需要 7 个参数(rx ry rot laf sf x y),给了 %d" % len(args)
rx, ry, rot, laf, sf, x, y = args
out.append("A %s %s %s %s %s %s %s" % tuple(_f(v) for v in
(rx, ry, rot, laf, sf, x, y)))
else:
n = need[op]
assert len(args) == n, "%s 需要 %d 个参数,给了 %d" % (op, n, len(args))
out.append("%s %s" % (op, " ".join(_f(a) for a in args)))
return " ".join(out)
def arch(shape="segmental", pad=0.13, stroke=nv.STROKE, col=RED, gap=0.0):
"""一拱 = 两腿 + 一道有厚度的顶跨 + 底下腾空。
caret 之所以不是拱,缺的就是那道梁。
全部由直段与圆弧构造,与字标同一套零件。
"""
m = S * pad
x0, x1 = m, S - m
yb, yt = S - m, m
w = x1 - x0
t = w * stroke * 1.30 # 腿宽 = 字标笔宽 × 1.30(上一版 1.48 重过头)
cx = (x0 + x1) / 2.0
if shape == "lintel": # 平顶横梁:零曲线,最接近汉字「门」的骨
d = _path(("M", x0, yb), ("L", x0, yt), ("L", x1, yt), ("L", x1, yb),
("L", x1 - t, yb), ("L", x1 - t, yt + t),
("L", x0 + t, yt + t), ("L", x0 + t, yb), ("Z",))
elif shape == "pointed": # 哥特尖跨(对照:仍可能被读成箭头)
apex = yt + t * 1.6
ys = yt + (yb - yt) * 0.42
d = _path(("M", x0, yb), ("L", x0, ys),
("Q", cx, apex, x1, ys), ("L", x1, yb),
("L", x1 - t, yb), ("L", x1 - t, ys),
("Q", cx, apex + t * 2.0, x0 + t, ys), ("L", x0 + t, yb), ("Z",))
else: # segmental 平拱 / round 半圆拱 / keystone
r_out, r_in = w / 2.0, w / 2.0 - t
ry_o = r_out if shape == "round" else r_out * 0.58
ry_i = max(ry_o - t, 1.0)
ys = yt + ry_o # 起拱线 = 顶 + 拱高
d = _path(("M", x0, yb), ("L", x0, ys),
("A", r_out, ry_o, 0, 0, 1, x1, ys),
("L", x1, yb), ("L", x1 - t, yb), ("L", x1 - t, ys),
("A", r_in, ry_i, 0, 0, 0, x0 + t, ys),
("L", x0 + t, yb), ("Z",))
body = '<path fill="%s" d="%s"/>' % (col, d)
if gap and shape == "keystone": # 顶上一道施工缝:拱还没放最后一块石
gw = t * gap
body += ('<rect x="%s" y="%s" width="%s" height="%s" fill="%s"/>'
% (_f(cx - gw / 2.0), _f(yt - 2), _f(gw), _f(t * 2.4), col))
return body
FORMS = [
("A1 平拱", arch("segmental"),
"浅椭圆跨 + 两腿。最接近 Roman 桥洞,稳、素,顶部不尖所以不会读成插入符。"),
("A2 半圆拱", arch("round"),
"标准半圆。构造最纯粹(一个圆 + 两条直段),识别度最高,风险是偏「古典/银行」。"),
("A3 石梁门", arch("lintel"),
"平顶横梁 + 两腿 = 最原始的「结构」,也最接近汉字「门」的骨。完全没有曲线。"),
("A4 尖拱", arch("pointed"),
"哥特尖跨。比 caret 多了梁的厚度,但尖顶仍可能被读成箭头 —— 放进来做对照。"),
("A5 半圆拱·顶缝", arch("keystone", gap=0.55),
"A2 加一道施工缝:拱还没放最后一块石的状态。是「结构正在成形」的说法。"),
("A0 旧符号(对照)", nv.mark(),
"上一版:没有横杠的 A。这就是被判定「不好看」的那个 caret。"),
]
CSS = """
*{box-sizing:border-box}body{margin:0;background:%(PAPER)s;color:%(BODY)s;
font:17px/1.9 "Songti SC","Noto Serif SC",Georgia,serif;-webkit-font-smoothing:antialiased}
.wrap{max-width:1180px;margin:0 auto;padding:48px 32px 100px}
.ey{font:12px/1.4 'PingFang SC',Inter,sans-serif;letter-spacing:.18em;text-transform:uppercase;color:%(MUTED)s}
h1{font-size:52px;line-height:1.14;color:%(HEAD)s;margin:12px 0 16px;font-weight:600}
h1 em{font-style:normal;color:%(RED)s}
h2{font-size:25px;color:%(HEAD)s;margin:60px 0 8px;font-weight:600}
h2 .no{color:%(RED)s;margin-right:10px}
p{max-width:78ch;margin:10px 0}
.lede{font-size:19px;color:%(HEAD)s;max-width:74ch}
.j{border-left:2px solid %(RED)s;padding:3px 0 3px 18px;margin:14px 0;color:%(HEAD)s;max-width:84ch}
.card{background:#fff;border:1px solid %(CARD)s;padding:22px 24px;margin:0 0 14px}
.hd{display:flex;justify-content:space-between;align-items:baseline;gap:16px;margin-bottom:14px}
.nm{font-weight:650;color:%(HEAD)s;font-size:16px;font-family:'PingFang SC',Inter,sans-serif}
.row{display:flex;gap:22px;align-items:flex-end;flex-wrap:wrap}
.cell{text-align:center}
.lab{font:11.5px/1.5 'PingFang SC',Inter,sans-serif;color:%(MUTED)s;margin-top:8px}
.tl{display:inline-flex;align-items:center;justify-content:center;border-radius:22.5%%;
overflow:hidden;box-shadow:0 0 0 1px %(CARD)s}
.tl svg{display:block}
.lock{display:flex;align-items:center;gap:16px;margin-top:18px;padding-top:18px;
border-top:1px solid %(CARD)s}
.why{font-size:14.5px;color:%(BODY)s;margin:14px 0 0;max-width:88ch}
table{border-collapse:collapse;width:100%%;margin:14px 0;font:14px/1.6 'PingFang SC',Inter,sans-serif}
th,td{padding:10px 12px;border-bottom:1px solid %(LINE)s;text-align:left}
th{font-size:11px;letter-spacing:.11em;text-transform:uppercase;color:%(MUTED)s;font-weight:500}
td.n{text-align:right;font-variant-numeric:tabular-nums;white-space:nowrap}
.pass{color:#0f7b3b;font-weight:600}.fail{color:%(RED)s;font-weight:600}
pre{font:9.5px/1.15 ui-monospace,Menlo,monospace;margin:0;text-align:left}
footer{margin-top:56px;padding-top:16px;border-top:1px solid %(LINE)s;
font:12.5px/1.7 'PingFang SC',Inter,sans-serif;color:%(MUTED)s}
""" % dict(PAPER=PAPER, BODY=BODY, HEAD=HEAD, RED=RED, CARD=CARD, MUTED=MUTED, LINE=LINE)
JS = r"""<script>
const WHT=[255,255,255],REDc=[196,30,58],INKc=[38,34,30];
function D(a,b){return Math.hypot(a[0]-b[0],a[1]-b[1],a[2]-b[2]);}
function isRed(p,a){return a>=40&&D(p,WHT)>=110&&D(p,REDc)<D(p,INKc);}
function ras(el,size){return new Promise(r=>{const s=new XMLSerializer().serializeToString(el);
const im=new Image(),cv=document.createElement('canvas');cv.width=size;cv.height=size;
const x=cv.getContext('2d');x.fillStyle='#fff';x.fillRect(0,0,size,size);
im.onload=()=>{x.drawImage(im,0,0,size,size);r(x.getImageData(0,0,size,size));};
im.onerror=()=>r(null);im.src='data:image/svg+xml;charset=utf-8,'+encodeURIComponent(s);});}
function ink(im){const d=im.data;let n=0;for(let i=0;i<d.length;i+=4){
if(isRed([d[i],d[i+1],d[i+2]],d[i+3]))n++;}return 100*n/(d.length/4);}
function runs(im,px,vert){const d=im.data;let best=Infinity;
for(let a=0;a<px;a++){let c=0;
for(let b=0;b<px;b++){const i=((vert?b:a)*px+(vert?a:b))*4;
if(isRed([d[i],d[i+1],d[i+2]],d[i+3]))c++;else{if(c)best=Math.min(best,c);c=0;}}
if(c)best=Math.min(best,c);}
return best===Infinity?0:best;}
function grid(im,px){const d=im.data,g=[];for(let y=0;y<px;y++){let s='';
for(let x=0;x<px;x++){const i=(y*px+x)*4,a=d[i+3],p=[d[i],d[i+1],d[i+2]];
s+=(isRed(p,a)?'#':'.');}g.push(s);}return g;}
(async()=>{
const out={};
for(const el of document.querySelectorAll('svg[data-k]')){
const i16=await ras(el,16),i512=await ras(el,512);
if(!i16)continue;
out[el.dataset.k]={ink16:ink(i16),ink512:ink(i512),hMin:runs(i16,16,false),
vMin:runs(i16,16,true),g:grid(i16,16)};
}
document.querySelectorAll('[data-cell]').forEach(td=>{
const c=td.dataset.cell,at=c.lastIndexOf('@');
const k=c.slice(0,at),f=c.slice(at+1),o=out[k];if(!o)return;
if(f==='ink')td.textContent=o.ink512.toFixed(1)+'%';
else if(f==='hmin'){td.textContent=o.hMin+'px';td.className=o.hMin>=2?'pass':'fail';}
else if(f==='vmin'){td.textContent=o.vMin+'px';td.className=o.vMin>=2?'pass':'fail';}
else if(f==='drift'){const d=Math.abs(o.ink512-o.ink16);td.textContent=d.toFixed(1)+'pt';
td.className=d<6?'pass':'fail';}
});
document.querySelectorAll('[data-g]').forEach(p=>{const o=out[p.dataset.g];
if(o)p.textContent=o.g.join(String.fromCharCode(10));});
window.__ar=out;
})();
</script>
"""
def svg(inner, px, key=None):
k = ' data-k="%s"' % key if key else ""
return ('<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 %g %g" '
'width="%d" height="%d" style="width:%dpx;height:%dpx;display:block"%s>%s</svg>'
% (S, S, px, px, px, px, k, inner))
def build():
H = ['<!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">']
H.append('<div class="ey">Cut 31 · 2026-10-14 · 字标保留,符号重做 · repo 零改动</div>')
H.append('<h1>拱:<em>caret 不是拱,拱要有梁</em></h1>')
H.append('<p class="lede">你说字标成了、符号没成,我接受,而且我知道为什么:'
'我拆出来的是<b>两根相交的线</b>,那是插入符。'
'拱的定义是<b>两腿 + 一道有厚度的顶跨 + 底下腾空</b>——它读作结构和门洞,'
'靠的就是那道梁。概念没错,形画错了。</p>')
H.append('<div class="j">新方案全部由<b>圆弧与等宽直段</b>构造,与字标同一套零件、'
'同一档笔宽(腿宽 = 字标笔宽 × 1.30,标志比文字略重的通行余量;'
'上一版是 1.48,重过头了)。</div>')
H.append('<h2><span class="no">1</span>五种拱,加旧符号对照</h2>')
for i, (nm, body, why) in enumerate(FORMS):
key = "F%d" % i
H.append('<div class="card"><div class="hd"><span class="nm">%s</span></div>'
'<div class="row">' % nm)
for px in (170, 84, 40, 24, 16):
H.append('<div class="cell"><span class="tl" style="background:%s">%s</span>'
'<div class="lab">%dpx</div></div>' % (PAPER, svg(body, px, "%s@%d" % (key, px)), px))
H.append('<div class="cell"><span class="tl" style="background:%s">%s</span>'
'<div class="lab">暖墨底反白</div></div>'
% (DEEP, svg(body.replace(RED, WHITE), 84)))
H.append('</div>')
H.append('<div class="lock">%s<span style="width:210px">%s</span></div>'
% (svg(body, 42), nv.wm_svg(210, HEAD)))
H.append('<p class="why">%s</p></div>' % why)
H.append('<h2><span class="no">2</span>度量</h2>')
H.append('<table><thead><tr><th>候选</th><th class="n">横向最细@16</th>'
'<th class="n">竖向最细@16</th><th class="n">墨率@512</th>'
'<th class="n">漂移</th></tr></thead><tbody>')
for i, (nm, body, why) in enumerate(FORMS):
key = "F%d" % i
H.append('<tr><td><b>%s</b></td><td class="n" data-cell="%s@16@hmin">…</td>'
'<td class="n" data-cell="%s@16@vmin">…</td>'
'<td class="n" data-cell="%s@16@ink">…</td>'
'<td class="n" data-cell="%s@16@drift">…</td></tr>'
% (nm, key, key, key, key))
H.append('</tbody></table>')
H.append('<h3>16×16 栅格</h3><div class="row">')
for i, (nm, body, why) in enumerate(FORMS):
key = "F%d" % i
H.append('<div class="cell"><pre data-g="%s@16">…</pre>'
'<div class="lab">%s</div></div>' % (key, nm.split()[0]))
H.append('</div>')
H.append('<p>字高、笔宽、字距与上一刀完全一致(%g / %g / %g),'
'标准字没有动过一个点。<b>本行数字由常量算出,不手写。</b></p>'
% (H_LOGO, T_LOGO, G_LOGO))
H.append('<footer>生成器 <code>arch.py</code> · 标准字沿用 <code>novalon.py</code> 未改动 · '
'拱全部由圆弧与等宽直段构造 · 度量为本页浏览器 16×16 与 512×512 栅格实测 · '
'repo 零改动</footer>')
H.append(JS)
H.append('</div></body></html>')
return "".join(H)
if __name__ == "__main__":
html = build()
out = os.path.join(HERE, "arch.html")
with open(out, "w", encoding="utf-8") as f:
f.write(html)
os.makedirs(os.path.join(HERE, "assets-arch"), exist_ok=True)
for i, (nm, body, why) in enumerate(FORMS, 1):
with open(os.path.join(HERE, "assets-arch", "arch-%d.svg" % i), "w",
encoding="utf-8") as fh:
fh.write('<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 %g %g">%s</svg>'
% (S, S, body))
print("arch.html %s B / %d 方案" % (format(len(html.encode("utf-8")), ","), len(FORMS)))