Copy link to clipboard
Copied
Hi Team,
The above image contain 4 types fonts, and need to script, how to get selected font content by using font name(i.e: If need to times font the alert will say the collected times font content),
Kindly help me this.
Thanks
Balaji
Copy link to clipboard
Copied
I do not understand the description.
What do you want as the result of the Script?
Copy link to clipboard
Copied
Need to get content using font names,
If the font description "Myriad pro" is given. the tool alert will need to display all the myriad pro font contents.
Thanks
Copy link to clipboard
Copied
Please provide a clearer description of the process including screenshots or sketches to illustrate the file structure, the input-dialog and the output.
Copy link to clipboard
Copied
Select the text layer, run the code, and look at the contents of the textKey object. Each style contains from and to marks (which correspond to the characters in your text), and the style also contains information about the fonts within these boundaries (except if the default style is applied). I hope you can handle the handling of the object yourself.
s2t = stringIDToTypeID;
(r = new ActionReference()).putProperty(s2t('property'), p=s2t('textKey'));
r.putEnumerated(s2t('layer'), s2t('ordinal'), s2t('targetEnum'));
(d = new ActionDescriptor()).putObject(s2t('object'), s2t('object'), executeActionGet(r));
eval ('textKey = ' +executeAction(s2t('convertJSONdescriptor'), d).getString(s2t('json')));
$.writeln(textKey.toSource());
{
"_obj": "object",
"textKey": {
"_obj": "textLayer",
"antiAlias": {
"_enum": "antiAliasType",
"_value": "antiAliasSharp"
},
"boundingBox": {
"_obj": "boundingBox",
"bottom": {
"_unit": "pointsUnit",
"_value": 330.0289306640625
},
"left": {
"_unit": "pointsUnit",
"_value": 7.096435546875
},
"right": {
"_unit": "pointsUnit",
"_value": 418.7510986328125
},
"top": {
"_unit": "pointsUnit",
"_value": 1.554901123046875
}
},
"bounds": {
"_obj": "bounds",
"bottom": {
"_unit": "pointsUnit",
"_value": 532.5
},
"left": {
"_unit": "pointsUnit",
"_value": 0
},
"right": {
"_unit": "pointsUnit",
"_value": 424.5
},
"top": {
"_unit": "pointsUnit",
"_value": -9.9071044921875
}
},
"kerningRange": [],
"orientation": {
"_enum": "orientation",
"_value": "horizontal"
},
"paragraphStyleRange": [
{
"_obj": "paragraphStyleRange",
"from": 0,
"paragraphStyle": {
"_obj": "paragraphStyle",
"align": {
"_enum": "alignmentType",
"_value": "center"
},
"autoLeadingPercentage": 1.75,
"hyphenate": true,
"hyphenateCapitalized": true,
"hyphenateLimit": 2,
"hyphenatePostLength": 3,
"hyphenatePreLength": 3,
"hyphenateWordSize": 8,
"hyphenationZone": 36,
"justificationGlyphDesired": 1,
"justificationGlyphMaximum": 1,
"justificationGlyphMinimum": 1,
"justificationLetterDesired": 0,
"justificationLetterMaximum": 0,
"justificationLetterMinimum": 0,
"justificationWordDesired": 1,
"justificationWordMaximum": 1.3300000429153442,
"justificationWordMinimum": 0.800000011920929,
"leadingType": {
"_enum": "leadingType",
"_value": "leadingAbove"
},
"styleSheetHasParent": true
},
"to": 11
},
{
"_obj": "paragraphStyleRange",
"from": 11,
"paragraphStyle": {
"_obj": "paragraphStyle",
"align": {
"_enum": "alignmentType",
"_value": "center"
},
"autoLeadingPercentage": 1.75,
"hyphenate": true,
"hyphenateCapitalized": true,
"hyphenateLimit": 2,
"hyphenatePostLength": 3,
"hyphenatePreLength": 3,
"hyphenateWordSize": 8,
"hyphenationZone": 36,
"justificationGlyphDesired": 1,
"justificationGlyphMaximum": 1,
"justificationGlyphMinimum": 1,
"justificationLetterDesired": 0,
"justificationLetterMaximum": 0,
"justificationLetterMinimum": 0,
"justificationWordDesired": 1,
"justificationWordMaximum": 1.3300000429153442,
"justificationWordMinimum": 0.800000011920929,
"leadingType": {
"_enum": "leadingType",
"_value": "leadingAbove"
},
"styleSheetHasParent": true
},
"to": 17
},
{
"_obj": "paragraphStyleRange",
"from": 17,
"paragraphStyle": {
"_obj": "paragraphStyle",
"align": {
"_enum": "alignmentType",
"_value": "center"
},
"autoLeadingPercentage": 1.75,
"hyphenate": true,
"hyphenateCapitalized": true,
"hyphenateLimit": 2,
"hyphenatePostLength": 3,
"hyphenatePreLength": 3,
"hyphenateWordSize": 8,
"hyphenationZone": 36,
"justificationGlyphDesired": 1,
"justificationGlyphMaximum": 1,
"justificationGlyphMinimum": 1,
"justificationLetterDesired": 0,
"justificationLetterMaximum": 0,
"justificationLetterMinimum": 0,
"justificationWordDesired": 1,
"justificationWordMaximum": 1.3300000429153442,
"justificationWordMinimum": 0.800000011920929,
"leadingType": {
"_enum": "leadingType",
"_value": "leadingAbove"
},
"styleSheetHasParent": true
},
"to": 23
}
],
"textClickPoint": {
"_obj": "paint",
"horizontal": {
"_unit": "percentUnit",
"_value": 29.21875
},
"vertical": {
"_unit": "percentUnit",
"_value": 18.5
}
},
"textGridding": {
"_enum": "textGridding",
"_value": "none"
},
"textKey": "MYRIAD PRO\rTIMES\rARIAL",
"textShape": [
{
"_obj": "textShape",
"bounds": {
"_obj": "rectangle",
"bottom": 532.5,
"left": 0,
"right": 424.5,
"top": 0
},
"char": {
"_enum": "char",
"_value": "box"
},
"columnCount": 1,
"columnGutter": {
"_unit": "pointsUnit",
"_value": 0
},
"firstBaselineMinimum": {
"_unit": "pointsUnit",
"_value": 0
},
"frameBaselineAlignment": {
"_enum": "frameBaselineAlignment",
"_value": "alignByAscent"
},
"orientation": {
"_enum": "orientation",
"_value": "horizontal"
},
"rowCount": 1,
"rowGutter": {
"_unit": "pointsUnit",
"_value": 0
},
"rowMajorOrder": true,
"spacing": {
"_unit": "pointsUnit",
"_value": 0
},
"transform": {
"_obj": "transform",
"tx": 0,
"ty": 0,
"xx": 1,
"xy": 0,
"yx": 0,
"yy": 1
}
}
],
"textStyleRange": [
{
"_obj": "textStyleRange",
"from": 0,
"textStyle": {
"_obj": "textStyle",
"baseParentStyle": {
"_obj": "textStyle",
"alternateLigatures": false,
"altligature": false,
"autoKern": {
"_enum": "autoKern",
"_value": "metricsKern"
},
"autoLeading": true,
"baseline": {
"_enum": "baseline",
"_value": "normal"
},
"baselineDirection": {
"_enum": "baselineDirection",
"_value": "rotated"
},
"baselineShift": {
"_unit": "pointsUnit",
"_value": 0
},
"characterRotation": 0,
"color": {
"_obj": "RGBColor",
"blue": 0,
"grain": 0,
"red": 0
},
"connectionForms": false,
"contextualLigatures": false,
"diacVPos": {
"_enum": "diacVPos",
"_value": "diacVPosOpenType"
},
"diacXOffset": {
"_unit": "pointsUnit",
"_value": 0
},
"diacYOffset": {
"_unit": "pointsUnit",
"_value": 0
},
"digitSet": {
"_enum": "digitSet",
"_value": "defaultDigits"
},
"dirOverride": {
"_enum": "dirOverride",
"_value": "dirOverrideDefault"
},
"enableWariChu": false,
"figureStyle": {
"_enum": "figureStyle",
"_value": "normal"
},
"fill": true,
"fillFirst": true,
"fillOverPrint": false,
"fontAvailable": true,
"fontCaps": {
"_enum": "fontCaps",
"_value": "normal"
},
"fontName": "Myriad Pro",
"fontPostScriptName": "MyriadPro-Regular",
"fontScript": 0,
"fontStyleName": "Regular",
"fontTechnology": 0,
"fractions": false,
"gridAlignment": {
"_enum": "gridAlignment",
"_value": "roman"
},
"horizontalScale": 100,
"impliedBaselineShift": {
"_unit": "pointsUnit",
"_value": 0
},
"impliedFontSize": {
"_unit": "pointsUnit",
"_value": 12
},
"italics": false,
"japaneseAlternate": {
"_enum": "japaneseAlternate",
"_value": "defaultForm"
},
"jiDori": 0,
"justificationAlternates": false,
"kana": false,
"kashidas": {
"_enum": "kashidas",
"_value": "kashidaDefault"
},
"leftAki": -1,
"ligature": true,
"lineCap": {
"_enum": "lineCap",
"_value": "buttCap"
},
"lineDashoffset": 0,
"lineJoin": {
"_enum": "lineJoin",
"_value": "miterJoin"
},
"lineWidth": {
"_unit": "pointsUnit",
"_value": 1
},
"markYDistFromBaseline": {
"_unit": "pointsUnit",
"_value": 100
},
"miterLimit": {
"_unit": "pointsUnit",
"_value": 4
},
"mojiZume": 0,
"noBreak": false,
"oldStyle": false,
"ordinals": false,
"ornaments": false,
"otbaseline": {
"_enum": "otbaseline",
"_value": "normal"
},
"proportionalMetrics": false,
"rightAki": -1,
"ruby": false,
"size": {
"_unit": "pointsUnit",
"_value": 12
},
"strikethrough": {
"_enum": "strikethrough",
"_value": "strikethroughOff"
},
"stroke": false,
"strokeColor": {
"_obj": "RGBColor",
"blue": 0,
"grain": 0,
"red": 0
},
"strokeOverPrint": false,
"stylisticAlternates": false,
"stylisticSets": 0,
"swash": false,
"syntheticBold": false,
"syntheticItalic": false,
"tcyLeftRight": 0,
"tcyUpDown": 0,
"textLanguage": {
"_enum": "textLanguage",
"_value": "englishLanguage"
},
"titling": false,
"tracking": 0,
"underline": {
"_enum": "underline",
"_value": "underlineOff"
},
"underlineOffset": {
"_unit": "pointsUnit",
"_value": 0
},
"verticalScale": 100,
"wariChuCount": 2,
"wariChuJustification": {
"_enum": "wariChuJustification",
"_value": "wariChuAutoJustify"
},
"wariChuLineGap": 0,
"wariChuOrphan": 2,
"wariChuScale": 0.5,
"wariChuWidow": 2
},
"color": {
"_obj": "RGBColor",
"blue": 255,
"grain": 150.0116792321205,
"red": 0.0038910505827516317
},
"digitSet": {
"_enum": "digitSet",
"_value": "defaultDigits"
},
"fontAvailable": true,
"fontName": "Myriad Pro",
"fontPostScriptName": "MyriadPro-Regular",
"fontScript": 0,
"fontStyleName": "Regular",
"fontTechnology": 0,
"impliedFontSize": {
"_unit": "pointsUnit",
"_value": 78
},
"markYDistFromBaseline": {
"_unit": "pointsUnit",
"_value": 24
},
"otbaseline": {
"_enum": "otbaseline",
"_value": "normal"
},
"size": {
"_unit": "pointsUnit",
"_value": 78
},
"styleSheetHasParent": true,
"textLanguage": {
"_enum": "textLanguage",
"_value": "englishLanguage"
}
},
"to": 11
},
{
"_obj": "textStyleRange",
"from": 11,
"textStyle": {
"_obj": "textStyle",
"color": {
"_obj": "RGBColor",
"blue": 255,
"grain": 150.0116792321205,
"red": 0.0038910505827516317
},
"digitSet": {
"_enum": "digitSet",
"_value": "defaultDigits"
},
"fontAvailable": true,
"fontName": "Times New Roman",
"fontPostScriptName": "TimesNewRomanPSMT",
"fontScript": 0,
"fontStyleName": "Regular",
"fontTechnology": 1,
"impliedFontSize": {
"_unit": "pointsUnit",
"_value": 78
},
"markYDistFromBaseline": {
"_unit": "pointsUnit",
"_value": 24
},
"otbaseline": {
"_enum": "otbaseline",
"_value": "normal"
},
"size": {
"_unit": "pointsUnit",
"_value": 78
},
"styleSheetHasParent": true,
"textLanguage": {
"_enum": "textLanguage",
"_value": "englishLanguage"
}
},
"to": 17
},
{
"_obj": "textStyleRange",
"from": 17,
"textStyle": {
"_obj": "textStyle",
"color": {
"_obj": "RGBColor",
"blue": 255,
"grain": 150.0116792321205,
"red": 0.0038910505827516317
},
"digitSet": {
"_enum": "digitSet",
"_value": "defaultDigits"
},
"fontAvailable": true,
"fontName": "Arial",
"fontPostScriptName": "ArialMT",
"fontScript": 0,
"fontStyleName": "Regular",
"fontTechnology": 1,
"impliedFontSize": {
"_unit": "pointsUnit",
"_value": 78
},
"markYDistFromBaseline": {
"_unit": "pointsUnit",
"_value": 24
},
"otbaseline": {
"_enum": "otbaseline",
"_value": "normal"
},
"size": {
"_unit": "pointsUnit",
"_value": 78
},
"styleSheetHasParent": true,
"textLanguage": {
"_enum": "textLanguage",
"_value": "englishLanguage"
}
},
"to": 23
}
],
"warp": {
"_obj": "warp",
"warpPerspective": 0,
"warpPerspectiveOther": 0,
"warpRotate": {
"_enum": "orientation",
"_value": "horizontal"
},
"warpStyle": {
"_enum": "warpStyle",
"_value": "warpNone"
},
"warpValue": 0
}
}
}