Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

large text #961

Open
ahmedhango opened this issue Oct 26, 2024 · 2 comments
Open

large text #961

ahmedhango opened this issue Oct 26, 2024 · 2 comments

Comments

@ahmedhango
Copy link

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?
Screenshot 2024-10-26 at 1 57 58 PM

@guhungry
Copy link
Owner

This feature is not implemented yet.
So it has to be estimated on react native side and send scaled values or added line break then send to library

@ansarikhurshid786
Copy link
Contributor

@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));

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants