Tracking for txt variable doest'n work



  • Hi,

    I started to write a Drawbot script to build automatic proofing files for my fonts.

    I would like to change the tracking of a textBox, but there is a problem.
    When I use a variable as txt, tracking doesn't work (example bellow)

    textBox(FormattedString(txt=Text_sample, fontSize=50, tracking=200, font='Helvetica'), (10, 10, 400, 400)
    

    But If I replace the variable Text_sample by a real text with '', it's work.

    textBox(FormattedString(txt='Test', fontSize=50, tracking=200, font='Helvetica'), (10, 10, 400, 400)
    

    How can I apply tracking to a textBox ?
    Or If it's not possible does it exist an alternative ?

    Thanks !



  • Is this something that would work for you?

    newPage('A4Landscape')
    BORDER = 20
    Text_sample = 'ABCDEFGI'
    t = FormattedString()
    t.font('Helvetica')
    t.fontSize(18)
    t.lineHeight(32)
    t.tracking(100)
    t.append(Text_sample)
    textBox(t, (BORDER, BORDER, width()-BORDER*2, height()-BORDER*2))
    

    Screen Shot 2021-05-04 at 13.32.06.png


  • admin

    Could you elaborate what is not working?

    Tracking can be added to formattedString during init or as with the t.tracking(value) method.

    Text_sample = "Test"
    
    textBox(
        FormattedString(
            txt=Text_sample, 
            fontSize=50, 
            tracking=200, 
            font='Helvetica'
        ), 
        (10, 10, 400, 400)
    )
    
    textBox(
        FormattedString(
            txt='Test', 
            fontSize=50, 
            tracking=200, 
            font='Helvetica'
        ), 
        (10, 300, 400, 400)
    )
    

    c47c1404-d185-41e0-82c6-a8e691539b43-image.png



  • Thanks for your help!
    I don't know what was wrong in my code, but if yours everything is working !


Log in to reply