Skip to main content
Participant
October 14, 2022
Answered

insert glyph by GID photoshop extendscript

  • October 14, 2022
  • 3 replies
  • 820 views

Goal :  to insert a character Glyph using script for Photoshop. 

Background:

I have read and tried to de-construct: 

https://creativepro.com/insert-a-character-by-unicode-or-gid/

but these are for framemaker/indesign

Then,

https://community.adobe.com/t5/photoshop-ecosystem-discussions/photoshop-script-to-change-the-font-for-superscript-in-glyph/m-p/12181932

this one changes style, but I need to insert a glyph in a certain font - it happens to be number 55 in this font  and is a different version of character "z" . the unicode character is not unique. 

I also tried recording an action, and then used Xtools kit to convert to javascript. 

However, this part of the script that inserts the character shows as 

desc2.putString(cTID('Txt '), "���or");

which does not work. 

In the Adobe extendscript docs, I see things about glyph scaling only. 

There must be some ancient actionscript kungfu that will work on this. 

I don't need a full function - I can handle that, I just need the nugget of code that chooses the glyph. 

thanks

 

This topic has been closed for replies.
Correct answer Stephen Marsh

Assuming you have the Adobe cloud font "Myriad Pro Regular", which has a PostScript font name of "MyriadPro-Regular" the following works for me, just escape the Unicode with \u before the number shown in the glyphs panel:

 

var LayerRef = activeDocument.artLayers.add();
LayerRef.kind = LayerKind.TEXT;
var textRef = LayerRef.textItem;
textRef.contents = "\u00A9"; // Unicode copyright symbol
textRef.position = new Array(100, 100);
app.preferences.rulerUnits = Units.POINTS;
textRef.size = 100; // Font size
textRef.font = 'MyriadPro-Regular'; // PostScript font name
textRef.justification = Justification.LEFT;
var textColor = new SolidColor;
textColor.rgb.red = 0;
textColor.rgb.green = 0;
textColor.rgb.blue = 0;
textRef.color = textColor;
app.preferences.rulerUnits = Units.PIXELS;

 

 

 

Edit: ScriptingListener records rubbish:

 

var desc12505 = new ActionDescriptor();
var idtextKey = stringIDToTypeID( "textKey" );
desc12505.putString( idtextKey, """�""" );

 

But changing it to the following also works:

 

var desc12505 = new ActionDescriptor();
var idtextKey = stringIDToTypeID( "textKey" );
desc12505.putString( idtextKey, """\u00A9""" );

 

(snippet, not full code)

3 replies

Stephen Marsh
Community Expert
Stephen MarshCommunity ExpertCorrect answer
Community Expert
October 15, 2022

Assuming you have the Adobe cloud font "Myriad Pro Regular", which has a PostScript font name of "MyriadPro-Regular" the following works for me, just escape the Unicode with \u before the number shown in the glyphs panel:

 

var LayerRef = activeDocument.artLayers.add();
LayerRef.kind = LayerKind.TEXT;
var textRef = LayerRef.textItem;
textRef.contents = "\u00A9"; // Unicode copyright symbol
textRef.position = new Array(100, 100);
app.preferences.rulerUnits = Units.POINTS;
textRef.size = 100; // Font size
textRef.font = 'MyriadPro-Regular'; // PostScript font name
textRef.justification = Justification.LEFT;
var textColor = new SolidColor;
textColor.rgb.red = 0;
textColor.rgb.green = 0;
textColor.rgb.blue = 0;
textRef.color = textColor;
app.preferences.rulerUnits = Units.PIXELS;

 

 

 

Edit: ScriptingListener records rubbish:

 

var desc12505 = new ActionDescriptor();
var idtextKey = stringIDToTypeID( "textKey" );
desc12505.putString( idtextKey, """�""" );

 

But changing it to the following also works:

 

var desc12505 = new ActionDescriptor();
var idtextKey = stringIDToTypeID( "textKey" );
desc12505.putString( idtextKey, """\u00A9""" );

 

(snippet, not full code)

Participant
October 17, 2022

thank you @Bojan Živković11378569 @Chuck Uebele @Stephen Marsh .

the font name is Felisha. the glyph I want does not have a unicode value, unlike the regular letter "z" 

 

I tried using Fontforge to copy/pastee the characters to a spot in the table with a unicode value, then re-generate the font as a new file and install. That didn't work I don't see the characters I made in the Adobe glyph table, nor does the script Stephen posted (using new unicode) work. I know very little about font creation, likely did something wrong. I will try other font creators to see if I can force these characters to have a "proper" unicode reference.

 

my fontforge attempt:

felisha font as is

 

copy pasted into an empty spot

 

 

 

Stephen Marsh
Community Expert
Community Expert
October 17, 2022

I only know how to do this with Unicode.

 

Looking at the following, it is possible to script in InDesign, however, I'm not sure if that could be rewritten for Photoshop or not (Photoshop's text scripting capabilities are not as strong).

 

https://creativepro.com/insert-a-character-by-unicode-or-gid/

 

https://creativepro.com/downloads/1254_floralheart_minionpro_GIDscript.jsx

Chuck Uebele
Community Expert
Community Expert
October 15, 2022

Can you provide a screenshot of this glyph and what font you want to use? Is this the only one you want to use and the only font? 

Yea scripts for ID and other programs are very different. I wrote a few for ID. It took a lot of research. Seems like if you get the basics of what the unicode and font are, it should hopefully work with how to apply text to a text layer, but I haven't attempted this.

Bojan Živković11378569
Community Expert
Community Expert
October 15, 2022

I will tag some scripters that may be able to help you @c.pfaffenbichler @Stephen Marsh @Chuck Uebele