MCPcopy Create free account
hub / github.com/PageBot/PageBot / getLineHeight

Function getLineHeight

Lib/pagebot/fonttoolbox/objects/font.py:210–236  ·  view source on GitHub ↗

>>> 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)

Source from the content-addressed store, hash-verified

208 return fontPath
209
210def 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
238def getMasterPath():
239 """Answers the path to read master fonts, which typically is a

Callers

nothing calls this directly

Calls 3

uptFunction · 0.90
isUnitFunction · 0.90
byBaseMethod · 0.45

Tested by

no test coverage detected