Is it possible to get the text and/or character count that is actually rendered with display.newText?

When the text exceeds the max texture size, it nicely trims it. Is there a way to get the text that was actually shown? I’m trying to easily break up text when it isn’t rendered, but the .text value of the object is the same as what it was provided upon creation, even though it isn’t the text displayed.

Any help from the Corona Staff would be much appreciated :slight_smile:

Edit: To clarify, say I pass the text ’ This is a test’ to create a display.newText object. If this was to exceed the max texture size of the device, it wouldn’t render it all. Say it trimmed it to ’ This is a’ instead. The .text property of the object would still return ’ This is a test’ even though the text rendered is ’ This is a’. I want to know if there is a way to get the text that is actually rendered, for example obj.renderedText 

Hi,

Can you specify more clear, exactly what your problem?

So far when it comes to count the number of char in a string or text we have:

[lua]

local _, count = string.gsub(argv, " %-%-", “”)

print(count)

–Not recommended for big files because the function saves the input to the _ variable, and will hold onto the memory until the variable is destroyed.

[/lua]

-Assif Riyazuddin

Hey, so pretty much say I pass the text ‘This is a test’ to create a display.newText object. If this was to exceed the max texture size of the device, it wouldn’t render it all. Say it trimmed it to 'This is a ’ instead. The .text property of the object would still return ‘This is a test’ even though the text rendered is 'This is a '. I want to know if there is a way to get the text that is actually rendered.

I’m not sure I follow. If you exceed the max texture size, it doesn’t render. There is no trimmed text to return.

We have a tutorial on managing large blocks of text:  https://docs.coronalabs.com/tutorial/system/textBlocks/index.html

You need to recognize when you have the potential for your text to exceed texture limits and proactively break your text down and generate multiple text objects.

Rob

Hey Rob,

No worries, I’ve had a look at the tutorial in the past, but am showing user generated text so don’t want to rely on it having line breaks. I currently render the text line by line if it exceeds the max texture size, but what I wanted to know is if it is possible to get the text actually rendered via the display object?

As I said, if it exceeds the texture limit, it won’t render. So there is no partial string to return.

i think this will help:

https://forums.coronalabs.com/topic/55926-working-with-large-blocks-of-text/

i’m using a code around this post, and never let me down.

Hi,

Can you specify more clear, exactly what your problem?

So far when it comes to count the number of char in a string or text we have:

[lua]

local _, count = string.gsub(argv, " %-%-", “”)

print(count)

–Not recommended for big files because the function saves the input to the _ variable, and will hold onto the memory until the variable is destroyed.

[/lua]

-Assif Riyazuddin

Hey, so pretty much say I pass the text ‘This is a test’ to create a display.newText object. If this was to exceed the max texture size of the device, it wouldn’t render it all. Say it trimmed it to 'This is a ’ instead. The .text property of the object would still return ‘This is a test’ even though the text rendered is 'This is a '. I want to know if there is a way to get the text that is actually rendered.

I’m not sure I follow. If you exceed the max texture size, it doesn’t render. There is no trimmed text to return.

We have a tutorial on managing large blocks of text:  https://docs.coronalabs.com/tutorial/system/textBlocks/index.html

You need to recognize when you have the potential for your text to exceed texture limits and proactively break your text down and generate multiple text objects.

Rob

Hey Rob,

No worries, I’ve had a look at the tutorial in the past, but am showing user generated text so don’t want to rely on it having line breaks. I currently render the text line by line if it exceeds the max texture size, but what I wanted to know is if it is possible to get the text actually rendered via the display object?

As I said, if it exceeds the texture limit, it won’t render. So there is no partial string to return.

i think this will help:

https://forums.coronalabs.com/topic/55926-working-with-large-blocks-of-text/

i’m using a code around this post, and never let me down.