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

Access Font Pathname through script

New Here ,
May 11, 2017 May 11, 2017

Copy link to clipboard

Copied

I am currently working on a fully automated script, which exports bulks of photoshop-layers and when encountering a Textlayer, the font file should be automatically copied into the export location aswell.

A xml file is also generated in which important the layerinformation  be saved, like bounds, transparency as well as fonts, to be able to recreate and know, which layers had which fonts used

My problem now is, it seems it is only possible to access the font information through layer.textItem.font, which doesnt contain the information i am after.

So for example a textelement uses the font "arial.ttf". The information given by photoshop is "ArialMT", in the actual registry there is no font with this name and for this reason my exporter thoesnt know, which font has to be exported. Same problem with many other fonts, which get "additions" in their name by photoshop. I havent found a way to solve this other than to manually clean up the names, but this doesnt work if the user of the script uses own fonts

Is there any way through javascript to access the actual fontname or filename?

Thanks!.

TOPICS
Actions and scripting

Views

1.5K

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 , May 11, 2017 May 11, 2017

dobe Photoshop has a Fonts collection that contains some information about fonts on your system Photoshop can use.  Fonts are installed into your OS.  Windows installs fonts into its folder "C:\Windows\Fonts\" I do not know how Fonts are installed on Mac s.

"ArialMT" seems to be the PostSsciptName for using  getByName gets this information from Photoshop fonts collection.

var myFont = app.fonts.getByName("ArialMT");

alert("Font family " + myFont.family +"\n"

+ "Font name "  + myFont.name +"\n"

+ "Fon

...

Votes

Translate

Translate
Adobe
Community Expert ,
May 11, 2017 May 11, 2017

Copy link to clipboard

Copied

dobe Photoshop has a Fonts collection that contains some information about fonts on your system Photoshop can use.  Fonts are installed into your OS.  Windows installs fonts into its folder "C:\Windows\Fonts\" I do not know how Fonts are installed on Mac s.

"ArialMT" seems to be the PostSsciptName for using  getByName gets this information from Photoshop fonts collection.

var myFont = app.fonts.getByName("ArialMT");

alert("Font family " + myFont.family +"\n"

+ "Font name "  + myFont.name +"\n"

+ "Font parent " + myFont.parent +"\n"

+ "Font postScriptName " + myFont.postScriptName +"\n"

+ "Font style " + myFont.style +"\n"

+ "Font typename " + myFont.typename );

Capture.jpg

Showing more info is widows file explore does not show and file name for that font.

Capture.jpg

JJMack

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 ,
May 15, 2017 May 15, 2017

Copy link to clipboard

Copied

Perfect, thank you.

Havent thought of that. The getByName function helped me quite a bit.

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
Guide ,
May 11, 2017 May 11, 2017

Copy link to clipboard

Copied

On Windows you could use vbs to get details...

This example will write out details to the desktop.

Set wshShell = WScript.CreateObject("WScript.Shell")

Set wshSysEnv = wshShell.Environment("PROCESS")

sMyFile = "c:" & wshSysEnv("HOMEPATH") & "\Desktop\Fontlist.txt"

Dim objFileSystem, objOutputFile

Dim strOutputFile

Set objFileSystem = CreateObject("Scripting.fileSystemObject")

Set objOutputFile = objFileSystem.CreateTextFile(sMyFile, TRUE)

Dim str

Const HKEY_LOCAL_MACHINE = &H80000002

strComputer = "."

Set objReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & _

strComputer & "\root\default:StdRegProv")

strKeyPath = "Software\Microsoft\Windows NT\CurrentVersion\Fonts"

objReg.EnumValues HKEY_LOCAL_MACHINE, _

strKeyPath,arrEntryNames,arrEntryZZZ

For Each entry in arrEntryNames

str = wshshell.RegRead("HKLM\Software\Microsoft\Windows NT\CurrentVersion\Fonts\" & entry)

       objOutputFile.WriteLine(entry & "," & str)

Next

objOutputFile.Close

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
Enthusiast ,
May 11, 2017 May 11, 2017

Copy link to clipboard

Copied

If you document uses Google fonts, you could maybe download them to you specified filepath.

They are available on GitHub: GitHub - google/fonts: Font files available from Google Fonts

Every font has metadata file with name and font file-name.

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 Beginner ,
Jan 21, 2023 Jan 21, 2023

Copy link to clipboard

Copied

LATEST

Hi!

If You use Mac you can find the name used in Photoshop scripts in the FontBook app panel. 

Search fot the name of the font, then click the 'i' button and it will show you the postScript name (see ScreenShot).

Screenshot 2023-01-21 at 15.57.10.jpg

 

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