Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(TextItem.font): Change font to a read/write string property #322

Merged
merged 2 commits into from
Nov 20, 2023

Conversation

Investigamer
Copy link
Contributor

@Investigamer Investigamer commented Nov 16, 2023

Problem

TextItem.font is currently returned as an inoperable TextFont object.

Solution

Return the raw TextItem.app.font which is a string representing the postScriptName of the TextItem's font. This is the normal behavior according to the Photoshop Javascript Reference. Documentation segment attached below.

Note

To set the font of a TextItem using a font existing in Photoshop, you can find the font by name using the Application.fonts collection and pass its postScriptName to TextItem.font, or provide the postScriptName manually if you know it.

# TextFont from fonts collection
arial_bold = app.fonts.getByName('Arial Bold')
text_layer.textItem.font = arial_bold.postScriptName

# Providing a postScriptName manually
text_layer.textItem.font = 'Arial-Bold'

image

Other Changes

  • Added some type annotations
  • Improved some docstrings

TextItem.font cannot be returned as a TextFont object (see Photoshop CC Javascript reference)

Signed-off-by: MrTeferi <[email protected]>
@loonghao loonghao merged commit 2a1a071 into loonghao:main Nov 20, 2023
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants