Skip to main content
Inspiring
February 19, 2021
해결됨

List of missing fonts in Photoshop (.psd images)

  • February 19, 2021
  • 1 답변
  • 861 조회

Hi All,

 

I am trying to find the "missing font list" from the *.psd file (Photoshop) using the javascript. Please help me to find the missing font list.

 

Thanks,
Magesh

이 주제는 답변이 닫혔습니다.
최고의 답변: jazz-y

missing fonts in the stylesheet are marked with fontAvailable == false

 

#target photoshop

var s2t = stringIDToTypeID,
    missingFontList = {};

(r = new ActionReference()).putProperty(s2t('property'), p = s2t('numberOfLayers'));
r.putEnumerated(s2t('document'), s2t('ordinal'), s2t('targetEnum'));
var len = executeActionGet(r).getInteger(p);

for (var i = 1; i <= len; i++) {
    (r = new ActionReference()).putProperty(s2t('property'), p = s2t('textKey'));
    r.putIndex(s2t('layer'), i);
    if (executeActionGet(r).hasKey(p)) {
        var sList = executeActionGet(r).getObjectValue(p).getList(s2t('textStyleRange'));
        for (var x = 0; x < sList.count; x++) {
            var k = sList.getObjectValue(x).getObjectValue(s2t('textStyle'))
            if (k.hasKey(s2t('fontAvailable'))) {
                if (!k.getBoolean(s2t('fontAvailable'))) {
                    missingFontList[k.getString(s2t('fontPostScriptName'))] = false
                }
            }
        }
    }
}

alert(missingFontList.toSource())

 

(I think it makes no sense to check the defaultStyle of the paragraph and the baseStyle of the textStyle)

 

1 답변

c.pfaffenbichler
Community Expert
Community Expert
February 20, 2021

I don’t recall a font list in the document properties. 

Which, if I’m not mistaken, would mean having to process the Type Layers – I am not sure if missing fonts can be directly recognized or if one would have to compare a list of all fonts with the list of fonts the application has access to. 

 

@r-bin , @Kukurykus , @jazz-y , please forgive the intrusion, but you seem to be some of the most active current posters when it comes to Photoshop Scripting – do you have ideas on this issue? (Or recall an existing Script for the task? ) 

jazz-y답변
Legend
February 20, 2021

missing fonts in the stylesheet are marked with fontAvailable == false

 

#target photoshop

var s2t = stringIDToTypeID,
    missingFontList = {};

(r = new ActionReference()).putProperty(s2t('property'), p = s2t('numberOfLayers'));
r.putEnumerated(s2t('document'), s2t('ordinal'), s2t('targetEnum'));
var len = executeActionGet(r).getInteger(p);

for (var i = 1; i <= len; i++) {
    (r = new ActionReference()).putProperty(s2t('property'), p = s2t('textKey'));
    r.putIndex(s2t('layer'), i);
    if (executeActionGet(r).hasKey(p)) {
        var sList = executeActionGet(r).getObjectValue(p).getList(s2t('textStyleRange'));
        for (var x = 0; x < sList.count; x++) {
            var k = sList.getObjectValue(x).getObjectValue(s2t('textStyle'))
            if (k.hasKey(s2t('fontAvailable'))) {
                if (!k.getBoolean(s2t('fontAvailable'))) {
                    missingFontList[k.getString(s2t('fontPostScriptName'))] = false
                }
            }
        }
    }
}

alert(missingFontList.toSource())

 

(I think it makes no sense to check the defaultStyle of the paragraph and the baseStyle of the textStyle)

 

c.pfaffenbichler
Community Expert
Community Expert
February 21, 2021

Impressive, thanks for checking into this thread!