It is currently 24 Jan 2022, 11:39

• Featuring Members' Images •
Could be related to 'Filled Text Selection Plug-in'
skinnyhouse
tim
tim
tim
skinnyhouse

GIMP/GL:  Tutorials | Tips | Questions | Interests | Script Requests
Recommendations:  Index | Top 10
Resources:  🡆 Python-Fu Plug-ins | Scheme-Fu Scripts | GIMP
Python:  Lessons | Questions | Exercises
The Arts:  GIMPed | GIMPed Photos | Other | Contests | Public Domain Images | Isolated Images | Blender
Inkscape
Social:  Say Hello | Anything Goes | Shares | FCSP

Filled Text Selection Plug-in

Share your Python Fu Scripts/plug-ins for GIMP here
tim
GL Blogger
1st Place
5775 Post(s)

Filled Text Selection Plug-in

Post#1 by tim » 04 Mar 2019, 18:40


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.
filled_text_selection.py #
Tested in GIMP 2.10.8 (Linux[Ubuntu])
(2.83 KiB) Downloaded 154 times
filled_text_selection.py #
version 2. Fixed error for when there's only one line of text with no line-breaks.
(2.92 KiB) Downloaded 138 times
filled_text_selection.py #
version 3. Strip leading/trailing whitespaces on each line (just in case user entered unwanted whitespaces).
(3.03 KiB) Downloaded 131 times
filled_text_selection.py #
version 4. Added Scale last line toggle option for when last line has too few characters you might not want to scale it.
(3.67 KiB) Downloaded 138 times
filled_text_selection.py #
version 5. Last line scale factor calculation fix.
(3.72 KiB) Downloaded 124 times
filled_text_selection.py #
version 6. Even better NO "Scale Last Line" calculation.
(3.84 KiB) Downloaded 116 times
filled_text_selection.py #
version 7. Irregular shapes (non-rectangle) selection support.
(4.42 KiB) Downloaded 152 times
filled_text_selection.py #
version 8. Scale path instead of font. Higher quality (suggested by ofnuts).
(5.86 KiB) Downloaded 151 times
filled_text_selection.py #
version 9. Fix when NO to Scale Last Line
(6.21 KiB) Downloaded 183 times
filled_text_selection.py #
version 10. Process empty lines to support new paragraphs (TO BE USED with version 2+ of Prepare Text Into Selection Plug-in)
(6.87 KiB) Downloaded 149 times
filled_text_selection.py #
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 226 times
Plug-in Menu Location: Python-Fu/Filled Text Selection

Instructions:
  1. 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.
  2. Create a selection (rectangular) or a shape that you've generally tried fitting the text to.
  3. While having the text layer as the active layer, Run Plug-in (Python-Fu/Filled Text Selection).
  4. 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.
  5. 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
Filled_Text_Selection.jpg # (52.28 KiB) Viewed 5230 times (Thumbnail | Recognize | Sq Tile | LNFI)
filled_text_selection_scale_last_line_YES_NO.jpg
filled_text_selection_scale_last_line_YES_NO.jpg # (105.42 KiB) Viewed 5197 times (Thumbnail | Recognize | Sq Tile | LNFI)
filled_text_selection_irregular_shapes.jpg
irregular shape support
filled_text_selection_irregular_shapes.jpg # (123.37 KiB) Viewed 5181 times (Thumbnail | Recognize | Sq Tile | LNFI)
version_8_scale_path_instead_of_scale_font_higher_quality.jpg
version_8_scale_path_instead_of_scale_font_higher_quality.jpg # (244.81 KiB) Viewed 5158 times (Thumbnail | Recognize | Sq Tile | LNFI)
text_fitted_to_silhouette_with_filled_text_selection_plug_in.jpg
text_fitted_to_silhouette_with_filled_text_selection_plug_in.jpg # (170.83 KiB) Viewed 5136 times (Thumbnail | Recognize | Sq Tile | LNFI)
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
aka Tin
World Food Program | Good Deeds Forum

         

Pat625
Tutorial Creator
2nd Place
4514 Post(s)

Post#2 by Pat625 » 04 Mar 2019, 20:12


Tin, you're really on a roll! A script a day. I will try it as soon as I can get to my computer.

tim
GL Blogger
1st Place
5775 Post(s)

Post#3 by tim » 04 Mar 2019, 20:28


I wish a script/day was true. It's hard coming up with that kind'a rate.
aka Tin
World Food Program | Good Deeds Forum

         

FlutteringBy
Forum Member
26th Place
81 Post(s)

Post#4 by FlutteringBy » 04 Mar 2019, 20:56


No, you really are on a roll....you've kept us busy all weekend which is just perfect, as there's too much snow & freezing temps to do anything outside.... :thank_you: ...
FlutteringBy

tim
GL Blogger
1st Place
5775 Post(s)

Post#5 by tim » 04 Mar 2019, 21:21


Thanks,
Version 7.
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 )
aka Tin
World Food Program | Good Deeds Forum

         

Krikor
Forum Member
12th Place
990 Post(s)

Post#6 by Krikor » 04 Mar 2019, 21:58


Maybe this script is not so intuitive, maybe I'm very noob (more likely) :roll: , but it just doesn't give the expected result.
The result I'm having is a blur of my text within the selected area.

Anyone else using version 7, are you getting good results?
"I feel that in both art and music, it's not the success that matters but the pleasure it gives you. Focus on the pleasure and the learning will come naturally." - Brian Weston

tim
GL Blogger
1st Place
5775 Post(s)

Post#7 by tim » 05 Mar 2019, 00:26


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).
aka Tin
World Food Program | Good Deeds Forum

         

Krikor
Forum Member
12th Place
990 Post(s)

Post#8 by Krikor » 05 Mar 2019, 02:26


I still have not got a good result, but with version 8 the quality is much better.

line 95, in python_tt_filled_text_selection
scale_x = scale_factor_x * ((max_width*1.0)/_width)
ZeroDivisionError: float division by zero
Attachments
GL0045.png
Krikor0045 - filledTextSelection error
GL0045.png # (30.59 KiB) Viewed 5147 times (Thumbnail | Recognize | Sq Tile | LNFI)
"I feel that in both art and music, it's not the success that matters but the pleasure it gives you. Focus on the pleasure and the learning will come naturally." - Brian Weston

tim
GL Blogger
1st Place
5775 Post(s)

Post#9 by tim » 05 Mar 2019, 02:43


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
aka Tin
World Food Program | Good Deeds Forum

         

tim
GL Blogger
1st Place
5775 Post(s)

Post#10 by tim » 05 Mar 2019, 03:21


Just for fun here's another video:
https://www.youtube.com/watch?v=
aka Tin
World Food Program | Good Deeds Forum

         


GIMP/GL:  Tutorials | Tips | Questions | Interests | Script Requests
Recommendations:  Index | Top 10
Resources:  🡆 Python-Fu Plug-ins | Scheme-Fu Scripts | GIMP
Python:  Lessons | Questions | Exercises
The Arts:  GIMPed | GIMPed Photos | Other | Contests | Public Domain Images | Isolated Images | Blender
Inkscape
Social:  Say Hello | Anything Goes | Shares | FCSP

Post Reply New Topic
  • Similar Topics
    Replies
    Views
    Last post

Who is online

Users browsing this forum: No registered users and 3 guests