Answers the Font instance, that connects to the fontPath. Note that there is no check if there is already anothe Font created on that path, as for PageBot purposes it is most likely for reading only. >>> from pagebot.fonttoolbox.fontpaths import getTestFontsPath >>> fontPath = getTe
(fontOrPath, lazy=True)
| 83 | return None |
| 84 | |
| 85 | def getFont(fontOrPath, lazy=True): |
| 86 | """Answers the Font instance, that connects to the fontPath. Note that |
| 87 | there is no check if there is already anothe Font created on that path, |
| 88 | as for PageBot purposes it is most likely for reading only. |
| 89 | |
| 90 | >>> from pagebot.fonttoolbox.fontpaths import getTestFontsPath |
| 91 | >>> fontPath = getTestFontsPath() |
| 92 | >>> path = fontPath + '/fontbureau/Amstelvar-Roman-VF.ttf' |
| 93 | >>> fontName = path2FontName(path) |
| 94 | >>> font = getFont(path) |
| 95 | >>> font.path == path |
| 96 | True |
| 97 | >>> # Answer the same font, if it is already one. |
| 98 | >>> font == getFont(font) |
| 99 | True |
| 100 | """ |
| 101 | if isinstance(fontOrPath, Font): |
| 102 | return fontOrPath |
| 103 | |
| 104 | fontOrPath = asFontPath(fontOrPath) # Find the real path, case corrected. |
| 105 | if not fontOrPath: |
| 106 | return None |
| 107 | |
| 108 | try: |
| 109 | return Font(fontOrPath, lazy=lazy) |
| 110 | except TTLibError: |
| 111 | # Could not open font, due to bad font file. |
| 112 | return None |
| 113 | |
| 114 | def findFonts(pattern, lazy=True): |
| 115 | """Answers a list of Font instances where the pattern fits the font path. |
no test coverage detected