Functions¶
src.utils.fonts.register_font(ps_app: PhotoshopHandler, font_path: str) -> bool
¶
Add FontResource using given font file, refresh Photoshop fonts.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ps_app
|
PhotoshopHandler
|
Photoshop application object. |
required |
font_path
|
str
|
Path to compatible font file. |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True if succeeded, False if failed. |
Source code in src\utils\fonts.py
src.utils.fonts.unregister_font(ps_app: PhotoshopHandler, font_path: str) -> bool
¶
Remove FontResource using given font file, refresh Photoshop fonts.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ps_app
|
PhotoshopHandler
|
Photoshop application object. |
required |
font_path
|
str
|
Path to compatible font file. |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True if succeeded, False if failed. |
Source code in src\utils\fonts.py
src.utils.fonts.get_ps_font_dict(ps_app: PhotoshopHandler) -> dict[str, str]
¶
Gets a dictionary of every font accessible in Photoshop.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ps_app
|
PhotoshopHandler
|
Photoshop application object. |
required |
Returns:
| Type | Description |
|---|---|
dict[str, str]
|
Dictionary with postScriptName as key, display name as value. |
Source code in src\utils\fonts.py
src.utils.fonts.get_document_fonts(ps_app: PhotoshopHandler, container: Optional[type[LayerContainer]] = None, fonts: Optional[dict] = None, ps_fonts: Optional[dict] = None) -> dict
¶
Get a list of all fonts used in a given Photoshop Document or LayerSet.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ps_app
|
PhotoshopHandler
|
Photoshop application object. |
required |
container
|
type[LayerContainer] | None
|
Photoshop Document or LayerSet object. |
None
|
fonts
|
dict | None
|
Existing fonts list to build onto. |
None
|
ps_fonts
|
dict | None
|
Pre-computed Photoshop fonts list. |
None
|
Returns:
| Type | Description |
|---|---|
dict
|
Unique list of font names. |
Source code in src\utils\fonts.py
src.utils.fonts.get_font_details(path: str) -> Optional[tuple[str, FontDetails]]
¶
Gets the font name and postscript name for a given font file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str
|
Path to ttf or otf file. |
required |
Returns:
| Type | Description |
|---|---|
tuple[str, FontDetails] | None
|
Tuple containing name and postscript name. |
Source code in src\utils\fonts.py
src.utils.fonts.get_fonts_from_folder(folder: str) -> dict[str, FontDetails]
¶
Return a dictionary of font details for the fonts contained in a target directory.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
folder
|
str
|
Directory containing font files to read (supports TTF and OTF fonts). |
required |
Returns:
| Type | Description |
|---|---|
dict[str, FontDetails]
|
Dictionary of FontDetails. |
Source code in src\utils\fonts.py
src.utils.fonts.get_installed_fonts_dict() -> dict[str, FontDetails]
¶
Gets a dictionary of every font installed by the user.
Returns:
| Type | Description |
|---|---|
dict[str, FontDetails]
|
Dictionary with postScriptName as key, and tuple of display name and version as value. |
Source code in src\utils\fonts.py
src.utils.fonts.get_outdated_fonts(fonts: dict[str, FontDetails], missing: Optional[dict[str, FontDetails]] = None) -> dict[str, FontDetails]
¶
Compares the version of each font given against installed fonts.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
fonts
|
dict[str, FontDetails]
|
A dictionary of fonts to check against installed fonts. |
required |
missing
|
dict[str, FontDetails] | None
|
An optional dictionary of fonts Photoshop couldn't locate, check in install dir. |
None
|
Returns:
| Type | Description |
|---|---|
dict[str, FontDetails]
|
A dict of fonts with outdated version number. Dict contains the newer version. |
Source code in src\utils\fonts.py
src.utils.fonts.get_missing_fonts(ps_app: PhotoshopHandler, fonts: dict[str, FontDetails]) -> tuple[dict[str, FontDetails], dict[str, FontDetails]]
¶
Checks each font to see if it's present in the Photoshop font list.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ps_app
|
PhotoshopHandler
|
Photoshop application object. |
required |
fonts
|
dict[str, FontDetails]
|
A dictionary of fonts to check for. |
required |
Returns:
| Type | Description |
|---|---|
tuple[dict[str, FontDetails], dict[str, FontDetails]]
|
Tuple containing a dictionary of fonts missing and fonts found. |
Source code in src\utils\fonts.py
src.utils.fonts.check_app_fonts(ps_app: PhotoshopHandler, folders: list[str]) -> tuple[dict[str, FontDetails], dict[str, FontDetails]]
¶
Checks each font in a folder to see if it is installed or outdated.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ps_app
|
PhotoshopHandler
|
Photoshop application object. |
required |
folders
|
list[str]
|
Folder paths containing fonts to check. |
required |
Returns:
| Type | Description |
|---|---|
tuple[dict[str, FontDetails], dict[str, FontDetails]]
|
A tuple containing a dict of missing fonts and a dict of outdated fonts. |