RetouchPRO

Welcome to RetouchPRO, the web community for retouchers.

You are currently viewing as an unregistered guest which gives you limited access. Registration is fast, simple and absolutely free so please, join RetouchPRO today!

If you have any problems with the registration process or your account login, please contact us. If you've forgotten your password, click here.

Go Back   RetouchPRO > Tools > Software > Photoshop Scripting
Register Blogs FAQ Search Today's Posts Mark Forums Read

Photoshop Scripting Learning and sharing for all platforms

Reply
 
LinkBack Thread Tools
  #1  
Old 02-23-2005, 12:41 PM
Junior Member
 
Join Date: Feb 2005
Posts: 5
Multiple fonts in text layer

I have a template I am using to make headers for a website. I currently have it working to where it will load a text file with all the information, cycle through it, create the graphic and then save it.

Where I'm running into a problem is if there's a registered trademark in the file, it needs to take the font size down to 11 points and to set the baseline shift up to 7 points (basically make a superscript for an 18 point font.)

I know how to write the code to find the location of the registered trademark, I just need to know what to do with this information.

In making stuff up just to see what I could do, I tried things like:

activeDocument.layers["HeaderText"].textItem[4].size = 11;
activeDocument.layers["HeaderText"].textItem[Array(4,5)].size = 11;

but nothing seems to work. Here's the entire code just in case my description isn't adequate.

Code:
var headerTemplate = activeDocument;
var strtRulerUnits = app.preferences.rulerUnits;
var strtTypeUnits = app.preferences.typeUnits;
app.preferences.rulerUnits = Units.PIXELS;
app.preferences.typeUnits = TypeUnits.POINTS;

dbFile = new File("//headers.txt");
dbFile.open ('r');

var headerTemplate = activeDocument;

for(a=0;a<=43;a++){
	textContents = dbFile.readln();
	fileRoot = dbFile.readln();
	saveFile = new File("//head_" + fileRoot + ".gif");

	activeDocument = headerTemplate;
	// suppress all dialogs
	app.displayDialogs = DialogModes.NO;

	activeDocument.layers["HeaderText"].textItem.contents = textContents;

	saveOptions = new GIFSaveOptions();
	saveOptions.colors = 256;
	saveOptions.preserveExactColors = true;
	saveOptions.dither = Dither.NONE;

	headerTemplate.saveAs(saveFile, saveOptions, true,Extension.LOWERCASE);

	activeDocument = headerTemplate
	headerTemplate.activeHistoryState = headerTemplate.historyStates[0]

	app.preferences.rulerUnits = strtRulerUnits;
	app.preferences.typeUnits = strtTypeUnits;
	docRef = null;
	textColor = null;
	newTextLayer = null;
	saveFile = null;
}

Last edited by MagiCat : 02-23-2005 at 12:56 PM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiReddit! Float This Post!Stumble this Post!Google Bookmark this Post!Yahoo Bookmark this Post!Live Bookmark this Post!Share this post on Facebook
Reply With Quote
  #2  
Old 02-23-2005, 01:05 PM
byRo's Avatar
Moderator
 
Join Date: May 2004
Location: Goiânia, Brazil
Posts: 1,536
Probably nothing to do with the problem, but shouldn't there be line to make the text layer "newTextLayer" named "HeaderText"?

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiReddit! Float This Post!Stumble this Post!Google Bookmark this Post!Yahoo Bookmark this Post!Live Bookmark this Post!Share this post on Facebook
Reply With Quote
  #3  
Old 02-23-2005, 02:09 PM
Junior Member
 
Join Date: Feb 2005
Posts: 5
Actually that is just an extraneous line. When I first undertook this I had it generate all the layers from scratch (hence the name "newTextLayer"). I decided that it would be better to just create a template and programatically change elements of the template and since I was only accessing the layer once at this point I just used the name of it rather than creating a reference to it.

I'm finding tons of Photoshop scripting references that have how to change the font size for the entire layer but none that will show me how to either change part of the layer or build the layer character by character.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiReddit! Float This Post!Stumble this Post!Google Bookmark this Post!Yahoo Bookmark this Post!Live Bookmark this Post!Share this post on Facebook
Reply With Quote
  #4  
Old 02-24-2005, 06:57 AM
byRo's Avatar
Moderator
 
Join Date: May 2004
Location: Goiânia, Brazil
Posts: 1,536
disclaimer 1: Can't confirm this for CS;
disclaimer 2: I don't work much with text


