MCPcopy Index your code
hub / github.com/microsoft/SandDance / widthGetter

Function widthGetter

docs/app/js/sanddance-app.js:122885–122895  ·  view source on GitHub ↗
(item)

Source from the content-addressed store, hash-verified

122883 return item.limit > 0 && text5.length ? truncate(item, text5) : text5;
122884}
122885function widthGetter(item) {
122886 if (textMetrics.width === measureWidth) {
122887 // we are using canvas
122888 const currentFont = font(item);
122889 return (text6)=>_measureWidth(text6, currentFont);
122890 } else {
122891 // we are relying on estimates
122892 const currentFontHeight = fontSize(item);
122893 return (text7)=>_estimateWidth(text7, currentFontHeight);
122894 }
122895}
122896function truncate(item, text8) {
122897 var limit = +item.limit, width = widthGetter(item);
122898 if (width(text8) < limit) return text8;

Callers 1

truncateFunction · 0.70

Calls 4

fontFunction · 0.70
_measureWidthFunction · 0.70
fontSizeFunction · 0.70
_estimateWidthFunction · 0.70

Tested by

no test coverage detected