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 个文本/矢量件。
284 lines
15 KiB
Python
284 lines
15 KiB
Python
#!/usr/bin/env python3
|
||
# -*- coding: utf-8 -*-
|
||
"""
|
||
环(第三十二刀)
|
||
|
||
甲方给了一张新参照:字母沿一道开口的圆环排布,环即标志、字即内容,
|
||
旁边放 descriptor。并说「之前的一相圆,做成这种设计呢」。
|
||
|
||
这一步把两条已成立的结论接上:
|
||
1. 甲方裁定「英文字体不错,但是符号不好看」
|
||
⇒ 那就不要再另外找一个我画不出来的形,把成了的东西直接当符号。
|
||
2. 一相圆是三十轮里唯一一次没被否掉的生成物,它的开口 = 「通」
|
||
(《说文》「叡,深明也。通也」)
|
||
⇒ 开口这件事保留,但改由「字母排到最后一格没有接上」来承担,
|
||
不再依赖笔画。
|
||
|
||
技术要点:字母沿圆周排布,每字切向旋转、字头朝外(章形/roundel 常规排法)。
|
||
字宽要换算成角度:θ_i = (累计弧长)/R。开口角度是一个可调的设计参数,不是误差。
|
||
"""
|
||
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
|
||
STROKE, H, T, G = nv.STROKE, nv.H, nv.T, nv.G
|
||
|
||
S = 400.0 # 环画布
|
||
CX = CY = S / 2.0
|
||
|
||
|
||
def glyph_paths(text):
|
||
"""逐字取出路径与字宽(沿用 novalon.py 的构造几何,一个点都没改)。"""
|
||
out = []
|
||
for ch in text:
|
||
d, w = nv.GLYPH[ch](0.0, H)
|
||
out.append((ch, d, w))
|
||
return out
|
||
|
||
|
||
def roundel(text="NOVALON", R=132.0, opening=68.0, col=RED, inward=False,
|
||
start_from_gap=True, gap_at=0.0, track=1.0):
|
||
"""把 text 排成一道开口的环。
|
||
|
||
R : 基线半径
|
||
opening : 开口角度(度)。这是设计参数 —— 它承担「通」。
|
||
inward : 字头朝内(False = 朝外,章形常规)
|
||
gap_at : 开口中心所在角度(0 = 正上方)
|
||
track : 字距倍率
|
||
"""
|
||
gl = glyph_paths(text)
|
||
adv = [w + G * track for _, _, w in gl]
|
||
total_arc = sum(adv) - adv[-1]
|
||
span = 360.0 - opening
|
||
if total_arc <= 0:
|
||
return ""
|
||
# 角度 = 弧长 / R(弧度)。用字宽直接当弧长,不缩字 —— 若环太小装不下,
|
||
# 宁可报错也不要悄悄把字母压扁(本项目吃过静默吸附的亏)。
|
||
need_R = total_arc / math.radians(span)
|
||
if R < need_R - 1e-6:
|
||
raise AssertionError("R=%g 装不下 %s:需要 R ≥ %g,否则字会被压扁"
|
||
% (R, text, round(need_R, 1)))
|
||
scale = min(1.0, R / need_R) if R > need_R else 1.0
|
||
|
||
out = []
|
||
s = 0.0
|
||
# 从开口中心起算:开口居中在 gap_at,则文字从 gap_at + opening/2 开始
|
||
a0 = gap_at + opening / 2.0
|
||
for i, (ch, d, w) in enumerate(gl):
|
||
s_center = s + w / 2.0
|
||
ang = a0 + math.degrees(s_center / R)
|
||
flip = 180.0 if inward else 0.0
|
||
tr = ("translate(%g,%g) rotate(%g) translate(%g,%g)"
|
||
% (CX, CY, ang + flip, -w / 2.0, -R if not inward else -(R - H)))
|
||
out.append('<g transform="%s"><g transform="translate(0,%g)">%s</g></g>'
|
||
% (tr, 0, '<path fill="%s" fill-rule="evenodd" d="%s"/>' % (col, d)))
|
||
s += w + (G * track if i < len(gl) - 1 else 0.0)
|
||
return "".join(out)
|
||
|
||
|
||
def lockup_ring(mark, px=150, col=HEAD, wpx=250):
|
||
return ('<div style="display:flex;align-items:center;gap:18px">'
|
||
'<span style="width:%dpx;height:%dpx;display:inline-block">%s</span>'
|
||
'<span style="width:%dpx">%s</span></div>'
|
||
% (px, px, mark, wpx, nv.wm_svg(wpx, col)))
|
||
|
||
|
||
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}
|
||
.cx{font:12px/1 'PingFang SC',Inter,sans-serif;color:%(MUTED)s;font-variant-numeric:tabular-nums}
|
||
.row{display:flex;gap:24px;align-items:center;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}
|
||
.why{font-size:14.5px;color:%(BODY)s;margin:16px 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}
|
||
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;}
|
||
(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)};
|
||
}
|
||
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==='min'){const m=Math.min(o.hMin,o.vMin);td.textContent=m+'px';
|
||
td.className=m>=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';}
|
||
});
|
||
window.__rd=out;
|
||
})();
|
||
</script>
|
||
"""
|
||
|
||
|
||
def svg(inner, px, key=None, vb=S):
|
||
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>'
|
||
% (vb, vb, px, px, px, px, k, inner))
|
||
|
||
|
||
VARIANTS = [
|
||
("K1 开口在右上", dict(R=140.0, opening=70.0, gap_at=40.0),
|
||
"开口朝右上,参照图就是这个方位。字头朝外,章形排法。"),
|
||
("K2 开口在正上", dict(R=140.0, opening=70.0, gap_at=0.0),
|
||
"开口移到正上方 —— 这是一相圆原来的开口方位,"
|
||
"也是《说文》那个「通」最直白的读法。"),
|
||
("K3 开口收窄", dict(R=140.0, opening=34.0, gap_at=40.0),
|
||
"开口压到 34°。更接近一枚闭合的丸印,气势足,但"
|
||
"「通」的那口气也小了。"),
|
||
("K4 字头朝内", dict(R=158.0, opening=70.0, gap_at=40.0, inward=True),
|
||
"对照:字头朝内。中心留白更大,但可读性明显差 —— 放进来是为了把它排除掉。"),
|
||
("K5 环更大更疏", dict(R=152.0, opening=88.0, gap_at=40.0, track=1.5),
|
||
"半径与字距都放宽,开口 88°。最接近参照图那种松弛的呼吸。"),
|
||
]
|
||
|
||
|
||
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>环 · NOVALON roundel</title><style>' + CSS + '</style></head><body><div class="wrap">']
|
||
P.append('<div class="ey">Cut 32 · 2026-10-14 · 一相圆的当代排法 · repo 零改动</div>')
|
||
P.append('<h1>环:<em>字就是标,开口就是「通」</em></h1>')
|
||
P.append('<p class="lede">你裁定英文字体成了、符号没成,那就不该再另外找一个形。'
|
||
'把字母排成一道开口的环 —— 环是形,字是内容,'
|
||
'而那个<b>没有接上</b>的缺口,就是一相圆的开口,也就是《说文》给睿下的定义:通。</p>')
|
||
P.append('<div class="j">字母沿圆周切向排布,字头朝外(章形常规排法)。'
|
||
'字宽按 θ = 弧长 / R 换算成角度,<b>不缩放、不压扁字母</b>:'
|
||
'半径不够装不下时直接断言报错,而不是悄悄把字挤扁 —— '
|
||
'本项目吃过静默吸附的亏。开口角度是设计参数,不是误差。</div>')
|
||
|
||
P.append('<h2><span class="no">1</span>五种开口</h2>')
|
||
for i, (nm, kw, why) in enumerate(VARIANTS):
|
||
key = "K%d" % (i + 1)
|
||
body = roundel(**kw)
|
||
P.append('<div class="card"><div class="hd"><span class="nm">%s</span>'
|
||
'<span class="cx">R %g · 开口 %g°</span></div><div class="row">'
|
||
% (nm, kw["R"], kw["opening"]))
|
||
P.append('<div class="cell">%s<div class="lab">260px</div></div>'
|
||
% svg(body, 260, "%s@260" % key))
|
||
P.append('<div class="cell">%s<div class="lab">120px</div></div>' % svg(body, 120))
|
||
P.append('<div class="cell">%s<div class="lab">64px</div></div>' % svg(body, 64))
|
||
P.append('<div class="cell">%s<div class="lab">32px</div></div>'
|
||
% svg(body, 32, "%s@32" % key))
|
||
P.append('<div class="cell"><span class="tl" style="background:%s">%s</span>'
|
||
'<div class="lab">暖墨底反白</div></div>'
|
||
% (DEEP, svg(roundel(col=WHITE, **kw), 120)))
|
||
P.append('<div class="cell"><span class="tl" style="background:%s">%s</span>'
|
||
'<div class="lab">朱砂底反白</div></div>'
|
||
% (RED, svg(roundel(col=WHITE, **kw), 120)))
|
||
P.append('</div><p class="why">%s</p></div>' % why)
|
||
|
||
P.append('<h2><span class="no">2</span>与 descriptor 同排(参照图的构成)</h2>')
|
||
b2 = roundel(R=140.0, opening=70.0, gap_at=0.0)
|
||
b1 = roundel(R=140.0, opening=70.0, gap_at=40.0)
|
||
P.append('<div class="card"><div class="row" style="gap:40px">'
|
||
'<div class="cell">%s<div class="lab">开口在正上 · 环 + 标准字横排</div></div>'
|
||
'<div class="cell">%s<div class="lab">开口在右上 · descriptor 落在开口里</div></div>'
|
||
'</div></div>'
|
||
% (lockup_ring(svg(b2, 150)),
|
||
'<div style="display:flex;align-items:center;gap:14px">'
|
||
+ svg(b1, 150)
|
||
+ '<div style="text-align:left"><div style="font:600 15px/1.5 '
|
||
'\'PingFang SC\',Inter,sans-serif;color:%s">睿新致远</div>'
|
||
'<div style="font:12px/1.6 \'PingFang SC\',Inter,sans-serif;color:%s">'
|
||
'IT Architecture Consulting</div></div></div>'
|
||
% (HEAD, MUTED)))
|
||
|
||
P.append('<h2><span class="no">3</span>度量</h2>')
|
||
P.append('<table><thead><tr><th>候选</th><th class="n">最细特征@32</th>'
|
||
'<th class="n">墨率@512</th><th class="n">漂移</th>'
|
||
'<th class="n">最细@16(环缩到 16px)</th></tr></thead><tbody>')
|
||
for i, (nm, kw, why) in enumerate(VARIANTS):
|
||
key = "K%d" % (i + 1)
|
||
P.append('<tr><td><b>%s</b></td>'
|
||
'<td class="n" data-cell="%s@32@min">…</td>'
|
||
'<td class="n" data-cell="%s@260@ink">…</td>'
|
||
'<td class="n" data-cell="%s@260@drift">…</td>'
|
||
'<td class="n" data-cell="%s@32@min">…</td></tr>'
|
||
% (nm, key, key, key, key))
|
||
P.append('</tbody></table>')
|
||
P.append('<p>先说结论:<b>环在 16px 一定不成立</b> —— 七个字母挤进 16 像素,'
|
||
'每个字母不到 2 像素宽,这是几何事实,不是我没调好。'
|
||
'所以环只能当<b>主标</b>,favicon 那一档仍要另出简标。'
|
||
'这一栏我照样量,是为了把「不成立」量化,而不是靠嘴说。</p>')
|
||
|
||
P.append('<footer>生成器 <code>roundel.py</code> · 字母沿用 <code>novalon.py</code> '
|
||
'的构造几何,未改一个点(字高 %g / 笔宽 %g / 字距 %g)· '
|
||
'R 不足时断言报错,不静默压扁 · 度量为本页浏览器栅格实测 · repo 零改动</footer>'
|
||
% (nv.H, nv.T, nv.G))
|
||
P.append(JS)
|
||
P.append('</div></body></html>')
|
||
return "".join(P)
|
||
|
||
|
||
if __name__ == "__main__":
|
||
html = build()
|
||
out = os.path.join(HERE, "roundel.html")
|
||
with open(out, "w", encoding="utf-8") as f:
|
||
f.write(html)
|
||
os.makedirs(os.path.join(HERE, "assets-roundel"), exist_ok=True)
|
||
for i, (nm, kw, why) in enumerate(VARIANTS, 1):
|
||
with open(os.path.join(HERE, "assets-roundel", "K%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, roundel(**kw)))
|
||
print("roundel.html %s B / %d 方案" % (format(len(html.encode("utf-8")), ","), len(VARIANTS)))
|