fully justified text ?


    Jun 13 2012 | 1:45 pm
    I'm looking for a way to display fully justified text (flush left and right) in Max / Jitter.
    ideally, I would want to display my text with gl objects (jit.gl.text2D / 3D) , but any solution to display justified text in Max (LCD, jit.lcd, jit.Mgraphic, JSUI, …) would be really helpful.
    in fact, I'm very surprised by the lack of solution, documentation & post about it ; any decent text editor or any software that can produce image containing text can do that very easily. Programming full text justification in Max would really be a pain ; you'll need to know the width of each char depending of font style & size, and adjust "tracking" (intra-character spacing) accordingly, to fill a "page" width...
    I can't believe that everybody who needs to display dynamic text in a Max / Jitter installation is content with only left/center/right text aligned…
    any thought ?
    many thanks in advance...
    Mathieu

    • Jun 18 2012 | 12:55 pm
      Come on list, I can't be the only text alignment maniac here !
      does anybody have any tips on how to produce fully justified text in Jitter ?
    • Jun 18 2012 | 1:41 pm
      Maybe using Syphon and another external program?
    • Jun 18 2012 | 8:16 pm
      I also thought there was some simple way to do this, but if Mathieu cries for help, this is hopeless for me !
    • Jun 19 2012 | 1:06 pm
      Thanks for the advice, Alersito
      but I don't think that syphon is an option for what I want to do ; all my text are stored / generated in Max, and I would need to generate several blocks of justified text at once, in real time. Using Syphon + another software would imply sending my raw text via OSC to another software that would render my texts to texture -> send back to max (on several syphon channels ?) ... I've checked the list of syphon-enabled softs, I can see only 2 candidates that *may* be able to make justified text : Quartz Composer & Processing But I would then have to dig into one of these tools to do what I need... !! that sounds a bit complicated to simply align a couple of words !!
      I'm still thinking that there's something missing in Max/Jitter about text layout... isn't it ? or am I missing something obvious that would let me display nice texts in Jitter ?
      (and I'm just talking of simply text justification... I dare not even dream of things like that : http://www.google.fr/search?q=text+layout&hl=fr&prmd=imvns&source=lnms&tbm=isch&sa=X&ei=wHfgT4PbCcqt8gPRvpWVDw&ved=0CFEQ_AUoAQ&biw=1280&bih=888 )
      Mathieu
    • Jun 19 2012 | 6:52 pm
      A good full justification is a few steps harder than left/right/centered. I did all of these as a CS undergrad, working with monospace text (it was the 80s, so that's all had on the university terminal pool:-) and getting a reasonable full justification was something not everybody got "right". So l/r/c tends to get implemented by more basic text tools, and justification tends to be in the domain of more "advanced" tools.
      You could conceivably roll your own. There's a thread I started about a half-year ago that produced a combination of JavaScript and Jitter to calculate the width required by an arbitrary jit.gl.text2d string. So you could create a text2d for each word, calculate the widths (and requisite inter-word spacing) and position the objects to suit your desires.
      It ain't a rose garden, but might get you through the night. Let me know if I should try to dig up that JScript.
    • Jun 22 2012 | 2:26 pm
      Hi Peter, thanks for replying. I couldn't find the thread you're talking about. but I'm sure your js / patch would be helpful :-) could you post a link, please ?
      exploring the new features of Max6, I've just discovered that jit.mgraphics has a very useful "text_measure" function, that could be a good starting point as well :
      maybe it would be easier (at least in my case) to render the text with jit.mgraphics and display it as a texture in my gl context..
      I'll give it a try.
      Mathieu
    • Jun 22 2012 | 4:41 pm
      Salut Mathieu,
      This is the thread in question: Using jit.submatrix in Javascript. Basically it was a Javascript that set up a jit.gl.text2d and a jit.render, rendered to a jit.matrix, then used jit.findbounds to get the bounds. It took one or two attempts plus some help from others to get it working for what I needed, which was simpler than fully justified text.
      Using jit.mgraphics.text_measure() is probably more elegant. It might have better performance, too (jit.gl.text2d and text3d both ate up a lot of CPU).
    • May 29 2013 | 9:00 pm
      hi,
      waking this thread again, as I have the same needs...
      Mathieu, did your come up with a satisfying solution ? And if so, would you share it ? :)
      In case this is useful to anyone, Max6 has a "bounds" attribute to most jitter object (including jit.text3d) that ease (both man and CPU wise) a little bit the task, compared to jit.findbounds !
      But if there exist any ready-made solution, I'd be glad not to re-invent the wheel.
      C74 fellows ? Any advice / promise on this topic ?