Often, when working with text, I'd like to fit a block of text (generally filled justified) to fit nicely in a block/rectangle.
Well filled justify doesn't do it for me because it keeps the text of the same size.
What I like to do is scale each line so that it fits nicely into the width of the rectangle. Like how newsprint/newspaper sometimes do it. They fit everything nicely into columns (with sometimes the last line not to fit but leave as is).
UPDATE: You can use the Prepare Text Into Selection Plug-in prior to running this plug-in to prepare your text with optimal font-size (to best fit selection) and automatically determine (hard) line-breaks before running this plug-in.
This plug-in helps with that once you have your text created.
version 11. Add "Did you use Prepare Text Into Selection to prepare this text" Toggle to use the same height (more uniform text).
(7.15 KiB) Downloaded 281 times
Plug-in Menu Location: Python-Fu/Filled Text Selection
Have a text layer with some block of text that is generally filled justify (meaning each line has enough text to fill the whole width of intended block/rectangle) with hard line breaks (you pressing enter key) that you've decided.
Create a selection (rectangular) or a shape that you've generally tried fitting the text to.
While having the text layer as the active layer, Run Plug-in (Python-Fu/Filled Text Selection).
Say YES/NO to "Scale Last Line" (If you think you have enough characters to scale last line to fit the width of your selection, choose YES. If you think you don't have enough characters and worry the last line it'll stretch too much, choose NO) Then click "OK" to run Plug-in.
That's it. It'll fill your selection with your text_layer you'll get a layer named "Filled Text Selection" as the result.
Sample before and after:
Filled_Text_Selection.jpg # (52.28 KiB) Viewed 6592 times Thumbnail
filled_text_selection_scale_last_line_YES_NO.jpg # (105.42 KiB) Viewed 6559 times Thumbnail
irregular shape support
filled_text_selection_irregular_shapes.jpg # (123.37 KiB) Viewed 6543 times Thumbnail
version_8_scale_path_instead_of_scale_font_higher_quality.jpg # (244.81 KiB) Viewed 6520 times Thumbnail
text_fitted_to_silhouette_with_filled_text_selection_plug_in.jpg # (170.83 KiB) Viewed 6498 times Thumbnail
Here's a video of me using the plug-in (I only turned selection to path so that I can turn it on for you to see, You don't need to turn your selection to path, You just need a selection). https://www.youtube.com/watch?v=P5_zEkkYW8o
Just updated with irregular shape support (for when you already manually adjusted the text to fit a general shape but this will fit it even finer, if you haven't manually tried to fit the general shape it'll still fit it into the shape it might just look weird with some text overly stretched and some overly squished. Here I just chose different shapes in sample in post 1 without any manual text adjustment and it looks okay/good still )
hehehe Working with font is never intuitive, at least not for me.
Did you follow the instructions right?
You have to have hard returns/enters to line break yourself in your text so that it's generally in the shape of what you want
Then this plug-in will fine tune it.
Please check version 8, it's higher quality (suggested by ofnuts to scale path instead of scaling font).
Do you have an empty line at the end of your text? maybe that's why _width is zero.
Anyways I added a youtube video at bottom of 1st post for people to see how i use the plug-in.
And I found a bug so I updated version 9