IMPORTANT ANNOUNCEMENT

These forums were permanently set to read-only mode on July 20, 2022. From that day onwards, no new posting or comment is allowed on the site, but the historical content remains intact and searchable.

A new location for posting questions about PlanetPress Suite is now available:

OL Learn - PlanetPress Classic (opens in new tab)

Topic Options
#57427 - 02/19/20 10:06 AM stop text from flowing outside the text box.
magus321 Offline
OL Newbie

Registered: 02/19/20
Posts: 2
Hello,
I thought my issue was easy to fix, but I could not figure it out by now. Hopefully someone here can help me.

How can I prevent text from flowing outside the definded textbox size?

I could limit the number of characters that I display, but different letters have different sizes, so I sometimes could end up with to much space.

Is it possible to just display what fits into the box and not display the rest.
Or set the box to only display three line breaks and not everything after that?

Regards
Jan

Top
#57428 - 02/19/20 10:27 AM Re: stop text from flowing outside the text box. [Re: magus321]
Jean-Cédric Offline
OL Expert

Registered: 10/03/16
Posts: 681
Loc: Québec, Canada
The only way I think of is to add white border, white filled box around your text object so overflow is hidden under.
_________________________
♪♫♪♫
99 frigging bugs in my code
99 frigging bugs
Take one down
Code around
127 frigging bugs in my code
♪♫♪♫

Top
#57429 - 02/19/20 10:50 AM Re: stop text from flowing outside the text box. [Re: magus321]
jim3108 Offline
OL Expert

Registered: 04/19/10
Posts: 316
Loc: London, UK
If you know the geometric boundaries that you need to avoid, you could use a PressTalk script and then check &physical.x and &physical.y after you put each character (or word) down and then just stop once you reach whatever arbitrary limit is set - most likely in a global variable.

Top
#57430 - 02/19/20 02:48 PM Re: stop text from flowing outside the text box. [Re: magus321]
Philippe F. Offline
OL Expert

Registered: 09/06/00
Posts: 1984
Loc: Objectif Lune, Montreal, Qc
Similar to Jean-Cedric's suggestion, you could create a white box that snaps to the bottom of your Text Object. When the content extends beyond the Text Object's lower boundary, it would get displayed "behind" the snapped white box below the Text Object.
_________________________
Technical Product Manager
I don't want to achieve immortality through my work; I want to achieve immortality through not dying - Woody Allen

Top
#57431 - 02/20/20 09:00 AM Re: stop text from flowing outside the text box. [Re: Philippe F.]
magus321 Offline
OL Newbie

Registered: 02/19/20
Posts: 2
I found the solution in Talk a bit more elegant.

This is based on the code from Raphael Lalonde Lefebvre from this post:
https://www.objectiflune.com/forum2/?ubb=showflat&Number=39850


Code:
define(&i, integer, 0)
define(&s, string, '')
define(&curstr, string, '')
define(&prevstr, string, '')
define(&tempstr, string, '')
define(&linecounter, integer, 1)

%Define size of space between lines
define(&gap, measure, 0.15)
%Define max. no. of lines
define(&lines, integer, 5)


&s := stringreplace(stringreplace(XmlGet('/label[1]/body[1]/ncoIssueNote[1]/text[1]'), '\015', ''), '\012', '|')

for(&i, 1, 1, length(&s))
  if(mid(&s, &i, 1) = ' ')
    if(stringwidth(&curstr) > &Width)
      show(&prevstr)
      crlf(&gap)
      &linecounter := &linecounter +1
      if(&linecounter > &lines)
        &curstr := ''
        exit
      endif
      &curstr := &tempstr + ' '
    elseif()
      &curstr := &curstr + ' '
      &prevstr := &curstr + ' '
    endif()
    &tempstr := ''
  elseif()
    if(mid(&s, &i, 1) = '|')
      if(stringwidth(&curstr) > &Width)
        show(&prevstr)
      elseif()
        show(&curstr)
      endif()
      crlf(&gap)
      &linecounter := &linecounter +1
      if(&linecounter > &lines)
        &curstr := ''
        exit
      endif
      &curstr := ''
    elseif()
      &curstr := &curstr + mid(&s, &i, 1)
      &tempstr := &tempstr + mid(&s, &i, 1)
    endif()
  endif()
endfor()

show(&curstr)

Top