Skip to content

Instantly share code, notes, and snippets.

@meltingice
Last active August 2, 2019 10:46
Show Gist options
  • Save meltingice/7ecb00f6081c8f3ac51d9791865d02ca to your computer and use it in GitHub Desktop.
Save meltingice/7ecb00f6081c8f3ac51d9791865d02ca to your computer and use it in GitHub Desktop.
// In the TypeTool, the StyleRun defines all of the different styles
// that are applied to a text layer. Each style is defined in the RunArray,
// and the character indices for each style is defined in the RunLengthArray,
// i.e. the first style exists for 7 characters, the 2nd for 7 characters,
// and the third for 10 characters.
> typeTool.engineData.EngineDict.StyleRun
{ DefaultRunData: { StyleSheet: { StyleSheetData: {} } },
RunArray:
[ { StyleSheet: [Object] },
{ StyleSheet: [Object] },
{ StyleSheet: [Object] } ],
RunLengthArray: [ 7, 7, 10 ],
IsJoinable: 2 }
// The RunArray is of a variable length depending on how many
// different styles are in the block of text. There will be
// an array item for every different font setting, which correlates
// to the RunLengthArray above.
> typeTool.engineData.EngineDict.StyleRun.RunArray
[ { StyleSheet: { StyleSheetData: [Object] } },
{ StyleSheet: { StyleSheetData: [Object] } },
{ StyleSheet: { StyleSheetData: [Object] } } ]
// These are the fonts that are defined for this text layer. Just like
// the web, Photoshop defines default fallback fonts in case the font
// that was used is not available on the computer that's viewing the file
// (the last 2 fonts in the list).
> typeTool.fonts()
[ 'AndaleMono',
'HelveticaNeue-Light',
'AdobeInvisFont',
'MyriadPro-Regular' ]
// Looking at the contents of one item in the RunArray, we can
// see the Font property. It's a number that specifies the index
// of the font being used in the font array above. So we can see that
// this particular character range is using HelveticaNeue-Light, and by
// also referencing the RunLengthArray, we know that the first 7 characters
// are using this font.
> typeTool.engineData.EngineDict.StyleRun.RunArray[0]
{ StyleSheet:
{ StyleSheetData:
{ Font: 1,
FontSize: 33,
FauxBold: false,
FauxItalic: false,
AutoLeading: true,
Leading: 27.6,
HorizontalScale: 1,
VerticalScale: 1,
Tracking: 0,
AutoKerning: true,
Kerning: 0,
BaselineShift: 0,
FontCaps: 0,
FontBaseline: 0,
Underline: false,
Strikethrough: false,
Ligatures: true,
DLigatures: false,
BaselineDirection: 1,
Tsume: 0,
StyleRunAlignment: 2,
Language: 0,
NoBreak: false,
FillColor: [Object],
StrokeColor: [Object],
FillFlag: true,
StrokeFlag: false,
FillFirst: false,
YUnderline: 1,
OutlineWidth: 0.99987,
CharacterDirection: 0,
HindiNumbers: false,
Kashida: 1,
DiacriticPos: 2 } } }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment