Jump to content

how to wrap text/font to shape?


Zigmund

Recommended Posts

Hi everybody!

I need some help. How can I wrap text to a shape like on the picture below?

 wrap-text-in-shape.thumb.png.8e1a1f1736b0fbc161948b7f4d990ebd.png

UV layout wraps words in a shape but does it in a random way. I need to wrap a text in a shape yet to preserve the order of the words so the text makes sense.

Any ideas or maybe some hda that can help with it?

Thanks in advance 

Link to comment
Share on other sites

21 hours ago, Atom said:

Check out the word cloud file posted on Houdini Blueprints.

https://hdbp.io/F200r4v3

Hey Atom, thanks for the reply!

I checked the file and I already saw it. Unfortunately it uses UV Layout which allocates all words in random order, making the text unreadable:(

Is there any way that I can make UV layout to allocate words from left to right and top to bottom?

 

Link to comment
Share on other sites

I think for something that specific, you might look for an illustrator tutorial. Then save the result in the Illustrator8 format and import it into Houdini. Another option is to save the Illustrator result as a hi-res PNG or TIFF (something with an alpha) that the Trace node can read.

Link to comment
Share on other sites

13 hours ago, paranoidx said:

Sorry, thats not what i'm looking for.

20 hours ago, Atom said:

I think for something that specific, you might look for an illustrator tutorial. Then save the result in the Illustrator8 format and import it into Houdini. Another option is to save the Illustrator result as a hi-res PNG or TIFF (something with an alpha) that the Trace node can read.

Illustrator was my last option, yet I thought it is possible to do it in a procedural way in houdini, so i can apply a lot of text to more complex shapes and then manipulate in 3d..

Link to comment
Share on other sites

@Zigmund Make some shape from Labs , use slice  assemble ,name, string ,
Don''t know how to make from word's name string, then it should be possible to mach somehow with this code. first(names from font) second input some sliced boxes from shape.Hm how to match those name?? we need Help!!

int dotranslate = chi("dotranslate");
int dotrotate = chi("dotrotate");
int doscale = chi("doscale");
int uniformscale = chi("uniformscale");

vector min0,max0,min1,max1;
float pb0[] = primintrinsic(0,'packedbounds',@primnum);
float pb1[] = primintrinsic(1,'packedbounds',@primnum);

for(int i;i<3;i++){
    min0[i]= pb0[i*2];
    max0[i]= pb0[i*2+1];
    min1[i]=pb1[i*2];
    max1[i]=pb1[i*2+1];
    }

vector size0 = max0-min0;
vector center0 = (max0+min0)/2;
vector size1 = max1 -min1;
vector center1 = (max1+min1)/2;

matrix T = 1 ;
matrix R = 1 ;
matrix S = 1 ;

if ( dotranslate){
    vector t = center1 -center0;
    translate(T,t);
    }

if (dotrotate){
    float size0_array[]= set(size0);
    float size1_array[]= set(size1);
    
    int size0_argsort[]= argsort(size0_array);
    int size1_argsort[]= argsort(size1_array);
    vector newsize = size0;
    
    vector mr[];
    for(int i;i<3; i++){
        vector axis;
        axis[size1_argsort[i] ]=1;
        mr[size0_argsort[i] ]=axis;
        
        newsize[size0_argsort[i]]= size0[size0_argsort[i]];
        }

        
    size0 = newsize;
    //mr[2]= cross(mr[0],mr[1]);
    R = set(mr);

}
if(doscale){
    //@P = fit(@P,min0,max0,min1,max1);
    vector s = size1/size0;
    if (uniformscale){
        s = min(s);
        }
        scale(S,s);
}

vector p = center0;matrix X = 1;translate(X,p);

matrix xform = invert(X)*R*S*T*X;

matrix fulltransform = primintrinsic(1,'packedfulltransform',@primnum);
setpackedtransform(0,@primnum,X*xform*fulltransform);


pr6.jpg.cc8efed3d659c9aa2f078d49f06ed1e8.jpg
 

pr6e.jpg

Edited by Librarian
Link to comment
Share on other sites

It kinda Works.

//prim
if (i@textindex - 1 != i@opinput1_textindex)
{
    @name = "word";
}
//detail
int wordnum = -1;

for (int i = 0; i < nprimitives(0); i++)
{
    if (string(prim(0, "name", i)) == "word")
    {
        wordnum++;
    }
    setprimattrib(0, "name", i, "word" + itoa(wordnum));
}


 

pr6ess.jpg

Chopddddddddffssssgasfsseerrrryyyjj.gif

Edited by Librarian
  • Like 1
Link to comment
Share on other sites

8 hours ago, Librarian said:

It kinda Works.

I already found how to make a word attribute, thanks to this forum! Your setup looks interesting, need sometime to understand how it works. Can u share your hip file?

7 hours ago, Fenolis said:

Doesn't preserve spaces, but maybe this can guide you in the right direction?

To preserve space we need to make a word attribute, look i modified your file, which is very helpful on its own!!! The only problem now is that chain node starts the text for each line instead of continuing it.

Any ideas?

word_wrap_in_shape_v2.hiplc

Link to comment
Share on other sites

Here's another partial solution building on what you posted. Basically you have a row of lines with two points. What I've done resample those lines to create more places where each letter can land. So there is no consideration for words or spacing. This gets your font spread across the lines.

A dual loop iterates over the primitive (i.e. the lines) then an inner loop iterates over the points on each given line distributing the characters. Before the loop, a wrangle counts the points on each line and adds an attribute with that value. This becomes a start index into where to copy the characters from on any given line.

 

So the todo could be to figure out the length of each line, then determine how many characters fit on that line and resample that line with that many points prior to entering the double loop deployment phase. Even Illustrator seems to fail at that.

 

ap_word_wrap_in_shape_v3.hiplc

Untitled-1.jpg

Edited by Atom
Link to comment
Share on other sites

Hey guys,

Thanks again for your help. I looked at the setup again and thought if it can be improved or simplified and I came up to this.

word_wrap_in_shape_v5.hiplc

I decided it might be interesting for you or helpful for someone in future.

The concept is the same: to make the lines in one straight line, transfer attributes and restore the position.

For aligning lines i decided to use Labs align and distribute. So no need for loop. Also transferring offset directly to the text without chain sop allows to preserve the kernel! Also, chain sop is heavy by it owns.

I also made a switch to allocate on letter basis, as we did in previous version, there is also an option to allocate purely on word basis.

  • Like 3
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

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.

×
×
  • Create New...