Text in Blocks



  • Hi everybody,

    Is there a simple way to align text justified in blocks form like this :
    text text text text text text text text 
    text text text text text text text text 
    text text text text text text text text 
    text text text text text text text text 
    To avoid to have text displayed like this :
    text text text text text text text text 
    text text text text text text 
    text text text text text text text text text text
    text text text text.
    Thanx.
    Matt 

  • Tech Staff

    Format the text with linebreaks after X words.

    How is the text being generated?


  • Pass it to the input of a JS Actor containing the following... should work...
    function main() {
      var result = '';
      while (arguments[0].length > 0) {
        result += str.substring(0, 200) + '\n';
        str = str.substring(200);
      }
      return result;
    }


  • Oops... correction...

    ----------
    function main() {
      var result = '', str = arguments[0];
      while (str.length > 0) {
        result += str.substring(0, 200) + '\n';
        str = str.substring(200);
      }
      return result;
    }


  • Hi @DusX ,

    The text is generated with a text draw.
    When you say "Format the text with linebreaks after X words."  Do you mean that I can do that with an Isadora object?
    The "bounds width" entry in the TextDraw object produce almost what I want but not if I copy and paste a block of text in it.
    In the meantime, I'll try @Marci 's Java solution.
    Thanx a lot to you both for your answer.
    Cheers.

  • Tech Staff

    I was meaning how is the test entered. Are you manually writing the text, loading it from a tcp-ip request, is it entered once and never again changed etc..

    If its very dynamic a Javascript solution would be the best option I think.
    If you are entering it once. You are probably best to manually format it.
    Using the 'bounds width' does give you are control over wrapping, which will make for nice columns if all entries are the same length.


  • Is there a way to output the text that you have generated and formatted? perhaps as a txt file or something similar?


  • Tech Staff

    Only way I can think of would be via a HTTP call (post)

    You could send the text as a string... and process the request via a server script.


  • Thanx for answering.

    I finally manually did it.
    The two solutions of @DusX look very nice but a bit out of my skills...
    Best.

Log in to reply
 

Looks like your connection to TroikaTronix Community Forum was lost, please wait while we try to reconnect.