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
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
|
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
69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 |
|
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
101 102 103 104 105 106 107 108 109 110 111 112 113 114 |
|
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
117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 |
|
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
166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 |
|
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
185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 |
|
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
202 203 204 205 206 207 208 209 210 211 212 213 214 215 |
|
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
223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 |
|
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
258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 |
|
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. |
Source code in src\utils\fonts.py
285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 |
|