`textBoxCharacterBounds(align="center")` doesn’t seem to work
Closed this issue · 2 comments
chrisjansky commented
Hello,
a quick test of textBoxCharacterBounds()
with align
parameter supplied doesn’t change the output as expected.
Minimal code to reproduce:
txt = "Testing Character Bounds"
box = 100, 100, 800, 800
fs = 100
l = 1.1
align = "center"
font("Times")
fontSize(fs)
lineHeight(fs * l)
charBounds = textBoxCharacterBounds(txt, box, align)
for b in charBounds:
fill(0, 1, 0)
rect(*b.bounds)
fill(0)
textBox(txt, box, align)
I am doing something wrong?
Thanks,
Christian
typemytype commented
nope, it seems the align
as not set while creating a attributed string inside DrawBot
will be fixed!!
for now, and I would also advise to use FormattedString
objects:
box = 100, 100, 800, 800
t = FormattedString()
t.font("Times", 100)
t.lineHeight(100 * 1.1)
t.align("center")
t += "Testing Character Bounds"
charBounds = textBoxCharacterBounds(t, box)
for b in charBounds:
fill(0, 1, 0)
rect(*b.bounds)
fill(0)
textBox(t, box)
chrisjansky commented
@typemytype Understood, thanks for the quick answer, Frederik.