Take that file part of the path, and get the chunk until the first period to remove the extension, version numbers, etc. If the extension is not in extensions (default id ('ttf', 'otf')) then answer None >>> path2FontName('/xxx/yyy/zzz/Agency_FB-Compressed.otf') 'Agency_FB-
(path, extensions=None)
| 647 | return scaledPath + fileName + params + '.' + extension |
| 648 | |
| 649 | def path2FontName(path, extensions=None): |
| 650 | """ |
| 651 | Take that file part of the path, and get the chunk until the first |
| 652 | period to remove the extension, version numbers, etc. |
| 653 | If the extension is not in extensions (default id ('ttf', 'otf')) |
| 654 | then answer None |
| 655 | |
| 656 | >>> path2FontName('/xxx/yyy/zzz/Agency_FB-Compressed.otf') |
| 657 | 'Agency_FB-Compressed' |
| 658 | >>> path2FontName('/xxx/yyy/zzz/Agency_FB-Compressed.version01.ufo') is None |
| 659 | True |
| 660 | >>> path2FontName('/xxx/yyy/zzz/Agency_FB-Compressed.version01.ufo', ['ufo']) |
| 661 | 'Agency_FB-Compressed' |
| 662 | >>> path2FontName('#xxx/yyy/zzz/Agency_FB-Bold.0001646411.ttf') |
| 663 | 'Agency_FB-Bold' |
| 664 | """ |
| 665 | if extensions is None: |
| 666 | extensions = ('ttf', 'otf', 'ttc') |
| 667 | if path2Extension(path) in extensions: |
| 668 | name = path2Name(path) |
| 669 | if name is not None: |
| 670 | return name.split('.')[0] |
| 671 | return None |
| 672 | |
| 673 | familyNameParts = re.compile('([A-Za-z]*)') |
| 674 |
no test coverage detected