>>> from pagebot.toolbox.units import pt, em >>> getLineHeight(em(1.5), pt(12)) 18 >>> getLineHeight(pt(15), pt(12)) 15 >>> getLineHeight(pt(19), None) 19 >>> getLineHeight(15, pt(16)) 240
(leading, fontSize)
| 208 | return fontPath |
| 209 | |
| 210 | def getLineHeight(leading, fontSize): |
| 211 | """ |
| 212 | |
| 213 | >>> from pagebot.toolbox.units import pt, em |
| 214 | >>> getLineHeight(em(1.5), pt(12)) |
| 215 | 18 |
| 216 | >>> getLineHeight(pt(15), pt(12)) |
| 217 | 15 |
| 218 | >>> getLineHeight(pt(19), None) |
| 219 | 19 |
| 220 | >>> getLineHeight(15, pt(16)) |
| 221 | 240 |
| 222 | """ |
| 223 | assert leading is not None |
| 224 | |
| 225 | if isinstance(leading, RelativeUnit): |
| 226 | lineHeight = upt(leading.byBase(fontSize)) |
| 227 | elif isinstance(leading, Unit): |
| 228 | lineHeight = upt(leading) |
| 229 | elif isUnit(fontSize): |
| 230 | # Leading is scalar? |
| 231 | lineHeight = leading * fontSize.pt |
| 232 | else: |
| 233 | # Both scalar? |
| 234 | lineHeight = leading * fontSize |
| 235 | |
| 236 | return lineHeight |
| 237 | |
| 238 | def getMasterPath(): |
| 239 | """Answers the path to read master fonts, which typically is a |