• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

insert glyph by GID photoshop extendscript

New Here ,
Oct 14, 2022 Oct 14, 2022

Copy link to clipboard

Copied

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-f...

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

 

TOPICS
Actions and scripting , Windows

Views

554

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Oct 15, 2022 Oct 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; // F
...

Votes

Translate

Translate
Adobe
Community Expert ,
Oct 14, 2022 Oct 14, 2022

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 14, 2022 Oct 14, 2022

Copy link to clipboard

Copied

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 15, 2022 Oct 15, 2022

Copy link to clipboard

Copied

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;

 

 

2022-10-15_22-02-21.png

 

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)

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Oct 17, 2022 Oct 17, 2022

Copy link to clipboard

Copied

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

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

 

offscript_0-1666037294822.png

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

offscript_2-1666040688186.png

 

copy pasted into an empty spot

offscript_1-1666040637928.png

 

 

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 17, 2022 Oct 17, 2022

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 17, 2022 Oct 17, 2022

Copy link to clipboard

Copied

I don't have access to that font, and not sure what font that I do have that would reproduce what you're getting. Odd that it doesn't have a unicode number.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Oct 21, 2022 Oct 21, 2022

Copy link to clipboard

Copied

LATEST

I ended up editing the font, copying the glyphs to locations with unicode, and then referencing that unicode as pointed out by Stephen. thanks. 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines