You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
what does the value returned by fontLeading() refer to exactly?
setting a lineHeight() with fonts that have a non-zero fontLeading() results in a different line height than the one specified (see example script below)
is there a way to set an exact lineHeight value which is independent of the font’s leading? is it possible to set the leading to zero?
fromrandomimportchoicetxt='Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed dignissim risus ac ex auctor laoreet. Vestibulum auctor libero vitae nisi tincidunt condimentum. Pellentesque sed feugiat nunc. Proin turpis urna, molestie sed turpis eu, placerat tristique nisl. Phasellus auctor lectus mi, ut dictum mauris tincidunt vel. Maecenas congue et elit ut iaculis. Nullam gravida viverra arcu nec efficitur. Nulla convallis diam neque, vitae bibendum ligula interdum non. Mauris a elementum magna. Curabitur lectus erat, aliquet vitae libero a, lobortis tempus ipsum. In mattis egestas pretium. Vestibulum et ligula semper, eleifend purus nec, maximus tortor. '*10size('A4')
allFonts=installedFonts()
aFont=choice(allFonts)
print('font:', aFont)
margin=40baselineHeight=30w=width() -margin*2h=height() -margin*2box=margin, margin, w, hfont(aFont, 16), lineHeight(baselineHeight)
print('line height:', fontLineHeight())
print('leading:', fontLeading())
# draw document baselinestroke(0, 1, 1), strokeWidth(1), fill(None)
rect(*box)
yPos=height() -marginwhileyPos>margin:
line((margin, yPos), (width() -margin, yPos))
yPos-=baselineHeight# adjust first line posYtextBaselines=textBoxBaselines(txt, box)
firstLineGap=height() -margin-textBaselines[0][-1]
translate(0, firstLineGap-baselineHeight)
# draw texbox baselinestroke(1, 0, 1)
forx, yintextBoxBaselines(txt, box):
line((x, y), (x+w, y))
# draw texboxstroke(None), fill(0)
textBox(txt, box)
thanks!
The text was updated successfully, but these errors were encountered:
for background info see TextBox and baseline alignment
fontLeading()
refer to exactly?lineHeight()
with fonts that have a non-zerofontLeading()
results in a different line height than the one specified (see example script below)lineHeight
value which is independent of the font’s leading? is it possible to set the leading to zero?thanks!
The text was updated successfully, but these errors were encountered: