Reserve serif glyph width inside vertical title slots
studio CI and deployment / verify-and-deploy (pull_request) Successful in 7m16s

This commit is contained in:
2026-10-28 18:33:43 +08:00
parent c6037664e1
commit 2e5fa40c19
2 changed files with 5 additions and 2 deletions
+1 -1
View File
@@ -41,7 +41,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:/[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)*.88);
if(slot.direction==='vertical')return Math.min(w*.75,h/Math.max(1,Array.from(text.replaceAll('\n','')).length)*.88);
if(slot.direction==='rotated')return Math.min(w*.85,h/Math.max(1,length(text)));
if(slot.direction==='curved')return Math.min(2.2,Math.max(w,h)*1.1/Math.max(1,length(text)));
const fitted=Math.min(h/(lines.length*1.15),w/Math.max(1,...lines.map(length)))*.92;