a few standard externals (textbutton, tab, etc….) feature a text truncation attribute that allows the user to truncate text that does not fit in the object box. Usually the truncation options are to truncate from the right, from the left or from the middle of the word or sentence.
I love Max/MSP
I love M… [truncate from the right]
I lo…/MSP [truncate from the middle]
…Max/MSP [truncate from the left]
I haven’t found any such feature built in the JGraphics API nor in textfield or textlayout, with the only exception of a TEXT_JUSTIFICATION_USEELLIPSIS flag which just allows truncation from the right.
I am wondering if there are other techniques or other not documented flags that allow to easily implement the above mentioned behavior.
Thank you for any help.
TEXT_JUSTIFICATION_USEELLIPSIS is the only one available. textbutton and tab have custom hand made truncation (just a few text measurement and string manipulation).
Ah, I see…
Would it be possible to post a brief code snippet to show how it’s done?
AFAIR it’s just something which uses
jfont_text_measure() and reduce the number of characters in a while loop.
do jfont_text_measure(jf, getyourtext(), &w, &h); while ( w > thewidthyouhave && --sizeofthetext > 1)
getyourtext() just insert the … in the middle or at then end depending on the mode.
C74 RSS Feed | © Copyright Cycling '74