Fit native uppercase headings within their editorial text blocks
studio CI and deployment / verify-and-deploy (push) Successful in 4m34s

This commit is contained in:
2026-10-27 17:01:28 +08:00
parent 513598cf86
commit c423accb59
+1 -1
View File
@@ -24,7 +24,7 @@ export function slotPosition(layout:Layout,slot:Slot):CSSProperties {
}
export function textSize(layout:Layout,slot:Slot,text:string):number {
const [, ,w,h]=slot.box,lines=text.split('\n');
const length=(s:string)=>Array.from(s).reduce((n,c)=>n+(/[\u3400-\u9fff]/.test(c)?1:.56),0);
const length=(s:string)=>Array.from(s).reduce((n,c)=>n+(/[\u3400-\u9fff]/.test(c)?1:/[A-Z]/.test(c)?.8:.6),0);
if(slot.direction==='vertical')return Math.min(w*.9,h/Math.max(1,Array.from(text.replaceAll('\n','')).length)*.95);
if(slot.direction==='rotated')return Math.min(w*.85,h/Math.max(1,length(text)));
if(slot.direction==='curved')return Math.min(2.2,w/Math.max(1,length(text)));