Shrink text to fit in Text Display Object (in Matrix (Frame))

I have a Text Display Object in a Matrix Frame.

Some of the text overflows the text display object space in the Matrix.

I’ve tried checking “expand/shrink” and “auto scale” but neither has forced overlfowing text to shrink in the Matrix and fit all the text in the Matrix cell.

Expand/shrink only works when printing.

Auto scale does not work in a matrix, only as a standalone object.

Bottom line, what you are trying to do is not possible in Panorama X.

Just to confirm: There is no way to have overflowing text in matrix cells automatically shrink.

Is there a way to programmatically get functionally the same behavior by using a formula to switch to a smaller font. (If a text display object, in a matrix frame, can have a formula that affects how the matrix displays the text display object; I imagine it can’t.)

For example, if the resulting string is X characters long, then switch to 11point font, instead of 14pt font. (However, I would imagine formulas in a text display object aren’t evaluated over each matrix cell iteration.)

If the TDO is set for RichText it can display a formula producing RichText, which could calculate the number of characters displayed and adjust color/style/content/font/fontsize/alignment output bases on that and other calculations. Can be as complex as you want and are able to write it. Predicting how exactly many characters of what kind of text is not simple, in a general case, with proportional fonts. If the possible text is limited to a few strings fontsize to be fit can be worked out experimentally. To get the formula to update when desired well placed use of showvariables and/or ignore() may help.

Thanks for this. It took a lot of experimenting but I think I got a pretty decent result using the formula below in the Text Display Object sitting inside the matrix frame. Turns out, the formula does indeed seem to evaluate for each Matrix cell iteration. The text is set to a particular size if the string length is between two values. I will probably eventually try to use the measuretext( function for similar, and maybe more predictable, functionality.

Here is the formula:

?(between(length(info(“matrixcelldata”)),0,20)=-1,‘size:15’+info(“matrixcelldata”),“”)+
?(between(length(info(“matrixcelldata”)),21,22)=-1,‘size:14’+info(“matrixcelldata”),“”)+
?(between(length(info(“matrixcelldata”)),23,23)=-1,‘size:13.5’+info(“matrixcelldata”),“”)+
?(between(length(info(“matrixcelldata”)),24,25)=-1,‘size:12.5’+info(“matrixcelldata”),“”)+
?(between(length(info(“matrixcelldata”)),26,28)=-1,‘size:11.7’+info(“matrixcelldata”),“”)+
?(between(length(info(“matrixcelldata”)),29,30)=-1,‘size:11’+info(“matrixcelldata”),“”)+
?(between(length(info(“matrixcelldata”)),31,32)=-1,‘size:9.6’+info(“matrixcelldata”),“”)+
?(between(length(info(“matrixcelldata”)),33,60)=-1,‘size:9.4’+info(“matrixcelldata”),“”)
//+" “+h(measuretext(info(“matrixcelldata”),”#SystemFont",13))
//+" "+length(info(“matrixcelldata”))

I think you can make this formula a lot simpler. I haven’t actually tested this, but I did verify that the syntax is correct.

ignore("",
    cache(length(info(“matrixcelldata”)),"tlen"),
    cache(
        ?(tlen<=20,15,
            tlen<=22,14,
            tlen<=23,13.5,
            tlen<=25,12.5,
            tlen<=28,11.7,
            tlen<=30,11,
            tlen<=32,9.6,
            9.4)
        ,"tsize")
)+
"<size:"+str(tsize)+">"+info("matrixcelldata")

In addition to being easier to understand and modify, this should also be faster, because it only calculates the length of the text once instead of 8 times. This may not matter in this version, but I think it might be an important difference if you change to using the measure text( function, which might take quite a bit more time than just counting characters.

To explain further, this formula uses the cache( function to create two temporary variables, tlen and tsize. First the number of characters is calculated, by using a variable we eliminate the need to do this over and over.

Then the number of characters is converted into the text height. This formula takes advantage of the fact that the ?( function can have an unlimited number of if-else pairs. This is much simpler to set up and eliminates the need for the between( function.

The ignore( function allows the variables to be calculated without modifying the final result.

Of course the indentation is not necessary, I just did that to make it more readable.