bug with text truncation (simulator, Android, macOS)

Hi,
I have an oddity … my text is sometimes getting truncated.
This happens on the simulator, Android, and (infrequently) on macOS.
(It has not happened yet on HTML5.)

The problem sometimes moves/appears/disappears if I add other text to
the app (unclear if it’s just text being displayed or…)

I recreated the problem with a tiny 125 line source, available (project, apk, and source) at:

The universe being perverse, this small subset of my app isn’t showing truncated text on Android (sigh), just on the simulator. But, I first noticed this when I saw truncated text in my app, so it’s a real problem (not just a simulator problem).

My text display is built via:

t_comment = display.newText (“explain_drill msg”, x, y, native.systemFont, 40)
t_comment.anchorX = 0
t_comment.anchorY = 0

Later, depending upon where you click, I fill in the t_comment.text field with a message of 3 to 5 lines of text:

t_comment.longdesc = drills [drill_num]

If I also do:

print (“text = '” .. drills [drill_num] .. “'”)

I see the correct untruncated text on the debugging console. The truncation in the sample is the line of dashes disappearing in three out of the five text messages. (In the real app, in addition to truncation, the text is sometimes folded (newline injected) needlessly in the middle, in addition to truncation.)

In one test case, if I make the text longer, the truncation disappears! (See comment in source.)

There are no objects on the screen that could collide with the text.
If I remove “width=”, “height=”, and “scale=” from config.lua, the problem still occurs.
My build.settings has nothing controlling the display other than specifying portrait orientation.

thanks,
Stan

1 Like

For multi-line text, you need to specify width and height when using display.newText(). Here is the example from documentation:

If you take a look at the Syntax, you will see detailed descriptions for width and height.

1 Like

I tried out your code, but I can’t see any truncation occurring. Looking at your code, I don’t see any reason why there would be truncation happening to begin with.


Just to be clear, when you mention truncation, are you referring to 1) string being cut shorter and three dots being added to the end of it ("..."), or 2) the text not being fully rendered?

If the issue is with the text not being fully rendered, then you’re probably creating multi-line text objects that @bgmadclown was referring to already. If you use display.newText function and you define width property, then the text will get automatic line breaks. If you also define height, then any text going beyond the maximum allowed height would get cut off (not rendered).

The final line (all dashes in the example file) was not showing up in 60% of the tests.

However, as you pointed it, it’s likely the multi-line problem. thanks!

Hi,

I suspect you’re right. I’ll give that a try, thanks.