MCPcopy Index your code
hub / github.com/OpenSignLabs/OpenSign / forceBreakLongWord

Function forceBreakLongWord

apps/OpenSign/src/constant/Utils.js:2020–2037  ·  view source on GitHub ↗
(word, width, font, fontSize)

Source from the content-addressed store, hash-verified

2018};
2019// Break a long word into smaller parts character-by-character
2020const forceBreakLongWord = (word, width, font, fontSize) => {
2021 const parts = [];
2022 let current = "";
2023
2024 for (const char of word) {
2025 const lineWidth = font.widthOfTextAtSize(current + char, fontSize);
2026
2027 if (lineWidth <= width) {
2028 current += char;
2029 } else {
2030 parts.push(current);
2031 current = char;
2032 }
2033 }
2034 if (current) parts.push(current);
2035
2036 return parts;
2037};
2038
2039export const isEmptyValue = (val) =>
2040 val === null ||

Callers 1

NewbreakTextIntoLinesFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected