Thanks @gferreira
I tried different ways to calculate the positioning of the first line in the textBox (looking for a magical match between the verticals metrics, lineHeight(), text size…) and I can never find a solution that works systematically from one font to another…
Rémi Forte
@RMFRT
Poetic Program, Typographic System
Best posts made by RMFRT
Latest posts made by RMFRT
-
RE: TextBox and baseline alignment
-
RE: TextBox and baseline alignment
Thank you @gferreira for your reply!
In your example, the baseline is defined by the textBox (and its position changes each time you change the font).
I want to first define a baseline for my document and then align the content of my TextBox to this baseline.
I have trouble understanding how the text is vertically aligned inside a textBox.
I just wrote the code below, which works, but I was wondering if there was a better way to do that.
txt = '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. ' * 10 size(600, 600) margin = 40 w = width() - margin * 2 h = height() - margin * 2 baselineHeight = 12 font('Menlo', 10), lineHeight(baselineHeight) # Show document baseline stroke(0, 0, 1), strokeWidth(0.3), fill(None) for i in range(1, round(h / baselineHeight)): yPos = height() - margin - (i * baselineHeight) line((margin, yPos), (width() - margin, yPos)) # Calculate the position of the first baseline in the textBox firstBaseline = height() - margin - baselineHeight box = margin, margin, w, h textBoxFirstBaseline = textBoxBaselines(txt, box)[0][1] # Calculate the gap between the baseline of the document and the baseline of the TextBox baselineGap = textBoxFirstBaseline - firstBaseline # Show text aligned to baseline box = margin, margin - baselineGap, w, h stroke(None), fill(0), textBox(txt, box)
-
TextBox and baseline alignment
Hi everyone,
for some time now I've been wondering how to fine-tune the alignment of my text on a baseline.Have you worked on this or found effective solutions?
The only option I see is to use textBoxBaselines() and specifying the parameters of my text (font(), fontSize() and lineHeight()).
But is it the more effective way to do it?Here after, to illustrate my words, a screenshot of the default gap between my textbox and its baseline:
Thank you,
Rémi -
RE: Drawbot no longer working after upgrading to Catalina
@frederik I installed the pre-release version but some (OpenType) features don’t seem to work.
I did a test with this basic script:
I have the following error message:
Traceback (most recent call last): File "<untitled>", line 9, in <module> File "drawBot/context/baseContext.pyc", line 1772, in appendGlyph AttributeError: module 'drawBot.context.tools.openType' has no attribute 'featureMap'
And of course it worked perfectly few days ago on my office computer (not upgraded to Catalina).
Thanks!