Reserve serif glyph width inside vertical title slots
studio CI and deployment / verify-and-deploy (pull_request) Successful in 7m16s
studio CI and deployment / verify-and-deploy (pull_request) Successful in 7m16s
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user