Graphics

 View Only
  • 1.  Text boxes

    Posted 12-27-2011 16:59
    There is any way I can set a fixed width to a text object so the inserted text will be wrapped and will flow on height without altering font size and dimensions?


  • 2.  RE: Text boxes

    Posted 12-30-2011 10:33
    Yes, by script editor...

    If needed, I can provide it to you...

    #XPression


  • 3.  RE: Text boxes

    Posted 01-23-2012 17:34
    Could you send that script to me as well? Thanks.

    #XPression


  • 4.  RE: Text boxes

    Posted 01-23-2012 19:09
    Unfortunately this is, at the moment, only possible when using scripting or the API.

    I've send an email to the lead-developper of XPression a few weeks back requesting the option to do this through XPression, i.e. without using scripting/API, so I have faith it will be added in the future (just like many other extensions I asked for in the past).

    #XPression


  • 5.  RE: Text boxes

    Posted 01-24-2012 07:51
    In settext of you're textobject :

    Dim newtext as string

    Dim list As Array

    Dim new_decoupage as array

    Dim decoupage as string

    Dim newtext1 as string

    Dim x as string

    Dim maxlinelen as integer

    Dim line as string

    maxlinelen = 20

    decoupage = text.Replace("|", Chr(10))

    new_decoupage = Split(decoupage, Chr(10), -1, 1)

    newtext1 = ""

    For Each newtext In new_decoupage

    list = Split(newtext, " ", -1, 1)

    line = ""

    For Each x In list

    If (Len(line) + Len(x)) > maxlinelen Then

    newtext1 = newtext1 & line & Chr(10)

    line = x & " "

    Else

    line = line & x & " "

    End If

    Next

    newtext1 = newtext1 & line & Chr(10)

    Next

    text = newtext1


    Replace the maxlinelen by the max number of char you want by line. If you need to make a line return by your owns, in the text, put a | character. (ie. "This is a very|long text that I need to wordwrap !")

    #XPression


  • 6.  RE: Text boxes

    Posted 01-24-2012 08:55
    The disadvantage of the method described above is that it counts characters while the "w" is wider then the "i". Therefor the warp won't occur at the same position in each line and the wider the line is (counted in characters), the bigger the difference can be.

    Better is when you use the BoundingBox of the text and compare it to an actual pixel count, but I'm not sure this will work in scripting, It does however in the API and I've been using this for years now.

    #XPression


  • 7.  RE: Text boxes

    Posted 01-24-2012 15:11
    This script will do it using the bounding box. It works in the OnSetText() event of a text object; but you must put the scene online from the Sequencer, otherwise OnSetText() doesn't get called.



    Dim maxWidth As Double

    Dim newText As String

    Dim line As String

    Dim strWord As String

    Dim list As Array

    maxWidth = 400 'maxWidth = Self.AutoSqueezeWidth

    If Self.GetTextWidthS(Text) > maxWidth Then

    list = Split(Text, " ", -1, 1)

    newText = ""

    line = ""

    For Each strWord In list

    If (Self.GetTextWidthS(line & strWord) > maxWidth) Then

    newText = newText & line & vbCrLf

    line = strWord & " "

    Else

    line = line & strWord & " "

    End If

    Next

    newText = newText & line

    Text = newText

    End If



    #XPression