- In Photoshop 7.0 the javascript documentation does not mention the possibility of having more than one textItem in a given layer.
- Using Photoshop directly, not js, if you try to write more text on a layer it will open up a new text layer and not add to the existing one.

I'd say that the solution is too have more layers, each with a part of the text. This should solve the formatting problems, but now you'll have to make up some tricks to get the alignment right.

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiReddit! Float This Post!Stumble this Post!Google Bookmark this Post!Yahoo Bookmark this Post!Live Bookmark this Post!Share this post on Facebook
Reply With Quote
  #5  
Old 02-24-2005, 03:45 PM
Junior Member
 
Join Date: Feb 2005
Posts: 5
What happens is if you select a range within the text layer, it will allow you to change the font information for just that range. You can have the entire sentence as 18 point font except 1 character as 11 point font. You can also have every character as a different fontsize, I thought this went back a long way but I haven't used 7.0 for a long time.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiReddit! Float This Post!Stumble this Post!Google Bookmark this Post!Yahoo Bookmark this Post!Live Bookmark this Post!Share this post on Facebook
Reply With Quote
  #6  
Old 02-25-2005, 04:24 AM
byRo's Avatar
Moderator
 
Join Date: May 2004
Location: Goiânia, Brazil
Posts: 1,536
Aha! Now you've given me a good idea.
I'd say that an answer would be to run the ScriptListener while manually doing this editing and see what it comes up with, maybe (but only, maybe) it will be possible to translate it into the program.

Will try lunch-time.

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiReddit! Float This Post!Stumble this Post!Google Bookmark this Post!Yahoo Bookmark this Post!Live Bookmark this Post!Share this post on Facebook
Reply With Quote
  #7  
Old 02-25-2005, 08:40 AM
byRo's Avatar
Moderator
 
Join Date: May 2004
Location: Goiânia, Brazil
Posts: 1,536
Wow!! I did some alterations to a text layer (font / size / colour) and the ScripListener came back with one command, but just look at the size of it 74K.
74K just to describe one command!! It's going to take a little time to analyse this but the answer is YES it can be done.


Last edited by byRo : 02-25-2005 at 08:50 AM. Reason: replied too soon - now I got it
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiReddit! Float This Post!Stumble this Post!Google Bookmark this Post!Yahoo Bookmark this Post!Live Bookmark this Post!Share this post on Facebook
Reply With Quote
  #8  
Old 02-25-2005, 08:55 AM
DannyRaphael's Avatar
Moderator
Patron
 
Join Date: Mar 2002
Location: Near Seattle, Washington, USA
Posts: 5,601
Quote:
Originally Posted by byRo
Wow!! I did some alterations to a text layer (font / size / colour) and the ScripListener came back with one command, but just look at the size of it 74K.
74K just to describe one command!! It's going to take a little time to analyse this but the answer is YES it can be done.

If the text is going to be the same from image-to-image, this might be a case where inserting a DoAction cmd in the script to call to an action that builds the multi-font style and/or multi-size font size text layer might be a reasonable alternative, no?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiReddit! Float This Post!Stumble this Post!Google Bookmark this Post!Yahoo Bookmark this Post!Live Bookmark this Post!Share this post on Facebook
Reply With Quote
  #9  
Old 02-25-2005, 02:10 PM
byRo's Avatar
Moderator
 
Join Date: May 2004
Location: Goiânia, Brazil
Posts: 1,536
Yes, but.....unfortunately.....the text does change.

I've sifted throught the ScriptListener listing:

When you alter something in an existing TextLayer it does not simply update the parameter that was changed, but it will rewrite the all of the layer's information.

A look at the amount of information that goes into a text layer is quite an eye-opener, besides the things you'd expect there is soooo much more!

How about these [value]:
- wariChuCount [1], ....Scale [1], ....Widow [25], ... Orphan [25];
- burasagari [false];
- preferredKinsokuOrder [push in];
- mojiKumiName [None]
The Script does show how it puts together a textLayer where some characters are different. For both text and paragraph parameters it sets up separate lists with arrays[start, finish] for each section, where start and finish are character counts.
If there were to be some sort of translation into "normal" JS commands it would indeed look something like MagiCat has been trying, though I find it hard to believe that this is possible.

