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 个文本/矢量件。
544 lines
35 KiB
Python
544 lines
35 KiB
Python
#!/usr/bin/env python3
|
||
# -*- coding: utf-8 -*-
|
||
"""
|
||
禁用条款(第四十八刀 · 任务 #14)
|
||
|
||
写法上的硬要求:每条规则都必须有【正例 + 反例两张真渲染的图】,
|
||
而且反例要在它自己那条判据上【真的不合格】。
|
||
否则就是"我画了个难看的图说这是错的"——那是装饰,不是条款。
|
||
|
||
所以页顶有一条双边门禁:每条量化规则都要 正例通过 且 反例失败;
|
||
任一侧不成立,那条规则标红并说明"这条没有约束力"。
|
||
不量化的条目(比如"不许加投影")就直说不量化,不假装有数。
|
||
|
||
四条已裁定/已实测的结论在这里当判据用:
|
||
· 字标最小 64px(安全)/40px(极限),40px 以下必须换简标
|
||
—— 第四十八刀更正过:旧数 160/96 是**空盒宽**不是标宽(viewBox 曾写死 460 而墨只到 255.6)。
|
||
文件头若与 R1 的实现不一致,下一个读这个文件的人会把头当合同 —— 所以两处必须同值。
|
||
· 简标白文睿 48px 是信息下限;16px 分主刻版与小刻版
|
||
· 横排只留名;号不得把基线压到名的墨底(实测中心偏低 9.82 单位)
|
||
· 号在中文锁定里字距 33.62,单独用时才用 22
|
||
· 构造标准字 fill-rule 必须 nonzero(evenodd 会在笔画重叠处挖洞)
|
||
· 马善政没有「遠」,不得用于品牌名
|
||
· 界灰 #C3BDB1 对宣纸 1.70:1,不得承担信息;深底红字 #E13C58 只剩 4.44:1,不得做正文
|
||
"""
|
||
import importlib.util
|
||
import os
|
||
|
||
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
|
||
|
||
|
||
bd = load("bd", "brand.py")
|
||
jb = load("jb", "jianbiao.py")
|
||
er = load("er", "enso-refine.py")
|
||
nv, lk = bd.nv, bd.lk
|
||
RED, INK, WHITE, PAPER = bd.RED, bd.INK, bd.WHITE, bd.PAPER
|
||
DEEP, MUTED, LINE, CARD = "#141210", "#8A8377", "#C3BDB1", "#EFEAE1"
|
||
RED_ON_DK = "#E13C58"
|
||
|
||
|
||
def wm_px(width, rule="nonzero", skew=None, stretch=None, text="NOVALON", variant="none"):
|
||
"""把标准字画成一张图,可选注入违规(非等比拉伸/斜体)。
|
||
text 默认 NOVALON;R8 那一组用 LVAN —— 见那里的注释。"""
|
||
d, w = nv.wordmark(text, INK)
|
||
import re as _re
|
||
dd = _re.search(r'd="([^"]*)"', d).group(1)
|
||
tr = ""
|
||
if stretch:
|
||
tr = ' transform="scale(%g,1)"' % stretch
|
||
if skew:
|
||
tr = ' transform="skewX(%g)"' % skew
|
||
return ('<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 %g 140" '
|
||
'style="width:%dpx;height:auto;display:block" data-probe="wm" '
|
||
'data-rule="%s" data-variant="%s"><g%s><path d="%s" fill="%s" '
|
||
'fill-rule="%s"/></g></svg>'
|
||
% (w + 20, width, rule, variant, tr, dd.strip(), INK, rule))
|
||
|
||
|
||
def seal_pair():
|
||
a = jb.seal_wen(16, face=0.78, tag="BAD_MAIN16")
|
||
b = jb.seal_wen(16, face=0.92, dg=0.5, tag="GOOD_SMALL16")
|
||
ref = jb.seal_wen(384, face=0.78, tag="REF_MAIN384")
|
||
ref2 = jb.seal_wen(384, face=0.92, dg=0.5, tag="REF_SMALL384")
|
||
return a, b, ref, ref2
|
||
|
||
|
||
def ring(prof, label):
|
||
return ('<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100" '
|
||
'width="150" height="150"><g transform="translate(50,50)">%s</g></svg>'
|
||
% er.enso(R=34.0, theta0=10.0, sweep=320.0, W=16.0, prof=prof))
|
||
|
||
|
||
CSS = """
|
||
*{box-sizing:border-box}
|
||
body{margin:0;background:#F7F4EF;color:#4F4A42;font:16px/1.9 "Songti SC",Georgia,serif;padding:36px 30px 110px}
|
||
.wrap{max-width:1200px;margin:0 auto}
|
||
h1{font-size:36px;color:#26221E;margin:8px 0 14px;line-height:1.2}
|
||
h1 em{font-style:normal;color:#C41E3A}
|
||
h2{font-size:15px;color:#26221E;margin:0 0 4px;font:650 16px/1.5 "PingFang SC",sans-serif}
|
||
.ey{font:12px/1.4 "PingFang SC",sans-serif;letter-spacing:.18em;text-transform:uppercase;color:#8A8377}
|
||
p{max-width:94ch}
|
||
.j{border-left:2px solid #C41E3A;padding:3px 0 3px 16px;margin:14px 0;color:#26221E;max-width:98ch}
|
||
.rule{background:#fff;border:1px solid #EFEAE1;padding:20px 24px;margin:0 0 14px}
|
||
.rule.bad{border-color:#C41E3A;background:#FDF6F7}
|
||
.pair{display:flex;gap:26px;flex-wrap:wrap;margin:12px 0 6px}
|
||
.cell{text-align:center;flex:0 0 auto}
|
||
.cell .box{background:#fff;border:1px dashed #C3BDB1;padding:14px 16px;min-width:120px;
|
||
display:flex;align-items:center;justify-content:center;min-height:96px}
|
||
.cell .box.dark{background:#141210;border-color:#26221E}
|
||
.lab{font:11.5px/1.6 "PingFang SC",sans-serif;color:#8A8377;margin-top:6px}
|
||
.tag{font:650 11px/1 "PingFang SC",sans-serif;padding:4px 8px;border-radius:2px;display:inline-block}
|
||
.t-good{background:#E7F2E9;color:#0f7b3b}.t-bad{background:#FBE9EC;color:#C41E3A}
|
||
.verdict{font:12.5px/1.6 "PingFang SC",sans-serif;margin-top:8px;color:#26221E}
|
||
.gate{position:sticky;top:0;z-index:9;background:#fff;border:1px solid #C3BDB1;padding:12px 16px;margin-bottom:12px}
|
||
.bad{color:#C41E3A;font-weight:700}.good{color:#0f7b3b;font-weight:700}
|
||
code{font:12.5px/1.5 ui-monospace,Menlo,monospace;background:#EFEAE1;padding:1px 5px}
|
||
footer{margin-top:48px;padding-top:16px;border-top:1px solid #C3BDB1;
|
||
font:12.5px/1.7 "PingFang SC",sans-serif;color:#8A8377}
|
||
"""
|
||
|
||
PROBE = r"""<script>
|
||
/* 复用前几刀已经验过的三件仪器:封闭白(洪水剔背景)、号的墨中心、字形墨迹指纹。
|
||
不重写几何、不重写判据 —— 只把它们接到"每条规则必须双边成立"这一件事上。 */
|
||
function isWht(p,a){return a>=40&&Math.hypot(p[0]-255,p[1]-255,p[2]-255)<110;}
|
||
function isInk(p,a){return a>=40&&Math.hypot(p[0]-255,p[1]-255,p[2]-255)>=110;}
|
||
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',{willReadFrequently:true});x.fillStyle='#fff';x.fillRect(0,0,size,size);
|
||
im.onload=()=>{try{x.drawImage(im,0,0,size,size);r(x.getImageData(0,0,size,size));}
|
||
catch(e){r(null);} };
|
||
im.onerror=()=>r(null);im.src='data:image/svg+xml;charset=utf-8,'+encodeURIComponent(s);});}
|
||
function closedWhite(im,px){const d=im.data;const w=new Uint8Array(px*px);
|
||
for(let i=0;i<px*px;i++){const j=i*4;w[i]=isWht([d[j],d[j+1],d[j+2]],d[j+3])?1:0;}
|
||
const bg=new Uint8Array(px*px),st=[];
|
||
const push=i=>{if(w[i]&&!bg[i]){bg[i]=1;st.push(i);}};
|
||
for(let x=0;x<px;x++){push(x);push((px-1)*px+x);}
|
||
for(let y=0;y<px;y++){push(y*px);push(y*px+px-1);}
|
||
while(st.length){const p=st.pop(),x=p%px,y=(p-x)/px;
|
||
for(const q of [x+1<px?p+1:p,x-1>=0?p-1:p,y+1<px?p+px:p,y-1>=0?p-px:p])
|
||
if(q!==p&&w[q]&&!bg[q]){bg[q]=1;st.push(q);}}
|
||
const seen=new Uint8Array(px*px);let comps=0,tot=0;
|
||
for(let i=0;i<px*px;i++){if(!w[i]||bg[i]||seen[i])continue;
|
||
let n=0;const s2=[i];seen[i]=1;
|
||
while(s2.length){const p=s2.pop();n++;const x=p%px,y=(p-x)/px;
|
||
for(const q of [x+1<px?p+1:p,x-1>=0?p-1:p,y+1<px?p+px:p,y-1>=0?p-px:p])
|
||
if(q!==p&&w[q]&&!bg[q]&&!seen[q]){seen[q]=1;s2.push(q);}}
|
||
comps++;tot+=n;}
|
||
return {comps:comps,white:100*tot/(px*px)};}
|
||
function holes(im,px){const d=im.data;const w=new Uint8Array(px*px);
|
||
for(let i=0;i<px*px;i++){const j=i*4;w[i]=isInk([d[j],d[j+1],d[j+2]],d[j+3])?0:1;}
|
||
const bg=new Uint8Array(px*px),st=[];
|
||
const push=i=>{if(w[i]&&!bg[i]){bg[i]=1;st.push(i);}};
|
||
for(let x=0;x<px;x++){push(x);push((px-1)*px+x);}
|
||
for(let y=0;y<px;y++){push(y*px);push(y*px+px-1);}
|
||
while(st.length){const p=st.pop(),x=p%px,y=(p-x)/px;
|
||
for(const q of [x+1<px?p+1:p,x-1>=0?p-1:p,y+1<px?p+px:p,y-1>=0?p-px:p])
|
||
if(q!==p&&w[q]&&!bg[q]){bg[q]=1;st.push(q);}}
|
||
const seen=new Uint8Array(px*px);let n=0;
|
||
for(let i=0;i<px*px;i++){if(!w[i]||bg[i]||seen[i])continue;
|
||
let c=0;const s2=[i];seen[i]=1;
|
||
while(s2.length){const p=s2.pop();c++;const x=p%px,y=(p-x)/px;
|
||
for(const q of [x+1<px?p+1:p,x-1>=0?p-1:p,y+1<px?p+px:p,y-1>=0?p-px:p])
|
||
if(q!==p&&w[q]&&!bg[q]&&!seen[q]){seen[q]=1;s2.push(q);}}
|
||
if(c>=6)n++;}
|
||
return n;}
|
||
function isRed(c){const m=(c||'').match(/\d+/g); if(!m||m.length<3)return false;
|
||
const [R,G,B]=m.map(Number); return R>140&&R-G>50&&R-B>50;}
|
||
/* 红占比按【几何】算,不按栅格:ras() 只能序列化 <svg>,
|
||
而这三格是普通 <div> —— 上一版拿 ras() 去画 HTML,Image 加载失败返回 null,
|
||
后面 .toFixed 当场抛,探针以一条零参数的 Uncaught (in promise) 死掉。
|
||
这几格的红是纯色块,几何算就是精确值,不需要"像素级"这个幌子。 */
|
||
function redPct(el){const box=el.getBoundingClientRect();
|
||
const total=box.width*box.height; if(!total)return null;
|
||
let red=0;
|
||
const self=el.getBoundingClientRect();
|
||
if(isRed(getComputedStyle(el).backgroundColor)) red+=self.width*self.height;
|
||
for(const d of el.querySelectorAll('*')){const st=getComputedStyle(d);
|
||
if(!isRed(st.backgroundColor))continue;
|
||
const r=d.getBoundingClientRect();
|
||
const w=Math.max(0,Math.min(r.right,box.right)-Math.max(r.left,box.left));
|
||
const h=Math.max(0,Math.min(r.bottom,box.bottom)-Math.max(r.top,box.top));
|
||
red+=w*h*parseFloat(st.opacity||1);}
|
||
return 100*Math.min(red,total)/total;}
|
||
function inkFp(fam,text,px){const cv=document.createElement('canvas');
|
||
cv.width=px*text.length+40;cv.height=Math.round(px*1.6);
|
||
const x=cv.getContext('2d');x.textBaseline='middle';
|
||
x.font=px+'px '+JSON.stringify(fam)+', monospace';x.fillText(text,4,px*0.8);
|
||
const d=x.getImageData(0,0,cv.width,cv.height).data;
|
||
let h=0,n=0;for(let i=3;i<d.length;i+=4){if(d[i]>16){n++;h=(h*31+d[i]+d[i-3]*3+d[i-2]*5+d[i-1]*7)|0;}}
|
||
return {hash:h,ink:n};}
|
||
(async()=>{
|
||
const R={rules:{},errs:[]};
|
||
/* R2 简标:主刻版 vs 小刻版 @16,各自与自己的 384 基准比 ⇒ 保留率 */
|
||
const sv=[...document.querySelectorAll('svg[data-seal]')];
|
||
const sm={};
|
||
for(const el of sv){const px=+el.dataset.px;const im=await ras(el,px);
|
||
if(!im){R.errs.push('seal '+el.dataset.seal+' 栅格失败');continue;}
|
||
sm[el.dataset.seal]=closedWhite(im,px);}
|
||
if(sm.BAD_MAIN16&&sm.REF_MAIN384&&sm.GOOD_SMALL16&&sm.REF_SMALL384){
|
||
const kb=100*sm.BAD_MAIN16.white/sm.REF_MAIN384.white;
|
||
const kg=100*sm.GOOD_SMALL16.white/sm.REF_SMALL384.white;
|
||
R.rules.R2={bad:+kb.toFixed(1),good:+kg.toFixed(1),
|
||
compsBad:sm.BAD_MAIN16.comps,compsGood:sm.GOOD_SMALL16.comps,
|
||
pass:(kg>kb)};}
|
||
/* R3 横排:号的墨中心 vs 名的墨中心 */
|
||
for(const el of document.querySelectorAll('svg[data-check]')){
|
||
const k=el.dataset.check;const sr=el.getBoundingClientRect();
|
||
const vb=el.getAttribute('viewBox').split(/[\s,]+/);const kk=sr.width/vb[2];
|
||
const g={};
|
||
for(const q of el.querySelectorAll('[data-g]')){const r=q.getBoundingClientRect();
|
||
if(!r.height)continue;g[q.dataset.g]=(r.top-sr.top)/kk+r.height/(2*kk);}
|
||
if(g.name&&g.wm)R.rules['R3_'+k]={off:+(g.wm-g.name).toFixed(2)};
|
||
else if(g.name)R.rules['R3_'+k]={off:0,onlyName:true};}
|
||
/* R8 fill-rule:同一份路径两种规则,数洞 */
|
||
for(const el of document.querySelectorAll('svg[data-rule]')){
|
||
const px=Math.round(el.getBoundingClientRect().width);
|
||
const im=await ras(el,px);if(!im)continue;
|
||
R.rules['R8_'+el.dataset.rule]=holes(im,px);}
|
||
/* R5 非等比拉伸:量实际渲染的字高/字宽比,与未拉伸的比 */
|
||
for(const el of document.querySelectorAll('svg[data-probe="wm"]')){
|
||
const r=el.getBoundingClientRect();
|
||
R.rules['R5_'+el.dataset.variant]={aspect:+(r.width/r.height).toFixed(3)};}
|
||
/* R9 品牌名覆盖:候选族 vs 兜底族画「遠」,相同即缺字 */
|
||
const FAMS=['Noto Serif SC Subset','Ma Shan Zheng Subset'];
|
||
for(const f of FAMS){
|
||
try{await document.fonts.load('64px '+JSON.stringify(f),'睿新致遠');}catch(e){}
|
||
await new Promise(r=>setTimeout(r,0));
|
||
const a=inkFp(f,'遠',64), b=inkFp('__no_such_font_zzz','遠',64);
|
||
R.rules['R9_'+f]={ok:(a.hash!==b.hash&&a.ink!==b.ink),ink:a.ink,fb:b.ink};}
|
||
/* R6 红色面积:整块 / 极小点 / 中等装饰条 */
|
||
for(const el of document.querySelectorAll('[data-redarea]')){
|
||
const v6=redPct(el);
|
||
R.rules['R6_'+el.dataset.redarea]=(v6===null?null:+v6.toFixed(1));}
|
||
/* 双边门禁 */
|
||
const CHECKS=[
|
||
['R2', r=>r&&r.pass, r=>'小刻版保留率 '+r.good+'% vs 主刻版 '+r.bad+'%'],
|
||
['R3_baseline', r=>r&&Math.abs(r.off)>5, r=>'反例号偏低 '+r.off+' 单位'],
|
||
['R3_center', r=>r&&Math.abs(r.off)<=1, r=>'正例偏差 '+r.off+' 单位'],
|
||
['R3_name_only', r=>!!r&&r.onlyName, ()=> '只留名,无号可偏'],
|
||
['R8_nonzero', r=>r===0, r=>'洞数 '+r],
|
||
['R8_evenodd', r=>r>0, r=>'洞数 '+r],
|
||
['R9_Noto Serif SC Subset', r=>r&&r.ok, ()=> '「遠」由本族提供'],
|
||
['R9_Ma Shan Zheng Subset', r=>r&&!r.ok, ()=> '「遠」与兜底相同 ⇒ 本族缺字'],
|
||
['R5_none', r=>!!r, r=>'基准宽高比 '+r.aspect],
|
||
['R5_stretch', r=>!!r && r.aspect>R.rules.R5_none.aspect*1.08,
|
||
r=>'拉伸后 '+r.aspect+'(基准 '+R.rules.R5_none.aspect+')'],
|
||
// 面积纪律:红只走"整块"或"极小点",中间那一档禁用。
|
||
// 中档边界取 5%–30%:低于 5% 读作点,高于 30% 读作色域,中间是"装饰带"。
|
||
['R6_block', r=>r>30, r=>'整块红占 '+r+'%(应 >30 ⇒ 读作色域)'],
|
||
['R6_dot', r=>r<5, r=>'极小点红占 '+r+'%(应 <5 ⇒ 读作点)'],
|
||
['R6_strip', r=>r>=5&&r<=30, r=>'装饰条红占 '+r+'%(落在被禁的 5–30% 中档 ⇒ 反例成立)'],
|
||
];
|
||
let fails=[];
|
||
for(const [k,fn,dump] of CHECKS){const v=R.rules[k];
|
||
/* 判"没测到"必须用 === undefined/null,不能用 !v ——
|
||
R8_nonzero 的正确读数就是 0(LVAN 在 nonzero 下零个洞),
|
||
!v 把合法的 0 当成缺失,于是门禁自己把唯一一条真达标的规则报成红。 */
|
||
if(v===undefined||v===null){fails.push(k+':没测到');continue;}
|
||
let ok=false;try{ok=!!fn(v);}catch(e){fails.push(k+':判据抛 '+e.message);continue;}
|
||
R.rules[k].verdict=ok;R.rules[k].text=dump(v);
|
||
if(!ok)fails.push(k+':'+R.rules[k].text+' ⇒ 这一侧不成立');}
|
||
const g=document.getElementById('gate');
|
||
if(g)g.innerHTML='<b>条款门禁(每条规则要求正例通过、反例失败)</b> '
|
||
+(fails.length?'<span class="bad">'+fails.length+' 项不成立:'+fails.join('; ')+'</span>'
|
||
:'<span class="good">'+CHECKS.length+' 项全部双边成立 ⇒ 下面每条反例都是"在它自己那条判据上真的不合格"</span>')
|
||
+'<br><span class="lab">'+Object.keys(R.rules).filter(k=>R.rules[k].text)
|
||
.map(k=>k+' = '+R.rules[k].text+(R.rules[k].verdict===false?' ✗':'')).join(' · ')+'</span>'
|
||
+(R.errs.length?'<br><span class="bad">'+R.errs.join(' / ')+'</span>':'');
|
||
/* 三个 verdict 占位格此前永远是「计算中…」——门禁用的是 R.rules,
|
||
没人把这些格子写回去。读者盯着未解析的占位,会以为整页没跑。
|
||
⇒ 门禁算完后逐格回填,并断言没有格子还停在占位上。 */
|
||
const OUT={'r3out':['R3_center','R3_baseline','R3_name_only'],
|
||
'r6out':['R6_block','R6_dot','R6_strip'],
|
||
'r8out':['R8_nonzero','R8_evenodd']};
|
||
let still=[];
|
||
for(const [id,keys] of Object.entries(OUT)){
|
||
const el=document.getElementById(id); if(!el) continue;
|
||
const parts=keys.map(k=>{const v=R.rules[k];
|
||
return (v&&typeof v==='object'&&v.text)?k.replace(/^R\d_/,'')+':'+v.text
|
||
:(v===undefined?'k':k.replace(/^R\d_/,'')+':'+v);});
|
||
el.innerHTML=parts.join(' · ');
|
||
if(el.textContent.indexOf('计算中')>=0) still.push(id);
|
||
}
|
||
if(still.length)R.errs.push('占位格未回填:'+still.join(',')); window.__mu={R:R,fails:fails};
|
||
})();
|
||
</script>"""
|
||
|
||
|
||
def build():
|
||
bad_main, good_small, ref_main, ref_small = seal_pair()
|
||
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="gate" id="gate">条款门禁:测量中…</div>')
|
||
P.append('<div class="ey">Cut 48 · 2026-10-14 · 任务 #14 · 每条都配真渲染的反例 · repo 零改动</div>')
|
||
P.append('<h1>禁用条款 —— <em>每条反例都在它自己那条判据上真的不合格</em></h1>')
|
||
P.append('<p>一份规范里最没用的就是"不许这样"后面跟一张凭手感画的丑图。'
|
||
'所以顶部那条门禁做的事是:对每一条量化规则,同时验'
|
||
'<b>正例通过</b>与<b>反例失败</b>;任何一侧不成立,那条规则就在门禁里被点名,'
|
||
'等于承认"这条没有约束力"。目前不量化的条目我也直说不量化。</p>')
|
||
|
||
def stack(svg_html, cap):
|
||
"""图在上、说明在下。上一版把 .lab 直接塞进 .box,
|
||
而 .box 是 align-items:center 的横向 flex ⇒ 文字压在印章上。"""
|
||
return ('<div style="display:flex;flex-direction:column;align-items:center;gap:8px">'
|
||
+ svg_html + '<div class="lab">' + cap + '</div></div>')
|
||
|
||
def rule(rid, title, body, good, badv, quant=True):
|
||
P.append('<div class="rule" id="%s"><h2>%s</h2>%s' % (rid, title, body))
|
||
if quant:
|
||
P.append('<div class="pair">')
|
||
for lab, cls, html in good + badv:
|
||
P.append('<div class="cell"><div class="box %s">%s</div>'
|
||
'<div class="lab"><span class="tag %s">%s</span></div></div>'
|
||
% (cls, html,
|
||
"t-good" if lab == "正" else "t-bad",
|
||
"正例" if lab == "正" else "反例"))
|
||
P.append('</div>')
|
||
P.append('</div>')
|
||
|
||
# R1 最小尺寸
|
||
rule("R1", "R1 · 字标最小 <b>64px</b>(安全)/<b>40px</b>(极限);40px 以下必须换简标",
|
||
'<p>判据落在<b>号的笔画像素</b>上,不落在"看起来还行"上:'
|
||
'笔画 = 14 单位 × 显示宽 ÷ 画布宽。≥3px 安全、2–3px 只可用于展示、<2px 塌。'
|
||
'算出来 64px→笔画 3.5px、40px→2.2px、32px→1.8px(塌)、24px→1.3px。'
|
||
'<b>这一条在第四十八刀被更正过</b>:此前报的是 160/96,那是<b>盒子宽</b>不是标宽 —— '
|
||
'主锁定的 viewBox 当时被写死成 460,而墨只到 255.6(浏览器 getBBox 实测,'
|
||
'右边 47.9% 是空的),所以"160px"那一档真实标宽只有 89px。'
|
||
'画布按墨收紧后同一个物理阈值落在 64/40 上:<b>规则没变,数被盒子放大了 1.8 倍</b>。'
|
||
'下面几格直接渲染标准字本身,不走那个盒子。</p>',
|
||
[("正", "", stack('<div style="width:66px">' + wm_px(64) + '</div>',
|
||
"64px · 笔画 3.5px")),
|
||
("正", "", stack('<div style="width:42px">' + wm_px(40) + '</div>',
|
||
"40px · 笔画 2.2px,极限"))],
|
||
[("反", "", stack('<div style="width:34px">' + wm_px(32) + '</div>',
|
||
"32px · 笔画 1.8px,塌")),
|
||
("反", "", stack('<div style="width:26px">' + wm_px(24) + '</div>',
|
||
"24px · 这一档归简标"))],
|
||
quant=True)
|
||
|
||
# R2 简标两副刻版
|
||
rule("R2", "R2 · ≤24px 不许用主刻版;且 16px 不承诺读得出「睿」",
|
||
'<p>白文睿的信息下限实测在 <b>48px</b> 一带。24px 以下必须换<b>小刻版</b>'
|
||
'(字面 0.92 + 减地 0.5px)。这条不是审美:16px 下主刻版的封闭白保留率 '
|
||
'<b>61.9%</b>,小刻版 <b>73.6%</b>,而两者在 384px 基准下都只有 4–5 个白连通体、'
|
||
'到 16px 都碎成 10–11 个 —— <b>栅格把字的骨架改写了</b>。'
|
||
'所以规范同时要说清:16px 那一档承载的是"朱砂方印"这个概念,不是一句可读的字。</p>',
|
||
[("正", "", stack(jb.seal_wen(48), "主刻版 48px(下限之上)")),
|
||
("正", "", stack(good_small.replace('data-k="GOOD_SMALL16"',
|
||
'data-k="GOOD_SMALL16" data-seal="GOOD_SMALL16" data-px="16"'),
|
||
"小刻版 16px"))],
|
||
[("反", "", stack(bad_main.replace('data-k="BAD_MAIN16"',
|
||
'data-k="BAD_MAIN16" data-seal="BAD_MAIN16" data-px="16"'),
|
||
"主刻版硬缩到 16px"))],
|
||
quant=True)
|
||
# 基准样张离屏,只为拿保留率的分母
|
||
P.append('<span style="position:absolute;left:-99999px;top:0">'
|
||
+ ref_main.replace('data-k="REF_MAIN384"', 'data-k="REF_MAIN384" data-seal="REF_MAIN384" data-px="384"')
|
||
+ ref_small.replace('data-k="REF_SMALL384"', 'data-k="REF_SMALL384" data-seal="REF_SMALL384" data-px="384"')
|
||
+ '</span>')
|
||
|
||
# R3 横排
|
||
body = ('<p>横排锁定<b>只走「名」</b>(已裁定)。若确有场景要名号并排,'
|
||
'号的<b>墨中心</b>必须对名的<b>墨中心</b>。'
|
||
'被禁止的是把号的名义基线压到名的实际墨底上 —— 汉字方块没有下伸部、'
|
||
'视觉重心在正中,那样排号会整体偏低 <b>9.82 单位(名高的 18.9%)</b>,'
|
||
'实测与解析同向。</p>')
|
||
sv_center, m_c = jb.inline_variant("center")
|
||
sv_base, m_b = jb.inline_variant("baseline")
|
||
sv_name, m_n = jb.inline_variant("name_only")
|
||
P.append('<div class="rule" id="R3"><h2>R3 · 横排不许把号的基线压到名的墨底</h2>' + body
|
||
+ '<div class="pair">')
|
||
for lab, cls, sv, note in [("正", "", sv_name, "只留名(裁定方案)"),
|
||
("正", "", sv_center, "名+号:墨中心对墨中心,偏差 0.00"),
|
||
("反", "", sv_base, "号墨底压名墨底:偏差 +9.82")]:
|
||
P.append('<div class="cell"><div class="box %s" style="padding:10px">%s</div>'
|
||
'<div class="lab"><span class="tag %s">%s</span><br>%s</div></div>'
|
||
% (cls, sv, "t-good" if lab == "正" else "t-bad",
|
||
"正例" if lab == "正" else "反例", note))
|
||
P.append('<div id="r3out" class="verdict">浏览器实测偏差:计算中…</div></div></div>')
|
||
|
||
# R4 字距
|
||
P.append('<div class="rule" id="R4"><h2>R4 · 号在中文锁定里字距必须 33.62,不得沿用单独用的 22</h2>'
|
||
'<p>两端对齐是靠<b>放宽字距</b>做到的:名宽 223.6 单位,号要咬住两边,'
|
||
'cap 锁在名高的 0.535 时字距必须 33.62(= 单独用时 22 的 1.53 倍)。'
|
||
'沿用 22 的话号只有 139.5 单位宽,右端差 <b>−85.47</b>,号挂不住、'
|
||
'并且和名变成同等重量抢层级。<b>这不是破例,是标志按语境做光学调整的常识。</b></p>'
|
||
'<div class="pair"><div class="cell"><div class="box">'
|
||
+ bd.lockup_stack(px=300)[0] + '</div><div class="lab"><span class="tag t-good">正例</span>'
|
||
'<br>字距 33.62 · 左差 0.00 · 右差 0.00</div></div>'
|
||
'<div class="cell"><div class="box">'
|
||
+ lk_svg_natural() + '</div><div class="lab"><span class="tag t-bad">反例</span>'
|
||
'<br>字距 22 · 右差 −85.47(号缩成一团,右边空出来)</div></div></div></div>')
|
||
|
||
# R5 变形
|
||
WMD = nv.wordmark("NOVALON", INK)[0].split('d="')[1].split('"')[0]
|
||
|
||
def cell(box_html, tag, lab, note):
|
||
cls = "t-good" if tag == "正例" else "t-bad"
|
||
return ('<div class="cell"><div class="box">' + box_html +
|
||
'</div><div class="lab"><span class="tag ' + cls + '">' + tag +
|
||
'</span><br>' + lab + '</div></div>')
|
||
|
||
outline = ('<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 740 140" '
|
||
'style="width:260px;height:auto;display:block"><path d="' + WMD +
|
||
'" fill="none" stroke="' + RED + '" stroke-width="3"/></svg>')
|
||
recolored = ('<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 740 140" '
|
||
'style="width:250px;height:auto;display:block"><path d="' + WMD +
|
||
'" fill="#1E5AA8"/></svg>')
|
||
shadowed = ('<div style="filter:drop-shadow(3px 4px 3px rgba(0,0,0,.45))">'
|
||
+ wm_px(240) + '</div>')
|
||
P.append('<div class="rule" id="R5"><h2>R5 · 不许拉伸、压扁、斜体、描边、加投影、改色相</h2>'
|
||
'<p>前两条量化得出来(量实际渲染的宽高比),后面几条我<b>不量化</b> —— '
|
||
'它们看一眼就知道,硬编一个数反而是假装有依据。</p><div class="pair">'
|
||
+ cell(wm_px(260, variant="none"), "正例", "等比 · 宽高比是基准值", "")
|
||
+ cell(wm_px(260, stretch=1.18, variant="stretch"), "反例", "横向拉伸 1.18×", "")
|
||
+ cell(outline, "反例", "描边空心(不量化)", "")
|
||
+ cell(shadowed, "反例", "加投影(不量化)", "")
|
||
+ cell(recolored, "反例", "改色相(不量化;朱砂 #C41E3A 是唯一母色)", "")
|
||
+ '</div></div>')
|
||
|
||
# R6 红色面积
|
||
P.append('<div class="rule" id="R6"><h2>R6 · 红只走「整块」或「极小点」两个尺度,禁中等面积的装饰条</h2>'
|
||
'<p>面积纪律不是"红越少越好":整块(印、色域底)和极小点(落款印、强调符)都成立,'
|
||
'中间那一档——比如一条装饰性红带——最廉价,也最容易把版面压死。'
|
||
'下面三格的红像素占比由浏览器数出来。</p><div class="pair">')
|
||
P.append('<div class="cell"><div class="box" data-redarea="block" style="background:#C41E3A;'
|
||
'color:#fff;padding:26px 30px;font:650 20px/1.4 PingFang SC,sans-serif">整块色域</div>'
|
||
'<div class="lab"><span class="tag t-good">正例</span><br>整块</div></div>')
|
||
P.append('<div class="cell"><div class="box" data-redarea="dot" style="gap:10px">'
|
||
'<span style="font:17px/1.9 Songti SC,serif;color:#26221E">睿新致遠</span>'
|
||
'<span style="width:9px;height:9px;background:#C41E3A;display:inline-block"></span></div>'
|
||
'<div class="lab"><span class="tag t-good">正例</span><br>极小点(落款位)</div></div>')
|
||
P.append('<div class="cell"><div class="box" data-redarea="strip" style="flex-direction:column;'
|
||
'gap:6px;padding:14px"><span style="width:100%;height:16px;background:#C41E3A;display:block"></span>'
|
||
'<span style="width:100%;height:16px;background:#C41E3A;display:block;opacity:.75"></span>'
|
||
'<span style="font:12px/1.5 PingFang SC,sans-serif;color:#26221E">装饰性红带</span></div>'
|
||
'<div class="lab"><span class="tag t-bad">反例</span><br>中等面积装饰条</div></div>')
|
||
P.append('</div><div class="verdict" id="r6out">红像素占比:计算中…</div></div>')
|
||
|
||
# R7 对比度
|
||
P.append('<div class="rule" id="R7"><h2>R7 · 承担信息的线/字不许用装饰色</h2>'
|
||
'<p>界灰 <code>#C3BDB1</code> 对宣纸 <code>#F7F4EF</code> 实测 '
|
||
+ ("%.2f" % bd.ratio(LINE, PAPER)) + ':1,不达非文本 3:1;'
|
||
'深底红字 <code>#E13C58</code> 对暖墨 <code>#141210</code> 只有 '
|
||
+ ("%.2f" % bd.ratio(RED_ON_DK, DEEP)) + ':1,不够正文 AA。'
|
||
'<b>处置不是把细线加深</b>,是按职责拆两色:装饰线留界灰,'
|
||
'凡承担信息的一律用弱文 <code>#8A8377</code>(对宣纸 '
|
||
+ ("%.2f" % bd.ratio(MUTED, PAPER)) + ':1,过 3:1)。'
|
||
'一刀切加深会把整套中性色的安静感毁掉。</p><div class="pair">')
|
||
P.append('<div class="cell"><div class="box" style="flex-direction:column;gap:12px;padding:18px">'
|
||
'<span style="width:100%%;border-top:2px solid %s"></span>'
|
||
'<span style="font:13px/1.6 PingFang SC,sans-serif;color:%s">'
|
||
'这条线旁边写着"必填项" —— 用弱文</span></div>'
|
||
'<div class="lab"><span class="tag t-good">正例</span><br>信息线 %s = %.2f:1</div></div>'
|
||
% (MUTED, MUTED, MUTED, bd.ratio(MUTED, PAPER)))
|
||
P.append('<div class="cell"><div class="box" style="flex-direction:column;gap:12px;padding:18px">'
|
||
'<span style="width:100%%;border-top:2px solid %s"></span>'
|
||
'<span style="font:13px/1.6 PingFang SC,sans-serif;color:%s">'
|
||
'这条线旁边写着"必填项" —— 用界灰</span></div>'
|
||
'<div class="lab"><span class="tag t-bad">反例</span><br>信息线 %s = %.2f:1,看不见</div></div>'
|
||
% (LINE, LINE, LINE, bd.ratio(LINE, PAPER)))
|
||
P.append('<div class="cell"><div class="box dark" style="flex-direction:column;gap:8px;padding:18px">'
|
||
'<span style="font:15px/1.8 Songti SC,serif;color:%s">'
|
||
'深底上的这段红字是正文长度,用来读的不是用来点缀的</span></div>'
|
||
'<div class="lab"><span class="tag t-bad">反例</span><br>%s 对 #141210 = %.2f:1 < 4.5</div></div>'
|
||
% (RED_ON_DK, RED_ON_DK, bd.ratio(RED_ON_DK, DEEP)))
|
||
P.append('</div>')
|
||
|
||
# R8 fill-rule
|
||
P.append('<div class="rule" id="R8"><h2>R8 · 构造标准字必须 <code>fill-rule="nonzero"</code></h2>'
|
||
'<p>N 是三根笔画拼的(斜笔要保 6% 减重,合不成一条折线),'
|
||
'笔画重叠区在 evenodd 下计数为偶 ⇒ <b>被挖空</b>。'
|
||
'这一条是从"甲方说 L 有点歪"追出来的,缺口只占画布 0.4–1.3%,肉眼看评审页发现不了。'
|
||
'两格洞数由浏览器数。<b>样张故意用 LVAN 而不是 NOVALON</b> —— '
|
||
'O 的字碗是合法的封闭白,混进来会让"正例洞数为 0"这条期望根本不成立。</p><div class="pair">')
|
||
# 样张用 LVAN 而不是 NOVALON:NOVALON 里有两个 O,O 的字碗本来就是【合法的封闭白】,
|
||
# 拿它当"洞"数会让正例永远不为 0 —— 上一版门禁就是这么报红的(nonzero 数到 2 个洞)。
|
||
# LVAN 四个字母全无字碗,"正例洞数必须为 0"这个期望才由构造成立。
|
||
P.append('<div class="cell"><div class="box">' + wm_px(220, "nonzero", text="LVAN") + '</div>'
|
||
'<div class="lab"><span class="tag t-good">正例</span><br>nonzero · 洞数应为 0</div></div>')
|
||
P.append('<div class="cell"><div class="box">' + wm_px(220, "evenodd", text="LVAN") + '</div>'
|
||
'<div class="lab"><span class="tag t-bad">反例</span><br>evenodd · 笔画重叠被挖空</div></div>')
|
||
P.append('</div><div class="verdict" id="r8out">洞数:计算中…</div></div>')
|
||
|
||
# R9 马善政
|
||
P.append('<div class="rule" id="R9"><h2>R9 · 马善政毛笔楷书不得用于品牌名,也不得用于任何含繁体的位置</h2>'
|
||
'<p>它<b>没有繁体「遠」,也没有「·」</b>——子集 cmap 回读与浏览器墨迹指纹两个独立仪器同向证实。'
|
||
'缺字时浏览器会静默改用兜底字族把字画出来,于是那一行看着"有字",'
|
||
'其实是两套字拼的。品牌名恰好是「睿新致遠」,这一条直接判死。</p><div class="pair">')
|
||
for fam, lab, cls in [("Noto Serif SC Subset", "正例", ""), ("Ma Shan Zheng Subset", "反例", "")]:
|
||
P.append('<div class="cell"><div class="box"><span style="font:30px/1.5 %s,serif">'
|
||
'睿新致遠 · 数字化</span></div><div class="lab">'
|
||
'<span class="tag %s">%s</span><br>%s<div data-r9="%s">检测中…</div></div></div>'
|
||
% ("'"+fam+"'", "t-good" if lab == "正" else "t-bad", lab,
|
||
"思源宋体" if "Noto" in fam else "马善政毛笔楷书", fam))
|
||
P.append('</div></div>')
|
||
|
||
# R10 一相圆
|
||
P.append('<div class="rule" id="R10"><h2>R10 · 开口环的<b>视觉</b>开口不得 > 55°,且尾端不许收到尖</h2>'
|
||
'<p>读作「圆」还是「字母 C/加载号」,取决于<b>被感知</b>的开口,不是几何缺口。'
|
||
'尾端一旦收到尖,那段几乎不占面积,几何缺口会被视觉撑大。'
|
||
'这条的数来自 <code>enso-fork.html</code> 那一批实测(E0 = 39°,'
|
||
'出锋端头 46°,出锋+钝起笔 48°,侧锋 101°),'
|
||
'<b>本页不复算</b> —— 只把两种端头摆在一起给你看差别。'
|
||
'另:一相圆在纯字标方案里已退到辅助图形位,能不能单独出现另有规则待定。</p>'
|
||
'<div class="pair">'
|
||
'<div class="cell"><div class="box">' + ring(er.BRUSH, "正") + '</div>'
|
||
'<div class="lab"><span class="tag t-good">正例</span><br>笔势收笔 · 视觉开口 39°</div></div>'
|
||
'<div class="cell"><div class="box">' + ring([(0.0, 1.0), (0.72, 0.62), (1.0, 0.035)], "反") + '</div>'
|
||
'<div class="lab"><span class="tag t-bad">反例</span><br>尾端收到尖 · 读作 C/加载号</div></div>'
|
||
'</div></div>')
|
||
|
||
# R11 不量化的
|
||
P.append('<div class="rule" id="R11"><h2>R11 · 其余不量化但同样禁止的</h2>'
|
||
'<p>① 不许把简标当主标识用(它是"印",不是"标");'
|
||
'② 不许在号里加字重变化或字距渐变(构造几何的前提是等宽等距);'
|
||
'③ 不许把「睿新致遠」写成简体「睿新致远」——品牌名用繁体是刻意的,'
|
||
'与公司注册名「睿新致远科技有限公司」并存但不可互换;'
|
||
'④ 不许给标识配任何图形符号(方案一已裁定:纯字标,无符号);'
|
||
'⑤ 不许用外部字体 CDN,一切字体本地自托管。</p></div>')
|
||
|
||
P.append('<footer>生成器 <code>misuse.py</code> · 复用 <code>brand.py</code> / '
|
||
'<code>lockup.py</code> / <code>novalon.py</code> / <code>jianbiao.py</code> / '
|
||
'<code>enso-refine.py</code> 的真实构造,未重画任何几何 · '
|
||
'洞数、保留率、墨中心偏差、红像素占比、字形墨迹指纹均由本页浏览器实测 · '
|
||
'对比度由 <code>brand.ratio()</code> 现算 · repo 零改动</footer>')
|
||
# 字体走本地子集文件(与 font-zh.html 同一批产物)。
|
||
# 上一稿这里写的是 <link href="fonts.googleapis.com/css2"> —— 那一页自己就违反了 R11⑤
|
||
# 「不许用外部字体 CDN」,规范页带头破规,比不写更糟。
|
||
P.append('<style>'
|
||
'@font-face{font-family:"Noto Serif SC Subset";'
|
||
"src:url('fonts/notoserifsc-subset.woff2') format('woff2');font-weight:200 900}"
|
||
'@font-face{font-family:"Ma Shan Zheng Subset";'
|
||
"src:url('fonts/mashanzheng-subset.woff2') format('woff2');font-weight:400}"
|
||
'</style>')
|
||
P.append(PROBE)
|
||
P.append('</div></body></html>')
|
||
return "".join(P)
|
||
|
||
|
||
def lk_svg_natural(px=300):
|
||
"""反例:号沿用单独用的字距 22,两端对不齐。"""
|
||
body, nl, nr, nh = lk.name_row(bd.LX, 44.0, bd.NAME_H, INK)
|
||
frag, ml, mr, ch = lk.wm_at(bd.LX, bd.YTOP, bd.WM_CAP, INK, nv.G)
|
||
W = max(nr, mr) + bd.LX
|
||
H = max(44.0 + nh / 2.0, bd.YTOP + ch) + 14.0
|
||
return ('<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 %g %g" '
|
||
'style="width:%dpx;height:auto;display:block">%s%s</svg>' % (W, H, px, body, frag))
|
||
|
||
|
||
if __name__ == "__main__":
|
||
html = build()
|
||
with open(os.path.join(HERE, "misuse.html"), "w", encoding="utf-8") as f:
|
||
f.write(html)
|
||
print("misuse.html %s B" % format(len(html.encode("utf-8")), ","))
|