Open stenson opened 3 years ago
Oh cool, please make a PR
Just one question: why using the typographic bounds over the image bounds? As far as I understands it the image bounds wrap the letters: so if the word does not contain ascenders or descenders the bounds are not unnecessary big
Thanks!
Im trying to reproduce your issue in the current DrawBot... This seems to work fine where "world" is always the clickable area:
t = FormattedString()
t.fontSize(20)
for i in range(20):
t += "hello "
t.url("http://www.drawbot.com")
t.fill(0, 0, 1)
t += "world "
t.fill(0)
t.url(None)
t += "hello "
textBox(t, (50, 50, 400, 400))
could you make a narrowed example?
thanks
Interesting! That example you provided does work for me in the app itself, both in the in-app view, and in a pdf saved from the app itself. But when using drawbot as a module (in a python3.7 virtualenv with the latest drawbot master), I get the same result as reported initially, where all the clickable areas aren't being advanced on the x-axis. Here's the pdf generated by this slightly modified version of the code:
from drawBot import *
t = FormattedString()
t.fontSize(20)
for i in range(20):
t += "hello "
t.url("http://www.drawbot.com")
t.fill(0, 0, 1)
t += "world "
t.fill(0)
t.url(None)
t += "hello "
textBox(t, (50, 50, 400, 400))
saveImage("~/Desktop/test_original.pdf")
(To answer the previous question, I was just using the typographic bounds b/c that's what the source code for textBoxCharacterBounds
uses)
Was playing around with adding some inline links in running text (using drawbot in module mode and the
url
property on FormattedString sub-strings) & ran into an issue with the bounding boxes not advancing along the x-axis (as in the first image below — the black boxes are just debug code added in pdfContext.py, to show where the clickable area is).I repurposed some code from the
textBoxCharacterBounds
source and got it working correctly (or at least it appears correct to me) on a fork: https://github.com/typemytype/drawbot/compare/master...stenson:masterCurrent drawbot/master
With change in url-linking code: https://github.com/typemytype/drawbot/compare/master...stenson:master
Happy to open a pull request if the change seems good, or discuss further if the original behavior is intentional and I've misunderstood!