Adjusting text leading

Hi,

Is there a way to adjust text leading (space between lines) when drawing a large chuck of text?

Thanks!

Is all of the text being displayed with 1 text statement and are you using textWrapWidth. If so I don’t think there’s a way to alter the spacing between lines.

Yes and yes. Thanks though! I’ll try and think of something…

maybe replacing every ’
’ with ’

’ using a for loop?

@Rodolphe You can always use a for loop and parse thru the text adding up each character and when it exceeds the linewidth you can “text” that line. By using individual “text” statements, you can vary the spacing of each “text” statement.

string.gsub(yourstring, ’
‘,’

') would do it as well, but again, this only matters if you want it to essentially be twice as spaced.

@Rodolphe Here’s a very simple example of altering line spacing. Slide the spacing parameter to alter the spacing. A lot of checking needs to be added so words won’t be split, but this is just a quick example.


function setup()
    parameter.integer("spacing",15,100)
    textMode(CORNER)
    str="qwer gubvyctvt yhuubvtrc ybnuji imiybyb exxewa vyyubun unubytvrv gybnuinim niunbytc rcrvtybun ybybyvtvtv tctvybniin innuyvrcrc tvh jn uubyby tv  uui iytgtv u unu  ybyyb yyvtvtv yy niinyb yy tvyb"
end    
    
function draw()
    background(0)
    str1=""
    cnt=0
    for z=1,string.len(str) do
        str1=str1..string.sub(str,z,z)
        w,h=textSize(str1)
        if w>200 then
            cnt=cnt+1
            text(str1,100,HEIGHT-cnt*spacing)
            str1=""
        end
    end
end

Ok, thanks a great start! Thanks a lot!