MCPcopy Index your code
hub / github.com/SuperMap/iClient-JavaScript / estimateLength

Function estimateLength

libs/echarts/echarts.simple.js:7939–7947  ·  view source on GitHub ↗
(text, contentWidth, ascCharWidth, cnCharWidth)

Source from the content-addressed store, hash-verified

7937}
7938
7939function estimateLength(text, contentWidth, ascCharWidth, cnCharWidth) {
7940 var width = 0;
7941 var i = 0;
7942 for (var len = text.length; i < len && width < contentWidth; i++) {
7943 var charCode = text.charCodeAt(i);
7944 width += (0 <= charCode && charCode <= 127) ? ascCharWidth : cnCharWidth;
7945 }
7946 return i;
7947}
7948
7949/**
7950 * @public

Callers 1

truncateSingleLineFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected