You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello,
When I type text with a large font, the text goes outside the image, whether it's left-to-right (LTR) or right-to-left (RTL). How can I manage the text so that, if it's too big, it doesn't go to the next line? Also, how can I center the text?
The text was updated successfully, but these errors were encountered:
@ahmedhango you can split text depend on area of image you have(width of image).
function splitText(text, maxWidth) {
const words = text.split(" ");
const lines = [];
let currentLine = "";
words.forEach((word) => {
if ((currentLine + word).length <= maxWidth) {
currentLine += word + " ";
} else {
lines.push(currentLine.trim());
currentLine = word + " ";
}
});
if (currentLine) {
lines.push(currentLine.trim());
}
return lines;
}
// Example usage
const text = "This is a sample text that we want to split based on the maximum width.";
const maxWidth = 20;
console.log(splitText(text, maxWidth));
Hello,
When I type text with a large font, the text goes outside the image, whether it's left-to-right (LTR) or right-to-left (RTL). How can I manage the text so that, if it's too big, it doesn't go to the next line? Also, how can I center the text?
The text was updated successfully, but these errors were encountered: