basiljs / basil.js

An attempt to port the spirit of the Processing visualization language to Adobe Indesign.
http://basiljs.ch/
Other
245 stars 30 forks source link

b.fitText() #112

Open trych opened 7 years ago

trych commented 7 years ago

As discussed in #108, a b.fitText() method would be nice, to fit an existing text to its textFrame (and I can confirm @ffd8 impression, that request/demand comes up all the time).

It could work like this b.fitText(textContainer, [textProperty]), where textProperty is an optional property, if the user would like to use another property instead of point size. Only properties that change the horizontal width of text should be allowed though.

@ffd8, in the other issue you stated

It could be connected to the b.typo function to accept any of those attributes which are number based and regularly check for overflow

What exactly do you mean by «it could be connected to b.typo»? That it should be used together with it? Or that the syntax works in the same way?

There was a nice algorithm by jongware for filling text frames (based on point size only) that I used in my bachelor's project as well, I will try to find the original link.

Edit: Here it is. Although I have to admit that my final implementation was quite a bit more complicated, as there were a lot of pitfalls to look out for. Then again, I was somewhat in a hurry, so when done properly this could probably be implemented quite nicely.

b-g commented 7 years ago

+1, yes this pops up very often!