RetouchPRO

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


Photoshop Scripting Learning and sharing for all platforms

Multiple fonts in text layer

Reply
 
Thread Tools
  #1  
Old 02-23-2005, 01:41 PM
MagiCat MagiCat is offline
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 01:56 PM.
Reply With Quote top
  #2  
Old 02-23-2005, 02:05 PM
byRo's Avatar
byRo byRo is offline
Senior Member
 
Join Date: May 2004
Location: Goianésia, Brazil
Posts: 1,609
Probably nothing to do with the problem, but shouldn't there be line to make the text layer "newTextLayer" named "HeaderText"?

Reply With Quote top
  #3  
Old 02-23-2005, 03:09 PM
MagiCat MagiCat is offline
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.
Reply With Quote top
  #4  
Old 02-24-2005, 07:57 AM
byRo's Avatar
byRo byRo is offline
Senior Member
 
Join Date: May 2004
Location: Goianésia, Brazil
Posts: 1,609
disclaimer 1: Can't confirm this for CS;
disclaimer 2: I don't work much with text


- In PS 7.0 the javascript documentation does not mention the possibility of having more than one textItem in a given layer.
- Using PS 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.

Reply With Quote top
  #5  
Old 02-24-2005, 04:45 PM
MagiCat MagiCat is offline
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.
Reply With Quote top
  #6  
Old 02-25-2005, 05:24 AM
byRo's Avatar
byRo byRo is offline
Senior Member
 
Join Date: May 2004
Location: Goianésia, Brazil
Posts: 1,609
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.

Reply With Quote top
  #7  
Old 02-25-2005, 09:40 AM
byRo's Avatar
byRo byRo is offline
Senior Member
 
Join Date: May 2004
Location: Goianésia, Brazil
Posts: 1,609
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 09:50 AM. Reason: replied too soon - now I got it
Reply With Quote top
  #8  
Old 02-25-2005, 09:55 AM
DannyRaphael's Avatar
DannyRaphael DannyRaphael is offline
Moderator
 
Join Date: Mar 2002
Location: Near Seattle, Washington, USA
Posts: 6,300
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?
Reply With Quote top
  #9  
Old 02-25-2005, 03:10 PM
byRo's Avatar
byRo byRo is offline
Senior Member
 
Join Date: May 2004
Location: Goianésia, Brazil
Posts: 1,609
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.

Reply With Quote top
  #10  
Old 02-26-2005, 10:54 PM
MagiCat MagiCat is offline
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.
Reply With Quote top
Reply

  RetouchPRO > Tools > Software > Photoshop Scripting


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are Off
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 17 05-22-2011 05:55 PM
help with german Photoshop commands please pure Photoshop Help 9 06-21-2010 03:33 PM
Layer Tutorials..again? zip022 RP Tutorials 21 11-18-2004 11:10 PM
select shape Peg Hidden Power Support 7 08-29-2004 07:10 PM
Help needed understanding these layers. peejay Photo-Based Art 3 01-16-2004 09:15 PM


All times are GMT -6. The time now is 03:05 PM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
Copyright © 2016 Doug Nelson. All Rights Reserved