5 Replies Latest reply on Sep 13, 2012 9:04 PM by jbrown

    Resizing text based on number of characters in a field

    jbrown

      At our school, we have a place for teachers to enter some shout out information (compliments) that get printed and hung up. I have a nice big text field that they type in the information they want to say. Some teachers wax long on their student, some keep it brief. I'd like the text to fill roughly the same area for each shout out. The brief text looks pitiful against the more filled-out text box. Is there a way to resize the text based on the number of characters entered in the field, so each shout out that's hung up shows the same area filled in?

      I would not really know where to start, except on here.

       

      thanks

      jb

        • 1. Re: Resizing text based on number of characters in a field
          robwoof

          You might like to look at conditional formatting using a formula on the field object on the print layout (not the input layout). It will probably require some testing to optimise the thresholds, but something like

           

          Let ( [ t = <textfield> ;

                     len = Length ( t ) ;

                    sizeNum = Case ( len > 400 ;  //Really long

                                                       5 ;                  //tiny text

                                                 len > 300 ;  //Quite long

                                                       7 ;                   //quite small text

                                                 len > 200 ;  //Long-ish

                                                       9 ;                   //small-ish text

                                                 len > 100 ;  //OK

                                                       10 ;                 //slightly reduced text

                                                       12 ) ] ;             //normal size text for entries shorter than 100 characters

          TextSize ( t ; sizeNum )

          )

           

          might be a good place to start.

           

          You will need to fiddle the threshold numbers (100, 200, 300, 400) and their matching text sizes (10, 9, 7, 5) to get the result you want.

          • 2. Re: Resizing text based on number of characters in a field

            If you use a non-proportional font such as Courier, you can get pretty using Rob's suggestion!

             

            Fonts will grow in height as well so give that SHOUT field plenty of height and center the text vertically as well as horizontally. 

            • 3. Re: Resizing text based on number of characters in a field
              LyndsayHowarth

              Obviously you can change Rob's character counts to suit your circumstances...

               

              You may also be able to do this with a web viewer and describe your text size by 100%.

               

              I was thinking about Robs calc... and hypothesising an alternative way with no conditions... Here is my 2 cents:

              If the max font size were say 48pt...

              If x were character count and y was 48 pt

              y/x would give you the factor that you then multiply 48pt by to get the appropriate font size... and round it down to the nearest whole point.

               

              Lyndsay

               

              Sent from my iPad

              Lyndsay Howarth

              11th Hour Group Pty Ltd

              • 4. Re: Resizing text based on number of characters in a field
                LyndsayHowarth

                whoops... I forgot the max characters aspects...

                 

                let's make z the max characters at 48pt

                then the factor calc is (y*z)/x

                 

                ... I think...

                I need to go to my computer to confirm this...

                 

                - Lyndsay

                • 5. Re: Resizing text based on number of characters in a field
                  jbrown

                  I'll give these a try, tomorrow. Its late and i still gotta wake up and grade papers and plan a lesson before 8:45 tomorrow.

                  Thanks.