5 Replies Latest reply on Apr 27, 2015 11:18 AM by Philip Cord

    How to get the name and the path of the font used in photoshop (not textItem.font)


      I'm trying to get the real name of the font and the path, is there a "easy" way to do it ?

      i need to get the font file (*.ttf or *.otf) and copy to the same directory as the psd file, that's why textItem.font doen't work for me.


      thanks in advance

        • 1. Re: How to get the name and the path of the font used in photoshop (not textItem.font)
          c.pfaffenbichler Level 9

          One can get the fontName and fontPostScriptName but I don’t know how they could be used to immediately identify the actual font file on disk.

          I suspect what with the differences of the OS’ and the possible locations of available fonts doing a comprehensive search for the connected files might be quite a hassle.


          Have you done a Forum search here and over on ps-scripts.com ?

          • 2. Re: How to get the name and the path of the font used in photoshop (not textItem.font)
            matias.kiviniemi Level 3

            I would even say what you propose is not allowed/intended behavior of platform fonts. Fonts are very much licensed/DRM-constrained content, i.e. either Apple/Microsoft or the user has a contract on the use of the file (you pay separately for web/app/print use) and redistribution is not permitted even in free fonts. So assuming you want to copy the so it could be distributed with the PSD without careful examination of the terms, you're likely to be on shaky legal ground. I would study if you could for example convert textItems to shapes, etc. to be portable.

            • 3. Re: How to get the name and the path of the font used in photoshop (not textItem.font)
              marqueth1054 Level 1

              Thanks guys for the answers.


              The purpose of this, i'm doing a script that export al the psd assets, and the xml for android projects, but when i use a different font, i have to embed it on the project, so that's why i need the file.


              And yes i already seach on ps-scripts c.pfaffenbichler .

              And we own the fonts we will use so i wont have this kind of problems Matias.

              • 4. Re: How to get the name and the path of the font used in photoshop (not textItem.font)
                matias.kiviniemi Level 3

                Ok. If it's a known set, could you put them in some known shared location and match file names to fontPostScriptName? I mean seems that font's I've installed have kept original name in \Windows\Fonts, but otherwise there is no correlation with the filename. Also tried copying one file in terminal and got "A required privilege is not held by the client.", so likely not possible to do from script even if you could get the filename.

                • 5. Re: How to get the name and the path of the font used in photoshop (not textItem.font)
                  Philip Cord Level 4

                  You could try this as it looks as if you are using Windows.

                  Run the VBS script to create a fontlist file on the desktop.

                  Then run the javaScript on the PSD document.

                  It should copy the fonts to the same folder as the document, it will also create a text file with a list of fonts.

                  It didn't find all the fonts in my test psd maybe because it wasn't in the windows/font folder?




                  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, _
                  For Each entry in arrEntryNames
                  str = wshshell.RegRead("HKLM\Software\Microsoft\Windows NT\CurrentVersion\Fonts\" & entry)
                         objOutputFile.WriteLine(entry & "," & str)




                  #target photoshop;
                  function main(){
                  if(!documents.length) return;
                  var Path = activeDocument.path;
                      alert("This document needs to be saved before running this script!");
                  var FontFile = File(Folder.desktop + "/FontList.txt");
                      alert("You need to run the vbs script first to create the FontList file!");
                  var FontList = new Array();
                      FontFile.open('r') ; 
                     strInputLine =FontFile.readln(); 
                     if (strInputLine.length > 3) inputArray  = strInputLine.split(","); 
                     if(inputArray.length == 2) FontList.push([[inputArray[0]],[inputArray[1]]]);
                  var PSDtextLayers = getNamesPlusIDs();
                  PSDtextLayers = UniqueSortedList(PSDtextLayers);
                  for(var a in PSDtextLayers){
                      for(var f in FontList){
                           var rex = new RegExp;
                           rex = PSDtextLayers[a].toString();
                              var From = new File("/c/windows/fonts/" + FontList[f][1].toString());
                              var To = new File(Path + "/"+  FontList[f][1].toString());
                  var rFonts = new File(Path + "/required Fonts.txt");
                  function UniqueSortedList(ArrayName){
                  var unduped = new Object;
                  for (var i = 0; i < ArrayName.length; i++) {   
                  unduped[ArrayName[i]] = ArrayName[i];
                  var uniques = new Array;for (var k in unduped) {
                  return uniques;
                  function getNamesPlusIDs(){ 
                     var ref = new ActionReference(); 
                     ref.putProperty( charIDToTypeID( "Prpr" ), charIDToTypeID( 'NmbL' ));
                     ref.putEnumerated( charIDToTypeID('Dcmn'), charIDToTypeID('Ordn'), charIDToTypeID('Trgt') ); 
                     var count = executeActionGet(ref).getInteger(charIDToTypeID('NmbL')) +1; 
                     var Names=[];
                  var i = 0; }catch(e){ var i = 1; };
                         if(i == 0) continue;
                          ref = new ActionReference(); 
                          ref.putIndex( charIDToTypeID( 'Lyr ' ), i );
                          var desc = executeActionGet(ref);
                          var layerName = desc.getString(charIDToTypeID( 'Nm  ' ));
                          var Id = desc.getInteger(stringIDToTypeID( 'layerID' ));
                          if(layerName.match(/^<\/Layer group/) ) continue;
                          if (desc.hasKey(stringIDToTypeID('textKey'))){
                              desc = desc.getObjectValue(stringIDToTypeID('textKey'));
                              desc = desc.getList(stringIDToTypeID('textStyleRange')).getObjectValue(0).getObjectValue(stringIDToTypeID('textStyle'));
                              var postScriptName = desc.getString( stringIDToTypeID('fontPostScriptName'));      
                  return Names;