fix(studio): fit default text to production font metrics

This commit is contained in:
2026-11-01 04:44:43 +08:00
parent b76642e06d
commit 34fa403a5d
2 changed files with 17 additions and 2 deletions
+12
View File
@@ -17,3 +17,15 @@ test('geometric templates retain their distinct silhouettes without bitmap masks
});
test('element IDs work on HTTP origins without secure-context randomUUID',()=>{const saved=Object.getOwnPropertyDescriptor(globalThis,'crypto');let calls=0;Object.defineProperty(globalThis,'crypto',{configurable:true,value:{getRandomValues(array){for(let i=0;i<array.length;i++)array[i]=++calls;return array}}});try{const first=newElementId(),second=newElementId();assert.match(first,/^user-[a-f0-9]{32}$/);assert.notEqual(first,second)}finally{Object.defineProperty(globalThis,'crypto',saved)}});
// Measured by ces-control Chromium/Noto in production run 660, at 860px art width.
// These glyph bounds exceed CSS line-height, including single-letter title slots.
test('default copy leaves room for production fallback glyph bounds',()=>{
const cases=[['ref-07','T02',97/73.7143],['ref-08','T01',112/85.2389],['ref-19','T01',287/217.055],['ref-19','T02',298/225.274],['ref-19','T03',313/237.451],['ref-19','T04',306/231.363],['ref-21','T01',195/160.307]];
for(const [id,slotId,glyphExtent] of cases){
const layout=layouts.find(l=>l.id===id),slot=layout.elements.find(s=>s.id===slotId);
const size=textSize(layout,slot,defaultText(layout,slot))*860/layout.width;
const crossAxis=slot.direction==='rotated'?slot.box[2]:slot.box[3];
assert.ok(Math.ceil(size*glyphExtent)<=crossAxis*860/layout.width+2,`${id}/${slotId}: fallback glyphs must fit`);
}
});