What's new

Formatting Text Variables


LightlyFried

Member
Messages
5
Likes
1
Hi All!

I'm trying to use a .csv file to batch edit a bunch of images, in which the only thing that differs is a bit of text. I've managed to get the content working fine, however the one last hurdle I'm facing is that I'd like different parts of the text to have simple formatting (i.e italics and bold).
The formatted text is inline, sometimes partway through a sentence so I can't cheat it with multiple text boxes. Some sample text is:
You point a finger at a target in range. Your magic grants you a brief insight into the target's defenses. On your next turn, you gain advantage on your first attack roll against the target, provided that this spell hasn't ended.
I've tried using both the source formatting of the excel file and rich text using < or [, none of which have worked. Is there something I'm missing?

Again, I've got the text to imput fine, but in PS the text only shows as:
You point a finger at a target in range. Your magic grants you a brief insight into the target's defenses. On your next turn, you gain advantage on your first attack roll against the target, provided that this spell hasn't ended.
Thanks for any and all advice!
 

hawkeye

Guru
Messages
2,343
Likes
1,084
You can't format the variable text, but you can go the opposite way and replace formatted text with non-formatted.
Type the text with the formatting.
Create a text variable and it will be unformatted.
 

thebestcpu

Guru
Messages
1,939
Likes
1,765
Hi LightlyFried
I am not the expert on Photoshop variables yet that alone I don't believe will work.
Pretty sure it just uses the text in the csv file with no formatting and then applies that to the Layer. I believe that the formatting that is then used in the Text Layer is determined by the formatting of the first character in the text and applied to all characters in that Layer.
So my understanding is that if all of the text in the text Layer is of one format, you will get the same format using variables. Replacing Text with different formats per character would be changed to one consistent format based on first character (have not thoroughly tested this)

To do what you want could be done yet may be much more involved most likely using scripts to search for the desired word and change the format for that specific word.

Others may have more insight to possibilities than I.
John Wheeler
 

LightlyFried

Member
Messages
5
Likes
1
Thank you both for your replies.
Hawkeye, I'm trying to wrap my head around your suggestion, how could I use that to achieve an inline formatting effect?
Alternatively, is there any addon or anything that could help me? One that let's Photoshop work with Rich Text maybe?
 

LightlyFried

Member
Messages
5
Likes
1
Hi LightlyFried
I am not the expert on Photoshop variables yet that alone I don't believe will work.
Pretty sure it just uses the text in the csv file with no formatting and then applies that to the Layer. I believe that the formatting that is then used in the Text Layer is determined by the formatting of the first character in the text and applied to all characters in that Layer.
So my understanding is that if all of the text in the text Layer is of one format, you will get the same format using variables. Replacing Text with different formats per character would be changed to one consistent format based on first character (have not thoroughly tested this)

To do what you want could be done yet may be much more involved most likely using scripts to search for the desired word and change the format for that specific word.

Others may have more insight to possibilities than I.
John Wheeler
Hi! Thanks for your in depth response!
Moat of the text I want to format will be certain substrings, so maybe Scripting is the way forward for me 😊 I'll check it out and jump back on the forum if I can't make sense of it 😁
Thanks for pointing me in the right direction!
 

hawkeye

Guru
Messages
2,343
Likes
1,084
Thank you both for your replies.
Hawkeye, I'm trying to wrap my head around your suggestion, how could I use that to achieve an inline formatting effect?
Alternatively, is there any addon or anything that could help me? One that let's Photoshop work with Rich Text maybe?
Start with a line of text that is formatted text and with identical text that does not have formatted text. Use the non-formatted text as the variable. This is the simplest form just 2 variations.
For more variations you would need to use additional layers and Visibility to control those you don't wish to display. It's hard to be more specific without knowing more.
 

LightlyFried

Member
Messages
5
Likes
1
Start with a line of text that is formatted text and with identical text that does not have formatted text. Use the non-formatted text as the variable. This is the simplest form just 2 variations.
For more variations you would need to use additional layers and Visibility to control those you don't wish to display. It's hard to be more specific without knowing more.
Here's an example:
Weapon - Spear.png

So you can see in the text under 'Properties' there's a few bold words. I'm pulling the text for each card's properties (among other things, which are working fine) from a csv file. There is sometimes more or less text in the box, and sometimes none at all, so I don't think I can split the text box into multiple. What thebestcpu said above might be the best solution as only certain words (Thrown, Versatile, etc) are going to be bold, so if I can format the text substrings with scripts that might be my best bet 😊
 

thebestcpu

Guru
Messages
1,939
Likes
1,765
Another possible alternate is to have a Layer that represents the area for the unique text you want, create those various files such as "Word" (it also has automation), output that text as bit-mapped image file, then use a pixel Layer replacement variable to bring tin the exact formatted text that you desire into Photoshop. Its just brought it as a pixel image instead of text.

Note: As I recall, it works best if the pixel dimensions match exactly the pixels of which you are replacing so there might be some learning curve to get it to work.

Not super easy yet might be easier than learning Photoshop scripting.
Just another option to consider
John Wheeler
 

thebestcpu

Guru
Messages
1,939
Likes
1,765
BTW - There is a typsetting program by Adobe that probably can do this much easier yet that is also buying and learning another application ---"InDesign" It targets this type or project much better than Photoshop.
 

hawkeye

Guru
Messages
2,343
Likes
1,084
Thinking outside the box...you could rasterize the text and save it as an image. Then use pixel replacement instead of text replacement.
 

LightlyFried

Member
Messages
5
Likes
1
Okay yeah, that's a couple great suggestions, I never thought to convert the text into an image before importing it. I'll have to figure out a way to get it the correct shape and dimensions, but I'm sure that'd be a mite easier than learning Photoshop's scripting language just for one hobby project.
It might be beneficial for me to check out InDesign too, instead of forcing PS to do something it's not designed to do.

Thank you both for your great suggestions!
 

Top