when to apply paragraphBottomSpacing



  • I tried to use paragraphBottomSpacing and was hoping that drawbot would interpret \n as still the same paragraph and only apply the extra white space once I use a \r.

    So there should only be extra white space after the line 'with new lines' but not after the other newlines.

    txt = 'Some Text\nwith new lines\rIs a return\na new line\ror a new paragraph?'
    fstr = FormattedString(txt, paragraphBottomSpacing=3)
    newPage(150, 150)
    text(fstr, (20, 110))
    

    asdtasdt.png

    hope that makes sense, thanks


  • admin

    I guess this is a coreText thing. When composing the same text with hard returns and soft returns (shift + enter) in TextEdit, there is no difference between soft and hard returns.

    97bc7514-5ad3-49a9-a954-a2362b5dd714-image.png

    I guess you'll need to script it and change the the bottom spacing for text-runs with soft returns.



  • oké
    I had some small hope but thanks for testing and clarifying!

    not very elegant but kind of working:

    txt = 'Some Text\nwith new lines\rIs a return\na new line\ror a new paragraph?'
    
    paras = [[l + '\n' for l in p.split('\n')] for p in txt.split('\r')]
    
    newPage(150, 150)
    
    fstr = FormattedString()
    for para in paras:
        for l in para:
            extra_space = 5 if l == para[-1] else 0
            fstr.append(l, paragraphBottomSpacing = extra_space)
    text(fstr, (20, 110))
    
    

    Screenshot 2023-03-17 at 10.42.24.png


Log in to reply