Jump to content

Sign in to follow this  
hammondchips

Text size script

Recommended Posts

Hi Cafe

Another day another question...

I have some Motext which uses a Volume to recreate the text from a cloner object.

All fine and dandy.

What i'd like to experiment with it changing the size of the font depending on how many letters there are in the MoText.

 

Currently the font size is 20, with 6 letters in the first line, if I add extra letters to the Motext those letter disappear off the edge of the screen. Ideally some script says that that if there are more than 6 letters, 8 for example, reduce the font size to 15, which would allow all 8 letters to fit within the frame. There would need to be  a min and max font size too, but right now i'm just wondering if and where the solution might lie.

 

Would this be something Xpresso could handle?

 

Any thoughts very welcome

 

File attached

 

 

Cafe File.c4d

Share this post


Link to post

On LHS of XPresso window under system presets there's some string functions. You could use 'length string' and a condition node to output the desired font heights. Condition starts at 0, 1, 2 etc so here I've subtracted 6 as a start value. Condition pipes thru the value from selected input.

 

texlen.png.075b1dcb3340667287f000b11adfd370.png

 

not sure if my scene file will work on your R18, because some nodes changed from COFFEE to Python in R20

 

textlen.c4d

 

bear in mind that fonts are monospaced or proportional. In a prop font, i is narrower than O, in mono (aka typewriter) font eg courier or consolas all chars have same width.

Share this post


Link to post
  • Topic Author
  • Hi @jed

    Amazing, gonna have a play with this tonight.

    Thanks so much...

     

    Ps. I'm on R20, guess I should update my profile

    Share this post


    Link to post

    Thinking about it, it's R18 coffee script in R20 that's the problem because R20 doesn't have Coffee. Other way around is OK, probably....

    Share this post


    Link to post

    Hello, @jed, @hammondchips

    ...

    What if changing your condition node for a Math node, as in the image?

    ...

    It will continues to diminish the height value.

    ...

    João Marco

    1234.thumb.jpg.e95b447e3782d68cb82678eb7c60d27a.jpg 

    Share this post


    Link to post

    @jmarco I think different width characters are going to be an issue. I came up with this python method of setting the actual length -

     

    motext2.c4d

     

    although the code is still WIP

    Share this post


    Link to post

    Really well done, Mister @jed :-)

    ...

    Congrats.

    Share this post


    Link to post
  • Topic Author
  • Such good logic

    Thanks @jed and @jmarco

    Now working with jed's python script to add in some functionality, when i get it sorted, i'll post back here for the community.

     

    Tah

     

    Share this post


    Link to post

    Join the conversation

    You can post now and register later. If you have an account, sign in now to post with your account.

    Guest
    Reply to this topic...

    ×   Pasted as rich text.   Paste as plain text instead

      Only 75 emoji are allowed.

    ×   Your link has been automatically embedded.   Display as a link instead

    ×   Your previous content has been restored.   Clear editor

    ×   You cannot paste images directly. Upload or insert images from URL.

    Sign in to follow this  

    • Recently Browsing   0 members

      No registered users viewing this page.

    ×
    ×
    • Create New...