Summary:
1) Quick 'n easy solution - don't think so;
2) ActionDescriptor setup - possible but very long-winded (deserves more investigation);
3) Separate Layer - still seems the best work-around.

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiReddit! Float This Post!Stumble this Post!Google Bookmark this Post!Yahoo Bookmark this Post!Live Bookmark this Post!Share this post on Facebook
Reply With Quote
  #10  
Old 02-26-2005, 09:54 PM
Junior Member
 
Join Date: Feb 2005
Posts: 5
Yeah, I tried the Script Listener, the way they did it appears to be to actually recreate the text layer. Would be more trouble than it's worth because reusing it would require that I recreate entire layer (including all the font information) in the script listener language.

I'm surprised that there isn't a way to edit the font information for just a portion of the text though, unless it's some way that's entirely undocumented. Unfortunately for me, if anyone had been interested in doing it in the past, they haven't even posted anything about a their failed attempt to let me know it was impossible.

How would I go about doing this with multiple layers?

Say I have the text:

"This is a test(R) of the emergency broadcasting system" How would I get the (R) to be in the appropriate place within the layers?

Right now I'm just having the code save the psd files for the items that have the registered trademark symbol and am doing those by hand.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiReddit! Float This Post!Stumble this Post!Google Bookmark this Post!Yahoo Bookmark this Post!Live Bookmark this Post!Share this post on Facebook
Reply With Quote
  #11  
Old 08-17-2005, 10:22 AM
Junior Member
 
Join Date: Feb 2005
Posts: 5
Kindof glad this board exists and I posted my code on it. Had to redo the project using a different color and I had reinstalled everything, losing the existing code, having the code here was a lifesaver.

Still wondering if anyone has figured out how to do what I was trying to do, but since it's only 4 items that have superscript, it was really easy to manually do them.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiReddit! Float This Post!Stumble this Post!Google Bookmark this Post!Yahoo Bookmark this Post!Live Bookmark this Post!Share this post on Facebook
Reply With Quote
  #12  
Old 09-08-2005, 08:21 AM
Member
 
Join Date: Aug 2004
Posts: 35
The ActionDescriptor route is still probably the best way to do this, though little bit different that Ro suggested.

You would have to:
1) Do a executeActionGet on the Document and traverse down to find the TextItem Layer that is currently active.
2) Modify the ActionDescriptor object so that it looks like what you want. Looking at ScriptListener code should give you a few clues.
3) Write up the ScriptListener code that does a text modification. Instead of futzing with that 74K beast, just pass in in the ActionDescriptor that you just modified.

This still isn't simple and easy, but doing it like this makes it tractable. The only thing that would throw a wrench in the works is if executeActionGet did not return information complete enough about the TextItem for you to use in an executeAction call to modify/replace the TextItem.

I'll try and take a crack at this over the the next week or two, time permitting.

ciao,
-X
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiReddit! Float This Post!Stumble this Post!Google Bookmark this Post!Yahoo Bookmark this Post!Live Bookmark this Post!Share this post on Facebook
Reply With Quote
  #13  
Old 12-15-2005, 06:17 PM
Member
 
Join Date: Aug 2004
Posts: 35
TextRange.jsx

I've posted a beta of a script that can handle multiple fonts, colors, and sizes.
You can find it here. I'll post a notice when it's 'finished'.

ciao,
-X
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiReddit! Float This Post!Stumble this Post!Google Bookmark this Post!Yahoo Bookmark this Post!Live Bookmark this Post!Share this post on Facebook
Reply With Quote
  #14  
Old 02-10-2006, 11:22 AM
Member
 
Join Date: Aug 2004
Posts: 35
Update to TextRange.jsx

Here's the current version of the newly named Text.jsx.

Use in peace.

-X
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiReddit! Float This Post!Stumble this Post!Google Bookmark this Post!Yahoo Bookmark this Post!Live Bookmark this Post!Share this post on Facebook
Reply With Quote
Reply


Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Tutorial 05: Converting a Color Image to Black and White grayscale BW DannyRaphael Photo-Art 101 13 06-03-2008 10:35 AM
help with german Photoshop commands please pure Photoshop Help 8 03-02-2006 12:01 PM
Layer Tutorials..again? zip022 RetouchPRO Tutorials 21 11-18-2004 10:10 PM
select shape Peg Hidden Power Support 7 08-29-2004 06:10 PM
Help needed understanding these layers. peejay Photo-Based Art 3 01-16-2004 08:15 PM


All times are GMT -6. The time now is 10:38 PM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Copyright © 2008 Doug Nelson. All Rights Reserved moo




1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50